Author: snjeza
Date: 2011-03-24 20:53:51 -0400 (Thu, 24 Mar 2011)
New Revision: 30002
Added:
trunk/runtime/tests/org.jboss.tools.runtime.test/.classpath
trunk/runtime/tests/org.jboss.tools.runtime.test/.project
trunk/runtime/tests/org.jboss.tools.runtime.test/.settings/
trunk/runtime/tests/org.jboss.tools.runtime.test/.settings/org.eclipse.jdt.core.prefs
trunk/runtime/tests/org.jboss.tools.runtime.test/META-INF/
trunk/runtime/tests/org.jboss.tools.runtime.test/META-INF/MANIFEST.MF
trunk/runtime/tests/org.jboss.tools.runtime.test/build.properties
trunk/runtime/tests/org.jboss.tools.runtime.test/plugin.properties
trunk/runtime/tests/org.jboss.tools.runtime.test/pom.xml
trunk/runtime/tests/org.jboss.tools.runtime.test/requirements.properties
trunk/runtime/tests/org.jboss.tools.runtime.test/src/
trunk/runtime/tests/org.jboss.tools.runtime.test/src/org/
trunk/runtime/tests/org.jboss.tools.runtime.test/src/org/jboss/
trunk/runtime/tests/org.jboss.tools.runtime.test/src/org/jboss/tools/
trunk/runtime/tests/org.jboss.tools.runtime.test/src/org/jboss/tools/runtime/
trunk/runtime/tests/org.jboss.tools.runtime.test/src/org/jboss/tools/runtime/test/
trunk/runtime/tests/org.jboss.tools.runtime.test/src/org/jboss/tools/runtime/test/IRuntimeDetectionConstants.java
trunk/runtime/tests/org.jboss.tools.runtime.test/src/org/jboss/tools/runtime/test/RuntimeDetectionAllTests.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
Added: trunk/runtime/tests/org.jboss.tools.runtime.test/.classpath
===================================================================
--- trunk/runtime/tests/org.jboss.tools.runtime.test/.classpath
(rev 0)
+++ trunk/runtime/tests/org.jboss.tools.runtime.test/.classpath 2011-03-25 00:53:51 UTC
(rev 30002)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/runtime/tests/org.jboss.tools.runtime.test/.project
===================================================================
--- trunk/runtime/tests/org.jboss.tools.runtime.test/.project (rev
0)
+++ trunk/runtime/tests/org.jboss.tools.runtime.test/.project 2011-03-25 00:53:51 UTC (rev
30002)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.runtime.test</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added:
trunk/runtime/tests/org.jboss.tools.runtime.test/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/runtime/tests/org.jboss.tools.runtime.test/.settings/org.eclipse.jdt.core.prefs
(rev 0)
+++
trunk/runtime/tests/org.jboss.tools.runtime.test/.settings/org.eclipse.jdt.core.prefs 2011-03-25
00:53:51 UTC (rev 30002)
@@ -0,0 +1,8 @@
+#Thu Mar 24 21:12:52 CET 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
Added: trunk/runtime/tests/org.jboss.tools.runtime.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/runtime/tests/org.jboss.tools.runtime.test/META-INF/MANIFEST.MF
(rev 0)
+++ trunk/runtime/tests/org.jboss.tools.runtime.test/META-INF/MANIFEST.MF 2011-03-25
00:53:51 UTC (rev 30002)
@@ -0,0 +1,39 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %BundleName
+Bundle-SymbolicName: org.jboss.tools.runtime.test
+Bundle-Version: 1.0.0.qualifier
+Require-Bundle: org.eclipse.core.runtime,
+ org.junit4,
+ org.jboss.tools.runtime,
+ org.jboss.tools.runtime.ui,
+ org.jboss.tools.runtime.core,
+ org.jboss.tools.tests,
+ org.jboss.tools.seam.core,
+ org.eclipse.datatools.connectivity,
+ org.eclipse.datatools.connectivity.db.generic,
+ org.jboss.tools.common,
+ org.jboss.tools.tests,
+ org.jboss.ide.eclipse.as.core,
+ org.eclipse.wst.server.core,
+ org.eclipse.datatools.enablement.hsqldb,
+ org.eclipse.datatools.enablement.hsqldb.dbdefinition,
+ org.eclipse.datatools.enablement.hsqldb.ui,
+ org.eclipse.jst.jee,
+ org.eclipse.jst.jee.ejb,
+ org.eclipse.jst.jee.ui,
+ org.eclipse.jst.jee.web,
+ org.eclipse.ui,
+ org.eclipse.core.resources,
+ org.junit4,
+ org.jboss.tools.jsf.vpe.seam,
+ org.jboss.tools.seam.pages.xml,
+ org.jboss.tools.seam.ui,
+ org.jboss.tools.seam.ui.pages,
+ org.jboss.tools.seam.xml,
+ org.jboss.tools.seam.xml.ui,
+ org.jboss.tools.seam.text.ext
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-Vendor: %BundleVendor
+Bundle-Localization: plugin
Added: trunk/runtime/tests/org.jboss.tools.runtime.test/build.properties
===================================================================
--- trunk/runtime/tests/org.jboss.tools.runtime.test/build.properties
(rev 0)
+++ trunk/runtime/tests/org.jboss.tools.runtime.test/build.properties 2011-03-25 00:53:51
UTC (rev 30002)
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.properties
Added: trunk/runtime/tests/org.jboss.tools.runtime.test/plugin.properties
===================================================================
--- trunk/runtime/tests/org.jboss.tools.runtime.test/plugin.properties
(rev 0)
+++ trunk/runtime/tests/org.jboss.tools.runtime.test/plugin.properties 2011-03-25 00:53:51
UTC (rev 30002)
@@ -0,0 +1,3 @@
+#Properties file for org.jboss.tools.project.examples
+BundleVendor = JBoss by Red Hat
+BundleName = JBoss Runtime Detection Tests
\ No newline at end of file
Added: trunk/runtime/tests/org.jboss.tools.runtime.test/pom.xml
===================================================================
--- trunk/runtime/tests/org.jboss.tools.runtime.test/pom.xml (rev
0)
+++ trunk/runtime/tests/org.jboss.tools.runtime.test/pom.xml 2011-03-25 00:53:51 UTC (rev
30002)
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.jboss.tools</groupId>
+ <artifactId>org.jboss.tools.parent.pom</artifactId>
+ <version>0.0.2-SNAPSHOT</version>
+ </parent>
+ <groupId>org.jboss.tools.runtime.tests</groupId>
+ <artifactId>org.jboss.tools.runtime.test</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>eclipse-test-plugin</packaging>
+
+ <properties>
+ <systemProperties>-Djbosstools.test.jboss.home.4.2=${requirement.build.root}/jboss-4.2.3.GA
-Djbosstools.test.jboss.home.5.1=${requirement.build.root}/jboss-5.1.0.GA
-Djbosstools.test.seam.2.0.1.GA.home=${requirement.build.root}/jboss-seam-2.0.1.GA
-Djbosstools.test.seam.2.2.0.GA.home=${requirement.build.root}/jboss-seam-2.2.0.GA
-Djbosstools.test.eap.4.3.home=${requirement.build.root}/jboss-eap-4.3</systemProperties>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.sonatype.tycho</groupId>
+ <artifactId>maven-osgi-test-plugin</artifactId>
+ <version>${tychoVersion}</version>
+ <configuration>
+ <useUIThread>false</useUIThread>
+ <useUIHarness>true</useUIHarness>
+ <testSuite>org.jboss.tools.runtime.test</testSuite>
+
<testClass>org.jboss.tools.runtime.test.RuntimeDetectionAllTests</testClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
Added: trunk/runtime/tests/org.jboss.tools.runtime.test/requirements.properties
===================================================================
--- trunk/runtime/tests/org.jboss.tools.runtime.test/requirements.properties
(rev 0)
+++ trunk/runtime/tests/org.jboss.tools.runtime.test/requirements.properties 2011-03-25
00:53:51 UTC (rev 30002)
@@ -0,0 +1 @@
+requirements=jbossas,seam-2.0.1.GA,seam-2.2.0.GA,jbeap
\ No newline at end of file
Added:
trunk/runtime/tests/org.jboss.tools.runtime.test/src/org/jboss/tools/runtime/test/IRuntimeDetectionConstants.java
===================================================================
---
trunk/runtime/tests/org.jboss.tools.runtime.test/src/org/jboss/tools/runtime/test/IRuntimeDetectionConstants.java
(rev 0)
+++
trunk/runtime/tests/org.jboss.tools.runtime.test/src/org/jboss/tools/runtime/test/IRuntimeDetectionConstants.java 2011-03-25
00:53:51 UTC (rev 30002)
@@ -0,0 +1,30 @@
+/*************************************************************************************
+ * Copyright (c) 2011 JBoss by Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.runtime.test;
+
+/**
+ *
+ * @author snjeza
+ *
+ */
+public interface IRuntimeDetectionConstants {
+
+ final static String JBOSS_42_HOME =
System.getProperty("jbosstools.test.jboss.home.4.2",
"E:\\JBossRuntimes\\jboss-4.2.3.GA");
+
+ final static String JBOSS_51_HOME =
System.getProperty("jbosstools.test.jboss.home.5.1",
"E:\\JBossRuntimes\\jboss-5.1.0.GA");
+
+ final static String SEAM_20_HOME =
System.getProperty("jbosstools.test.seam.2.0.1.GA.home",
"E:\\JBossRuntimes\\jboss-seam-2.0.1.GA");
+
+ final static String SEAM_22_HOME =
System.getProperty("jbosstools.test.seam.2.2.0.GA.home",
"E:\\jboss-seam-2.2.1.Final");
+
+ final static String EAP_43_HOME =
System.getProperty("jbosstools.test.eap.4.3.home",
"E:\\jboss-eap43_cp03");
+
+}
Added:
trunk/runtime/tests/org.jboss.tools.runtime.test/src/org/jboss/tools/runtime/test/RuntimeDetectionAllTests.java
===================================================================
---
trunk/runtime/tests/org.jboss.tools.runtime.test/src/org/jboss/tools/runtime/test/RuntimeDetectionAllTests.java
(rev 0)
+++
trunk/runtime/tests/org.jboss.tools.runtime.test/src/org/jboss/tools/runtime/test/RuntimeDetectionAllTests.java 2011-03-25
00:53:51 UTC (rev 30002)
@@ -0,0 +1,24 @@
+/*************************************************************************************
+ * Copyright (c) 2011 JBoss by Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.runtime.test;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+
+(a)Suite.SuiteClasses({
+ RuntimeDetectionTest.class,
+})
+
+(a)RunWith(Suite.class)
+public class RuntimeDetectionAllTests {
+
+}
\ No newline at end of file
Added:
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
(rev 0)
+++
trunk/runtime/tests/org.jboss.tools.runtime.test/src/org/jboss/tools/runtime/test/RuntimeDetectionTest.java 2011-03-25
00:53:51 UTC (rev 30002)
@@ -0,0 +1,154 @@
+/*************************************************************************************
+ * Copyright (c) 2011 JBoss by Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.runtime.test;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.wst.server.core.IRuntime;
+import org.eclipse.wst.server.core.IRuntimeType;
+import org.eclipse.wst.server.core.ServerCore;
+import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
+import org.jboss.tools.runtime.core.JBossRuntimeLocator;
+import org.jboss.tools.runtime.core.RuntimeCoreActivator;
+import org.jboss.tools.runtime.core.model.IRuntimeDetector;
+import org.jboss.tools.runtime.core.model.RuntimePath;
+import org.jboss.tools.runtime.core.model.ServerDefinition;
+import org.jboss.tools.runtime.ui.RuntimeUIActivator;
+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.Test;
+
+/**
+ *
+ * @author snjeza
+ *
+ */
+public class RuntimeDetectionTest {
+
+ @Test
+ 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("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};
+
+ for (String path : paths) {
+ assertTrue(path != null);
+ File file = new File(path);
+ 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) {
+ if (detector.isEnabled()) {
+ detector.initializeRuntimes(serverDefinitions);
+ }
+ }
+ assertTrue("serverDefinitions.size()\nExpected: 0\nWas: " +
serverDefinitions.size(), serverDefinitions.size() == 0);
+ }
+
+ @Test
+ public void createRuntimes() {
+ JBossRuntimeLocator locator = new JBossRuntimeLocator();
+ List<RuntimePath> runtimePaths =
RuntimeUIActivator.getDefault().getRuntimePaths();
+ for (RuntimePath runtimePath : runtimePaths) {
+ List<ServerDefinition> serverDefinitions = locator
+ .searchForRuntimes(runtimePath.getPath(), new NullProgressMonitor());
+ runtimePath.getServerDefinitions().clear();
+ for (ServerDefinition serverDefinition : serverDefinitions) {
+ serverDefinition.setRuntimePath(runtimePath);
+ }
+ 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) {
+ 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) {
+ SeamVersion version = seamRuntime.getVersion();
+ if (SeamVersion.SEAM_2_0.equals(version)) {
+ seam20Exists = true;
+ }
+ if (SeamVersion.SEAM_2_2.equals(version)) {
+ seam22Exists = true;
+ }
+ if (SeamVersion.SEAM_1_2.equals(version)) {
+ seam12Exists = true;
+ }
+ }
+ 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);
+ }
+
+ @Test
+ public void testWtpRuntimes() {
+ 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) {
+ IRuntimeType runtimeType = runtime.getRuntimeType();
+ if (IJBossToolingConstants.AS_42.equals(runtimeType.getId())) {
+ as42Exists = true;
+ }
+ if (IJBossToolingConstants.AS_51.equals(runtimeType.getId())) {
+ as51Exists = true;
+ }
+ if (IJBossToolingConstants.EAP_43.equals(runtimeType.getId())) {
+ eap43Exists = true;
+ }
+ }
+ 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);
+ }
+}