Author: snjeza
Date: 2011-03-26 10:18:09 -0400 (Sat, 26 Mar 2011)
New Revision: 30053
Modified:
trunk/runtime/tests/org.jboss.tools.runtime.test/src/org/jboss/tools/runtime/test/RuntimeDetectionTest.java
Log:
JBIDE-7583 Add tests for org.jboss.tools.runtime plugin
Modified:
trunk/runtime/tests/org.jboss.tools.runtime.test/src/org/jboss/tools/runtime/test/RuntimeDetectionTest.java
===================================================================
---
trunk/runtime/tests/org.jboss.tools.runtime.test/src/org/jboss/tools/runtime/test/RuntimeDetectionTest.java 2011-03-26
01:51:17 UTC (rev 30052)
+++
trunk/runtime/tests/org.jboss.tools.runtime.test/src/org/jboss/tools/runtime/test/RuntimeDetectionTest.java 2011-03-26
14:18:09 UTC (rev 30053)
@@ -31,124 +31,195 @@
import org.jboss.tools.seam.core.project.facet.SeamRuntime;
import org.jboss.tools.seam.core.project.facet.SeamRuntimeManager;
import org.jboss.tools.seam.core.project.facet.SeamVersion;
+import org.junit.BeforeClass;
import org.junit.Test;
/**
*
* @author snjeza
- *
+ *
*/
public class RuntimeDetectionTest {
- @Test
- public void testRuntimeDetectors() {
- Set<IRuntimeDetector> detectors = RuntimeCoreActivator.getRuntimeDetectors();
- assertTrue("Runtime detectors don't exist.",detectors.size() > 0);
+ @BeforeClass
+ public static void create() {
+ addRuntimePaths();
+ createRuntimes();
}
-
- @Test
- public void testRuntimePaths() {
- List<RuntimePath> runtimePaths =
RuntimeUIActivator.getDefault().getRuntimePaths();
- assertTrue("There are initial runtime paths.", runtimePaths.size() == 0);
- }
-
- @Test
- public void addRuntimePaths() {
- List<RuntimePath> runtimePaths =
RuntimeUIActivator.getDefault().getRuntimePaths();
- String[] paths = { IRuntimeDetectionConstants.JBOSS_42_HOME,
IRuntimeDetectionConstants.JBOSS_51_HOME,
- IRuntimeDetectionConstants.SEAM_20_HOME, IRuntimeDetectionConstants.SEAM_22_HOME,
- IRuntimeDetectionConstants.EAP_43_HOME};
-
+
+ private static void addRuntimePaths() {
+ List<RuntimePath> runtimePaths = RuntimeUIActivator.getDefault()
+ .getRuntimePaths();
+ String[] paths = { IRuntimeDetectionConstants.JBOSS_42_HOME,
+ IRuntimeDetectionConstants.JBOSS_51_HOME,
+ IRuntimeDetectionConstants.SEAM_20_HOME,
+ IRuntimeDetectionConstants.SEAM_22_HOME,
+ IRuntimeDetectionConstants.EAP_43_HOME };
+
for (String path : paths) {
assertTrue(path != null);
File file = new File(path);
- assertTrue("The '" + path + "' path isn't valid.",
file.isDirectory());
+ assertTrue("The '" + path + "' path isn't valid.",
+ file.isDirectory());
RuntimePath runtimePath = new RuntimePath(path);
runtimePaths.add(runtimePath);
}
RuntimeUIActivator.getDefault().saveRuntimePaths();
runtimePaths = null;
- runtimePaths = RuntimeUIActivator.getDefault().getRuntimePaths();
- assertTrue("runtimePaths.size()\nExpected: 5\nWas: " + runtimePaths.size(),
runtimePaths.size() == 5);
List<ServerDefinition> serverDefinitions = new
ArrayList<ServerDefinition>();
- Set<IRuntimeDetector> detectors = RuntimeCoreActivator.getRuntimeDetectors();
- for( IRuntimeDetector detector:detectors) {
+ Set<IRuntimeDetector> detectors = RuntimeCoreActivator
+ .getRuntimeDetectors();
+ for (IRuntimeDetector detector : detectors) {
if (detector.isEnabled()) {
detector.initializeRuntimes(serverDefinitions);
}
}
- assertTrue("serverDefinitions.size()\nExpected: 0\nWas: " +
serverDefinitions.size(), serverDefinitions.size() == 0);
+ assertTrue("serverDefinitions.size()\nExpected: 0\nWas: "
+ + serverDefinitions.size(), serverDefinitions.size() == 0);
}
-
- @Test
- public void createRuntimes() {
+
+ private static void createRuntimes() {
JBossRuntimeLocator locator = new JBossRuntimeLocator();
- List<RuntimePath> runtimePaths =
RuntimeUIActivator.getDefault().getRuntimePaths();
+ List<RuntimePath> runtimePaths = RuntimeUIActivator.getDefault()
+ .getRuntimePaths();
for (RuntimePath runtimePath : runtimePaths) {
List<ServerDefinition> serverDefinitions = locator
- .searchForRuntimes(runtimePath.getPath(), new NullProgressMonitor());
+ .searchForRuntimes(runtimePath.getPath(),
+ new NullProgressMonitor());
runtimePath.getServerDefinitions().clear();
for (ServerDefinition serverDefinition : serverDefinitions) {
serverDefinition.setRuntimePath(runtimePath);
}
- runtimePath.getServerDefinitions()
- .addAll(serverDefinitions);
+ runtimePath.getServerDefinitions().addAll(serverDefinitions);
}
- List<ServerDefinition> serverDefinitions =
RuntimeUIActivator.getDefault().getServerDefinitions();
- assertTrue("serverDefinitions.size()\nExpected: >0\nWas: " +
serverDefinitions.size(), serverDefinitions.size() > 0);
- Set<IRuntimeDetector> detectors = RuntimeCoreActivator.getRuntimeDetectors();
- for( IRuntimeDetector detector:detectors) {
+ List<ServerDefinition> serverDefinitions = RuntimeUIActivator
+ .getDefault().getServerDefinitions();
+ Set<IRuntimeDetector> detectors = RuntimeCoreActivator
+ .getRuntimeDetectors();
+ for (IRuntimeDetector detector : detectors) {
if (detector.isEnabled()) {
detector.initializeRuntimes(serverDefinitions);
}
}
}
-
+
@Test
- public void testSeamRuntimes() {
- SeamRuntime[] seamRuntimes = SeamRuntimeManager.getInstance().getRuntimes();
- assertTrue("seamRuntimes.length\nExpected: 4\nWas: " + seamRuntimes.length,
seamRuntimes.length == 4);
- boolean seam20Exists = false;
- boolean seam22Exists = false;
- boolean seam12Exists = false;
- for(SeamRuntime seamRuntime:seamRuntimes) {
+ public void testRuntimeDetectors() {
+ Set<IRuntimeDetector> detectors = RuntimeCoreActivator
+ .getRuntimeDetectors();
+ assertTrue("Runtime detectors don't exist.", detectors.size() > 0);
+ }
+
+ @Test
+ public void testRuntimePaths() {
+ List<RuntimePath> runtimePaths = RuntimeUIActivator.getDefault()
+ .getRuntimePaths();
+ assertTrue(
+ "runtimePaths.size()\nExpected: 5\nWas: " + runtimePaths.size(),
+ runtimePaths.size() == 5);
+ }
+
+ @Test
+ public void testServerDefinitions() {
+ List<ServerDefinition> serverDefinitions = RuntimeUIActivator
+ .getDefault().getServerDefinitions();
+ assertTrue("serverDefinitions.size()\nExpected: 5\nWas: "
+ + serverDefinitions.size(), serverDefinitions.size() == 5);
+ }
+
+ @Test
+ public void testSeam22() {
+ SeamRuntime[] seamRuntimes = SeamRuntimeManager.getInstance()
+ .getRuntimes();
+ int count = 0;
+ for (SeamRuntime seamRuntime : seamRuntimes) {
SeamVersion version = seamRuntime.getVersion();
+ if (SeamVersion.SEAM_2_2.equals(version)) {
+ count++;
+ }
+ }
+ assertTrue("Seam 2.2\nExpected: 1\nWas: " + count, count == 1);
+ }
+
+ @Test
+ public void testSeam20() {
+ SeamRuntime[] seamRuntimes = SeamRuntimeManager.getInstance()
+ .getRuntimes();
+ int count = 0;
+ for (SeamRuntime seamRuntime : seamRuntimes) {
+ SeamVersion version = seamRuntime.getVersion();
if (SeamVersion.SEAM_2_0.equals(version)) {
- seam20Exists = true;
+ count++;
}
- if (SeamVersion.SEAM_2_2.equals(version)) {
- seam22Exists = true;
- }
+ }
+ assertTrue("Seam 2.0\nExpected: 2\nWas: " + count, count == 2);
+ }
+
+ @Test
+ public void testSeam12() {
+ SeamRuntime[] seamRuntimes = SeamRuntimeManager.getInstance()
+ .getRuntimes();
+ int count = 0;
+ for (SeamRuntime seamRuntime : seamRuntimes) {
+ SeamVersion version = seamRuntime.getVersion();
if (SeamVersion.SEAM_1_2.equals(version)) {
- seam12Exists = true;
+ count++;
}
}
- assertTrue("Seam 2.0 Runtime isn't created.", seam20Exists);
- assertTrue("Seam 2.2 Runtime isn't created.", seam22Exists);
- assertTrue("Seam 1.2 Runtime isn't created.", seam12Exists);
+ assertTrue("Seam 1.2\nExpected: 1\nWas: " + count, count == 1);
}
-
+
@Test
- public void testWtpRuntimes() {
+ public void testSeamRuntimes() {
+ SeamRuntime[] seamRuntimes = SeamRuntimeManager.getInstance()
+ .getRuntimes();
+ assertTrue("seamRuntimes.length\nExpected: 4\nWas: "
+ + seamRuntimes.length, seamRuntimes.length == 4);
+ }
+
+ @Test
+ public void testJBossAs42() {
IRuntime[] runtimes = ServerCore.getRuntimes();
- assertTrue("runtimes.length\nExpected: 3\nWas: " + runtimes.length,
runtimes.length == 3);
- boolean as42Exists = false;
- boolean as51Exists = false;
- boolean eap43Exists = false;
- for(IRuntime runtime:runtimes) {
+ int count = 0;
+ for (IRuntime runtime : runtimes) {
IRuntimeType runtimeType = runtime.getRuntimeType();
if (IJBossToolingConstants.AS_42.equals(runtimeType.getId())) {
- as42Exists = true;
+ count++;
}
+ }
+ assertTrue("JBoss AS 4.2\nExpected: 1\nWas: " + count, count == 1);
+ }
+
+ @Test
+ public void testJBossAs51() {
+ IRuntime[] runtimes = ServerCore.getRuntimes();
+ int count = 0;
+ for (IRuntime runtime : runtimes) {
+ IRuntimeType runtimeType = runtime.getRuntimeType();
if (IJBossToolingConstants.AS_51.equals(runtimeType.getId())) {
- as51Exists = true;
+ count++;
}
+ }
+ assertTrue("JBoss AS 5.1\nExpected: 1\nWas: " + count, count == 1);
+ }
+
+ @Test
+ public void testJBossEap43() {
+ IRuntime[] runtimes = ServerCore.getRuntimes();
+ int count = 0;
+ for (IRuntime runtime : runtimes) {
+ IRuntimeType runtimeType = runtime.getRuntimeType();
if (IJBossToolingConstants.EAP_43.equals(runtimeType.getId())) {
- eap43Exists = true;
+ count++;
}
}
- assertTrue("JBoss AS 4.2 Runtime isn't created.", as42Exists);
- assertTrue("JBoss AS 5.1 Runtime isn't created.", as51Exists);
- assertTrue("JBoss EAP 4.3 Runtime isn't created.", eap43Exists);
+ assertTrue("JBoss EAP 4.3\nExpected: 1\nWas: " + count, count == 1);
}
+
+ @Test
+ public void testWtpRuntimes() {
+ IRuntime[] runtimes = ServerCore.getRuntimes();
+ assertTrue("runtimes.length\nExpected: 3\nWas: " + runtimes.length,
+ runtimes.length == 3);
+ }
}
Show replies by date