Author: rob.stryker(a)jboss.com
Date: 2012-02-28 01:59:09 -0500 (Tue, 28 Feb 2012)
New Revision: 39159
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/SimpleServerImplTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/StringSubstitutionTest.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/META-INF/MANIFEST.MF
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/descriptors/XPathQuery.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/resolvers/ConfigNameResolver.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml
trunk/as/plugins/org.jboss.ide.eclipse.as.core/properties/jboss.70.default.ports.properties
trunk/as/plugins/org.jboss.ide.eclipse.as.core/properties/jboss.71.default.ports.properties
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs/XPathDialogs.java
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/server/XPathModelTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/ServerRuntimeUtils.java
Log:
JBIDE-11058 - config file change to standalone-ha does not work for ports and xpaths
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/META-INF/MANIFEST.MF 2012-02-28
04:06:02 UTC (rev 39158)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/META-INF/MANIFEST.MF 2012-02-28
06:59:09 UTC (rev 39159)
@@ -34,6 +34,7 @@
org.jboss.ide.eclipse.as.core.modules,
org.jboss.ide.eclipse.as.core.publishers,
org.jboss.ide.eclipse.as.core.publishers.patterns,
+ org.jboss.ide.eclipse.as.core.resolvers,
org.jboss.ide.eclipse.as.core.server,
org.jboss.ide.eclipse.as.core.server.bean,
org.jboss.ide.eclipse.as.core.server.internal,
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/descriptors/XPathQuery.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/descriptors/XPathQuery.java 2012-02-28
04:06:02 UTC (rev 39158)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/descriptors/XPathQuery.java 2012-02-28
06:59:09 UTC (rev 39159)
@@ -29,6 +29,7 @@
import org.jaxen.dom4j.Dom4jXPath;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import
org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathFileResult.XPathResultNode;
+import org.jboss.ide.eclipse.as.core.resolvers.ConfigNameResolver;
import org.jboss.ide.eclipse.as.core.util.IMemento;
/**
@@ -46,6 +47,7 @@
protected String baseDir;
protected volatile String effectiveBaseDir;
protected String filePattern;
+ protected volatile String effectiveFilePattern;
protected String xpathPattern;
protected String attribute;
@@ -70,6 +72,7 @@
this.xpathPattern = memento.getString("xpathPattern"); //$NON-NLS-1$
this.attribute = memento.getString("attribute"); //$NON-NLS-1$
setEffectiveBaseDir();
+ setEffectiveFilePattern();
}
public XPathQuery(String name, List list) {
@@ -79,6 +82,7 @@
this.xpathPattern = list.get(2).equals(XPathModel.EMPTY_STRING) ? null :
(String)list.get(2);
this.attribute = list.size() < 3 || list.get(3).equals(XPathModel.EMPTY_STRING) ?
null : (String)list.get(3);
setEffectiveBaseDir();
+ setEffectiveFilePattern();
}
public XPathQuery(IServer server, String name, String baseDir,
@@ -91,42 +95,33 @@
this.attribute = attribute;
this.results = null;
setEffectiveBaseDir();
+ setEffectiveFilePattern();
}
private void setEffectiveBaseDir() {
String serverName = server == null ? "" : server.getName(); //$NON-NLS-1$
String dir1 = baseDir == null ? null : baseDir;
-
- String dir2 = null;
- if( dir1 != null ) {
- dir2 = dir1.replace("${jboss_config_dir}", //$NON-NLS-1$
- "${jboss_config_dir:" + serverName + "}"); //$NON-NLS-1$
//$NON-NLS-2$
- dir2 = dir2.replace("${jboss_config}", //$NON-NLS-1$
- "${jboss_config:" + serverName + "}"); //$NON-NLS-1$
//$NON-NLS-2$
-
- try {
- StringSubstitutionEngine engine = new StringSubstitutionEngine();
- dir2 = engine.performStringSubstitution(dir2, true,
- true, StringVariableManager.getDefault());
- } catch( CoreException ce ) {
- JBossServerCorePlugin.log(ce.getStatus());
- }
- }
-
-
+ String dir2 = new ConfigNameResolver().performSubstitutions(dir1, serverName);
IPath dir = dir2 == null ? null : new Path(dir2);
if( dir == null && category != null) {
dir = getCategory().getServer().getRuntime().getLocation();
}
if( dir != null && !dir.isAbsolute() && category != null)
dir = getCategory().getServer().getRuntime().getLocation().append(dir);
-
effectiveBaseDir = dir == null ? null : dir.toString();
}
+ private void setEffectiveFilePattern() {
+ String serverName = server == null ? "" : server.getName(); //$NON-NLS-1$
+ String pattern = filePattern == null ? null : filePattern;
+ String pattern2 = new ConfigNameResolver().performSubstitutions(pattern, serverName);
+ effectiveFilePattern = pattern2;
+ }
+
+
protected AntFileFilter getFilter() {
if( filter == null ) {
- filter = new AntFileFilter(effectiveBaseDir, filePattern);
+ filter = new AntFileFilter(effectiveBaseDir, effectiveFilePattern);
}
return filter;
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/resolvers/ConfigNameResolver.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/resolvers/ConfigNameResolver.java 2012-02-28
04:06:02 UTC (rev 39158)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/resolvers/ConfigNameResolver.java 2012-02-28
06:59:09 UTC (rev 39159)
@@ -11,6 +11,8 @@
package org.jboss.ide.eclipse.as.core.resolvers;
+import org.eclipse.core.internal.variables.StringSubstitutionEngine;
+import org.eclipse.core.internal.variables.StringVariableManager;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.variables.IDynamicVariable;
@@ -18,31 +20,83 @@
import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.ServerCore;
+import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
+import org.jboss.ide.eclipse.as.core.server.internal.v7.LocalJBoss7ServerRuntime;
/**
* These classes are primarily geared for as6-and-below
* and are meant to serve as a dereferencing point to discover
* the configuration name and it's parent directory in the case
* other portions of the tool, such as xpaths or classpaths,
* want to use these variables in their saved strings.
- *
- * They are not really geared for use with as7 and above, and their
- * behaviour with regards to as7 and above are officially undefined,
- * though unofficially both should return the empty string in these cases
- * @author rob
- *
*/
public class ConfigNameResolver implements IDynamicVariableResolver {
+ public static final String JBOSS_CONFIG = "jboss_config"; //$NON-NLS-1$
+ public static final String JBOSS_CONFIG_DIR = "jboss_config_dir";
//$NON-NLS-1$
+ public static final String JBOSS_AS7_CONFIG_FILE = "jboss_as7_config_file";
//$NON-NLS-1$
+
+ /*
+ * entry points to fill out the server name in these variable substitutions
+ */
+
+ /**
+ * Kick off the substitution engine for this string, doing
+ * server-related replacements (adding variables) beforehand.
+ *
+ * @param dir1
+ * @param serverName
+ * @return
+ */
+ public String performSubstitutions(String dir1, String serverName) {
+ String dir2 = null;
+ if( dir1 != null ) {
+ dir2 = replace(dir1, ConfigNameResolver.JBOSS_CONFIG, serverName);
+ dir2 = replace(dir2, ConfigNameResolver.JBOSS_CONFIG_DIR, serverName);
+ dir2 = replace(dir2, ConfigNameResolver.JBOSS_AS7_CONFIG_FILE, serverName);
+
+ try {
+ StringSubstitutionEngine engine = new StringSubstitutionEngine();
+ dir2 = engine.performStringSubstitution(dir2, true,
+ true, StringVariableManager.getDefault());
+ } catch( CoreException ce ) {
+ JBossServerCorePlugin.log(ce.getStatus());
+ }
+ }
+ return dir2;
+ }
+
+ private String replace(String original, String variable, String serverName) {
+ if( original != null ) {
+ return original.replace(getVariablePattern(variable), getVariablePattern(variable,
serverName));
+ }
+ return null;
+ }
+
+ private String getVariablePattern(String var) {
+ return "${" + var + "}"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ private String getVariablePattern(String var, String serverName) {
+ return "${" + var + ":" + serverName + "}"; //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+
+ /*
+ * Actual resolution of these dynamic variables are performed below
+ */
+
public String resolveValue(IDynamicVariable variable, String argument)
throws CoreException {
- if( variable.getName().equals("jboss_config")) //$NON-NLS-1$
+ if( variable.getName().equals(JBOSS_CONFIG))
return handleConfig(variable, argument);
- if( variable.getName().equals("jboss_config_dir")) //$NON-NLS-1$
+ if( variable.getName().equals(JBOSS_CONFIG_DIR))
return handleConfigDir(variable, argument);
+ if( variable.getName().equals(JBOSS_AS7_CONFIG_FILE))
+ return handleAS7ConfigFile(variable, argument);
return null;
}
-
+
protected String handleConfig(IDynamicVariable variable, String argument) {
IJBossServerRuntime ajbsrt = findJBossServerRuntime(argument);
if( ajbsrt != null ) {
@@ -66,6 +120,14 @@
return null;
}
+ protected String handleAS7ConfigFile(IDynamicVariable variable, String argument) {
+ IJBossServerRuntime ajbsrt = findJBossServerRuntime(argument);
+ if( ajbsrt != null && ajbsrt instanceof LocalJBoss7ServerRuntime) {
+ return ((LocalJBoss7ServerRuntime)ajbsrt).getConfigurationFile();
+ }
+ return null;
+ }
+
private IJBossServerRuntime findJBossServerRuntime(String serverName) {
IServer[] servers = ServerCore.getServers();
for( int i = 0; i < servers.length; i++ ) {
@@ -82,7 +144,6 @@
}
}
return null;
-
}
}
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-28 04:06:02 UTC (rev
39158)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml 2012-02-28 06:59:09 UTC (rev
39159)
@@ -1123,6 +1123,12 @@
resolver="org.jboss.ide.eclipse.as.core.resolvers.ConfigNameResolver"
supportsArgument="true">
</variable>
+ <variable
+ name="jboss_as7_config_file"
+ description="Returns the full path of the configuration file for the
server who's name matches the variable, or, if none, the runtime who's
name matches the variable"
+
resolver="org.jboss.ide.eclipse.as.core.resolvers.ConfigNameResolver"
+ supportsArgument="true">
+ </variable>
</extension>
<extension
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/properties/jboss.70.default.ports.properties
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/properties/jboss.70.default.ports.properties 2012-02-28
04:06:02 UTC (rev 39158)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/properties/jboss.70.default.ports.properties 2012-02-28
06:59:09 UTC (rev 39159)
@@ -3,4 +3,4 @@
JBoss_Web_ATTRIBUTE=port
JBoss_Management=//*[local-name()="management-interfaces"]/*[local-name()="native-interface"]
JBoss_Management_ATTRIBUTE=port
-JBoss_Management_FILE=standalone/configuration/standalone.xml
\ No newline at end of file
+JBoss_Management_FILE=standalone/configuration/${jboss_as7_config_file}
\ No newline at end of file
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/properties/jboss.71.default.ports.properties
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/properties/jboss.71.default.ports.properties 2012-02-28
04:06:02 UTC (rev 39158)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/properties/jboss.71.default.ports.properties 2012-02-28
06:59:09 UTC (rev 39159)
@@ -3,4 +3,4 @@
JBoss_Web_ATTRIBUTE=port
JBoss_Management=//*[local-name()="socket-binding-group"]/*[local-name()="socket-binding"][@name="management-native"]
JBoss_Management_ATTRIBUTE=port
-JBoss_Management_FILE=standalone/configuration/standalone.xml
\ No newline at end of file
+JBoss_Management_FILE=standalone/configuration/${jboss_as7_config_file}
\ No newline at end of file
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs/XPathDialogs.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs/XPathDialogs.java 2012-02-28
04:06:02 UTC (rev 39158)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs/XPathDialogs.java 2012-02-28
06:59:09 UTC (rev 39159)
@@ -67,6 +67,7 @@
import
org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathFileResult.XPathResultNode;
import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathModel;
import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathQuery;
+import org.jboss.ide.eclipse.as.core.resolvers.ConfigNameResolver;
import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
import org.jboss.ide.eclipse.as.ui.Messages;
@@ -372,27 +373,23 @@
final String xpText = xpathText.getText();
final String attText = attributeText.getText();
- final String filePattern = filesetText.getText();
+ String filePattern = filesetText.getText();
String directory = baseDirText.getText();
- directory = directory.replace("${jboss_config_dir}", //$NON-NLS-1$
- "${jboss_config_dir:" + server.getName() + "}"); //$NON-NLS-1$
//$NON-NLS-2$
- directory = directory.replace("${jboss_config}", //$NON-NLS-1$
- "${jboss_config:" + server.getName() + "}"); //$NON-NLS-1$
//$NON-NLS-2$
- try {
- StringSubstitutionEngine engine = new StringSubstitutionEngine();
- directory = engine.performStringSubstitution(directory, true,
- true, StringVariableManager.getDefault());
- } catch( CoreException ce ) {
- //use the non-substituted string instead
- }
+
+ // substitute in basedir
+ directory = new ConfigNameResolver().performSubstitutions(directory,
server.getName());
if( !new Path(directory).isAbsolute()) {
directory = server.getRuntime().getLocation().append(directory).toString();
}
-
final String directory2 = directory;
+
+ // substitute in filePattern
+ filePattern = new ConfigNameResolver().performSubstitutions(filePattern,
server.getName());
+ final String filePattern2 = filePattern;
+
IRunnableWithProgress op = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException,
InterruptedException {
- XPathQuery tmp = new XPathQuery(null, "", directory2, filePattern, xpText,
attText); //$NON-NLS-1$
+ XPathQuery tmp = new XPathQuery(null, "", directory2, filePattern2,
xpText, attText); //$NON-NLS-1$
tmp.setRepository(repository);
final ArrayList<XPathFileResult> list = new
ArrayList<XPathFileResult>();
list.addAll(Arrays.asList(tmp.getResults()));
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-28
04:06:02 UTC (rev 39158)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/ASTestSuite.java 2012-02-28
06:59:09 UTC (rev 39159)
@@ -46,7 +46,7 @@
import org.jboss.ide.eclipse.as.test.publishing.v2.SingleFileDeploymentTester;
import org.jboss.ide.eclipse.as.test.server.JBossServerAPITest;
import org.jboss.ide.eclipse.as.test.server.ServerBeanLoaderTest;
-import org.jboss.ide.eclipse.as.test.server.ServerSecureStorageTest;
+import org.jboss.ide.eclipse.as.test.server.StringSubstitutionTest;
import org.jboss.ide.eclipse.as.test.server.XPathModelTest;
import org.jboss.ide.eclipse.as.test.util.ArgsUtilTest;
import org.jboss.ide.eclipse.as.test.util.ExpressionResolverUtilTest;
@@ -60,6 +60,7 @@
suite.addTestSuite(PreReqTest.class);
suite.addTestSuite(ServerBeanLoaderTest.class);
+
// Cannot find a way to run this test and pre-load the credentials for the
keystore
//suite.addTestSuite(ServerSecureStorageTest.class);
suite.addTestSuite(RuntimeServerModelTest.class);
@@ -68,6 +69,7 @@
suite.addTestSuite(JSTDeploymentWarUpdateXML.class);
suite.addTestSuite(SingleFileDeployableMockDeploymentTester.class);
suite.addTestSuite(XPathModelTest.class);
+ suite.addTestSuite(StringSubstitutionTest.class);
// Publishing tests
suite.addTestSuite(BehaviourModelDefectTest.class);
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/SimpleServerImplTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/SimpleServerImplTest.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/SimpleServerImplTest.java 2012-02-28
06:59:09 UTC (rev 39159)
@@ -0,0 +1,63 @@
+package org.jboss.ide.eclipse.as.test.server;
+
+import junit.framework.TestCase;
+
+import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
+import org.jboss.ide.eclipse.as.test.ASTest;
+import org.jboss.ide.eclipse.as.test.util.ServerRuntimeUtils;
+import org.jboss.ide.eclipse.as.test.util.wtp.ProjectUtility;
+
+/**
+ * Superclass for testing simple bits of functionality for each
+ * and every server type
+ *
+ * @author rob
+ *
+ */
+
+public abstract class SimpleServerImplTest extends TestCase {
+
+ protected abstract void serverTestImpl(String type);
+
+ public void tearDown() {
+ try {
+ ServerRuntimeUtils.deleteAllServers();
+ ServerRuntimeUtils.deleteAllRuntimes();
+ ProjectUtility.deleteAllProjects();
+ ASTest.clearStateLocation();
+ } catch(Exception ce ) {
+ // ignore
+ }
+ }
+
+ 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);
+ }
+}
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/StringSubstitutionTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/StringSubstitutionTest.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/StringSubstitutionTest.java 2012-02-28
06:59:09 UTC (rev 39159)
@@ -0,0 +1,39 @@
+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.wst.server.core.IRuntime;
+import org.eclipse.wst.server.core.IRuntimeWorkingCopy;
+import org.eclipse.wst.server.core.IServer;
+import org.jboss.ide.eclipse.as.core.resolvers.ConfigNameResolver;
+import org.jboss.ide.eclipse.as.core.server.internal.v7.LocalJBoss7ServerRuntime;
+import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
+import org.jboss.ide.eclipse.as.test.util.ServerRuntimeUtils;
+
+
+public class StringSubstitutionTest extends TestCase /* SimpleServerImplTest */ {
+
+ public void testAS7ConfigFileReplacement() throws CoreException {
+ IServer server =
ServerRuntimeUtils.createMockServerWithRuntime(IJBossToolingConstants.SERVER_AS_70,
"server1", "default");
+ IRuntime rt = server.getRuntime();
+
+ String ret = new ConfigNameResolver().performSubstitutions("some/path",
server.getName());
+ assertEquals("some/path", ret);
+ ret = new
ConfigNameResolver().performSubstitutions("some/path/${jboss_as7_config_file}" ,
server.getName());
+ assertEquals("some/path/standalone.xml", ret);
+
+ IRuntimeWorkingCopy rtwc = rt.createWorkingCopy();
+ LocalJBoss7ServerRuntime rtwc7 =
(LocalJBoss7ServerRuntime)rtwc.loadAdapter(LocalJBoss7ServerRuntime.class, new
NullProgressMonitor());
+ rtwc7.setConfigurationFile("someFile.xml");
+ rtwc.save(false, new NullProgressMonitor());
+ ret = new
ConfigNameResolver().performSubstitutions("some/path/${jboss_as7_config_file}" ,
server.getName());
+ assertEquals("some/path/someFile.xml", ret);
+ }
+
+// protected void serverTestImpl(String type) {
+// // TODO how to handle this check for every server type? Not needed right now
+// }
+
+}
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/XPathModelTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/XPathModelTest.java 2012-02-28
04:06:02 UTC (rev 39158)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/XPathModelTest.java 2012-02-28
06:59:09 UTC (rev 39159)
@@ -2,9 +2,6 @@
import java.io.File;
-import junit.framework.TestCase;
-
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.wst.server.core.IServer;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
@@ -13,7 +10,7 @@
import org.jboss.ide.eclipse.as.test.util.wtp.ProjectUtility;
import org.jboss.tools.test.util.JobUtils;
-public class XPathModelTest extends TestCase {
+public class XPathModelTest extends SimpleServerImplTest {
static {
JobUtils.waitForIdle(5000);
@@ -23,17 +20,6 @@
JobUtils.waitForIdle();
}
- public void tearDown() {
- try {
- ServerRuntimeUtils.deleteAllServers();
- ServerRuntimeUtils.deleteAllRuntimes();
- ProjectUtility.deleteAllProjects();
- ASTest.clearStateLocation();
- } catch(Exception ce ) {
- // ignore
- }
- }
-
protected void serverTestImpl(String type) {
IServer server = ServerRuntimeUtils.createMockServerWithRuntime(type,
"server1", "default");
File xpathFile =
JBossServerCorePlugin.getServerStateLocation(server).append(IJBossToolingConstants.XPATH_FILE_NAME).toFile();
@@ -44,35 +30,5 @@
if( !xpathFile.exists())
fail("The XPath File has not been created. Xpaths will be lost on workspace
restart");
}
- 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);
- }
-
}
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/ServerRuntimeUtils.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/ServerRuntimeUtils.java 2012-02-28
04:06:02 UTC (rev 39158)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/ServerRuntimeUtils.java 2012-02-28
06:59:09 UTC (rev 39159)
@@ -38,6 +38,7 @@
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.IServerType;
import org.eclipse.wst.server.core.IServer.IOperationListener;
import org.eclipse.wst.server.core.IServerWorkingCopy;
import org.eclipse.wst.server.core.ServerCore;
@@ -51,6 +52,7 @@
import org.jboss.ide.eclipse.as.core.util.RuntimeUtils;
import org.jboss.ide.eclipse.as.core.util.ServerConverter;
import org.jboss.ide.eclipse.as.core.util.ServerCreationUtils;
+import org.jboss.ide.eclipse.as.core.util.ServerUtil;
import org.jboss.ide.eclipse.as.test.ASTest;
import org.jboss.ide.eclipse.as.test.publishing.AbstractDeploymentTest;
import org.osgi.framework.Bundle;
@@ -159,9 +161,9 @@
public static IServer createMockServerWithRuntime(String serverType, String name, String
config) {
try {
- if( serverType.equals(IJBossToolingConstants.SERVER_AS_70))
+ IServerType type = ServerCore.findServerType(serverType);
+ if( ServerUtil.isJBoss7(type))
return createMockJBoss7Server();
-
IPath serverDir = createAS6AndBelowMockServerDirectory(name,
asSystemJar.get(serverType), config);
return createServer(serverRuntimeMap.get(serverType), serverType,
serverDir.toOSString(), config);
} catch( CoreException ce ) {