Author: Grid.Qian
Date: 2010-04-22 23:19:09 -0400 (Thu, 22 Apr 2010)
New Revision: 21626
Added:
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/src/org/jboss/tools/ws/creation/core/test/command/JBossWSClientSampleCreationCommandTest.java
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/AbstractGenerateCodeCommand.java
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/ClientSampleCreationCommand.java
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/src/org/jboss/tools/ws/creation/core/test/command/JBossWSClientCommandTest.java
Log:
JBIDE-6175: to trunk
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/AbstractGenerateCodeCommand.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/AbstractGenerateCodeCommand.java 2010-04-23
03:11:19 UTC (rev 21625)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/AbstractGenerateCodeCommand.java 2010-04-23
03:19:09 UTC (rev 21626)
@@ -43,14 +43,14 @@
this.model = model;
cmdFileName_linux = getCommandLineFileName_linux();
cmdFileName_win = getCommandLineFileName_win();
-
+
}
@Override
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {
- if(monitor==null) {
- monitor=new NullProgressMonitor();
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
}
try {
monitor.beginTask("", 100); //$NON-NLS-1$
@@ -114,11 +114,14 @@
JBossWSCreationCorePlugin.getDefault().logError(
inputResult.toString());
-// there is no way to know if the failure of invoking is because of failure of
-// compiling or because of failure of generating java code, so try to analyze the
-// output string of the command, if the string contains "javac -d", means
the java
-// java code generating is complete.
-
+ // there is no way to know if the failure of invoking is
+ // because of failure of
+ // compiling or because of failure of generating java code,
+ // so try to analyze the
+ // output string of the command, if the string contains
+ // "javac -d", means the java
+ // java code generating is complete.
+
if (resultInput != null
&& resultInput.indexOf("javac -d") >= 0) {//$NON-NLS-1$
return StatusUtils
@@ -126,17 +129,28 @@
}
return StatusUtils.errorStatus(errorResult.toString());
} else {
- if (resultInput != null
- && resultInput.indexOf("[ERROR]") >= 0) { //$NON-NLS-1$
- JBossWSCreationCorePlugin.getDefault()
- .logWarning(resultInput);
- IStatus errorStatus = StatusUtils
- .warningStatus(resultInput);
- status = StatusUtils
- .warningStatus(
- JBossWSCreationCoreMessages.Error_Message_Failed_To_Generate_Code,
- new CoreException(errorStatus));
- }
+ if (resultInput != null) {
+ if (resultInput.indexOf("[ERROR]") >= 0) { //$NON-NLS-1$
+ JBossWSCreationCorePlugin.getDefault().logWarning(
+ resultInput);
+ IStatus errorStatus = StatusUtils
+ .warningStatus(resultInput);
+ status = StatusUtils
+ .warningStatus(
+ JBossWSCreationCoreMessages.Error_Message_Failed_To_Generate_Code,
+ new CoreException(errorStatus));
+ }
+ if (resultInput.indexOf("error") >= 0) { //$NON-NLS-1$
+ JBossWSCreationCorePlugin.getDefault().logError(
+ resultInput);
+ IStatus errorStatus = StatusUtils
+ .errorStatus(resultInput);
+ status = StatusUtils
+ .errorStatus(
+ JBossWSCreationCoreMessages.Error_Message_Failed_To_Generate_Code,
+ new CoreException(errorStatus));
+ }
+ }
}
} catch (InterruptedException e) {
@@ -159,33 +173,36 @@
}
- //SET JAVA_HOME environment variable to the location of java runtime of the project if
the user
+ // SET JAVA_HOME environment variable to the location of java runtime of the
+ // project if the user
// doesn't set the env variable
- private String[] getEnvironmentVariables(IProject project){
+ private String[] getEnvironmentVariables(IProject project) {
String[] env = null;
String javaHome = System.getenv(JAVA_HOME);
- if(javaHome == null || !(new File(javaHome).exists())){
+ if (javaHome == null || !(new File(javaHome).exists())) {
IJavaProject javaProject = JavaCore.create(project);
- if(javaProject == null || !javaProject.exists()) return null;
-
+ if (javaProject == null || !javaProject.exists())
+ return null;
+
try {
- if(!javaProject.isOpen()){
+ if (!javaProject.isOpen()) {
javaProject.open(null);
}
-
+
IVMInstall vm = JavaRuntime.getVMInstall(javaProject);
String javaLocation = vm.getInstallLocation().toString();
- env = new String[]{JAVA_HOME + "=" + javaLocation}; //$NON-NLS-1$
-
+ env = new String[] { JAVA_HOME + "=" + javaLocation }; //$NON-NLS-1$
+
} catch (CoreException e1) {
e1.printStackTrace();
}
}
-
+
return env;
}
-
- private void addCommonArgs(List<String> command, IProject project) throws
Exception {
+
+ private void addCommonArgs(List<String> command, IProject project)
+ throws Exception {
String projectRoot = JBossWSCreationUtils.getProjectRoot(
model.getWebProjectName()).toOSString();
IJavaProject javaProject = JavaCore.create(project);
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/ClientSampleCreationCommand.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/ClientSampleCreationCommand.java 2010-04-23
03:11:19 UTC (rev 21625)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/ClientSampleCreationCommand.java 2010-04-23
03:19:09 UTC (rev 21626)
@@ -302,15 +302,20 @@
* @param annotation
* @return
*/
- private List<ICompilationUnit> findJavaUnitsByAnnotation(
+ public List<ICompilationUnit> findJavaUnitsByAnnotation(
IJavaProject project, String annotation) {
List<ICompilationUnit> units = new LinkedList<ICompilationUnit>();
try {
- ICompilationUnit[] javaFiles = project.findPackageFragment(
- addPackagetoPath(project)).getCompilationUnits();
- for (ICompilationUnit unit : javaFiles) {
- if (unit.getSource().contains(annotation)) {
- units.add(unit);
+ ICompilationUnit[] javaFiles = null;
+ if (project.findPackageFragment(addPackagetoPath(project)) != null) {
+ javaFiles = project.findPackageFragment(
+ addPackagetoPath(project)).getCompilationUnits();
+ }
+ if (javaFiles != null) {
+ for (ICompilationUnit unit : javaFiles) {
+ if (unit.getSource().contains(annotation)) {
+ units.add(unit);
+ }
}
}
} catch (JavaModelException e) {
Modified:
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/src/org/jboss/tools/ws/creation/core/test/command/JBossWSClientCommandTest.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/src/org/jboss/tools/ws/creation/core/test/command/JBossWSClientCommandTest.java 2010-04-23
03:11:19 UTC (rev 21625)
+++
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/src/org/jboss/tools/ws/creation/core/test/command/JBossWSClientCommandTest.java 2010-04-23
03:19:09 UTC (rev 21626)
@@ -29,7 +29,7 @@
import org.eclipse.wst.ws.internal.wsrt.WebServiceScenario;
import org.jboss.tools.ws.core.classpath.JBossWSRuntime;
import org.jboss.tools.ws.core.classpath.JBossWSRuntimeManager;
-import
org.jboss.tools.ws.core.classpath.JBossWSRuntimeClassPathInitializer.JBossWSRuntimeClasspathContainer;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntimeClasspathContainer;
import org.jboss.tools.ws.core.facet.delegate.IJBossWSFacetDataModelProperties;
import org.jboss.tools.ws.core.facet.delegate.JBossWSFacetInstallDataModelProvider;
import org.jboss.tools.ws.creation.core.JBossWSCreationCorePlugin;
Added:
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/src/org/jboss/tools/ws/creation/core/test/command/JBossWSClientSampleCreationCommandTest.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/src/org/jboss/tools/ws/creation/core/test/command/JBossWSClientSampleCreationCommandTest.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/src/org/jboss/tools/ws/creation/core/test/command/JBossWSClientSampleCreationCommandTest.java 2010-04-23
03:19:09 UTC (rev 21626)
@@ -0,0 +1,63 @@
+package org.jboss.tools.ws.creation.core.test.command;
+
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.JavaCore;
+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.ClientSampleCreationCommand;
+import org.jboss.tools.ws.creation.core.data.ServiceModel;
+
+public class JBossWSClientSampleCreationCommandTest 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 testJBIDE6175() throws ExecutionException{
+ IResource src = prj.findMember("src");
+ assertTrue("src is there",src.exists());
+ ServiceModel model = new ServiceModel();
+ model.setCustomPackage("");
+ model.setWebProjectName("WebTest");
+ ClientSampleCreationCommand command = new ClientSampleCreationCommand(model);
+ List<ICompilationUnit> list =
command.findJavaUnitsByAnnotation(JavaCore.create(prj), "@WebService");
+ assertTrue("No java files in src!",list.isEmpty());
+ }
+
+ 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/JBossWSClientSampleCreationCommandTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Show replies by date