Author: snjeza
Date: 2011-03-22 20:04:53 -0400 (Tue, 22 Mar 2011)
New Revision: 29964
Added:
trunk/examples/tests/org.jboss.tools.project.examples.test/plugin.properties
trunk/examples/tests/org.jboss.tools.project.examples.test/requirements.properties
trunk/examples/tests/org.jboss.tools.project.examples.test/src/org/jboss/tools/project/examples/test/ProjectExamplesAllTests.java
trunk/examples/tests/org.jboss.tools.project.examples.test/src/org/jboss/tools/project/examples/test/ProjectExamplesUtil.java
trunk/examples/tests/org.jboss.tools.project.examples.test/src/org/jboss/tools/project/examples/test/ProjectTest.java
trunk/examples/tests/org.jboss.tools.project.examples.test/src/org/jboss/tools/project/examples/test/SiteTest.java
Removed:
trunk/examples/tests/org.jboss.tools.project.examples.test/src/org/jboss/tools/project/examples/test/ProjectExamplesPluginsLoadTest.java
trunk/examples/tests/org.jboss.tools.project.examples.test/src/org/jboss/tools/project/examples/test/ProjectExamplesTestSuite.java
Modified:
trunk/examples/tests/org.jboss.tools.project.examples.test/.classpath
trunk/examples/tests/org.jboss.tools.project.examples.test/.settings/org.eclipse.jdt.core.prefs
trunk/examples/tests/org.jboss.tools.project.examples.test/META-INF/MANIFEST.MF
trunk/examples/tests/org.jboss.tools.project.examples.test/build.properties
trunk/examples/tests/org.jboss.tools.project.examples.test/pom.xml
Log:
JBIDE-8618 Add JUnit tests for Project Examples
Modified: trunk/examples/tests/org.jboss.tools.project.examples.test/.classpath
===================================================================
--- trunk/examples/tests/org.jboss.tools.project.examples.test/.classpath 2011-03-23
00:04:18 UTC (rev 29963)
+++ trunk/examples/tests/org.jboss.tools.project.examples.test/.classpath 2011-03-23
00:04:53 UTC (rev 29964)
@@ -1,7 +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/J2SE-1.5"/>
- <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
+<?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>
Modified:
trunk/examples/tests/org.jboss.tools.project.examples.test/.settings/org.eclipse.jdt.core.prefs
===================================================================
---
trunk/examples/tests/org.jboss.tools.project.examples.test/.settings/org.eclipse.jdt.core.prefs 2011-03-23
00:04:18 UTC (rev 29963)
+++
trunk/examples/tests/org.jboss.tools.project.examples.test/.settings/org.eclipse.jdt.core.prefs 2011-03-23
00:04:53 UTC (rev 29964)
@@ -1,8 +1,8 @@
-#Wed Oct 21 17:40:14 PDT 2009
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
+#Thu Feb 10 15:37:17 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
Modified: trunk/examples/tests/org.jboss.tools.project.examples.test/META-INF/MANIFEST.MF
===================================================================
---
trunk/examples/tests/org.jboss.tools.project.examples.test/META-INF/MANIFEST.MF 2011-03-23
00:04:18 UTC (rev 29963)
+++
trunk/examples/tests/org.jboss.tools.project.examples.test/META-INF/MANIFEST.MF 2011-03-23
00:04:53 UTC (rev 29964)
@@ -1,12 +1,31 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
-Bundle-Name: Project Examples Test Suite
+Bundle-Name: %BundleName
Bundle-SymbolicName: org.jboss.tools.project.examples.test;singleton:=true
-Bundle-Version: 1.1.0.qualifier
+Bundle-Version: 1.2.0.qualifier
Require-Bundle: org.eclipse.core.runtime,
- org.junit;bundle-version="3.8.2",
- org.jboss.tools.tests;bundle-version="2.0.0",
- org.jboss.tools.project.examples;bundle-version="1.1.0"
+ org.jboss.tools.tests,
+ org.jboss.tools.project.examples,
+ org.jboss.tools.community.project.examples,
+ org.jboss.tools.project.examples.cheatsheet,
+ 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;bundle-version="4.8.1"
Bundle-ActivationPolicy: lazy
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Export-Package: org.jboss.tools.project.examples.test
+Bundle-Vendor: %BundleVendor
Modified: trunk/examples/tests/org.jboss.tools.project.examples.test/build.properties
===================================================================
--- trunk/examples/tests/org.jboss.tools.project.examples.test/build.properties 2011-03-23
00:04:18 UTC (rev 29963)
+++ trunk/examples/tests/org.jboss.tools.project.examples.test/build.properties 2011-03-23
00:04:53 UTC (rev 29964)
@@ -1,4 +1,5 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
- .
+ .,\
+ plugin.properties
Added: trunk/examples/tests/org.jboss.tools.project.examples.test/plugin.properties
===================================================================
--- trunk/examples/tests/org.jboss.tools.project.examples.test/plugin.properties
(rev 0)
+++
trunk/examples/tests/org.jboss.tools.project.examples.test/plugin.properties 2011-03-23
00:04:53 UTC (rev 29964)
@@ -0,0 +1,9 @@
+#Properties file for org.jboss.tools.project.examples
+BundleVendor = JBoss by Red Hat
+BundleName = Project Examples
+JBoss_Tools_category = JBoss Tools
+Project_Examples_wizard = Project Examples
+Project_Examples_command =Project Examples...
+ProjectExamples=Project Examples file
+Project_Examples = Project Examples
+JBoss_Tools_32_Community_Examples = JBoss Tools 3.2 Community Examples
\ No newline at end of file
Modified: trunk/examples/tests/org.jboss.tools.project.examples.test/pom.xml
===================================================================
--- trunk/examples/tests/org.jboss.tools.project.examples.test/pom.xml 2011-03-23 00:04:18
UTC (rev 29963)
+++ trunk/examples/tests/org.jboss.tools.project.examples.test/pom.xml 2011-03-23 00:04:53
UTC (rev 29964)
@@ -8,11 +8,25 @@
</parent>
<groupId>org.jboss.tools.examples.tests</groupId>
<artifactId>org.jboss.tools.project.examples.test</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>1.2.0-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<properties>
- <emma.filter>org.jboss.tools.project.examples*</emma.filter>
- <emma.instrument.bundles>org.jboss.tools.project.examples</emma.instrument.bundles>
+ <systemProperties>-Djbosstools.test.jboss.home.4.2=${requirement.build.root}/jboss-4.2.3.GA
-Djbosstools.test.seam.2.0.1.GA.home=${requirement.build.root}/jboss-seam-2.0.2.SP1</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.project.examples.test</testSuite>
+
<testClass>org.jboss.tools.project.examples.test.ProjectExamplesAllTests</testClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
\ No newline at end of file
Added: trunk/examples/tests/org.jboss.tools.project.examples.test/requirements.properties
===================================================================
--- trunk/examples/tests/org.jboss.tools.project.examples.test/requirements.properties
(rev 0)
+++
trunk/examples/tests/org.jboss.tools.project.examples.test/requirements.properties 2011-03-23
00:04:53 UTC (rev 29964)
@@ -0,0 +1 @@
+requirements=jbossas,seam-2.0.2.SP1
\ No newline at end of file
Added:
trunk/examples/tests/org.jboss.tools.project.examples.test/src/org/jboss/tools/project/examples/test/ProjectExamplesAllTests.java
===================================================================
---
trunk/examples/tests/org.jboss.tools.project.examples.test/src/org/jboss/tools/project/examples/test/ProjectExamplesAllTests.java
(rev 0)
+++
trunk/examples/tests/org.jboss.tools.project.examples.test/src/org/jboss/tools/project/examples/test/ProjectExamplesAllTests.java 2011-03-23
00:04:53 UTC (rev 29964)
@@ -0,0 +1,25 @@
+/*************************************************************************************
+ * 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.project.examples.test;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+
+(a)Suite.SuiteClasses({
+ SiteTest.class,
+ ProjectTest.class,
+})
+
+(a)RunWith(Suite.class)
+public class ProjectExamplesAllTests {
+
+}
\ No newline at end of file
Deleted:
trunk/examples/tests/org.jboss.tools.project.examples.test/src/org/jboss/tools/project/examples/test/ProjectExamplesPluginsLoadTest.java
===================================================================
---
trunk/examples/tests/org.jboss.tools.project.examples.test/src/org/jboss/tools/project/examples/test/ProjectExamplesPluginsLoadTest.java 2011-03-23
00:04:18 UTC (rev 29963)
+++
trunk/examples/tests/org.jboss.tools.project.examples.test/src/org/jboss/tools/project/examples/test/ProjectExamplesPluginsLoadTest.java 2011-03-23
00:04:53 UTC (rev 29964)
@@ -1,10 +0,0 @@
-package org.jboss.tools.project.examples.test;
-
-import org.eclipse.core.runtime.Platform;
-import org.jboss.tools.tests.AbstractPluginsLoadTest;
-
-public class ProjectExamplesPluginsLoadTest extends AbstractPluginsLoadTest {
- public void testOrgJbossToolsProjectExamplesAreResolvedAndActivated() {
- assertPluginResolved(Platform.getBundle("org.jboss.tools.project.examples"));
- }
-}
Deleted:
trunk/examples/tests/org.jboss.tools.project.examples.test/src/org/jboss/tools/project/examples/test/ProjectExamplesTestSuite.java
===================================================================
---
trunk/examples/tests/org.jboss.tools.project.examples.test/src/org/jboss/tools/project/examples/test/ProjectExamplesTestSuite.java 2011-03-23
00:04:18 UTC (rev 29963)
+++
trunk/examples/tests/org.jboss.tools.project.examples.test/src/org/jboss/tools/project/examples/test/ProjectExamplesTestSuite.java 2011-03-23
00:04:53 UTC (rev 29964)
@@ -1,12 +0,0 @@
-package org.jboss.tools.project.examples.test;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class ProjectExamplesTestSuite {
- public static Test suite() {
- TestSuite suite = new TestSuite();
- suite.addTestSuite(ProjectExamplesPluginsLoadTest.class);
- return suite;
- }
-}
Added:
trunk/examples/tests/org.jboss.tools.project.examples.test/src/org/jboss/tools/project/examples/test/ProjectExamplesUtil.java
===================================================================
---
trunk/examples/tests/org.jboss.tools.project.examples.test/src/org/jboss/tools/project/examples/test/ProjectExamplesUtil.java
(rev 0)
+++
trunk/examples/tests/org.jboss.tools.project.examples.test/src/org/jboss/tools/project/examples/test/ProjectExamplesUtil.java 2011-03-23
00:04:53 UTC (rev 29964)
@@ -0,0 +1,303 @@
+/*************************************************************************************
+ * 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.project.examples.test;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Properties;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.datatools.connectivity.ConnectionProfileConstants;
+import org.eclipse.datatools.connectivity.ConnectionProfileException;
+import org.eclipse.datatools.connectivity.ProfileManager;
+import org.eclipse.datatools.connectivity.db.generic.IDBConnectionProfileConstants;
+import org.eclipse.datatools.connectivity.db.generic.IDBDriverDefinitionConstants;
+import org.eclipse.datatools.connectivity.drivers.DriverInstance;
+import org.eclipse.datatools.connectivity.drivers.DriverManager;
+import org.eclipse.datatools.connectivity.drivers.IDriverMgmtConstants;
+import org.eclipse.datatools.connectivity.drivers.IPropertySet;
+import org.eclipse.datatools.connectivity.drivers.PropertySetImpl;
+import org.eclipse.datatools.connectivity.drivers.models.TemplateDescriptor;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IPerspectiveDescriptor;
+import org.eclipse.ui.IPerspectiveRegistry;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.wst.server.core.IRuntime;
+import org.eclipse.wst.server.core.IRuntimeType;
+import org.eclipse.wst.server.core.IRuntimeWorkingCopy;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.IServerType;
+import org.eclipse.wst.server.core.IServerWorkingCopy;
+import org.eclipse.wst.server.core.ServerCore;
+import org.eclipse.wst.server.core.ServerUtil;
+import org.eclipse.wst.server.core.internal.RuntimeWorkingCopy;
+import org.eclipse.wst.server.core.internal.ServerWorkingCopy;
+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;
+
+/**
+ * @author snjeza
+ */
+public class ProjectExamplesUtil {
+
+ public static final int IDLE_TIME = 60000;
+
+ public static final String CONNECTION_PROFILE_NAME = "DefaultDS";
+
+ public static final String SEAM_RUNTIME_NAME = "Seam 2.0";
+
+ public static final String JBOSS_AS_RUNTIME_NAME = "JBoss AS 4.2 Runtime";
+
+ public static final String JBOSS_AS_SERVER_NAME = "JBoss AS 4.2.3 Server";
+
+ public static final String JBOSS_AS_HOST = "localhost"; //$NON-NLS-1$
+
+ public static final String JBOSS_AS_DEFAULT_CONFIGURATION_NAME = "default";
//$NON-NLS-1$
+
+ public static final String HSQL_DRIVER_DEFINITION_ID
+ = "DriverDefn.Hypersonic DB"; //$NON-NLS-1$
+
+ public static final String HSQL_DRIVER_NAME = "Hypersonic DB"; //$NON-NLS-1$
+
+ public static final String HSQL_DRIVER_TEMPLATE_ID
+ = "org.eclipse.datatools.enablement.hsqldb.1_8.driver"; //$NON-NLS-1$
+
+ public static final String DTP_DB_URL_PROPERTY_ID
+ = "org.eclipse.datatools.connectivity.db.URL"; //$NON-NLS-1$
+
+ public static final String HSQL_PROFILE_ID =
"org.eclipse.datatools.enablement.hsqldb.connectionProfile";
+
+ public static final String JBOSS_AS_HOME =
System.getProperty("jbosstools.test.jboss.home.4.2",
"E:\\JBossRuntimes\\jboss-4.2.3.GA");
+
+ public static final String JBOSS_AS_RUNTIME_ID =
"org.jboss.ide.eclipse.as.runtime.42";
+
+ public static final String JBOSS_AS_SERVER_ID =
"org.jboss.ide.eclipse.as.42";
+
+ public static final String SEAM_HOME_PROPERTY =
System.getProperty("jbosstools.test.seam.2.0.1.GA.home",
"E:\\jboss-seam-2.0.2.SP1");
+
+ public static final String HSQLDB_DRIVER_JAR_NAME = "hsqldb.jar";
//$NON-NLS-1$
+
+ public static final String HSQLDB_DRIVER_LOCATION = "/common/lib/" +
HSQLDB_DRIVER_JAR_NAME; //$NON-NLS-1$
+
+ public static final String PROJECT_NAME_WAR = "MavenizedSeamProjectWar";
+
+ public static final String TEST_PROJECT_NAME_WAR =
"MavenizedSeamProjectWar-test";
+
+ public static final String PARENT_PROJECT_NAME_WAR =
"MavenizedSeamProjectWar-parent";
+
+
+ public static final String PROJECT_NAME = "MavenizedSeamProject";
+
+ public static final String EAR_PROJECT_NAME = "MavenizedSeamProject-ear";
+
+ public static final String EJB_PROJECT_NAME = "MavenizedSeamProject-ejb";
+
+ public static final String TEST_PROJECT_NAME = "MavenizedSeamProject-test";
+
+ public static final String PARENT_PROJECT_NAME =
"MavenizedSeamProject-parent";
+
+ public static final String DEPLOY_TYPE_EAR = "EAR";
+
+ public static final String DEPLOY_TYPE_WAR = "WAR";
+
+ public static void initRuntimes() throws Exception {
+ switchPerspective("org.jboss.tools.seam.ui.SeamPerspective");
+
+ String asLocation = JBOSS_AS_HOME;
+
+ String runtimeType = JBOSS_AS_RUNTIME_ID;
+ String serverType = JBOSS_AS_SERVER_ID;
+
+ createJBossServer(new File(asLocation), serverType, runtimeType, JBOSS_AS_SERVER_NAME,
JBOSS_AS_RUNTIME_NAME);
+
+ String seamPath = SEAM_HOME_PROPERTY;
+ createSeamRuntime(SEAM_RUNTIME_NAME, seamPath, SeamVersion.SEAM_2_0);
+
+ createDriver(asLocation, HSQLDB_DRIVER_LOCATION);
+ }
+
+ public static void removeProjects() throws CoreException {
+ final IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ workspace.run(new IWorkspaceRunnable() {
+ public void run(IProgressMonitor monitor) throws CoreException {
+ IProject[] projects = workspace.getRoot().getProjects();
+ for (int i = 0; i < projects.length; i++) {
+ projects[i].delete(true, true, monitor);
+ }
+ }
+ }, new NullProgressMonitor());
+ }
+ protected static void switchPerspective(final String pid) {
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ IPerspectiveRegistry perspectiveRegistry = workbench
+ .getPerspectiveRegistry();
+ IPerspectiveDescriptor perspective = perspectiveRegistry
+ .findPerspectiveWithId(pid);
+ workbench.getActiveWorkbenchWindow().getActivePage()
+ .setPerspective(perspective);
+ }
+ });
+ }
+
+ protected static void createJBossServer(File asLocation, String serverType, String
runtimeType, String name, String runtimeName) throws CoreException {
+ if (!asLocation.isDirectory()) {
+ return;
+ }
+ IPath jbossAsLocationPath = new Path(asLocation.getAbsolutePath());
+
+ IServer[] servers = ServerCore.getServers();
+ for (int i = 0; i < servers.length; i++) {
+ IRuntime runtime = servers[i].getRuntime();
+ if(runtime != null && runtime.getLocation().equals(jbossAsLocationPath)) {
+ return;
+ }
+ }
+
+ IRuntime runtime = null;
+ IRuntime[] runtimes = ServerCore.getRuntimes();
+ for (int i = 0; i < runtimes.length; i++) {
+ if (runtimes[0].getLocation().equals(jbossAsLocationPath)) {
+ runtime = runtimes[0].createWorkingCopy();
+ break;
+ }
+ }
+
+ IProgressMonitor progressMonitor = new NullProgressMonitor();
+ if (runtime == null) {
+ runtime = createRuntime(runtimeName, asLocation.getAbsolutePath(), progressMonitor,
runtimeType);
+ }
+ if (runtime != null) {
+ createServer( runtime, serverType, name, progressMonitor);
+ }
+ }
+
+ protected static IRuntime createRuntime(String runtimeName, String jbossASLocation,
IProgressMonitor progressMonitor, String runtimeType) throws CoreException {
+ IRuntimeWorkingCopy runtime = null;
+ String type = null;
+ String version = null;
+ String runtimeId = null;
+ IPath jbossAsLocationPath = new Path(jbossASLocation);
+ IRuntimeType[] runtimeTypes = ServerUtil.getRuntimeTypes(type, version, runtimeType);
+ if (runtimeTypes.length > 0) {
+ runtime = runtimeTypes[0].createRuntime(runtimeId, progressMonitor);
+ runtime.setLocation(jbossAsLocationPath);
+ if(runtimeName!=null) {
+ runtime.setName(runtimeName);
+ }
+ ((RuntimeWorkingCopy)
runtime).setAttribute("org.jboss.ide.eclipse.as.core.runtime.configurationName",
JBOSS_AS_DEFAULT_CONFIGURATION_NAME); //$NON-NLS-1$
+
+ return runtime.save(false, progressMonitor);
+ }
+ return runtime;
+ }
+
+ protected static void createDriver(String jbossASLocation, String driverLocation) throws
ConnectionProfileException, IOException {
+ if(ProfileManager.getInstance().getProfileByName(CONNECTION_PROFILE_NAME) != null) {
+ return;
+ }
+ String driverPath = new File(jbossASLocation + driverLocation).getCanonicalPath();
//$NON-NLS-1$
+
+ DriverInstance driver =
DriverManager.getInstance().getDriverInstanceByName(HSQL_DRIVER_NAME);
+ if (driver == null) {
+ TemplateDescriptor descr =
TemplateDescriptor.getDriverTemplateDescriptor(HSQL_DRIVER_TEMPLATE_ID);
+ IPropertySet instance = new PropertySetImpl(HSQL_DRIVER_NAME,
HSQL_DRIVER_DEFINITION_ID);
+ instance.setName(HSQL_DRIVER_NAME);
+ instance.setID(HSQL_DRIVER_DEFINITION_ID);
+ Properties props = new Properties();
+
+ IConfigurationElement[] template = descr.getProperties();
+ for (int i = 0; i < template.length; i++) {
+ IConfigurationElement prop = template[i];
+ String id = prop.getAttribute("id"); //$NON-NLS-1$
+
+ String value = prop.getAttribute("value"); //$NON-NLS-1$
+ props.setProperty(id, value == null ? "" : value); //$NON-NLS-1$
+ }
+ props.setProperty(DTP_DB_URL_PROPERTY_ID, "jdbc:hsqldb:."); //$NON-NLS-1$
+ props.setProperty(IDriverMgmtConstants.PROP_DEFN_TYPE, descr.getId());
+ props.setProperty(IDriverMgmtConstants.PROP_DEFN_JARLIST, driverPath);
+
+ instance.setBaseProperties(props);
+ DriverManager.getInstance().removeDriverInstance(instance.getID());
+ System.gc();
+ DriverManager.getInstance().addDriverInstance(instance);
+ }
+
+ driver = DriverManager.getInstance().getDriverInstanceByName(HSQL_DRIVER_NAME);
+ if (driver != null &&
ProfileManager.getInstance().getProfileByName(CONNECTION_PROFILE_NAME) == null) {
//$NON-NLS-1$
+ // create profile
+ Properties props = new Properties();
+ props.setProperty(ConnectionProfileConstants.PROP_DRIVER_DEFINITION_ID,
HSQL_DRIVER_DEFINITION_ID);
+ props.setProperty(IDBConnectionProfileConstants.CONNECTION_PROPERTIES_PROP_ID,
""); //$NON-NLS-1$
+ props.setProperty(IDBDriverDefinitionConstants.DRIVER_CLASS_PROP_ID,
driver.getProperty(IDBDriverDefinitionConstants.DRIVER_CLASS_PROP_ID));
+ props.setProperty(IDBDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID, driver.getProperty(IDBDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID));
+ props.setProperty(IDBDriverDefinitionConstants.DATABASE_VERSION_PROP_ID,
driver.getProperty(IDBDriverDefinitionConstants.DATABASE_VERSION_PROP_ID));
+ props.setProperty(IDBDriverDefinitionConstants.DATABASE_NAME_PROP_ID,
"Default"); //$NON-NLS-1$
+ props.setProperty(IDBDriverDefinitionConstants.PASSWORD_PROP_ID, "");
//$NON-NLS-1$
+ props.setProperty(IDBConnectionProfileConstants.SAVE_PASSWORD_PROP_ID,
"false"); //$NON-NLS-1$
+ props.setProperty(IDBDriverDefinitionConstants.USERNAME_PROP_ID,
driver.getProperty(IDBDriverDefinitionConstants.USERNAME_PROP_ID));
+ props.setProperty(IDBDriverDefinitionConstants.URL_PROP_ID,
driver.getProperty(IDBDriverDefinitionConstants.URL_PROP_ID));
+
+ ProfileManager.getInstance().createProfile(CONNECTION_PROFILE_NAME, "The JBoss AS
Hypersonic embedded database", HSQL_PROFILE_ID, props, "", false);
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ }
+
+ protected static IServerWorkingCopy createServer(IRuntime runtime, String runtimeType,
String name, IProgressMonitor progressMonitor) throws CoreException {
+ IServerType serverType = ServerCore.findServerType(runtimeType);
+ IServerWorkingCopy server = serverType.createServer(null, null, runtime,
progressMonitor);
+
+ server.setHost(JBOSS_AS_HOST);
+ server.setName(name);
+
+ // JBossServer.DEPLOY_DIRECTORY
+ String deployVal =
runtime.getLocation().append("server").append(JBOSS_AS_DEFAULT_CONFIGURATION_NAME).append("deploy").toOSString();
//$NON-NLS-1$ //$NON-NLS-2$
+ ((ServerWorkingCopy)
server).setAttribute("org.jboss.ide.eclipse.as.core.server.deployDirectory",
deployVal); //$NON-NLS-1$
+
+ // IDeployableServer.TEMP_DEPLOY_DIRECTORY
+ String deployTmpFolderVal =
runtime.getLocation().append("server").append(JBOSS_AS_DEFAULT_CONFIGURATION_NAME).append("tmp").append("jbosstoolsTemp").toOSString();
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ ((ServerWorkingCopy)
server).setAttribute("org.jboss.ide.eclipse.as.core.server.tempDeployDirectory",
deployTmpFolderVal); //$NON-NLS-1$
+
+ server.save(false, progressMonitor);
+ return server;
+ }
+
+ protected static void createSeamRuntime(String name, String seamPath, SeamVersion
seamVersion) {
+ SeamRuntime seamRuntime = SeamRuntimeManager.getInstance().findRuntimeByName(name);
+ if (seamRuntime != null) {
+ return;
+ }
+ File seamFolder = new File(seamPath);
+ if(seamFolder.exists() && seamFolder.isDirectory()) {
+ SeamRuntime rt = new SeamRuntime();
+ rt.setHomeDir(seamPath);
+ rt.setName(name);
+ rt.setDefault(true);
+ rt.setVersion(seamVersion);
+ SeamRuntimeManager.getInstance().addRuntime(rt);
+ }
+ }
+
+}
Added:
trunk/examples/tests/org.jboss.tools.project.examples.test/src/org/jboss/tools/project/examples/test/ProjectTest.java
===================================================================
---
trunk/examples/tests/org.jboss.tools.project.examples.test/src/org/jboss/tools/project/examples/test/ProjectTest.java
(rev 0)
+++
trunk/examples/tests/org.jboss.tools.project.examples.test/src/org/jboss/tools/project/examples/test/ProjectTest.java 2011-03-23
00:04:53 UTC (rev 29964)
@@ -0,0 +1,142 @@
+/*************************************************************************************
+ * 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.project.examples.test;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.resources.WorkspaceJob;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.jboss.tools.project.examples.Messages;
+import org.jboss.tools.project.examples.ProjectExamplesActivator;
+import org.jboss.tools.project.examples.model.Category;
+import org.jboss.tools.project.examples.model.Project;
+import org.jboss.tools.project.examples.model.ProjectUtil;
+import org.jboss.tools.project.examples.wizard.NewProjectExamplesWizard;
+import org.jboss.tools.test.util.JobUtils;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ * @author snjeza
+ *
+ */
+public class ProjectTest {
+
+ @BeforeClass
+ public static void initRuntimes() throws Exception {
+ ProjectExamplesUtil.initRuntimes();
+ }
+
+ @AfterClass
+ public static void removeProjects() throws Exception {
+ ProjectExamplesUtil.removeProjects();
+ }
+
+ @Test
+ public void importNumberguess() throws Exception {
+ WorkspaceJob workspaceJob = new
WorkspaceJob(Messages.NewProjectExamplesWizard_Downloading) {
+
+ public IStatus runInWorkspace(IProgressMonitor monitor)
+ throws CoreException {
+ try {
+ importProject(monitor);
+ } catch (Exception e) {
+ // ignore
+ }
+ return Status.OK_STATUS;
+ }
+
+ };
+ workspaceJob.setUser(true);
+ workspaceJob.schedule();
+ JobUtils.waitForIdle(ProjectExamplesUtil.IDLE_TIME);
+ }
+
+ private void importProject(IProgressMonitor monitor) throws MalformedURLException,
Exception {
+ List<Category> projects = ProjectUtil.getProjects(monitor);
+ Category seamCategory = null;
+ for (Category category: projects) {
+ if ("Seam".equals(category.getName())) {
+ seamCategory = category;
+ break;
+ }
+ }
+ assertNotNull(seamCategory);
+ Project projectExample = null;
+ for (Project project: seamCategory.getProjects()) {
+ if ("numberguess".equals(project.getName())) {
+ projectExample = project;
+ break;
+ }
+ }
+ assertNotNull(projectExample);
+ String urlString = projectExample.getUrl();
+ String name = projectExample.getName();
+ URL url = null;
+ url = new URL(urlString);
+ File file = ProjectUtil.getProjectExamplesFile(
+ url, name, ".zip", monitor); //$NON-NLS-1$
+ assertNotNull(file);
+ NewProjectExamplesWizard.importProject(projectExample, file, monitor);
+ ProjectExamplesActivator.fix(projectExample, monitor);
+ }
+
+ @Test
+ public void testImportedProjects() {
+ projectExists("numberguess");
+ projectExists("numberguess-ejb");
+ projectExists("numberguess-ear");
+ }
+
+ private void projectExists(String projectName) {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot()
+ .getProject(projectName);
+ assertTrue(project != null && project.isOpen());
+ }
+
+ @Test
+ public void testErrors() throws Exception {
+ checkErrors("numberguess");
+ checkErrors("numberguess-ejb");
+ checkErrors("numberguess-ear");
+ }
+
+ private void checkErrors(String projectName) throws CoreException {
+ List<IMarker> markers = new ArrayList<IMarker>();
+ IProject project = ResourcesPlugin.getWorkspace().getRoot()
+ .getProject(projectName);
+ IMarker[] projectMarkers = project.findMarkers(IMarker.PROBLEM, true,
+ IResource.DEPTH_INFINITE);
+ for (int i = 0; i < projectMarkers.length; i++) {
+ if (projectMarkers[i].getAttribute(IMarker.SEVERITY,
+ IMarker.SEVERITY_ERROR) == IMarker.SEVERITY_ERROR) {
+ markers.add(projectMarkers[i]);
+ }
+ }
+ assertTrue("The '" + projectName + "' contains errors.",
markers.size() == 0);
+ }
+}
Added:
trunk/examples/tests/org.jboss.tools.project.examples.test/src/org/jboss/tools/project/examples/test/SiteTest.java
===================================================================
---
trunk/examples/tests/org.jboss.tools.project.examples.test/src/org/jboss/tools/project/examples/test/SiteTest.java
(rev 0)
+++
trunk/examples/tests/org.jboss.tools.project.examples.test/src/org/jboss/tools/project/examples/test/SiteTest.java 2011-03-23
00:04:53 UTC (rev 29964)
@@ -0,0 +1,46 @@
+/*************************************************************************************
+ * 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.project.examples.test;
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.jboss.tools.project.examples.model.ProjectExampleSite;
+import org.jboss.tools.project.examples.model.ProjectUtil;
+import org.junit.Test;
+
+/**
+ *
+ * @author snjeza
+ *
+ */
+public class SiteTest {
+
+ @Test
+ public void sitesPresent() {
+ Set<ProjectExampleSite> sites = new HashSet<ProjectExampleSite>();
+ sites.addAll(ProjectUtil.getPluginSites());
+ sites.addAll(ProjectUtil.getUserSites());
+ assertTrue(sites.size() > 0);
+ }
+
+ @Test
+ public void testInvalidSites() {
+ ProjectUtil.getProjects(new NullProgressMonitor());
+ HashSet<ProjectExampleSite> invalidSites = ProjectUtil.getInvalidSites();
+ assertTrue(invalidSites.size() <= 0);
+ }
+
+
+}