Author: Grid.Qian
Date: 2010-12-08 03:57:20 -0500 (Wed, 08 Dec 2010)
New Revision: 27220
Added:
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/src/org/jboss/tools/ws/creation/core/test/command/AbstractJBossWSGenerationTest.java
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/src/org/jboss/tools/ws/creation/core/test/util/
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/src/org/jboss/tools/ws/creation/core/test/util/JBossWSCreationCoreTestUtils.java
Removed:
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/src/org/jboss/tools/ws/creation/core/test/command/AbstractJBossWSCommandTest.java
Modified:
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/META-INF/MANIFEST.MF
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/JBossWSJavaFirstCommandTest.java
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/src/org/jboss/tools/ws/creation/core/test/command/JBossWSTopDownCommandTest.java
Log:
JBIDE-6581: modify thes ws tests for using AS new api
Modified: trunk/ws/tests/org.jboss.tools.ws.creation.core.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.creation.core.test/META-INF/MANIFEST.MF 2010-12-08
08:53:28 UTC (rev 27219)
+++ trunk/ws/tests/org.jboss.tools.ws.creation.core.test/META-INF/MANIFEST.MF 2010-12-08
08:57:20 UTC (rev 27220)
@@ -32,7 +32,8 @@
org.eclipse.jface.text,
org.jboss.ide.eclipse.as.classpath.core,
org.jboss.ide.eclipse.as.ui;bundle-version="2.1.0",
- org.jboss.ide.eclipse.as.wtp.core;bundle-version="2.1.0"
+ org.jboss.ide.eclipse.as.wtp.core;bundle-version="2.1.0",
+ org.jboss.ide.eclipse.as.test;bundle-version="2.2.0"
Bundle-ActivationPolicy: lazy
Export-Package: org.jboss.tools.ws.creation.core.test,
org.jboss.tools.ws.creation.core.test.command
Deleted:
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/src/org/jboss/tools/ws/creation/core/test/command/AbstractJBossWSCommandTest.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/src/org/jboss/tools/ws/creation/core/test/command/AbstractJBossWSCommandTest.java 2010-12-08
08:53:28 UTC (rev 27219)
+++
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/src/org/jboss/tools/ws/creation/core/test/command/AbstractJBossWSCommandTest.java 2010-12-08
08:57:20 UTC (rev 27220)
@@ -1,475 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.ws.creation.core.test.command;
-
-import java.io.File;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Set;
-
-import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.core.IStreamListener;
-import org.eclipse.debug.core.model.IProcess;
-import org.eclipse.debug.core.model.IStreamMonitor;
-import org.eclipse.jdt.launching.IVMInstall;
-import org.eclipse.jdt.launching.JavaRuntime;
-import org.eclipse.swt.SWTException;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-import org.eclipse.wst.common.project.facet.core.IFacetedProject;
-import org.eclipse.wst.common.project.facet.core.IProjectFacet;
-import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
-import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
-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.IServer.IOperationListener;
-import org.eclipse.wst.server.core.IServerListener;
-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.ServerEvent;
-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.ide.eclipse.as.core.server.IJBossServerRuntime;
-import org.jboss.ide.eclipse.as.core.server.internal.DeployableServer;
-import org.jboss.ide.eclipse.as.core.server.internal.JBossServerBehavior;
-import
org.jboss.ide.eclipse.as.core.server.internal.JBossServerBehavior.JBossBehaviourDelegate;
-import org.jboss.ide.eclipse.as.core.server.internal.LocalJBossBehaviorDelegate;
-import org.jboss.tools.test.util.JobUtils;
-import org.jboss.tools.test.util.ResourcesUtils;
-import org.jboss.tools.test.util.TestProjectProvider;
-import org.jboss.tools.ws.creation.core.data.ServiceModel;
-
-@SuppressWarnings("restriction")
-public abstract class AbstractJBossWSCommandTest extends TestCase {
- public static final IVMInstall VM_INSTALL = JavaRuntime
- .getDefaultVMInstall();
- protected static final IWorkspace ws = ResourcesPlugin.getWorkspace();
- protected static final IWorkbench wb = PlatformUI.getWorkbench();
-
- protected static final int DEFAULT_STARTUP_TIME = 150000;
- protected static final int DEFAULT_SHUTDOWN_TIME = 90000;
-
- public static final String JBOSSWS_42_HOME =
"jbosstools.test.jboss.home.4.2";
- public static final String JBOSS_RUNTIME_42 =
"org.jboss.ide.eclipse.as.runtime.42";
- public static final String JBOSS_AS_42_HOME = System.getProperty(
- JBOSSWS_42_HOME);
- public static final String JBOSS_SERVER_42 = "org.jboss.ide.eclipse.as.42";
-
- protected final Set<IResource> resourcesToCleanup = new
HashSet<IResource>();
-
- protected static final IProjectFacetVersion dynamicWebVersion;
- protected static final IProjectFacetVersion javaVersion;
- protected static final IProjectFacetVersion jbosswsFacetVersion;
- private static final IProjectFacet jbosswsFacet;
-
- static String wsdlFileName = "hello_world.wsdl";
- static String BUNDLE = "org.jboss.tools.ws.creation.core.test";
-
- IFacetedProject fproject;
- protected IRuntime currentRuntime;
- protected IServer currentServer;
- protected ServerStateListener stateListener;
-
- static {
- javaVersion = ProjectFacetsManager.getProjectFacet("jst.java")
- .getVersion("5.0");
- dynamicWebVersion = ProjectFacetsManager.getProjectFacet("jst.web")
- .getVersion("2.5");
- jbosswsFacet = ProjectFacetsManager.getProjectFacet("jbossws.core");
- jbosswsFacetVersion = jbosswsFacet.getVersion("2.0");
-
- }
-
- public AbstractJBossWSCommandTest() {
- }
-
- protected void setUp() throws Exception {
- super.setUp();
-
- // create jbossws web project
-
- createServer(JBOSS_RUNTIME_42, JBOSS_SERVER_42,
getJBossWSHomeFolder().getAbsolutePath(),
- "default");
- // first thing's first. Let's add a server state listener
- stateListener = new ServerStateListener();
- currentServer.addServerListener(stateListener);
-
- JobUtils.delay(3000);
- }
-
- public IProject createProject(String prjName) throws CoreException {
- TestProjectProvider provider = new TestProjectProvider(BUNDLE, "/projects/" +
prjName,
- prjName, true);
- IProject prj = provider.getProject();
- return prj;
- }
-
- protected void tearDown() throws Exception {
- // Wait until all jobs is finished to avoid delete project problems
-
- undeployWebProject();
-
- boolean oldAutoBuilding = ResourcesUtils.setBuildAutomatically(false);
- Exception last = null;
-
- try {
- JobUtils.delay(500);
- for (IResource r : this.resourcesToCleanup) {
- try {
- System.out.println("Deleting " + r);
- r.delete(true, null);
- JobUtils.delay(500);
- } catch (Exception e) {
- System.out.println("Error deleting " + r);
- e.printStackTrace();
- last = e;
- }
- }
- } finally {
- ResourcesUtils.setBuildAutomatically(oldAutoBuilding);
- }
-
- if (last != null)
- throw last;
-
- resourcesToCleanup.clear();
- // cleanProjectFromServer() ;
- shutdown();
- currentServer.removeServerListener(stateListener);
- currentRuntime.delete();
- currentServer.delete();
-
- super.tearDown();
- }
-
- protected void createServer(String runtimeID, String serverID,
- String location, String configuration) throws CoreException {
- // if file doesnt exist, abort immediately.
- assertTrue(new Path(location).toFile().exists());
-
- currentRuntime = createRuntime(runtimeID, location, configuration);
- IServerType serverType = ServerCore.findServerType(serverID);
- IServerWorkingCopy serverWC = serverType.createServer(null, null,
- new NullProgressMonitor());
- serverWC.setRuntime(currentRuntime);
- serverWC.setName(serverID);
- serverWC.setServerConfiguration(null);
- IPath path = new Path(location).append("server").append("default")
- .append("deploy");
- ((ServerWorkingCopy) serverWC).setAttribute(
- DeployableServer.DEPLOY_DIRECTORY, path.toOSString());
- currentServer = serverWC.save(true, new NullProgressMonitor());
-
- }
-
- private IRuntime createRuntime(String runtimeId, String homeDir,
- String config) throws CoreException {
- IRuntimeType[] runtimeTypes = ServerUtil.getRuntimeTypes(null, null,
- runtimeId);
- assertEquals("expects only one runtime type", runtimeTypes.length, 1);
- IRuntimeType runtimeType = runtimeTypes[0];
- IRuntimeWorkingCopy runtimeWC = runtimeType.createRuntime(null,
- new NullProgressMonitor());
- runtimeWC.setName(runtimeId);
- runtimeWC.setLocation(new Path(homeDir));
- ((RuntimeWorkingCopy) runtimeWC).setAttribute(
- IJBossServerRuntime.PROPERTY_VM_ID, VM_INSTALL.getId());
- ((RuntimeWorkingCopy) runtimeWC).setAttribute(
- IJBossServerRuntime.PROPERTY_VM_TYPE_ID, VM_INSTALL
- .getVMInstallType().getId());
- ((RuntimeWorkingCopy) runtimeWC).setAttribute(
- IJBossServerRuntime.PROPERTY_CONFIGURATION_NAME, config);
- IRuntime savedRuntime = runtimeWC.save(true, new NullProgressMonitor());
- return savedRuntime;
- }
-
- protected ServiceModel createServiceModel() {
- ServiceModel model = new ServiceModel();
- model.setWebProjectName(fproject.getProject().getName());
- IFile wsdlFile = fproject.getProject().getFile(wsdlFileName);
- model.setWsdlURI(wsdlFile.getLocation().toOSString());
- model.setCustomPackage("org.apache.hello_world_soap_http");
-
- return model;
-
- }
-
- protected void publishWebProject() throws CoreException {
- IModule[] modules = ServerUtil.getModules(currentServer.getServerType()
- .getRuntimeType().getModuleTypes());
- IServerWorkingCopy serverWC = currentServer.createWorkingCopy();
- serverWC.modifyModules(modules, null, null);
- serverWC.save(true, null).publish(0, null);
- currentServer.publish(IServer.PUBLISH_FULL, null);
-
- }
-
- protected void undeployWebProject() throws CoreException {
- IModule[] modules = ServerUtil.getModules(currentServer.getServerType()
- .getRuntimeType().getModuleTypes());
- IServerWorkingCopy serverWC = currentServer.createWorkingCopy();
- serverWC.modifyModules(null, modules, null);
- serverWC.save(true, null).publish(0, null);
- currentServer.publish(IServer.PUBLISH_FULL, null);
-
- }
-
- protected void cleanProjectFromServer() throws CoreException {
- IModule[] modules = ServerUtil.getModules(currentServer.getServerType()
- .getRuntimeType().getModuleTypes());
- IServerWorkingCopy serverWC = currentServer.createWorkingCopy();
- serverWC.modifyModules(null, modules, null);
- currentServer.publish(0, null);
- currentServer.stop(true);
-
- }
-
- protected boolean isServerSupplied() {
- return false;
- }
-
- protected IFacetedProject createJBossWSProject(String baseProjectName,
- boolean isServerSupplied) throws CoreException {
- IProject project = createProject(baseProjectName);
- final IFacetedProject fproj = ProjectFacetsManager.create(project);
-
- // installDependentFacets(fproj);
- fproj.installProjectFacet(jbosswsFacetVersion,
- createJBossWSDataModel(isServerSupplied), null);
-
- assertNotNull(project);
-
- this.addResourceToCleanup(project);
-
- return fproj;
- }
-
- abstract IDataModel createJBossWSDataModel(boolean isServerSupplied);
-
- protected final void addResourceToCleanup(final IResource resource) {
- this.resourcesToCleanup.add(resource);
- }
-
- protected File getJBossWSHomeFolder() {
-
- String jbosshome = System.getProperty(JBOSSWS_42_HOME);
- if (jbosshome==null) {
- String message = "{0} system property is not defined. Use
-D{0}=/path/to/the/server in command line or in VM Arguments group of Aclipse Application
Launch Configuration Arguments tab";
- throw new IllegalArgumentException(MessageFormat.format(message, JBOSSWS_42_HOME));
- }
- String wrongLocationMessage = "{0} system property points to none existing
folder";
- File runtimelocation = new File(jbosshome);
- assertTrue(MessageFormat.format(wrongLocationMessage,JBOSSWS_42_HOME),
runtimelocation.exists());
-
- String cmdFileLocation = jbosshome + File.separator + "bin"
- + File.separator + "wsconsume.sh";
- assertTrue(jbosshome + " is not a valid jboss EAP home", new File(
- cmdFileLocation).exists());
- return runtimelocation;
- }
-
- protected void startup() {
- startup(DEFAULT_STARTUP_TIME);
- }
-
- protected void startup(int maxWait) {
- long finishTime = new Date().getTime() + maxWait;
-
- // operation listener, which is only alerted when the startup is *done*
- final StatusWrapper opWrapper = new StatusWrapper();
- final IOperationListener listener = new IOperationListener() {
- public void done(IStatus result) {
- opWrapper.setStatus(result);
- }
- };
-
- // a stream listener to listen for errors
- ErrorStreamListener streamListener = new ErrorStreamListener();
-
- // the thread to actually start the server
- Thread startThread = new Thread() {
- public void run() {
- currentServer.start(ILaunchManager.RUN_MODE, listener);
- }
- };
-
- startThread.start();
-
- boolean addedStream = false;
- while (finishTime > new Date().getTime()
- && opWrapper.getStatus() == null) {
- // we're waiting for startup to finish
- if (!addedStream) {
- IStreamMonitor mon = getStreamMonitor();
- if (mon != null) {
- mon.addListener(streamListener);
- addedStream = true;
- }
- }
- try {
- Display.getDefault().readAndDispatch();
- } catch (SWTException swte) {
- }
- }
-
- try {
- assertTrue(
- "Startup has taken longer than what is expected for a default startup",
- finishTime >= new Date().getTime());
- assertFalse("Startup had System.error output", streamListener
- .hasError());
- } catch (AssertionFailedError afe) {
- // cleanup
- currentServer.stop(true);
- // rethrow
- throw afe;
- }
- getStreamMonitor().removeListener(streamListener);
- }
-
- protected void shutdown() {
- shutdown(DEFAULT_SHUTDOWN_TIME);
- }
-
- protected void shutdown(int maxWait) {
- long finishTime = new Date().getTime() + maxWait;
-
- // operation listener, which is only alerted when the startup is *done*
- final StatusWrapper opWrapper = new StatusWrapper();
- final IOperationListener listener = new IOperationListener() {
- public void done(IStatus result) {
- opWrapper.setStatus(result);
- }
- };
-
- // a stream listener to listen for errors
- ErrorStreamListener streamListener = new ErrorStreamListener();
- if (getStreamMonitor() != null)
- getStreamMonitor().addListener(streamListener);
-
- // the thread to actually start the server
- Thread stopThread = new Thread() {
- public void run() {
- currentServer.stop(false, listener);
- }
- };
-
- stopThread.start();
-
- while (finishTime > new Date().getTime()
- && opWrapper.getStatus() == null) {
- // we're waiting for startup to finish
- try {
- Display.getDefault().readAndDispatch();
- } catch (SWTException swte) {
- }
- }
-
- try {
- assertTrue(
- "Startup has taken longer than what is expected for a default startup",
- finishTime >= new Date().getTime());
- assertFalse("Startup had System.error output", streamListener
- .hasError());
- } catch (AssertionFailedError afe) {
- // cleanup
- currentServer.stop(true);
- // rethrow
- throw afe;
- }
- }
-
- protected IStreamMonitor getStreamMonitor() {
- JBossServerBehavior behavior = (JBossServerBehavior) currentServer
- .loadAdapter(JBossServerBehavior.class, null);
- if (behavior != null) {
- JBossBehaviourDelegate del = behavior.getDelegate();
- if( del instanceof LocalJBossBehaviorDelegate ) {
- IProcess p = ((LocalJBossBehaviorDelegate)del).getProcess();
- if (p != null) {
- return p.getStreamsProxy()
- .getOutputStreamMonitor();
- }
- }
- }
- return null;
- }
-
- protected class ServerStateListener implements IServerListener {
- private ArrayList<Integer> stateChanges;
-
- public ServerStateListener() {
- this.stateChanges = new ArrayList<Integer>();
- }
-
- public ArrayList<Integer> getStateChanges() {
- return stateChanges;
- }
-
- public void serverChanged(ServerEvent event) {
- if ((event.getKind() & ServerEvent.SERVER_CHANGE) != 0) {
- if ((event.getKind() & ServerEvent.STATE_CHANGE) != 0) {
- if (event.getState() != IServer.STATE_STOPPED)
- stateChanges.add(new Integer(event.getState()));
- }
- }
- }
- }
-
- protected class ErrorStreamListener implements IStreamListener {
- protected boolean errorFound = false;
- String entireLog = "";
-
- public void streamAppended(String text, IStreamMonitor monitor) {
- entireLog += text;
- }
-
- // will need to be fixed or decided how to figure out errors
- public boolean hasError() {
- return errorFound;
- }
- }
-
- public class StatusWrapper {
- protected IStatus status;
-
- public IStatus getStatus() {
- return this.status;
- }
-
- public void setStatus(IStatus s) {
- this.status = s;
- }
- }
-
-}
Added:
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/src/org/jboss/tools/ws/creation/core/test/command/AbstractJBossWSGenerationTest.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/src/org/jboss/tools/ws/creation/core/test/command/AbstractJBossWSGenerationTest.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/src/org/jboss/tools/ws/creation/core/test/command/AbstractJBossWSGenerationTest.java 2010-12-08
08:57:20 UTC (rev 27220)
@@ -0,0 +1,172 @@
+package org.jboss.tools.ws.creation.core.test.command;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.IServerWorkingCopy;
+import org.eclipse.wst.server.core.ServerUtil;
+import org.jboss.ide.eclipse.as.test.ASTest;
+import org.jboss.ide.eclipse.as.test.util.ServerRuntimeUtils;
+import org.jboss.tools.test.util.JobUtils;
+import org.jboss.tools.test.util.ResourcesUtils;
+import org.jboss.tools.test.util.TestProjectProvider;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntime;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntimeManager;
+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.data.ServiceModel;
+
+public class AbstractJBossWSGenerationTest extends ServerRuntimeUtils {
+ protected IServer currentServer;
+ protected final Set<IResource> resourcesToCleanup = new
HashSet<IResource>();
+ static String BUNDLE = "org.jboss.tools.ws.creation.core.test";
+ private String RuntimeName = "testjbosswsruntime";
+ public String wsdlFileName = "hello_world.wsdl";
+ public ServiceModel model;
+ private String JBOSS_AS_423_HOME = ASTest.JBOSS_AS_42_HOME;
+ private String JBOSS_WS_HOME = JBOSS_AS_423_HOME;
+ public String wsHomePath;
+ IFacetedProject fproject;
+ public IFile wsdlFile;
+
+ public void setUp() throws Exception{
+ super.setUp();
+ createWSServer();
+ wsHomePath = getJBossWSHomeFolder().toString();
+ JBossWSRuntimeManager.getInstance().addRuntime(RuntimeName,wsHomePath, "",
true);
+ }
+
+ public void createWSServer() throws Exception {
+ currentServer = create42Server();
+ }
+
+ public IProject createProject(String prjName) throws CoreException {
+ TestProjectProvider provider = new TestProjectProvider(BUNDLE, "/projects/" +
prjName,
+ prjName, true);
+ IProject prj = provider.getProject();
+ return prj;
+ }
+
+ public IFacetedProject createJBossWSProject(String baseProjectName) throws CoreException
{
+ IProject project = createProject(baseProjectName);
+ final IFacetedProject fproj = ProjectFacetsManager.create(project);
+ fproj.installProjectFacet(getJBossWSFacetVersion(),createJBossWSDataModel(isServerSupplied()),
null);
+ assertNotNull(project);
+ this.addResourceToCleanup(project);
+
+ return fproj;
+ }
+
+ public IProjectFacetVersion getJBossWSFacetVersion(){
+ IProjectFacet jbosswsFacet =
ProjectFacetsManager.getProjectFacet("jbossws.core");
+ IProjectFacetVersion jbosswsFacetVersion = jbosswsFacet.getVersion("3.0");
+ return jbosswsFacetVersion;
+ }
+
+ protected ServiceModel createServiceModel() {
+ model = new ServiceModel();
+ model.setWebProjectName(fproject.getProject().getName());
+ if(wsdlFile != null) {
+ model.setWsdlURI(wsdlFile.getLocationURI().toString());
+ }
+ model.setCustomPackage("org.apache.hello_world_soap_http");
+ model.setUpdateWebxml(true);
+ return model;
+ }
+
+ public void publishWebProject() throws CoreException {
+ IModule[] modules = ServerUtil.getModules(currentServer.getServerType()
+ .getRuntimeType().getModuleTypes());
+ IServerWorkingCopy serverWC = currentServer.createWorkingCopy();
+ serverWC.modifyModules(modules, null, null);
+ serverWC.save(true, null).publish(0, null);
+ currentServer.publish(IServer.PUBLISH_FULL, null);
+ }
+
+ private boolean isServerSupplied() {
+ return false;
+ }
+
+ public void tearDown() throws Exception{
+ undeployWebProject();
+ cleanResouces();
+ JBossWSRuntime runtime =
JBossWSRuntimeManager.getInstance().findRuntimeByName(RuntimeName);
+ JBossWSRuntimeManager.getInstance().removeRuntime(runtime);
+ shutdown(currentServer);
+ try {
+ if( currentServer != null )
+ currentServer.delete();
+ } catch( CoreException ce ) {
+ // report
+ }
+ super.tearDown();
+ }
+
+ private void cleanResouces() throws Exception {
+ boolean oldAutoBuilding = ResourcesUtils.setBuildAutomatically(false);
+ Exception last = null;
+ try {
+ JobUtils.delay(500);
+ for (IResource r : this.resourcesToCleanup) {
+ try {
+ r.delete(true, null);
+ JobUtils.delay(500);
+ } catch (Exception e) {
+ e.printStackTrace();
+ last = e;
+ }
+ }
+ } finally {
+ ResourcesUtils.setBuildAutomatically(oldAutoBuilding);
+ }
+ if (last != null)
+ throw last;
+ resourcesToCleanup.clear();
+ }
+
+ protected void undeployWebProject() throws CoreException {
+ IModule[] modules = ServerUtil.getModules(currentServer.getServerType()
+ .getRuntimeType().getModuleTypes());
+ IServerWorkingCopy serverWC = currentServer.createWorkingCopy();
+ serverWC.modifyModules(null, modules, null);
+ serverWC.save(true, null).publish(0, null);
+ currentServer.publish(IServer.PUBLISH_FULL, null);
+ }
+
+ private final void addResourceToCleanup(final IResource resource) {
+ this.resourcesToCleanup.add(resource);
+ }
+
+ private IDataModel createJBossWSDataModel( boolean isServerSupplied) {
+ IDataModel config = (IDataModel) new JBossWSFacetInstallDataModelProvider().create();
+ if(isServerSupplied) {
+ config.setBooleanProperty(IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_IS_SERVER_SUPPLIED,
true);
+ } else {
+ config.setBooleanProperty(IJBossWSFacetDataModelProperties.JBOSS_WS_DEPLOY, false);
+ config.setStringProperty(IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_ID,
RuntimeName);
+ config.setStringProperty(IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_HOME,
wsHomePath);
+ }
+ return config;
+ }
+
+ private File getJBossWSHomeFolder() {
+ assertTrue("No system property for the WS Home",JBOSS_WS_HOME != null);
+ File runtimelocation = new File(JBOSS_WS_HOME);
+ assertTrue("The system WS Home doesn't exist",runtimelocation.exists());
+ String cmdFileLocation = JBOSS_WS_HOME + File.separator + "bin" +
File.separator + "wsconsume.sh";
+ assertTrue(JBOSS_WS_HOME + " is not a valid jboss AS home", new
File(cmdFileLocation).exists());
+ return runtimelocation;
+ }
+}
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-12-08
08:53:28 UTC (rev 27219)
+++
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/src/org/jboss/tools/ws/creation/core/test/command/JBossWSClientCommandTest.java 2010-12-08
08:57:20 UTC (rev 27220)
@@ -11,82 +11,47 @@
package org.jboss.tools.ws.creation.core.test.command;
import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.core.IClasspathContainer;
import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaModel;
-import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.ws.internal.wsrt.IWebServiceClient;
import org.eclipse.wst.ws.internal.wsrt.WebServiceClientInfo;
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.facet.delegate.IJBossWSFacetDataModelProperties;
-import org.jboss.tools.ws.core.facet.delegate.JBossWSFacetInstallDataModelProvider;
import org.jboss.tools.ws.creation.core.JBossWSCreationCorePlugin;
import org.jboss.tools.ws.creation.core.commands.ClientSampleCreationCommand;
import org.jboss.tools.ws.creation.core.commands.InitialClientCommand;
import org.jboss.tools.ws.creation.core.commands.RemoveClientJarsCommand;
import org.jboss.tools.ws.creation.core.commands.WSDL2JavaCommand;
-import org.jboss.tools.ws.creation.core.data.ServiceModel;
+import org.jboss.tools.ws.creation.core.test.util.JBossWSCreationCoreTestUtils;
import org.jboss.tools.ws.creation.ui.wsrt.JBossWebServiceClient;
/**
* @author Grid Qian
*/
@SuppressWarnings("restriction")
-public class JBossWSClientCommandTest extends AbstractJBossWSCommandTest {
+public class JBossWSClientCommandTest extends AbstractJBossWSGenerationTest {
- private static final String RuntimeName;
- private static final boolean isDeployed;
-
- static {
- RuntimeName = "testjbosswsruntime";
- isDeployed = false;
- }
-
public JBossWSClientCommandTest() {
}
- protected void setUp() throws Exception {
+ public void setUp() throws Exception {
super.setUp();
- JBossWSRuntimeManager.getInstance().addRuntime(RuntimeName,
- getJBossWSHomeFolder().toString(), "", true);
// create jbossws web project
- fproject = createJBossWSProject("JBossWSTestProject",
- isServerSupplied());
- IFile wsdlFile = fproject.getProject().getFile(wsdlFileName);
-
+ fproject = createJBossWSProject("JBossWSTestProject");
+ wsdlFile = fproject.getProject().getFile(wsdlFileName);
+ model = createServiceModel();
assertTrue(wsdlFile.exists());
}
- protected void tearDown() throws Exception {
- super.tearDown();
- resourcesToCleanup.clear();
- JBossWSRuntime runtime = JBossWSRuntimeManager.getInstance()
- .findRuntimeByName(RuntimeName);
- JBossWSRuntimeManager.getInstance().removeRuntime(runtime);
- }
-
public void testInitialClientCommand() throws CoreException,
ExecutionException {
-
- IFile wsdlFile = fproject.getProject().getFile(wsdlFileName);
- ServiceModel model = new ServiceModel();
- model.setWebProjectName(fproject.getProject().getName());
- model.setCustomPackage("org.apache.hello_world_soap_http");
- // model.setWsdlURI(wsdlFile.getLocation().toOSString());
-
WebServiceClientInfo info = new WebServiceClientInfo();
info.setWsdlURL(wsdlFile.getLocation().toOSString());
IWebServiceClient ws = new JBossWebServiceClient(info);
@@ -96,57 +61,37 @@
WebServiceScenario.CLIENT);
IStatus status = cmdInitial.execute(null, null);
assertTrue(status.getMessage(), status.isOK());
-
assertEquals(wsdlFile.getLocation().toOSString(), model.getWsdlURI());
- assertEquals("", model
- .getCustomPackage());
+ assertEquals("", model.getCustomPackage());
}
public void testClientCodeGenerationCommand() throws ExecutionException {
-
- ServiceModel model = createServiceModel();
IProject project = fproject.getProject();
+
// test wsdl2Javacommand
WSDL2JavaCommand cmdW2j = new WSDL2JavaCommand(model);
IStatus status = cmdW2j.execute(null, null);
assertFalse(status.getMessage(), Status.ERROR == status.getSeverity());
- assertTrue(project.getFile(
- "src/org/apache/hello_world_soap_http/Greeter.java").exists());
+ assertTrue(project.getFile("src/org/apache/hello_world_soap_http/Greeter.java").exists());
// test ClientSampleCreationCommand
- ClientSampleCreationCommand cmdImpl = new ClientSampleCreationCommand(
- model);
+ ClientSampleCreationCommand cmdImpl = new ClientSampleCreationCommand(model);
status = cmdImpl.execute(null, null);
assertTrue(status.getMessage(), status.isOK());
- assertTrue(
- "failed to generate sample class",
- project
- .getFile(
- "src/org/apache/hello_world_soap_http/clientsample/ClientSample.java")
- .exists());
-
+ assertTrue("failed to generate sample
class",project.getFile("src/org/apache/hello_world_soap_http/clientsample/ClientSample.java").exists());
}
public void testRemoveClientJarsCommand() throws ExecutionException {
-
- ServiceModel model = new ServiceModel();
- model.setWebProjectName(fproject.getProject().getName());
-
RemoveClientJarsCommand command = new RemoveClientJarsCommand(model);
IStatus status = command.execute(null, null);
assertTrue(status.getMessage(), status.isOK());
try {
- IClasspathEntry[] entries = getJavaProjectByName(
- fproject.getProject().getName()).getRawClasspath();
-
+ IClasspathEntry[] entries =
JBossWSCreationCoreTestUtils.getJavaProjectByName(fproject.getProject().getName()).getRawClasspath();
for (IClasspathEntry entry : entries) {
- IClasspathContainer container = JavaCore.getClasspathContainer(
- entry.getPath(), getJavaProjectByName(fproject
- .getProject().getName()));
+ IClasspathContainer container = JavaCore.getClasspathContainer(entry.getPath(),
JBossWSCreationCoreTestUtils.getJavaProjectByName(fproject.getProject().getName()));
if (container instanceof JBossWSRuntimeClasspathContainer) {
boolean nojar = true;
- for (IClasspathEntry jar : ((JBossWSRuntimeClasspathContainer) container)
- .getClasspathEntries()) {
+ for (IClasspathEntry jar : ((JBossWSRuntimeClasspathContainer)
container).getClasspathEntries()) {
if (jar.getPath().toString().contains("jaxws-rt.jar")) {
nojar = false;
}
@@ -157,48 +102,5 @@
} catch (JavaModelException e) {
JBossWSCreationCorePlugin.getDefault().logError(e);
}
-
}
-
- public static IJavaProject getJavaProjectByName(String projectName)
- throws JavaModelException {
-
- IJavaModel model = JavaCore.create(ResourcesPlugin.getWorkspace()
- .getRoot());
- model.open(null);
-
- IJavaProject[] projects = model.getJavaProjects();
-
- for (IJavaProject proj : projects) {
- if (proj.getProject().getName().equals(projectName)) {
- return proj;
- }
- }
-
- return null;
- }
-
- @Override
- IDataModel createJBossWSDataModel(boolean isServerSupplied) {
- IDataModel config = (IDataModel) new JBossWSFacetInstallDataModelProvider()
- .create();
- if (isServerSupplied) {
- config
- .setBooleanProperty(
- IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_IS_SERVER_SUPPLIED,
- true);
- } else {
- config.setBooleanProperty(
- IJBossWSFacetDataModelProperties.JBOSS_WS_DEPLOY,
- isDeployed);
- config.setStringProperty(
- IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_ID,
- RuntimeName);
- config.setStringProperty(
- IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_HOME,
- getJBossWSHomeFolder().toString());
- }
- return config;
- }
-
}
Modified:
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/src/org/jboss/tools/ws/creation/core/test/command/JBossWSJavaFirstCommandTest.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/src/org/jboss/tools/ws/creation/core/test/command/JBossWSJavaFirstCommandTest.java 2010-12-08
08:53:28 UTC (rev 27219)
+++
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/src/org/jboss/tools/ws/creation/core/test/command/JBossWSJavaFirstCommandTest.java 2010-12-08
08:57:20 UTC (rev 27220)
@@ -18,7 +18,6 @@
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
@@ -28,204 +27,118 @@
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.console.AbstractConsole;
-import org.eclipse.ui.console.ConsolePlugin;
import org.eclipse.ui.console.IConsole;
-import org.eclipse.ui.console.IConsoleListener;
import org.eclipse.ui.console.IConsoleManager;
import org.eclipse.ui.console.TextConsole;
-import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.ws.internal.wsrt.IWebService;
import org.eclipse.wst.ws.internal.wsrt.WebServiceInfo;
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.facet.delegate.IJBossWSFacetDataModelProperties;
-import org.jboss.tools.ws.core.facet.delegate.JBossWSFacetInstallDataModelProvider;
+import org.jboss.tools.test.util.JobUtils;
import org.jboss.tools.ws.creation.core.commands.InitialCommand;
+import org.jboss.tools.ws.creation.core.commands.Java2WSCommand;
import org.jboss.tools.ws.creation.core.commands.MergeWebXMLCommand;
import org.jboss.tools.ws.creation.core.commands.RemoveClientJarsCommand;
import org.jboss.tools.ws.creation.core.commands.ValidateWSImplCommand;
-import org.jboss.tools.ws.creation.core.commands.Java2WSCommand;
-import org.jboss.tools.ws.creation.core.data.ServiceModel;
import org.jboss.tools.ws.creation.core.messages.JBossWSCreationCoreMessages;
+import org.jboss.tools.ws.creation.core.test.util.JBossWSCreationCoreTestUtils;
import org.jboss.tools.ws.creation.ui.wsrt.JBossWebService;
/**
* @author Grid Qian
*/
@SuppressWarnings("restriction")
-public class JBossWSJavaFirstCommandTest extends AbstractJBossWSCommandTest {
- protected static final IWorkspace ws = ResourcesPlugin.getWorkspace();
- protected static final IWorkbench wb = PlatformUI.getWorkbench();
-
- private static final String RuntimeName;
- private static final boolean isDeployed;
+public class JBossWSJavaFirstCommandTest extends AbstractJBossWSGenerationTest {
private IProject clientProject;
- static {
- RuntimeName = "testjbosswsruntime";
- isDeployed = false;
- }
-
public JBossWSJavaFirstCommandTest() {
}
- protected void setUp() throws Exception {
+ public void setUp() throws Exception {
super.setUp();
- JBossWSRuntimeManager.getInstance().addRuntime(RuntimeName,
- getJBossWSHomeFolder().toString(), "", true);
- // create jbossws web project
- fproject = createJBossWSProject("JavaFirstTestProject",
- isServerSupplied());
-
+ //create jbossws web project
+ fproject = createJBossWSProject("JavaFirstTestProject");
+ model = createServiceModel();
+
if (!ResourcesPlugin.getWorkspace().getRoot().getProject("ClientTest")
.exists()) {
createProject("ClientTest");
- // this.addResourceToCleanup(clientProject);
}
-
}
+
- protected void tearDown() throws Exception {
- super.tearDown();
+ public void testDeployResult() throws ExecutionException, CoreException,IOException {
+ doInitialCommand();
+ doValidateWSImplCommand();
+ doJava2WSCommand();
- resourcesToCleanup.clear();
- JBossWSRuntime runtime = JBossWSRuntimeManager.getInstance()
- .findRuntimeByName(RuntimeName);
- JBossWSRuntimeManager.getInstance().removeRuntime(runtime);
- }
+ IProject project = fproject.getProject();
+ project.refreshLocal(IResource.DEPTH_INFINITE, null);
+ project.build(IncrementalProjectBuilder.FULL_BUILD, null);
+
+ publishWebProject();
+ assertTrue(currentServer.getModules().length > 0);
+ startup(currentServer);
+ JobUtils.delay(12000);
+ String webServiceUrl =
"http://127.0.0.1:8080/JavaFirstTestProject/HelloWorld?wsdl";
+ URL url = new URL(webServiceUrl);
+ URLConnection conn = url.openConnection();
+ assertEquals("unable to start JBoss server",
IServer.STATE_STARTED,currentServer.getServerState());
+ conn.connect();
+ assertFalse("The url connection's status is "+ ((HttpURLConnection)
conn).getResponseMessage(), "Ok".equals(((HttpURLConnection)
conn).getResponseMessage()));
- public void testInitialCommand() throws CoreException, ExecutionException {
+ model.setWebProjectName("ClientTest");
+ RemoveClientJarsCommand cmd = new RemoveClientJarsCommand(model);
+ assertTrue(cmd.execute(null, null).getMessage(), cmd.execute(null, null).isOK());
- ServiceModel model = new ServiceModel();
- model.setWebProjectName(fproject.getProject().getName());
+ clientProject =
ResourcesPlugin.getWorkspace().getRoot().getProject("ClientTest");
+ clientProject.open(null);
+ clientProject.refreshLocal(IResource.DEPTH_INFINITE, null);
+
+ ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
+ ILaunchConfigurationType launchConfigurationType =
launchManager.getLaunchConfigurationType("org.eclipse.jdt.launching.localJavaApplication");
+ ILaunchConfigurationWorkingCopy wc = launchConfigurationType.newInstance(null,
"ClientSample");
+ wc.setAttribute("org.eclipse.debug.core.MAPPED_RESOURCE_TYPES",
"1");
+ wc.setAttribute("org.eclipse.jdt.launching.MAIN_TYPE","org.example.www.helloworld.clientsample.ClientSample");
+ wc.setAttribute("org.eclipse.jdt.launching.PROGRAM_ARGUMENTS",
"Test");
+ wc.setAttribute("org.eclipse.jdt.launching.PROJECT_ATTR",
"ClientTest");
+ wc.doSave();
+ wc.launch(ILaunchManager.RUN_MODE, null);
+ IConsoleManager consolemanager = JBossWSCreationCoreTestUtils.getConsoleManager();
+ checkText(consolemanager.getConsoles());
+ }
+
+ public void doInitialCommand() throws CoreException, ExecutionException {
WebServiceInfo info = new WebServiceInfo();
info.setImplURL("org.example.www.helloworld.HelloWorld");
IWebService ws = new JBossWebService(info);
// test initial command
- InitialCommand cmdInitial = new InitialCommand(model, ws,
- WebServiceScenario.BOTTOMUP);
+ InitialCommand cmdInitial = new InitialCommand(model, ws,
WebServiceScenario.BOTTOMUP);
IStatus status = cmdInitial.execute(null, null);
-
assertTrue(status.getMessage(), status.isOK());
- assertTrue(model.getServiceClasses().get(0).equals(
- "org.example.www.helloworld.HelloWorld"));
+ assertTrue(model.getServiceClasses().get(0).equals("org.example.www.helloworld.HelloWorld"));
}
- public void testValidateWSImplCommand() throws ExecutionException {
-
- ServiceModel model = new ServiceModel();
- model.setWebProjectName(fproject.getProject().getName());
- model.addServiceClasses("org.example.www.helloworld.HelloWorld");
-
+ public void doValidateWSImplCommand() throws ExecutionException {
ValidateWSImplCommand command = new ValidateWSImplCommand(model);
IStatus status = command.execute(null, null);
-
assertTrue(status.getMessage(), status.isOK());
-
}
- public void testJava2WSCommand() throws ExecutionException, CoreException {
-
- ServiceModel model = new ServiceModel();
- model.setWebProjectName(fproject.getProject().getName());
- model.addServiceClasses("org.example.www.helloworld.HelloWorld");
+ public void doJava2WSCommand() throws ExecutionException, CoreException {
model.setGenWSDL(true);
IProject project = fproject.getProject();
-
- fproject.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
- fproject.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null);
-
Java2WSCommand command = new Java2WSCommand(model);
IStatus status = command.execute(null, null);
-
assertFalse(status.getMessage(), Status.ERROR == status.getSeverity());
- assertTrue(project.getFile(
- "src/org/example/www/helloworld/jaxws/SayHello.java").exists());
+ assertTrue(project.getFile("src/org/example/www/helloworld/jaxws/SayHello.java").exists());
assertTrue(project.getFile("wsdl/HelloWorldService.wsdl").exists());
- }
-
- public void testDeployResult() throws ExecutionException, CoreException,
- IOException {
-
- ServiceModel model = new ServiceModel();
- model.setWebProjectName(fproject.getProject().getName());
-
- WebServiceInfo info = new WebServiceInfo();
- info.setImplURL("org.example.www.helloworld.HelloWorld");
- IWebService ws = new JBossWebService(info);
-
- // test initial command
- AbstractDataModelOperation cmd = new InitialCommand(model, ws,
- WebServiceScenario.BOTTOMUP);
- IStatus status = cmd.execute(null, null);
- assertTrue(status.getMessage(), status.isOK());
-
- fproject.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
- fproject.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null);
-
- cmd = new Java2WSCommand(model);
+
+ MergeWebXMLCommand cmd = new MergeWebXMLCommand(model);
status = cmd.execute(null, null);
assertTrue(status.getMessage(), status.isOK());
-
- cmd = new MergeWebXMLCommand(model);
- status = cmd.execute(null, null);
- assertTrue(status.getMessage(), status.isOK());
-
- fproject.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
- fproject.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null);
- publishWebProject();
-
- assertTrue(currentServer.getModules().length > 0);
- String webServiceUrl =
"http://localhost:8080/JavaFirstTestProject/HelloWorld?wsdl";
- URL url = new URL(webServiceUrl);
- URLConnection conn = url.openConnection();
-
- startup();
-
- assertEquals("unable to start JBoss server", IServer.STATE_STARTED,
- currentServer.getServerState());
-
- conn.connect();
- assertFalse("The url connection's status is "
- + ((HttpURLConnection) conn).getResponseMessage(), "Ok"
- .equals(((HttpURLConnection) conn).getResponseMessage()));
-
- model = new ServiceModel();
- model.setWebProjectName("ClientTest");
-
- cmd = new RemoveClientJarsCommand(model);
- status = cmd.execute(null, null);
- assertTrue(status.getMessage(), status.isOK());
-
- clientProject = ResourcesPlugin.getWorkspace().getRoot().getProject(
- "ClientTest");
- clientProject.open(null);
- clientProject.refreshLocal(IResource.DEPTH_INFINITE, null);
-
- ILaunchManager launchManager = DebugPlugin.getDefault()
- .getLaunchManager();
- ILaunchConfigurationType launchConfigurationType = launchManager
- .getLaunchConfigurationType("org.eclipse.jdt.launching.localJavaApplication");
- ILaunchConfigurationWorkingCopy wc = launchConfigurationType
- .newInstance(null, "ClientSample");
- wc.setAttribute("org.eclipse.debug.core.MAPPED_RESOURCE_TYPES",
"1");
- wc.setAttribute("org.eclipse.jdt.launching.MAIN_TYPE",
- "org.example.www.helloworld.clientsample.ClientSample");
- wc.setAttribute("org.eclipse.jdt.launching.PROGRAM_ARGUMENTS",
"Test");
- wc.setAttribute("org.eclipse.jdt.launching.PROJECT_ATTR",
"ClientTest");
- wc.doSave();
- wc.launch(ILaunchManager.RUN_MODE, null);
- IConsoleManager consolemanager = getConsoleManager();
- checkText(consolemanager.getConsoles());
}
private void checkText(IConsole[] consoles) {
@@ -233,18 +146,11 @@
for (IConsole console : consoles) {
if (console.getName().contains("ClientSample")) {
int i = 0;
- while (i < 30
- && !isContainString(
- console,
- JBossWSCreationCoreMessages.Client_Sample_Run_Over)) {
- delay(1000);
+ while (i < 30&&
!isContainString(console,JBossWSCreationCoreMessages.Client_Sample_Run_Over)) {
+ JBossWSCreationCoreTestUtils.delay(1000);
i++;
}
- assertTrue(
- ((TextConsole) console).getDocument().get(),
- isContainString(
- console,
- JBossWSCreationCoreMessages.Client_Sample_Run_Over));
+ assertTrue(((TextConsole)
console).getDocument().get(),isContainString(console,JBossWSCreationCoreMessages.Client_Sample_Run_Over));
}
}
}
@@ -252,68 +158,4 @@
public static boolean isContainString(IConsole console, String str) {
return ((TextConsole) console).getDocument().get().contains(str);
}
-
- public static void delay(long durationInMilliseconds) {
- Display display = Display.getCurrent();
- if (display != null) {
- long t2 = System.currentTimeMillis() + durationInMilliseconds;
- while (System.currentTimeMillis() < t2) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
- display.update();
- } else {
- try {
- Thread.sleep(durationInMilliseconds);
- } catch (InterruptedException e) {
- }
- }
- }
-
- public static IConsoleManager getConsoleManager() {
- IConsoleManager consolemanager = ConsolePlugin.getDefault()
- .getConsoleManager();
-
- consolemanager.addConsoleListener(new IConsoleListener() {
- public void consolesAdded(IConsole[] consoles) {
- for (int i = 0; i < consoles.length; i++) {
- ((AbstractConsole) consoles[i]).activate();
- }
-
- }
-
- public void consolesRemoved(IConsole[] consoles) {
- for (int i = 0; i < consoles.length; i++) {
- ((AbstractConsole) consoles[i]).destroy();
- }
-
- }
- });
- return consolemanager;
- }
-
- @Override
- IDataModel createJBossWSDataModel(boolean isServerSupplied) {
- IDataModel config = (IDataModel) new JBossWSFacetInstallDataModelProvider()
- .create();
- if (isServerSupplied) {
- config
- .setBooleanProperty(
- IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_IS_SERVER_SUPPLIED,
- true);
- } else {
- config.setBooleanProperty(
- IJBossWSFacetDataModelProperties.JBOSS_WS_DEPLOY,
- isDeployed);
- config.setStringProperty(
- IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_ID,
- RuntimeName);
- config.setStringProperty(
- IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_HOME,
- getJBossWSHomeFolder().toString());
- }
- return config;
- }
-
}
Modified:
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/src/org/jboss/tools/ws/creation/core/test/command/JBossWSTopDownCommandTest.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/src/org/jboss/tools/ws/creation/core/test/command/JBossWSTopDownCommandTest.java 2010-12-08
08:53:28 UTC (rev 27219)
+++
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/src/org/jboss/tools/ws/creation/core/test/command/JBossWSTopDownCommandTest.java 2010-12-08
08:57:20 UTC (rev 27220)
@@ -11,6 +11,7 @@
package org.jboss.tools.ws.creation.core.test.command;
import java.io.IOException;
+import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
@@ -18,9 +19,7 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IncrementalProjectBuilder;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@@ -30,100 +29,74 @@
import org.eclipse.jst.javaee.web.Servlet;
import org.eclipse.jst.javaee.web.ServletMapping;
import org.eclipse.jst.javaee.web.WebApp;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.ws.internal.wsrt.IWebService;
import org.eclipse.wst.ws.internal.wsrt.WebServiceInfo;
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.facet.delegate.IJBossWSFacetDataModelProperties;
-import org.jboss.tools.ws.core.facet.delegate.JBossWSFacetInstallDataModelProvider;
+import org.jboss.tools.test.util.JobUtils;
import org.jboss.tools.ws.creation.core.commands.ImplementationClassCreationCommand;
import org.jboss.tools.ws.creation.core.commands.InitialCommand;
import org.jboss.tools.ws.creation.core.commands.MergeWebXMLCommand;
import org.jboss.tools.ws.creation.core.commands.WSDL2JavaCommand;
-import org.jboss.tools.ws.creation.core.data.ServiceModel;
import org.jboss.tools.ws.creation.ui.wsrt.JBossWebService;
@SuppressWarnings("restriction")
-public class JBossWSTopDownCommandTest extends AbstractJBossWSCommandTest {
- protected static final IWorkspace ws = ResourcesPlugin.getWorkspace();
- protected static final IWorkbench wb = PlatformUI.getWorkbench();
+public class JBossWSTopDownCommandTest extends AbstractJBossWSGenerationTest {
-
-
- private static final String RuntimeName;
- private static final boolean isDeployed;
-
- static String wsdlFileName = "hello_world.wsdl";
-
- static {
- RuntimeName = "testjbosswsruntime";
- isDeployed = false;
- }
-
public JBossWSTopDownCommandTest() {
}
- protected void setUp() throws Exception {
+ public void setUp() throws Exception {
super.setUp();
- JBossWSRuntimeManager.getInstance().addRuntime(RuntimeName,
getJBossWSHomeFolder().toString(), "", true);
//create jbossws web project
- fproject = createJBossWSProject("JBossWSTestProject", isServerSupplied());
- IFile wsdlFile = fproject.getProject().getFile(wsdlFileName);
-
+ fproject = createJBossWSProject("JBossWSTestProject");
+ wsdlFile = fproject.getProject().getFile(wsdlFileName);
+ model = createServiceModel();
assertTrue(wsdlFile.exists());
}
-
-
- protected void tearDown() throws Exception {
- // Wait until all jobs is finished to avoid delete project problems
- super.tearDown();
- resourcesToCleanup.clear();
- JBossWSRuntime runtime =
JBossWSRuntimeManager.getInstance().findRuntimeByName(RuntimeName);
- JBossWSRuntimeManager.getInstance().removeRuntime(runtime);
+ public void testDeployResult() throws ExecutionException, CoreException, IOException{
+ doInitialCommand();
+ doCodeGenerationCommand();
+ doMergeWebXMLCommand();
+
+ fproject.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
+ fproject.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null);
+ publishWebProject();
+ startup(currentServer);
+ JobUtils.delay(12000);
+ assertTrue(currentServer.getModules().length > 0);
+ String webServiceUrl =
"http://127.0.0.1:8080/JBossWSTestProject/Greeter?wsdl";
+ URL url = new URL(webServiceUrl);
+ URLConnection conn = url.openConnection();
+ assertEquals("unable to start JBoss server",IServer.STATE_STARTED,
currentServer.getServerState());
+ conn.connect();
+ assertFalse("The url connection's status is "+ ((HttpURLConnection)
conn).getResponseMessage(), "Ok".equals(((HttpURLConnection)
conn).getResponseMessage()));
+ conn.getContent();
}
-
- public void testInitialCommand() throws CoreException, ExecutionException{
-
- IFile wsdlFile = fproject.getProject().getFile(wsdlFileName);
- ServiceModel model = new ServiceModel();
- model.setWebProjectName(fproject.getProject().getName());
- model.setCustomPackage("org.apache.hello_world_soap_http");
- //model.setWsdlURI(wsdlFile.getLocation().toOSString());
-
-
+ public void doInitialCommand() throws CoreException, ExecutionException{
WebServiceInfo info = new WebServiceInfo();
- info.setWsdlURL(wsdlFile.getLocation().toOSString());
+ info.setWsdlURL(wsdlFile.getLocationURI().toString());
IWebService ws = new JBossWebService(info);
//test initial command
InitialCommand cmdInitial = new InitialCommand(model, ws, WebServiceScenario.TOPDOWN);
IStatus status = cmdInitial.execute(null, null);
assertTrue(status.getMessage(), status.isOK());
-
- assertEquals(wsdlFile.getLocation().toOSString(), model.getWsdlURI());
- assertEquals("", model.getCustomPackage());
-
+ assertEquals(wsdlFile.getLocationURI().toString(), model.getWsdlURI());
+ assertEquals("", model.getCustomPackage());
}
- public void testCodeGenerationCommand() throws ExecutionException{
-
- ServiceModel model = createServiceModel();
+ public void doCodeGenerationCommand() throws ExecutionException{
IProject project = fproject.getProject();
+
//test wsdl2Javacommand
WSDL2JavaCommand cmdW2j = new WSDL2JavaCommand(model);
IStatus status = cmdW2j.execute(null, null);
- assertTrue(status.getMessage(), status.getSeverity() != Status.ERROR);
-
+ assertTrue(status.getMessage(), status.getSeverity() != Status.ERROR);
assertTrue(project.getFile("src/org/apache/hello_world_soap_http/Greeter.java").exists());
// test ImplementationClassCreationCommand
@@ -137,17 +110,13 @@
cmdImpl = new ImplementationClassCreationCommand(model);
status = cmdImpl.execute(null, null);
assertTrue(status.getMessage(), status.getSeverity() != Status.ERROR);
- assertTrue("failed to generate implemenatation class",
project.getFile("src/org/apache/hello_world_soap_http/GreeterImpl.java").exists());
-
-
+ assertTrue("failed to generate implemenatation class",
project.getFile("src/org/apache/hello_world_soap_http/GreeterImpl.java").exists());
}
- public void testMergeWebXMLCommand() throws ExecutionException{
- ServiceModel model = createServiceModel();
+ public void doMergeWebXMLCommand() throws ExecutionException{
model.setGenerateImplementatoin(true);
- model.setUpdateWebxml(true);
- model.setWebProjectName(fproject.getProject().getName());
model.addServiceClasses("org.apache.hello_world_soap_http.GreeterImpl");
+
MergeWebXMLCommand cmdweb = new MergeWebXMLCommand(model);
IStatus status = cmdweb.execute(null, null);
assertTrue(status.getMessage(), status.isOK());
@@ -155,21 +124,18 @@
IProject project = fproject.getProject();
IFile webxml = project.getFile("WebContent/WEB-INF/web.xml");
assertTrue(webxml.exists());
- IModelProvider provider = ModelProviderManager
- .getModelProvider(project);
+ IModelProvider provider = ModelProviderManager.getModelProvider(project);
Object object = provider.getModelObject();
if (object instanceof WebApp) {
WebApp webApp = (WebApp) object;
assertTrue("failed to update web.xml ", webApp.getServlets().size() >
0);
Servlet servlet = (Servlet)webApp.getServlets().get(0);
- assertEquals("the servlet with the name 'Greeger' was not created",
servlet.getServletName(), "Greeter");
- assertTrue("the servlet display names should contain 'Greeter'",
servlet.getDisplayNames().contains("Greeter"));
+ assertEquals("the servlet with the name 'Greeter' was not created",
servlet.getServletName(), "Greeter");
assertEquals("org.apache.hello_world_soap_http.GreeterImpl",
servlet.getServletClass());
ServletMapping mapping = (ServletMapping)webApp.getServletMappings().get(0);
- assertTrue("url patterns should contain '/Greeter'",
mapping.getUrlPatterns().contains("/Greeter"));
assertEquals("Greeter", mapping.getServletName());
- }else if(object instanceof org.eclipse.jst.j2ee.webapplication.WebApp){
+ }else if (object instanceof org.eclipse.jst.j2ee.webapplication.WebApp) {
org.eclipse.jst.j2ee.webapplication.WebApp webApp =
(org.eclipse.jst.j2ee.webapplication.WebApp) object;
assertTrue("failed to update web.xml ", webApp.getServlets().size() >
0);
org.eclipse.jst.j2ee.webapplication.Servlet servlet =
(org.eclipse.jst.j2ee.webapplication.Servlet)webApp.getServlets().get(0);
@@ -178,98 +144,10 @@
if(servlet.getWebType() instanceof ServletType){
ServletType webtype = (ServletType)servlet.getWebType();
assertEquals("org.apache.hello_world_soap_http.GreeterImpl",
webtype.getClassName());
- }
-
+ }
org.eclipse.jst.j2ee.webapplication.ServletMapping mapping =
(org.eclipse.jst.j2ee.webapplication.ServletMapping)webApp.getServletMappings().get(0);
assertEquals("url pattern: ","/Greeter",
mapping.getUrlPattern());
assertEquals("Greeter", mapping.getServlet().getServletName());
- }
- //ServerType d; d.createServer(id, file, monitor)
-
+ }
}
-
- public void testDeployResult() throws ExecutionException, CoreException, IOException{
-
- //currentServer.start(ILaunchManager.RUN_MODE, new NullProgressMonitor());
- IFile wsdlFile = fproject.getProject().getFile(wsdlFileName);
- ServiceModel model = new ServiceModel();
- model.setWebProjectName(fproject.getProject().getName());
- model.setCustomPackage("org.apache.hello_world_soap_http");
- //model.setWsdlURI(wsdlFile.getLocation().toOSString());
-
-
- WebServiceInfo info = new WebServiceInfo();
- info.setWsdlURL(wsdlFile.getLocation().toOSString());
- IWebService ws = new JBossWebService(info);
-
- //test initial command
- AbstractDataModelOperation cmd = new InitialCommand(model, ws,
WebServiceScenario.TOPDOWN);
- IStatus status = cmd.execute(null, null);
- assertTrue(status.getMessage(), status.getSeverity() != Status.ERROR);
-
- cmd = new WSDL2JavaCommand(model);
- status = cmd.execute(null, null);
- assertTrue(status.getMessage(), status.getSeverity() != Status.ERROR);
-
- cmd = new ImplementationClassCreationCommand(model);
- status = cmd.execute(null, null);
- assertTrue(status.getMessage(), status.getSeverity() != Status.ERROR);
-
- cmd = new MergeWebXMLCommand(model);
- status = cmd.execute(null, null);
- assertTrue(status.getMessage(), status.isOK());
-
- fproject.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
- fproject.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null);
- publishWebProject();
-
- assertTrue(currentServer.getModules().length > 0);
- String webServiceUrl =
"http://localhost:8080/JBossWSTestProject/Greeter?wsdl";
- URL url = new URL(webServiceUrl);
- URLConnection conn = url.openConnection();
-
- startup();
-
- assertEquals("unable to start JBoss server",IServer.STATE_STARTED,
currentServer.getServerState());
-
- conn.connect();
- conn.getContent();
-
-
-
- }
-
- protected ServiceModel createServiceModel(){
- ServiceModel model = new ServiceModel();
- model.setWebProjectName(fproject.getProject().getName());
- IFile wsdlFile = fproject.getProject().getFile(wsdlFileName);
- model.setWsdlURI(wsdlFile.getLocation().toOSString());
- model.setCustomPackage("org.apache.hello_world_soap_http");
-
- return model;
-
- }
-
-
- protected boolean isServerSupplied(){
- return false;
- }
-
-
-
- protected IDataModel createJBossWSDataModel( boolean isServerSupplied) {
- IDataModel config = (IDataModel) new JBossWSFacetInstallDataModelProvider().create();
- if(isServerSupplied){
- config.setBooleanProperty(IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_IS_SERVER_SUPPLIED,
true);
- }else{
- config.setBooleanProperty(IJBossWSFacetDataModelProperties.JBOSS_WS_DEPLOY,
isDeployed);
- config.setStringProperty(IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_ID,
RuntimeName);
- config.setStringProperty(IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_HOME,
getJBossWSHomeFolder().toString());
- }
- return config;
- }
-
-
-
-
}
Added:
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/src/org/jboss/tools/ws/creation/core/test/util/JBossWSCreationCoreTestUtils.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/src/org/jboss/tools/ws/creation/core/test/util/JBossWSCreationCoreTestUtils.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/src/org/jboss/tools/ws/creation/core/test/util/JBossWSCreationCoreTestUtils.java 2010-12-08
08:57:20 UTC (rev 27220)
@@ -0,0 +1,72 @@
+package org.jboss.tools.ws.creation.core.test.util;
+
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jdt.core.IJavaModel;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.console.AbstractConsole;
+import org.eclipse.ui.console.ConsolePlugin;
+import org.eclipse.ui.console.IConsole;
+import org.eclipse.ui.console.IConsoleListener;
+import org.eclipse.ui.console.IConsoleManager;
+
+public class JBossWSCreationCoreTestUtils {
+
+ public static IJavaProject getJavaProjectByName(String projectName)
+ throws JavaModelException {
+
+ IJavaModel model = JavaCore.create(ResourcesPlugin.getWorkspace()
+ .getRoot());
+ model.open(null);
+
+ IJavaProject[] projects = model.getJavaProjects();
+
+ for (IJavaProject proj : projects) {
+ if (proj.getProject().getName().equals(projectName)) {
+ return proj;
+ }
+ }
+
+ return null;
+ }
+
+ public static IConsoleManager getConsoleManager() {
+ IConsoleManager consolemanager = ConsolePlugin.getDefault()
+ .getConsoleManager();
+ consolemanager.addConsoleListener(new IConsoleListener() {
+ public void consolesAdded(IConsole[] consoles) {
+ for (int i = 0; i < consoles.length; i++) {
+ ((AbstractConsole) consoles[i]).activate();
+ }
+
+ }
+ public void consolesRemoved(IConsole[] consoles) {
+ for (int i = 0; i < consoles.length; i++) {
+ ((AbstractConsole) consoles[i]).destroy();
+ }
+
+ }
+ });
+ return consolemanager;
+ }
+
+ public static void delay(long durationInMilliseconds) {
+ Display display = Display.getCurrent();
+ if (display != null) {
+ long t2 = System.currentTimeMillis() + durationInMilliseconds;
+ while (System.currentTimeMillis() < t2) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+ display.update();
+ } else {
+ try {
+ Thread.sleep(durationInMilliseconds);
+ } catch (InterruptedException e) {
+ }
+ }
+ }
+}