Author: rob.stryker(a)jboss.com
Date: 2008-06-19 19:45:51 -0400 (Thu, 19 Jun 2008)
New Revision: 8855
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.test/projectPieces/
trunk/as/tests/org.jboss.ide.eclipse.as.test/projectPieces/1104-application.xml
trunk/as/tests/org.jboss.ide.eclipse.as.test/projectPieces/1104-jboss-app.xml
trunk/as/tests/org.jboss.ide.eclipse.as.test/projectPieces/1104.properties
trunk/as/tests/org.jboss.ide.eclipse.as.test/projectPieces/EJB3WithDescriptor.jar
trunk/as/tests/org.jboss.ide.eclipse.as.test/projectPieces/Ejb3NoDescriptor.jar
trunk/as/tests/org.jboss.ide.eclipse.as.test/projectPieces/WebArchive.war
trunk/as/tests/org.jboss.ide.eclipse.as.test/projectPieces/directory-monitor.sar
trunk/as/tests/org.jboss.ide.eclipse.as.test/projects/SimpleEar/
trunk/as/tests/org.jboss.ide.eclipse.as.test/projects/SimpleEar/.project
trunk/as/tests/org.jboss.ide.eclipse.as.test/projects/SimpleEar/.settings/
trunk/as/tests/org.jboss.ide.eclipse.as.test/projects/SimpleEar/.settings/org.eclipse.wst.common.component
trunk/as/tests/org.jboss.ide.eclipse.as.test/projects/SimpleEar/.settings/org.eclipse.wst.common.project.facet.core.xml
trunk/as/tests/org.jboss.ide.eclipse.as.test/projects/SimpleEar/EarContent/
trunk/as/tests/org.jboss.ide.eclipse.as.test/projects/SimpleEar/EarContent/META-INF/
trunk/as/tests/org.jboss.ide.eclipse.as.test/projects/TempProject/
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/AbstractDeploymentTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/JBIDE1104Test.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/testOutputs/
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/RuntimeServerModelTest.java
Log:
JBIDE-1104 and others will use this
Added: trunk/as/tests/org.jboss.ide.eclipse.as.test/projectPieces/1104-application.xml
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.test/projectPieces/1104-application.xml
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/projectPieces/1104-application.xml 2008-06-19
23:45:51 UTC (rev 8855)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<application
xmlns="http://java.sun.com/xml/ns/j2ee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+
http://java.sun.com/xml/ns/j2ee/application_1_4.xsd"
+ version="1.4">
+
+ <display-name>Simple example of application</display-name>
+
+ <module>
+ <ejb>EJB3WithDescriptor.jar</ejb>
+ </module>
+</application>
\ No newline at end of file
Added: trunk/as/tests/org.jboss.ide.eclipse.as.test/projectPieces/1104-jboss-app.xml
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.test/projectPieces/1104-jboss-app.xml
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/projectPieces/1104-jboss-app.xml 2008-06-19
23:45:51 UTC (rev 8855)
@@ -0,0 +1,5 @@
+<jboss-app>
+ <module>
+ <service>directory-monitor.sar</service>
+ </module>
+</jboss-app>
\ No newline at end of file
Added: trunk/as/tests/org.jboss.ide.eclipse.as.test/projectPieces/1104.properties
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.test/projectPieces/1104.properties
(rev 0)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.test/projectPieces/1104.properties 2008-06-19
23:45:51 UTC (rev 8855)
@@ -0,0 +1,8 @@
+copy1src=directory-monitor.sar
+copy1dest=EarContent/directory-monitor.sar
+copy2src=EJB3WithDescriptor.jar
+copy2dest=EarContent/EJB3WithDescriptor.jar
+copy3src=1104-application.xml
+copy3dest=EarContent/META-INF/application.xml
+copy4src=1104-jboss-app.xml
+copy4dest=EarContent/META-INF/jboss-app.xml
\ No newline at end of file
Added: trunk/as/tests/org.jboss.ide.eclipse.as.test/projectPieces/EJB3WithDescriptor.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/as/tests/org.jboss.ide.eclipse.as.test/projectPieces/EJB3WithDescriptor.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/as/tests/org.jboss.ide.eclipse.as.test/projectPieces/Ejb3NoDescriptor.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/as/tests/org.jboss.ide.eclipse.as.test/projectPieces/Ejb3NoDescriptor.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/as/tests/org.jboss.ide.eclipse.as.test/projectPieces/WebArchive.war
===================================================================
(Binary files differ)
Property changes on:
trunk/as/tests/org.jboss.ide.eclipse.as.test/projectPieces/WebArchive.war
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/as/tests/org.jboss.ide.eclipse.as.test/projectPieces/directory-monitor.sar
===================================================================
(Binary files differ)
Property changes on:
trunk/as/tests/org.jboss.ide.eclipse.as.test/projectPieces/directory-monitor.sar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/as/tests/org.jboss.ide.eclipse.as.test/projects/SimpleEar/.project
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.test/projects/SimpleEar/.project
(rev 0)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.test/projects/SimpleEar/.project 2008-06-19
23:45:51 UTC (rev 8855)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>SimpleEar</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.wst.common.project.facet.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.validation.validationbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+ <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
+ </natures>
+</projectDescription>
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.test/projects/SimpleEar/.settings/org.eclipse.wst.common.component
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/projects/SimpleEar/.settings/org.eclipse.wst.common.component
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/projects/SimpleEar/.settings/org.eclipse.wst.common.component 2008-06-19
23:45:51 UTC (rev 8855)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project-modules id="moduleCoreId" project-version="1.5.0">
+ <wb-module deploy-name="SimpleEar">
+ <wb-resource deploy-path="/"
source-path="/EarContent"/>
+ </wb-module>
+</project-modules>
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.test/projects/SimpleEar/.settings/org.eclipse.wst.common.project.facet.core.xml
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/projects/SimpleEar/.settings/org.eclipse.wst.common.project.facet.core.xml
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/projects/SimpleEar/.settings/org.eclipse.wst.common.project.facet.core.xml 2008-06-19
23:45:51 UTC (rev 8855)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <runtime name="JBoss 4.2 Runtime"/>
+ <fixed facet="jst.ear"/>
+ <installed facet="jst.ear" version="5.0"/>
+</faceted-project>
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/RuntimeServerModelTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/RuntimeServerModelTest.java 2008-06-19
16:42:58 UTC (rev 8854)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/RuntimeServerModelTest.java 2008-06-19
23:45:51 UTC (rev 8855)
@@ -59,7 +59,7 @@
return new IRuntime[] { savedRuntime, secondSavedRuntime };
}
- public void testCreateBrokenServer() throws CoreException {
+ public void testCreateBrokenRuntime() throws CoreException {
IRuntimeType[] runtimeTypes = ServerUtil.getRuntimeTypes(null,null,
ASTest.JBOSS_RUNTIME_42);
assertEquals("expects only one runtime type for jboss 4.2",
runtimeTypes.length, 1);
IRuntimeType runtimeType = runtimeTypes[0];
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/AbstractDeploymentTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/AbstractDeploymentTest.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/AbstractDeploymentTest.java 2008-06-19
23:45:51 UTC (rev 8855)
@@ -0,0 +1,157 @@
+package org.jboss.ide.eclipse.as.test.publishing;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Properties;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.server.core.IModule;
+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.internal.ServerWorkingCopy;
+import org.jboss.ide.eclipse.as.core.server.internal.DeployableServer;
+import org.jboss.ide.eclipse.as.core.util.FileUtil;
+import org.jboss.ide.eclipse.as.test.ASTest;
+import org.jboss.tools.common.test.util.TestProjectProvider;
+import org.osgi.framework.Bundle;
+
+public abstract class AbstractDeploymentTest extends TestCase {
+ protected String BUNDLE_NAME = "org.jboss.ide.eclipse.as.test";
+ private TestProjectProvider provider;
+ protected IProject workspaceProject;
+ protected String sourceProjectName;
+ protected String testProperties;
+ protected IRuntime runtime;
+ protected IServer server;
+
+ public AbstractDeploymentTest(String projectName, String testProperties) {
+ this.sourceProjectName = projectName;
+ this.testProperties = testProperties;
+ }
+
+ protected void setUp() throws Exception {
+ cleanFolder(getProjectLocation("TempProject").getAbsolutePath());
+ assembleInTempProject();
+ createServer();
+ String path = "/projects/TempProject/" + sourceProjectName;
+ provider = new TestProjectProvider(BUNDLE_NAME, path, sourceProjectName, true);
+ workspaceProject = provider.getProject();
+ workspaceProject.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ }
+
+ protected void cleanFolder(String folder) throws CoreException {
+ cleanFolder(new File(folder));
+ }
+ protected void cleanFolder(File folder) throws CoreException {
+ if( folder != null && folder.exists() ) {
+ File[] children = folder.listFiles();
+ for( int i = 0; i < children.length; i++ )
+ FileUtil.safeDelete(children[i]);
+ }
+ }
+
+ protected File getProjectLocation(String name) throws CoreException {
+ return getFileLocation("/projects/" + name);
+ }
+
+ protected File getFileLocation(String path) throws CoreException {
+ Bundle bundle = Platform.getBundle(BUNDLE_NAME);
+ URL url = null;
+ try {
+ url = FileLocator.resolve(bundle.getEntry(path));
+ } catch (IOException e) {
+ String msg = "Cannot find file " + path + " in " + BUNDLE_NAME;
+ IStatus status = new Status(IStatus.ERROR, ASTest.PLUGIN_ID, msg, e);
+ throw new CoreException(status);
+ }
+ String location = url.getFile();
+ return new File(location);
+ }
+
+ protected void assembleInTempProject() throws CoreException {
+ File tempProject = getProjectLocation("TempProject");
+ File srcProject = getProjectLocation(sourceProjectName);
+ File destProject = new File(tempProject, sourceProjectName);
+ FileUtil.fileSafeCopy(srcProject, destProject);
+
+ // now copy files over from the properties file
+ File propertiesFile = getFileLocation("projectPieces/" + testProperties);
+ Properties props = new Properties();
+ try {
+ props.load(new FileInputStream(propertiesFile));
+ boolean done = false;
+ String srcKey, destKey;
+ int i = 1;
+ while( !done ) {
+ srcKey = "copy" + i + "src";
+ destKey = "copy" + i + "dest";
+ done = copy(props.getProperty(srcKey), props.getProperty(destKey));
+ i++;
+ }
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ protected boolean copy(String src, String dest) throws CoreException {
+ if( src == null || dest == null )
+ return true;
+
+ // do the copy
+ File srcFile, destFile, tmp;
+ srcFile = getFileLocation("projectPieces/" + src);
+ tmp = getFileLocation("projects/TempProject/" + sourceProjectName);
+ destFile = new File(tmp, dest);
+ FileUtil.fileSafeCopy(srcFile, destFile);
+
+ return false;
+ }
+
+
+ protected void createServer() throws CoreException {
+ IRuntimeType rt =
ServerCore.findRuntimeType("org.jboss.ide.eclipse.as.runtime.stripped");
+ IRuntimeWorkingCopy wc = rt.createRuntime("testRuntime", null);
+ runtime = wc.save(true, null);
+ IServerType st =
ServerCore.findServerType("org.jboss.ide.eclipse.as.systemCopyServer");
+ ServerWorkingCopy swc = (ServerWorkingCopy) st.createServer("testServer",
null, null);
+ swc.setServerConfiguration(null);
+ swc.setName("testServer");
+ swc.setAttribute(DeployableServer.DEPLOY_DIRECTORY,
getFileLocation("/testOutputs").getAbsolutePath());
+ server = swc.save(true, null);
+ }
+
+ protected IStatus publish(IModule module) throws CoreException {
+ IServerWorkingCopy copy = server.createWorkingCopy();
+ copy.modifyModules(new IModule[]{module}, new IModule[0], new NullProgressMonitor());
+ server = copy.save(false, new NullProgressMonitor());
+ return server.publish(IServer.PUBLISH_INCREMENTAL, new NullProgressMonitor());
+ }
+
+ protected void tearDown() throws Exception {
+ provider.dispose();
+ cleanFolder(getProjectLocation("TempProject").getAbsolutePath());
+ cleanFolder(getFileLocation("testOutputs"));
+ runtime.delete();
+ server.delete();
+ }
+
+}
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/JBIDE1104Test.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/JBIDE1104Test.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/JBIDE1104Test.java 2008-06-19
23:45:51 UTC (rev 8855)
@@ -0,0 +1,29 @@
+package org.jboss.ide.eclipse.as.test.publishing;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IModuleArtifact;
+import org.eclipse.wst.server.core.internal.ServerPlugin;
+
+public class JBIDE1104Test extends AbstractDeploymentTest {
+
+ public JBIDE1104Test() {
+ super("SimpleEar", "1104.properties");
+ }
+
+ public void testJBIDE1104() throws Exception {
+ IModuleArtifact[] artifacts = ServerPlugin.getModuleArtifacts(workspaceProject);
+ assertNotNull(artifacts);
+ assertEquals(1, artifacts.length);
+ assertNotNull(artifacts[0]);
+ IModule module = artifacts[0].getModule();
+ assertNotNull(module);
+ IStatus result = publish(module);
+ assertEquals(IStatus.OK, result.getSeverity());
+
+ // now do my asserts regarding the output structure
+ // TODO
+
+ }
+
+}