Author: Grid.Qian
Date: 2010-04-07 04:10:14 -0400 (Wed, 07 Apr 2010)
New Revision: 21297
Added:
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/.classpath
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/.project
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/.settings/
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/.settings/.jsdtscope
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/.settings/org.eclipse.jdt.core.prefs
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/.settings/org.eclipse.wst.common.component
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/.settings/org.eclipse.wst.common.project.facet.core.xml
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/.settings/org.eclipse.wst.jsdt.ui.superType.container
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/.settings/org.eclipse.wst.jsdt.ui.superType.name
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/WebContent/
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/WebContent/META-INF/
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/WebContent/META-INF/MANIFEST.MF
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/WebContent/WEB-INF/
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/WebContent/WEB-INF/lib/
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/build/
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/build/classes/
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/src/
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/src/org/jboss/tools/ws/creation/core/test/command/JBossWSMergeWebXMLCommandTest.java
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/MergeWebXMLCommand.java
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/src/org/jboss/tools/ws/creation/core/test/JBossWSCreationCoreTests.java
Log:
JBIDE-5991: to trunk
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/MergeWebXMLCommand.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/MergeWebXMLCommand.java 2010-04-07
06:38:22 UTC (rev 21296)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/MergeWebXMLCommand.java 2010-04-07
08:10:14 UTC (rev 21297)
@@ -11,6 +11,7 @@
package org.jboss.tools.ws.creation.core.commands;
+import java.io.File;
import java.util.List;
import org.eclipse.core.commands.ExecutionException;
@@ -18,6 +19,7 @@
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.jst.j2ee.model.IModelProvider;
import org.eclipse.jst.j2ee.model.ModelProviderManager;
@@ -28,7 +30,14 @@
import org.eclipse.jst.javaee.web.ServletMapping;
import org.eclipse.jst.javaee.web.WebApp;
import org.eclipse.jst.javaee.web.WebFactory;
+import org.eclipse.jst.jee.project.facet.ICreateDeploymentFilesDataModelProperties;
+import org.eclipse.jst.jee.project.facet.WebCreateDeploymentFilesDataModelProvider;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation;
import org.jboss.tools.ws.core.utils.StatusUtils;
import org.jboss.tools.ws.creation.core.data.ServiceModel;
import org.jboss.tools.ws.creation.core.data.ServletDescriptor;
@@ -42,6 +51,7 @@
private ServiceModel model;
IStatus status;
+ private static String WEB_XML = "web.xml"; //$NON-NLS-1$
public MergeWebXMLCommand(ServiceModel model) {
this.model = model;
@@ -61,7 +71,19 @@
for (int i = 0; i < serviceClasses.size(); i++) {
servletDescriptors[i] = getServletDescriptor(serviceClasses.get(i));
}
-
+ IProject pro = JBossWSCreationUtils.getProjectByName(model.getWebProjectName());
+ if (!hasWebXML(pro)) {
+ IVirtualComponent vc = ComponentCore.createComponent(pro);
+ IDataModel model = DataModelFactory.createDataModel(new
WebCreateDeploymentFilesDataModelProvider());
+ model.setProperty(ICreateDeploymentFilesDataModelProperties.GENERATE_DD, vc);
+ model.setProperty(ICreateDeploymentFilesDataModelProperties.TARGET_PROJECT, pro);
+ IDataModelOperation op = model.getDefaultOperation();
+ try {
+ op.execute(new NullProgressMonitor(), null);
+ } catch (ExecutionException e1) {
+ // Ignore
+ }
+ }
mergeWebXML(servletDescriptors);
return status;
}
@@ -212,4 +234,15 @@
webapp.getServletMappings().add(servletMapping);
}
}
+
+ private boolean hasWebXML(IProject pro) {
+ // we are looking for this recursively because though application.xml
+ // is always in META-INF, it's not always in "earcontent" since the
+ // earcontent folder name can be custom
+ File file = JBossWSCreationUtils.findFileByPath(WEB_XML,
pro.getLocation().toOSString());
+ if(file == null){
+ return false;
+ }
+ return true;
+ }
}
Added: trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/.classpath
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/.classpath
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/.classpath 2010-04-07
08:10:14 UTC (rev 21297)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.5.0_15">
+ <attributes>
+ <attribute name="owner.project.facets" value="jst.java"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con"
path="org.eclipse.jst.j2ee.internal.web.container"/>
+ <classpathentry kind="con"
path="org.eclipse.jst.j2ee.internal.module.container"/>
+ <classpathentry kind="output" path="build/classes"/>
+</classpath>
Property changes on:
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/.classpath
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/.project
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/.project
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/.project 2010-04-07
08:10:14 UTC (rev 21297)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>WebTest</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <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.jem.workbench.JavaEMFNature</nature>
+ <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
+ </natures>
+</projectDescription>
Property changes on:
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/.project
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/.settings/.jsdtscope
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/.settings/.jsdtscope
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/.settings/.jsdtscope 2010-04-07
08:10:14 UTC (rev 21297)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con"
path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con"
path="org.eclipse.wst.jsdt.launching.WebProject">
+ <attributes>
+ <attribute name="hide" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con"
path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
+ <classpathentry kind="output" path=""/>
+</classpath>
Added:
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/.settings/org.eclipse.jdt.core.prefs
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/.settings/org.eclipse.jdt.core.prefs
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/.settings/org.eclipse.jdt.core.prefs 2010-04-07
08:10:14 UTC (rev 21297)
@@ -0,0 +1,7 @@
+#Wed Apr 07 14:51:03 CST 2010
+eclipse.preferences.version=1
+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
Property changes on:
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/.settings/org.eclipse.jdt.core.prefs
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/.settings/org.eclipse.wst.common.component
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/.settings/org.eclipse.wst.common.component
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/.settings/org.eclipse.wst.common.component 2010-04-07
08:10:14 UTC (rev 21297)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project-modules id="moduleCoreId" project-version="1.5.0">
+<wb-module deploy-name="WebTest">
+<wb-resource deploy-path="/" source-path="/WebContent"/>
+<wb-resource deploy-path="/WEB-INF/classes"
source-path="/src"/>
+<property name="context-root" value="WebTest"/>
+<property name="java-output-path"
value="/WebTest/build/classes"/>
+</wb-module>
+</project-modules>
Added:
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/.settings/org.eclipse.wst.common.project.facet.core.xml
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/.settings/org.eclipse.wst.common.project.facet.core.xml
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/.settings/org.eclipse.wst.common.project.facet.core.xml 2010-04-07
08:10:14 UTC (rev 21297)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <fixed facet="jst.java"/>
+ <fixed facet="jst.web"/>
+ <installed facet="jst.java" version="5.0"/>
+ <installed facet="jst.web" version="2.5"/>
+</faceted-project>
Property changes on:
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/.settings/org.eclipse.wst.common.project.facet.core.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/.settings/org.eclipse.wst.jsdt.ui.superType.container
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/.settings/org.eclipse.wst.jsdt.ui.superType.container
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/.settings/org.eclipse.wst.jsdt.ui.superType.container 2010-04-07
08:10:14 UTC (rev 21297)
@@ -0,0 +1 @@
+org.eclipse.wst.jsdt.launching.baseBrowserLibrary
\ No newline at end of file
Added:
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/.settings/org.eclipse.wst.jsdt.ui.superType.name
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/.settings/org.eclipse.wst.jsdt.ui.superType.name
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/.settings/org.eclipse.wst.jsdt.ui.superType.name 2010-04-07
08:10:14 UTC (rev 21297)
@@ -0,0 +1 @@
+Window
\ No newline at end of file
Added:
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/WebContent/META-INF/MANIFEST.MF
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/WebContent/META-INF/MANIFEST.MF
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/WebContent/META-INF/MANIFEST.MF 2010-04-07
08:10:14 UTC (rev 21297)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Property changes on:
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/projects/WebTest/WebContent/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/src/org/jboss/tools/ws/creation/core/test/JBossWSCreationCoreTests.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/src/org/jboss/tools/ws/creation/core/test/JBossWSCreationCoreTests.java 2010-04-07
06:38:22 UTC (rev 21296)
+++
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/src/org/jboss/tools/ws/creation/core/test/JBossWSCreationCoreTests.java 2010-04-07
08:10:14 UTC (rev 21297)
@@ -17,6 +17,7 @@
import org.jboss.tools.ws.creation.core.test.command.JBossWSClientCommandTest;
import org.jboss.tools.ws.creation.core.test.command.JBossWSJavaFirstCommandTest;
+import org.jboss.tools.ws.creation.core.test.command.JBossWSMergeWebXMLCommandTest;
import org.jboss.tools.ws.creation.core.test.command.JBossWSTopDownCommandTest;
public class JBossWSCreationCoreTests extends TestCase {
@@ -27,6 +28,7 @@
suite.addTestSuite(JBossWSTopDownCommandTest.class);
suite.addTestSuite(JBossWSJavaFirstCommandTest.class);
suite.addTestSuite(JBossWSClientCommandTest.class);
+ suite.addTestSuite(JBossWSMergeWebXMLCommandTest.class);
return suite;
}
}
\ No newline at end of file
Added:
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/src/org/jboss/tools/ws/creation/core/test/command/JBossWSMergeWebXMLCommandTest.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/src/org/jboss/tools/ws/creation/core/test/command/JBossWSMergeWebXMLCommandTest.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/src/org/jboss/tools/ws/creation/core/test/command/JBossWSMergeWebXMLCommandTest.java 2010-04-07
08:10:14 UTC (rev 21297)
@@ -0,0 +1,63 @@
+package org.jboss.tools.ws.creation.core.test.command;
+
+import java.io.File;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IProject;
+import org.jboss.tools.common.test.util.TestProjectProvider;
+import org.jboss.tools.test.util.JobUtils;
+import org.jboss.tools.test.util.ResourcesUtils;
+import org.jboss.tools.ws.creation.core.commands.MergeWebXMLCommand;
+import org.jboss.tools.ws.creation.core.data.ServiceModel;
+import org.jboss.tools.ws.creation.core.utils.JBossWSCreationUtils;
+
+public class JBossWSMergeWebXMLCommandTest extends TestCase {
+
+ static String BUNDLE = "org.jboss.tools.ws.creation.core.test";
+ IProject prj;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ TestProjectProvider provider = new TestProjectProvider(BUNDLE,
+ "/projects/" + "WebTest", "WebTest", true);
+ prj = provider.getProject();
+ JobUtils.delay(3000);
+ }
+
+ public void testMergeWebXMLCommand() throws ExecutionException{
+ File file = JBossWSCreationUtils.findFileByPath("web.xml",
prj.getLocation().toOSString());
+ assertTrue("For now, no web.xml",file == null);
+ ServiceModel model = new ServiceModel();
+ model.setUpdateWebxml(true);
+ model.setWebProjectName("WebTest");
+ MergeWebXMLCommand command = new MergeWebXMLCommand(model);
+ command.execute(null, null);
+ file = JBossWSCreationUtils.findFileByPath("web.xml",
prj.getLocation().toOSString());
+ assertTrue("For now, web.xml should be there",file != null);
+ }
+
+ protected void tearDown() throws Exception {
+ boolean oldAutoBuilding = ResourcesUtils.setBuildAutomatically(false);
+ Exception last = null;
+ try {
+ JobUtils.delay(500);
+ try {
+ System.out.println("Deleting " + prj);
+ prj.delete(true, null);
+ JobUtils.delay(500);
+ } catch (Exception e) {
+ System.out.println("Error deleting " + prj);
+ e.printStackTrace();
+ last = e;
+ }
+ } finally {
+ ResourcesUtils.setBuildAutomatically(oldAutoBuilding);
+ }
+
+ if (last != null)
+ throw last;
+ super.tearDown();
+ }
+}
Property changes on:
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/src/org/jboss/tools/ws/creation/core/test/command/JBossWSMergeWebXMLCommandTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain