Author: rob.stryker(a)jboss.com
Date: 2012-01-31 23:24:24 -0500 (Tue, 31 Jan 2012)
New Revision: 38352
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/BehaviourModelDefectTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/MockArgsTests.java
Removed:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/MockTests.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/ExtensionManager.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/BehaviourModel.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/DeploymentPreferenceLoader.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/ASTestSuite.java
Log:
JBIDE-10768 - fixes and tests
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/ExtensionManager.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/ExtensionManager.java 2012-02-01
03:57:02 UTC (rev 38351)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/ExtensionManager.java 2012-02-01
04:24:24 UTC (rev 38352)
@@ -227,7 +227,6 @@
}
}
-
public IJBossServerPublisher[] getZippedPublishers() {
if( publishers == null )
loadPublishers();
@@ -242,47 +241,6 @@
return list.toArray(new IJBossServerPublisher[list.size()]);
}
-
-//
-// private ServerPublishMethodType[] publishMethodTypes;
-// public ServerPublishMethodType[] getPublishMethodTypes() {
-// if(publishMethodTypes == null )
-// publishMethodTypes = loadPublishMethodTypes();
-// return publishMethodTypes;
-// }
-//
-// public ServerPublishMethodType[] loadPublishMethodTypes() {
-// ArrayList<ServerPublishMethodType> types = new
ArrayList<ServerPublishMethodType>();
-// IExtensionRegistry registry = Platform.getExtensionRegistry();
-// IConfigurationElement[] cf =
registry.getConfigurationElementsFor(JBossServerCorePlugin.PLUGIN_ID,
"publishMethod"); //$NON-NLS-1$
-// for( int i = 0; i < cf.length; i++ ) {
-// types.add(new ServerPublishMethodType(cf[i]));
-// }
-// return types.toArray(new ServerPublishMethodType[types.size()]);
-// }
-//
-// public IJBossServerPublishMethodType getPublishMethod(String id) {
-// ServerPublishMethodType[] publishMethods = getPublishMethodTypes();
-// for( int i = 0; i < publishMethods.length; i++ )
-// if( publishMethods[i].getId().equals(id))
-// return publishMethods[i];
-// return null;
-// }
-// public IJBossServerPublishMethodType[] findPossiblePublishMethods(IServerType type) {
-// ArrayList<IJBossServerPublishMethodType> list = new
ArrayList<IJBossServerPublishMethodType>();
-// list.addAll(Arrays.asList(getPublishMethodTypes()));
-// Iterator<IJBossServerPublishMethodType> i = list.iterator();
-// while(i.hasNext()) {
-// if( !i.next().accepts(type.getId()))
-// i.remove();
-// }
-// return list.toArray(new IJBossServerPublishMethodType[list.size()]);
-// }
-//
-// public IJBossServerPublishMethodType[] findPossiblePublishMethods(IServer server) {
-// return findPossiblePublishMethods(server.getServerType());
-// }
-
// API extension
public static interface IServerJMXRunnable {
public void run(MBeanServerConnection connection) throws Exception;
@@ -328,40 +286,4 @@
public void setAlreadyStartedHandler(IServerAlreadyStartedHandler handler) {
defaultAlreadyStartedHandler = handler;
}
-
-
-// /**
-// * Temporary home for start launch setup participants and launch configs
-// * Should eventually be replaced by an extension point of some type
-// *
-// * TODO Convert this into a suitable fixed API
-// */
-// public static HashMap<String, IStartLaunchDelegate> JBoss7launchDelegates;
-// public static ArrayList<IStartLaunchSetupParticipant> JBoss7setupParticipants;
-// public static HashMap<String, IStartLaunchDelegate> JBossLaunchDelegates;
-// public static ArrayList<IStartLaunchSetupParticipant> JBossSetupParticipants;
-// static {
-// JBoss7setupParticipants = new ArrayList<IStartLaunchSetupParticipant>();
-// JBoss7launchDelegates = new HashMap<String, IStartLaunchDelegate>();
-// JBoss7setupParticipants.add(new LocalJBoss7StartLaunchDelegate());
-// JBoss7launchDelegates.put(LocalPublishMethod.LOCAL_PUBLISH_METHOD, new
LocalJBoss7StartLaunchDelegate());
-//
-// JBossSetupParticipants = new ArrayList<IStartLaunchSetupParticipant>();
-// JBossLaunchDelegates = new HashMap<String, IStartLaunchDelegate>();
-// JBossSetupParticipants.add(new LocalJBossStartLaunchDelegate());
-// JBossLaunchDelegates.put(LocalPublishMethod.LOCAL_PUBLISH_METHOD, new
LocalJBossStartLaunchDelegate());
-// }
-// public HashMap<String, IStartLaunchDelegate> getLaunchDelegates(IServer server)
{
-// if( server.getServerType().getId().equals(IJBossToolingConstants.SERVER_AS_70)) {
-// return JBoss7launchDelegates;
-// }
-// return JBossLaunchDelegates;
-// }
-// public ArrayList<IStartLaunchSetupParticipant> getSetupParticipants(IServer
server) {
-// if( ServerUtil.isJBoss7(server)) {
-// return JBoss7setupParticipants;
-// }
-// return JBossSetupParticipants;
-// }
-//
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/BehaviourModel.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/BehaviourModel.java 2012-02-01
03:57:02 UTC (rev 38351)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/BehaviourModel.java 2012-02-01
04:24:24 UTC (rev 38352)
@@ -33,9 +33,11 @@
loadModel();
}
- public static IJBossServerPublishMethodType getPublishMethodType(IServer server) {
+ public static IJBossServerPublishMethodType getPublishMethodType(IServer server, String
defaultType) {
String serverType = server.getServerType().getId();
String behaviourType =
DeploymentPreferenceLoader.getCurrentDeploymentMethodTypeId(server);
+ if( behaviourType == null )
+ behaviourType = defaultType;
return BehaviourModel.getModel().getBehaviour(serverType).getImpl(behaviourType);
}
@@ -159,7 +161,14 @@
return null;
}
+ private boolean isEmpty(String s) {
+ return s == null || "".equals(s); //$NON-NLS-1$
+ }
+
public IJBossLaunchDelegate createLaunchDelegate() {
+ if( isEmpty(element.getAttribute("launchDelegate"))) //$NON-NLS-1$
+ return null;
+
try {
return (IJBossLaunchDelegate)
element.createExecutableExtension("launchDelegate"); //$NON-NLS-1$
} catch( CoreException ce ) {
@@ -169,6 +178,9 @@
}
public IJBossBehaviourDelegate createBehaviourDelegate() {
+ if( isEmpty(element.getAttribute("behaviourDelegate"))) //$NON-NLS-1$
+ return null;
+
try {
return
(IJBossBehaviourDelegate)element.createExecutableExtension("behaviourDelegate");
//$NON-NLS-1$
} catch(CoreException ce) {
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/DeploymentPreferenceLoader.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/DeploymentPreferenceLoader.java 2012-02-01
03:57:02 UTC (rev 38351)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/DeploymentPreferenceLoader.java 2012-02-01
04:24:24 UTC (rev 38352)
@@ -51,7 +51,7 @@
}
public static IJBossServerPublishMethodType getCurrentDeploymentMethodType(IServer
server, String defaultType) {
- return BehaviourModel.getPublishMethodType(server);
+ return BehaviourModel.getPublishMethodType(server, defaultType);
}
public static String getCurrentDeploymentMethodTypeId(IServer server) {
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml 2012-02-01 03:57:02 UTC (rev
38351)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml 2012-02-01 04:24:24 UTC (rev
38352)
@@ -1125,21 +1125,17 @@
</variable>
</extension>
- <!--
<extension
- point="org.jboss.ide.eclipse.as.core.publishMethod">
- <publishMethod
- id="local"
- name="Local"
-
class="org.jboss.ide.eclipse.as.core.publishers.LocalPublishMethod"
- serverTypes="%AllJBTServerTypes">
- </publishMethod>
- </extension>
- -->
-
- <extension
point="org.jboss.ide.eclipse.as.core.behaviourExtension">
<behaviour
+ behaviourDelegate=""
+ launchDelegate=""
+ name="Local"
+
publishMethod="org.jboss.ide.eclipse.as.core.publishers.LocalPublishMethod"
+ serverTypes="org.jboss.ide.eclipse.as.systemCopyServer"
+ typeId="local">
+ </behaviour>
+ <behaviour
behaviourDelegate="org.jboss.ide.eclipse.as.core.server.internal.LocalJBossBehaviorDelegate"
launchDelegate="org.jboss.ide.eclipse.as.core.server.internal.launch.LocalJBossStartLaunchDelegate"
name="Local"
@@ -1147,9 +1143,6 @@
serverTypes="%ServerTypesJBoss6OrLower"
typeId="local">
</behaviour>
- </extension>
- <extension
- point="org.jboss.ide.eclipse.as.core.behaviourExtension">
<behaviour
behaviourDelegate="org.jboss.ide.eclipse.as.core.server.internal.v7.LocalJBoss7BehaviorDelegate"
launchDelegate="org.jboss.ide.eclipse.as.core.server.internal.v7.LocalJBoss7StartLaunchDelegate"
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/ASTestSuite.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/ASTestSuite.java 2012-02-01
03:57:02 UTC (rev 38351)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/ASTestSuite.java 2012-02-01
04:24:24 UTC (rev 38352)
@@ -33,6 +33,7 @@
import org.jboss.ide.eclipse.as.test.publishing.JBIDE2512aTest;
import org.jboss.ide.eclipse.as.test.publishing.JBIDE2512bTest;
import org.jboss.ide.eclipse.as.test.publishing.JBIDE4184Test;
+import org.jboss.ide.eclipse.as.test.publishing.v2.BehaviourModelDefectTest;
import org.jboss.ide.eclipse.as.test.publishing.v2.JSTDeployBinaryChildModuleTest;
import org.jboss.ide.eclipse.as.test.publishing.v2.JSTDeploymentTester;
import org.jboss.ide.eclipse.as.test.publishing.v2.JSTDeploymentWarUpdateXML;
@@ -66,6 +67,7 @@
suite.addTestSuite(SingleFileDeployableMockDeploymentTester.class);
// Publishing tests
+ suite.addTestSuite(BehaviourModelDefectTest.class);
suite.addTestSuite(MockJSTPublisherTest.class);
suite.addTestSuite(MockJSTPublisherTestDynUtil.class);
suite.addTestSuite(JBIDE1657Test.class);
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/BehaviourModelDefectTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/BehaviourModelDefectTest.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/BehaviourModelDefectTest.java 2012-02-01
04:24:24 UTC (rev 38352)
@@ -0,0 +1,85 @@
+package org.jboss.ide.eclipse.as.test.publishing.v2;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.wst.server.core.IServer;
+import org.jboss.ide.eclipse.as.core.server.internal.BehaviourModel;
+import org.jboss.ide.eclipse.as.core.util.DeploymentPreferenceLoader;
+import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
+import org.jboss.ide.eclipse.as.test.util.ServerRuntimeUtils;
+
+public class BehaviourModelDefectTest extends TestCase {
+ public void tearDown() {
+ try {
+ ServerRuntimeUtils.deleteAllServers();
+ ServerRuntimeUtils.deleteAllRuntimes();
+ } catch(CoreException ce) {}
+ }
+
+ public void serverTestImpl(String type) {
+ IServer server = ServerRuntimeUtils.createMockServerWithRuntime(type,
"server1", "default");
+ serverTestBehaviourImpl(server);
+ serverTestBehaviourImplLaunches(server);
+ }
+ public void serverTestBehaviourImpl(IServer server) {
+ // all should have a publish method
+ String serverType = server.getServerType().getId();
+ String behaviourType =
DeploymentPreferenceLoader.getCurrentDeploymentMethodTypeId(server);
+ assertNotNull(behaviourType);
+ assertNotNull(BehaviourModel.getModel().getBehaviour(serverType).getImpl(behaviourType));
+ assertNotNull(BehaviourModel.getModel().getBehaviour(serverType).getImpl(behaviourType).createPublishMethod());
+ }
+
+ public void serverTestBehaviourImplLaunches(IServer server) {
+ String serverType = server.getServerType().getId();
+ String behaviourType =
DeploymentPreferenceLoader.getCurrentDeploymentMethodTypeId(server);
+ assertNotNull(behaviourType);
+ assertNotNull(BehaviourModel.getModel().getBehaviour(serverType).getImpl(behaviourType).createLaunchDelegate());
+ }
+
+ public void testDeployOnlyBehaviourModel() throws CoreException {
+ IServer server = ServerRuntimeUtils.createMockDeployOnlyServer();
+ String serverType = server.getServerType().getId();
+ String behaviourType =
DeploymentPreferenceLoader.getCurrentDeploymentMethodTypeId(server);
+ assertNull(behaviourType);
+ assertNotNull(BehaviourModel.getModel().getBehaviour(serverType).getImpl("local"));
+ assertNotNull(BehaviourModel.getModel().getBehaviour(serverType).getImpl("local").createPublishMethod());
+ assertNull(BehaviourModel.getModel().getBehaviour(serverType).getImpl("local").createLaunchDelegate());
+ }
+
+ public void test32BehaviourModel() {
+ serverTestImpl(IJBossToolingConstants.SERVER_AS_32);
+ }
+ public void test40BehaviourModel() {
+ serverTestImpl(IJBossToolingConstants.SERVER_AS_40);
+ }
+ public void test42BehaviourModel() {
+ serverTestImpl(IJBossToolingConstants.SERVER_AS_42);
+ }
+ public void test50BehaviourModel() {
+ serverTestImpl(IJBossToolingConstants.SERVER_AS_50);
+ }
+ public void test51BehaviourModel() {
+ serverTestImpl(IJBossToolingConstants.SERVER_AS_51);
+ }
+ public void test60BehaviourModel() {
+ serverTestImpl(IJBossToolingConstants.SERVER_AS_60);
+ }
+ public void test70BehaviourModel() {
+ serverTestImpl(IJBossToolingConstants.SERVER_AS_70);
+ }
+ public void test71BehaviourModel() {
+ serverTestImpl(IJBossToolingConstants.SERVER_AS_71);
+ }
+ public void testEap43BehaviourModel() {
+ serverTestImpl(IJBossToolingConstants.SERVER_EAP_43);
+ }
+ public void testEap50BehaviourModel() {
+ serverTestImpl(IJBossToolingConstants.SERVER_EAP_50);
+ }
+ public void testEap60BehaviourModel() {
+ serverTestImpl(IJBossToolingConstants.SERVER_EAP_60);
+ }
+
+}
Copied:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/MockArgsTests.java
(from rev 38327,
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/MockTests.java)
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/MockArgsTests.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/MockArgsTests.java 2012-02-01
04:24:24 UTC (rev 38352)
@@ -0,0 +1,163 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.ide.eclipse.as.test.server;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.IServerWorkingCopy;
+import org.jboss.ide.eclipse.as.core.server.internal.DelegatingServerBehavior;
+import org.jboss.ide.eclipse.as.core.server.internal.IProcessProvider;
+import org.jboss.ide.eclipse.as.core.server.internal.LocalJBossServerRuntime;
+import org.jboss.ide.eclipse.as.core.server.internal.ServerAttributeHelper;
+import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
+import org.jboss.ide.eclipse.as.test.util.ServerRuntimeUtils;
+
+public class MockArgsTests extends TestCase {
+ public void setUp() {
+ }
+ public void tearDown() {
+ try {
+ ServerRuntimeUtils.deleteAllServers();
+ ServerRuntimeUtils.deleteAllRuntimes();
+ } catch(CoreException ce) {}
+ }
+
+
+ public void testRemoveCriticalVMArgs() {
+ IServer server = serverTestImpl(IJBossToolingConstants.SERVER_AS_50);
+ try {
+ ILaunchConfiguration config = server.getLaunchConfiguration(true, new
NullProgressMonitor());
+ ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
"hello");
+ wc.doSave();
+
+ // re-get it and check the changes
+ ILaunchConfiguration launchConfig = server.getLaunchConfiguration(false, null);
+ String vmArgs =
launchConfig.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
(String)null);
+ LocalJBossServerRuntime rt =
(LocalJBossServerRuntime)server.getRuntime().loadAdapter(LocalJBossServerRuntime.class,
new NullProgressMonitor());
+ String defaultVMArgs = rt.getDefaultRunVMArgs();
+ assertFalse(vmArgs == null);
+ assertFalse(vmArgs.equals(rt.getDefaultRunVMArgs()));
+ assertFalse(vmArgs.equals(defaultVMArgs));
+ assertTrue(vmArgs.startsWith("hello -Djava.endorsed.dirs=\""));
+ assertTrue(vmArgs.endsWith(".metadata/.plugins/org.jboss.ide.eclipse.as.test/mockedServers/server1/lib/endorsed\""));
+ } catch(CoreException ce) {
+ fail(ce.getMessage());
+ }
+ }
+
+ public void testChangeArgs() {
+ // should still match the defaults since the defaults are extremely all required
+ IServer server = serverTestImpl(IJBossToolingConstants.SERVER_AS_50);
+ try {
+ ILaunchConfiguration config = server.getLaunchConfiguration(true, new
NullProgressMonitor());
+ ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
"");
+ wc.doSave();
+ String command = runAndGetCommand(server);
+ assertFalse("No args found from process", command == null);
+ LocalJBossServerRuntime rt =
(LocalJBossServerRuntime)server.getRuntime().loadAdapter(LocalJBossServerRuntime.class,
new NullProgressMonitor());
+ String defaultArgs = rt.getDefaultRunArgs().replace("\"",
"");
+ assertTrue(command.replace("\"", "").contains(defaultArgs));
+ } catch(CoreException ce) {
+ fail(ce.getMessage());
+ }
+ }
+
+ protected IServer serverTestImpl(String type) {
+ IServer server = ServerRuntimeUtils.createMockServerWithRuntime(type,
"server1", "default");
+ IServer fixed = setMockDetails(server);
+ String command = runAndGetCommand(fixed);
+ assertFalse("No args found from process", command == null);
+
+ LocalJBossServerRuntime rt =
(LocalJBossServerRuntime)server.getRuntime().loadAdapter(LocalJBossServerRuntime.class,
new NullProgressMonitor());
+ String defaultArgs = rt.getDefaultRunArgs().replace("\"",
"");
+ String defaultVMArgs = rt.getDefaultRunVMArgs().replace("\"",
"");
+ assertTrue(command.replace("\"",
"").contains(defaultArgs.trim()));
+ assertTrue(command.replace("\"",
"").contains(defaultVMArgs.trim()));
+ return fixed;
+ }
+
+ protected IProcess runAndGetProcess(final IServer server) {
+ try {
+ server.start("run", new NullProgressMonitor());
+ } catch( CoreException ce) {}
+
+ int loops = 0;
+ DelegatingServerBehavior behavior =
(DelegatingServerBehavior)server.loadAdapter(DelegatingServerBehavior.class, null);
+
+ while(loops < 50) {
+ if( ((IProcessProvider)behavior.getDelegate()).getProcess() != null ) {
+ return ((IProcessProvider)behavior.getDelegate()).getProcess();
+ }
+ try {
+ loops++;
+ Thread.sleep(1000);
+ } catch(Exception e){}
+ }
+ return null;
+ }
+
+ protected String runAndGetCommand(final IServer server) {
+ return runAndGetProcess(server).getAttribute(IProcess.ATTR_CMDLINE);
+ }
+
+ private IServer setMockDetails(IServer server) {
+ IServerWorkingCopy copy = server.createWorkingCopy();
+ ServerAttributeHelper helper = new ServerAttributeHelper(server, copy);
+ helper.setAttribute("start-timeout", "2");
+ helper.setAttribute("org.jboss.ide.eclipse.as.core.server.attributes.startupPollerKey",
+ "org.jboss.ide.eclipse.as.core.runtime.server.timeoutpoller");
+ try {
+ return copy.save(true, new NullProgressMonitor());
+ } catch( CoreException ce ) {
+ }
+ return null;
+ }
+
+ public void test32Mock() {
+ serverTestImpl(IJBossToolingConstants.SERVER_AS_32);
+ }
+
+ public void test40Mock() {
+ serverTestImpl(IJBossToolingConstants.SERVER_AS_40);
+ }
+
+ public void test42Mock() {
+ serverTestImpl(IJBossToolingConstants.SERVER_AS_42);
+ }
+
+ public void test50Mock() {
+ serverTestImpl(IJBossToolingConstants.SERVER_AS_50);
+ }
+ public void test51Mock() {
+ serverTestImpl(IJBossToolingConstants.SERVER_AS_51);
+ }
+ public void test60Mock() {
+ serverTestImpl(IJBossToolingConstants.SERVER_AS_60);
+ }
+ public void testEap43Mock() {
+ serverTestImpl(IJBossToolingConstants.SERVER_EAP_43);
+ }
+ public void testEap50Mock() {
+ serverTestImpl(IJBossToolingConstants.SERVER_EAP_50);
+ }
+ public void testEap60Mock() {
+ serverTestImpl(IJBossToolingConstants.SERVER_EAP_60);
+ }
+}
Deleted:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/MockTests.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/MockTests.java 2012-02-01
03:57:02 UTC (rev 38351)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/MockTests.java 2012-02-01
04:24:24 UTC (rev 38352)
@@ -1,160 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.ide.eclipse.as.test.server;
-
-import junit.framework.TestCase;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.core.model.IProcess;
-import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.IServerWorkingCopy;
-import org.jboss.ide.eclipse.as.core.server.internal.DelegatingServerBehavior;
-import org.jboss.ide.eclipse.as.core.server.internal.IProcessProvider;
-import org.jboss.ide.eclipse.as.core.server.internal.LocalJBossServerRuntime;
-import org.jboss.ide.eclipse.as.core.server.internal.ServerAttributeHelper;
-import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
-import org.jboss.ide.eclipse.as.test.util.ServerRuntimeUtils;
-
-public class MockTests extends TestCase {
- public void setUp() {
- }
- public void tearDown() {
- try {
- ServerRuntimeUtils.deleteAllServers();
- ServerRuntimeUtils.deleteAllRuntimes();
- } catch(CoreException ce) {}
- }
-
-
- public void testRemoveCriticalVMArgs() {
- IServer server = serverTestImpl(IJBossToolingConstants.SERVER_AS_50);
- try {
- ILaunchConfiguration config = server.getLaunchConfiguration(true, new
NullProgressMonitor());
- ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
"hello");
- wc.doSave();
-
- // re-get it and check the changes
- ILaunchConfiguration launchConfig = server.getLaunchConfiguration(false, null);
- String vmArgs =
launchConfig.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
(String)null);
- LocalJBossServerRuntime rt =
(LocalJBossServerRuntime)server.getRuntime().loadAdapter(LocalJBossServerRuntime.class,
new NullProgressMonitor());
- String defaultVMArgs = rt.getDefaultRunVMArgs();
- assertFalse(vmArgs == null);
- assertFalse(vmArgs.equals(rt.getDefaultRunVMArgs()));
- assertFalse(vmArgs.equals(defaultVMArgs));
- assertTrue(vmArgs.startsWith("hello -Djava.endorsed.dirs=\""));
- assertTrue(vmArgs.endsWith(".metadata/.plugins/org.jboss.ide.eclipse.as.test/mockedServers/server1/lib/endorsed\""));
- } catch(CoreException ce) {
- fail(ce.getMessage());
- }
- }
-
- public void testChangeArgs() {
- // should still match the defaults since the defaults are extremely all required
- IServer server = serverTestImpl(IJBossToolingConstants.SERVER_AS_50);
- try {
- ILaunchConfiguration config = server.getLaunchConfiguration(true, new
NullProgressMonitor());
- ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
"");
- wc.doSave();
- String command = runAndGetCommand(server);
- assertFalse("No args found from process", command == null);
- LocalJBossServerRuntime rt =
(LocalJBossServerRuntime)server.getRuntime().loadAdapter(LocalJBossServerRuntime.class,
new NullProgressMonitor());
- String defaultArgs = rt.getDefaultRunArgs().replace("\"",
"");
- assertTrue(command.replace("\"", "").contains(defaultArgs));
- } catch(CoreException ce) {
- fail(ce.getMessage());
- }
- }
-
- protected IServer serverTestImpl(String type) {
- IServer server = ServerRuntimeUtils.createMockServerWithRuntime(type,
"server1", "default");
- IServer fixed = setMockDetails(server);
- String command = runAndGetCommand(fixed);
- assertFalse("No args found from process", command == null);
-
- LocalJBossServerRuntime rt =
(LocalJBossServerRuntime)server.getRuntime().loadAdapter(LocalJBossServerRuntime.class,
new NullProgressMonitor());
- String defaultArgs = rt.getDefaultRunArgs().replace("\"",
"");
- String defaultVMArgs = rt.getDefaultRunVMArgs().replace("\"",
"");
- assertTrue(command.replace("\"",
"").contains(defaultArgs.trim()));
- assertTrue(command.replace("\"",
"").contains(defaultVMArgs.trim()));
- return fixed;
- }
-
- protected IProcess runAndGetProcess(final IServer server) {
- try {
- server.start("run", new NullProgressMonitor());
- } catch( CoreException ce) {}
-
- int loops = 0;
- DelegatingServerBehavior behavior =
(DelegatingServerBehavior)server.loadAdapter(DelegatingServerBehavior.class, null);
-
- while(loops < 50) {
- if( ((IProcessProvider)behavior.getDelegate()).getProcess() != null ) {
- return ((IProcessProvider)behavior.getDelegate()).getProcess();
- }
- try {
- loops++;
- Thread.sleep(1000);
- } catch(Exception e){}
- }
- return null;
- }
-
- protected String runAndGetCommand(final IServer server) {
- return runAndGetProcess(server).getAttribute(IProcess.ATTR_CMDLINE);
- }
-
- private IServer setMockDetails(IServer server) {
- IServerWorkingCopy copy = server.createWorkingCopy();
- ServerAttributeHelper helper = new ServerAttributeHelper(server, copy);
- helper.setAttribute("start-timeout", "2");
- helper.setAttribute("org.jboss.ide.eclipse.as.core.server.attributes.startupPollerKey",
- "org.jboss.ide.eclipse.as.core.runtime.server.timeoutpoller");
- try {
- return copy.save(true, new NullProgressMonitor());
- } catch( CoreException ce ) {
- }
- return null;
- }
-
- public void test32Mock() {
- serverTestImpl(IJBossToolingConstants.SERVER_AS_32);
- }
-
- public void test40Mock() {
- serverTestImpl(IJBossToolingConstants.SERVER_AS_40);
- }
-
- public void test42Mock() {
- serverTestImpl(IJBossToolingConstants.SERVER_AS_42);
- }
-
- public void test50Mock() {
- serverTestImpl(IJBossToolingConstants.SERVER_AS_50);
- }
- public void test51Mock() {
- serverTestImpl(IJBossToolingConstants.SERVER_AS_51);
- }
- public void test60Mock() {
- serverTestImpl(IJBossToolingConstants.SERVER_AS_60);
- }
- public void testEap43Mock() {
- serverTestImpl(IJBossToolingConstants.SERVER_EAP_43);
- }
- public void testEap50Mock() {
- serverTestImpl(IJBossToolingConstants.SERVER_EAP_50);
- }
-}