Author: snjeza
Date: 2011-03-27 15:29:59 -0400 (Sun, 27 Mar 2011)
New Revision: 30058
Modified:
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/SeamHandler.java
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/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/SeamHandler.java
===================================================================
---
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/SeamHandler.java 2011-03-27
15:58:03 UTC (rev 30057)
+++
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/SeamHandler.java 2011-03-27
19:29:59 UTC (rev 30058)
@@ -225,7 +225,7 @@
if ("seam-gen".equals(name)) {
return true;
}
- if ("examples".equals(name)) {
+ if ("lib".equals(name)) {
return true;
}
return false;
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-27
15:58:03 UTC (rev 30057)
+++
trunk/runtime/tests/org.jboss.tools.runtime.test/src/org/jboss/tools/runtime/test/RuntimeDetectionTest.java 2011-03-27
19:29:59 UTC (rev 30058)
@@ -13,9 +13,13 @@
import static org.junit.Assert.assertTrue;
import java.io.File;
+import java.io.FilenameFilter;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.wst.server.core.IRuntime;
@@ -40,6 +44,7 @@
*
*/
public class RuntimeDetectionTest {
+ private final static String seamVersionAttributeName = "Seam-Version";
@BeforeClass
public static void create() {
@@ -139,11 +144,54 @@
}
@Test
+ public void testSeam22Location() throws Exception {
+ String seamHome = IRuntimeDetectionConstants.SEAM_22_HOME;
+ testSeamHome(seamHome, "2.2");
+ }
+
+ @Test
+ public void testSeam20Location() throws Exception {
+ String seamHome = IRuntimeDetectionConstants.SEAM_20_HOME;
+ testSeamHome(seamHome, "2.0");
+ }
+
+ private void testSeamHome(String seamHome, String seamVersion) throws IOException {
+ File file = new File(seamHome);
+ assertTrue("The '" + file.getAbsolutePath()
+ + "' path isn't valid.", file.isDirectory());
+ String[] seamFiles = file.list(new FilenameFilter() {
+
+ public boolean accept(File dir, String name) {
+ if ("seam-gen".equals(name)) {
+ return true;
+ }
+ if ("lib".equals(name)) {
+ return true;
+ }
+ return false;
+ }
+ });
+ assertTrue("seamFiles : " + seamFiles, seamFiles != null
+ && seamFiles.length == 2);
+ File jarFile = new File(seamHome, "lib/jboss-seam.jar");
+ assertTrue("The '" + jarFile.getAbsolutePath() + "' path
isn't valid.",
+ jarFile.isFile());
+ JarFile jar = new JarFile(jarFile);
+ Attributes attributes = jar.getManifest().getMainAttributes();
+ String version = attributes.getValue(seamVersionAttributeName);
+ assertTrue("seamVersion: " + version, version != null &&
version.startsWith(seamVersion));
+ }
+
+ @Test
public void testServerDefinitions() {
List<ServerDefinition> serverDefinitions = RuntimeUIActivator
.getDefault().getServerDefinitions();
+ List<RuntimePath> runtimePaths = RuntimeUIActivator.getDefault()
+ .getRuntimePaths();
assertTrue("serverDefinitions.size()\nExpected: 5\nWas: "
- + serverDefinitions.size() + "\n" + serverDefinitions,
serverDefinitions.size() == 5);
+ + serverDefinitions.size() +
+ "\nserverDefinitions: " + serverDefinitions +
+ "\nruntimePaths=" + runtimePaths, serverDefinitions.size() == 5);
}
@Test