1 13 14 package org.eclipse.jdt.internal.junit.launcher; 15 16 import org.eclipse.core.runtime.CoreException; 17 import org.eclipse.core.runtime.IConfigurationElement; 18 19 import org.eclipse.jdt.internal.junit.ui.JUnitPlugin; 20 21 22 public class TestKind implements ITestKind { 23 24 private final IConfigurationElement fElement; 25 private ITestFinder fFinder; 26 27 public TestKind(IConfigurationElement element) { 28 fElement = element; 29 fFinder= null; 30 } 31 32 35 public ITestFinder getFinder() { 36 if (fFinder == null) { 37 try { 38 fFinder= (ITestFinder) fElement.createExecutableExtension(FINDER_CLASS_NAME); 39 } catch (CoreException e1) { 40 JUnitPlugin.log(e1); 41 fFinder= ITestFinder.NULL; 42 } 43 } 44 return fFinder; 45 } 46 47 50 public String getDisplayName() { 51 return getAttribute(DISPLAY_NAME); 52 } 53 54 57 public String getFinderClassName() { 58 return getAttribute(FINDER_CLASS_NAME); 59 } 60 61 64 public String getId() { 65 return getAttribute(ID); 66 } 67 68 71 public String getLoaderClassName() { 72 return getAttribute(LOADER_CLASS_NAME); 73 } 74 75 public String getLoaderPluginId() { 76 return getAttribute(LOADER_PLUGIN_ID); 77 } 78 79 82 public String getPrecededKindId() { 83 String attribute= getAttribute(PRECEDES); 84 return attribute == null ? "" : attribute; } 86 87 90 public boolean isNull() { 91 return false; 92 } 93 94 protected String getAttribute(String attributeName) { 95 return fElement.getAttribute(attributeName); 96 } 97 98 boolean precedes(ITestKind otherKind) { 99 final String precededKindId = getPrecededKindId(); 100 String [] ids = precededKindId.split(","); for (int i = 0; i < ids.length; i++) { 102 if (ids[i].equals(otherKind.getId())) 103 return true; 104 } 105 return false; 106 } 107 108 111 public JUnitRuntimeClasspathEntry[] getClasspathEntries() { 112 IConfigurationElement[] children= fElement.getChildren(ITestKind.RUNTIME_CLASSPATH_ENTRY); 113 JUnitRuntimeClasspathEntry[] returnThis= new JUnitRuntimeClasspathEntry[children.length]; 114 for (int i= 0; i < children.length; i++) { 115 IConfigurationElement element= children[i]; 116 String pluginID= element.getAttribute(ITestKind.CLASSPATH_PLUGIN_ID); 117 String pathToJar= element.getAttribute(ITestKind.CLASSPATH_PATH_TO_JAR); 118 returnThis[i]= new JUnitRuntimeClasspathEntry(pluginID, pathToJar); 119 } 120 return returnThis; 121 } 122 123 126 public String toString() { 127 return getDisplayName() + " (id: " + getId() + ")"; } 129 } 130 | Popular Tags |