Permalink
Browse files

AS7-5703 cli tests rely on JBOSS_HOME

  • Loading branch information...
1 parent 163b7ec commit 84cd8134e81a2dc9fc7199f035494c9ba1af4422 @aloubyansky aloubyansky committed with bstansberry Oct 12, 2012
View
3 cli/pom.xml
@@ -47,6 +47,9 @@
<include>**/*TestCase.java</include>
</includes>
<enableAssertions>false</enableAssertions>
+ <systemPropertyVariables>
+ <jboss.cli.config>${project.basedir}/../build/src/main/resources/bin/jboss-cli.xml</jboss.cli.config>
+ </systemPropertyVariables>
</configuration>
</plugin>
<plugin>
View
1 ...n/basic/src/test/java/org/jboss/as/test/integration/management/cli/CliScriptTestBase.java
@@ -88,6 +88,7 @@ protected int execute(String host, int port, boolean connect, String cmd, boolea
final List<String> command = new ArrayList<String>();
command.add("java");
TestSuiteEnvironment.getIpv6Args(command);
+ command.add("-Djboss.cli.config=" + jbossDist + File.separator + "bin" + File.separator + "jboss-cli.xml");
command.add("-jar");
command.add(jbossDist + File.separatorChar + "jboss-modules.jar");
command.add("-mp");
View
1 ...asic/src/test/java/org/jboss/as/test/integration/management/cli/FileArgumentTestCase.java
@@ -171,6 +171,7 @@ protected int execute(File f, boolean logFailure) {
final List<String> command = new ArrayList<String>();
command.add("java");
TestSuiteEnvironment.getIpv6Args(command);
+ command.add("-Djboss.cli.config=" + jbossDist + File.separator + "bin" + File.separator + "jboss-cli.xml");
command.add("-jar");
command.add(jbossDist + File.separatorChar + "jboss-modules.jar");
command.add("-mp");
View
2 ...rc/test/java/org/jboss/as/test/integration/management/cli/FileWithPropertiesTestCase.java
@@ -240,6 +240,8 @@ protected int execute(boolean resolveProps, boolean logFailure) {
TestSuiteEnvironment.getIpv6Args(command);
if(resolveProps) {
command.add("-Djboss.cli.config=" + TMP_JBOSS_CLI_FILE.getAbsolutePath());
+ } else {
+ command.add("-Djboss.cli.config=" + jbossDist + File.separator + "bin" + File.separator + "jboss-cli.xml");
}
command.add("-jar");
command.add(jbossDist + File.separatorChar + "jboss-modules.jar");
View
22 ...suite/shared/src/main/java/org/jboss/as/test/integration/management/util/CLITestUtil.java
@@ -21,6 +21,9 @@
*/
package org.jboss.as.test.integration.management.util;
+import static org.junit.Assert.fail;
+
+import java.io.File;
import java.io.OutputStream;
import org.jboss.as.cli.CliInitializationException;
@@ -34,15 +37,32 @@
*/
public class CLITestUtil {
+ private static final String JBOSS_CLI_CONFIG = "jboss.cli.config";
+ private static final String JREADLINE_TERMINAL = "jreadline.terminal";
+ private static final String JREADLINE_TEST_TERMINAL = "org.jboss.jreadline.terminal.TestTerminal";
+
private static final String serverAddr = TestSuiteEnvironment.getServerAddress();
private static final int serverPort = TestSuiteEnvironment.getServerPort();
public static CommandContext getCommandContext() throws CliInitializationException {
+ setJBossCliConfig();
return CommandContextFactory.getInstance().newCommandContext(serverAddr, serverPort, null, null);
}
public static CommandContext getCommandContext(OutputStream out) throws CliInitializationException {
- System.setProperty("jreadline.terminal","org.jboss.jreadline.terminal.TestTerminal");
+ SecurityActions.setSystemProperty(JREADLINE_TERMINAL, JREADLINE_TEST_TERMINAL);
+ setJBossCliConfig();
return CommandContextFactory.getInstance().newCommandContext(serverAddr, serverPort, null, null, null, out);
}
+
+ protected static void setJBossCliConfig() {
+ final String jbossCliConfig = SecurityActions.getSystemProperty(JBOSS_CLI_CONFIG);
+ if(jbossCliConfig == null) {
+ final String jbossDist = System.getProperty("jboss.dist");
+ if(jbossDist == null) {
+ fail("jboss.dist system property is not set");
+ }
+ SecurityActions.setSystemProperty(JBOSS_CLI_CONFIG, jbossDist + File.separator + "bin" + File.separator + "jboss-cli.xml");
+ }
+ }
}
View
97 ...e/shared/src/main/java/org/jboss/as/test/integration/management/util/SecurityActions.java
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.as.test.integration.management.util;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+
+/**
+ * Package privileged actions
+ *
+ * @author Scott.Stark@jboss.org
+ * @author Alexey Loubyansky
+ */
+class SecurityActions {
+ private interface TCLAction {
+ class UTIL {
+ static TCLAction getTCLAction() {
+ return System.getSecurityManager() == null ? NON_PRIVILEGED : PRIVILEGED;
+ }
+
+ public static String getSystemProperty(String name) {
+ return getTCLAction().getSystemProperty(name);
+ }
+
+ public static void setSystemProperty(String name, String value) {
+ getTCLAction().setSystemProperty(name, value);
+ }
+ }
+
+ TCLAction NON_PRIVILEGED = new TCLAction() {
+
+ @Override
+ public String getSystemProperty(String name) {
+ return System.getProperty(name);
+ }
+
+ @Override
+ public void setSystemProperty(String name, String value) {
+ System.setProperty(name, value);
+ }
+ };
+
+ TCLAction PRIVILEGED = new TCLAction() {
+
+ @Override
+ public String getSystemProperty(final String name) {
+ return (String) AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ return System.getProperty(name);
+ }
+ });
+ }
+
+ @Override
+ public void setSystemProperty(final String name, final String value) {
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ System.setProperty(name, value);
+ return null;
+ }
+ });
+ }
+ };
+
+ String getSystemProperty(String name);
+
+ void setSystemProperty(String name, String value);
+ }
+
+ protected static String getSystemProperty(String name) {
+ return TCLAction.UTIL.getSystemProperty(name);
+ }
+
+ protected static void setSystemProperty(String name, String value) {
+ TCLAction.UTIL.setSystemProperty(name, value);
+ }
+}

0 comments on commit 84cd813

Please sign in to comment.