ARTEMIS-4020 Fixing Management DTO Parsing with custom ETC
This is fixing an issue introduced by the logging changes where a custome ETC would not work correctly.
This commit is contained in:
parent
38fc74749b
commit
db1338af52
|
@ -26,8 +26,6 @@ import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -37,8 +35,6 @@ import java.util.logging.Logger;
|
||||||
*/
|
*/
|
||||||
public class Artemis {
|
public class Artemis {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(Artemis.class.getName());
|
|
||||||
|
|
||||||
public static void main(String[] args) throws Throwable {
|
public static void main(String[] args) throws Throwable {
|
||||||
String home = System.getProperty("artemis.home");
|
String home = System.getProperty("artemis.home");
|
||||||
|
|
||||||
|
@ -47,7 +43,22 @@ public class Artemis {
|
||||||
String instance = System.getProperty("artemis.instance");
|
String instance = System.getProperty("artemis.instance");
|
||||||
File fileInstance = instance != null ? new File(instance) : null;
|
File fileInstance = instance != null ? new File(instance) : null;
|
||||||
|
|
||||||
Object result = execute(fileHome, fileInstance, true, args);
|
|
||||||
|
String brokerEtc = System.getProperty("artemis.instance.etc");
|
||||||
|
File fileBrokerETC = null;
|
||||||
|
if (brokerEtc != null) {
|
||||||
|
brokerEtc = brokerEtc.replace("\\", "/");
|
||||||
|
fileBrokerETC = new File(brokerEtc);
|
||||||
|
} else {
|
||||||
|
if (instance != null) {
|
||||||
|
brokerEtc = instance + "/etc";
|
||||||
|
fileBrokerETC = new File(brokerEtc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Object result = execute(fileHome, fileInstance, fileBrokerETC, true, args);
|
||||||
if (result instanceof Exception) {
|
if (result instanceof Exception) {
|
||||||
// Set a nonzero status code for the exceptions caught and printed by org.apache.activemq.artemis.cli.Artemis.execute
|
// Set a nonzero status code for the exceptions caught and printed by org.apache.activemq.artemis.cli.Artemis.execute
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
|
@ -57,14 +68,14 @@ public class Artemis {
|
||||||
/**
|
/**
|
||||||
* This is a good method for booting an embedded command
|
* This is a good method for booting an embedded command
|
||||||
*/
|
*/
|
||||||
public static Object execute(File artemisHome, File artemisInstance, boolean useSystemOut, List<String> args) throws Throwable {
|
public static Object execute(File artemisHome, File artemisInstance, File fileBrokerETC, boolean useSystemOut, List<String> args) throws Throwable {
|
||||||
return execute(artemisHome, artemisInstance, useSystemOut, args.toArray(new String[args.size()]));
|
return execute(artemisHome, artemisInstance, fileBrokerETC, useSystemOut, args.toArray(new String[args.size()]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a good method for booting an embedded command
|
* This is a good method for booting an embedded command
|
||||||
*/
|
*/
|
||||||
public static Object execute(File fileHome, File fileInstance, boolean useSystemOut, String... args) throws Throwable {
|
public static Object execute(File fileHome, File fileInstance, File fileBrokerETC, boolean useSystemOut, String... args) throws Throwable {
|
||||||
ArrayList<File> dirs = new ArrayList<>();
|
ArrayList<File> dirs = new ArrayList<>();
|
||||||
if (fileHome != null) {
|
if (fileHome != null) {
|
||||||
dirs.add(new File(fileHome, "lib"));
|
dirs.add(new File(fileHome, "lib"));
|
||||||
|
@ -76,11 +87,16 @@ public class Artemis {
|
||||||
ArrayList<URL> urls = new ArrayList<>();
|
ArrayList<URL> urls = new ArrayList<>();
|
||||||
|
|
||||||
// Without the etc on the config, things like JGroups configuration wouldn't be loaded
|
// Without the etc on the config, things like JGroups configuration wouldn't be loaded
|
||||||
if (fileInstance != null) {
|
if (fileBrokerETC == null && fileInstance != null) {
|
||||||
File etcFile = new File(fileInstance, "etc");
|
// the fileBrokerETC could be null if execute is called directly from an external module
|
||||||
// Adding etc to the classLoader so modules can lookup for their configs
|
fileBrokerETC = new File(fileInstance, "etc");
|
||||||
urls.add(etcFile.toURI().toURL());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fileBrokerETC != null) {
|
||||||
|
// Adding etc to the classLoader so modules can lookup for their configs
|
||||||
|
urls.add(fileBrokerETC.toURI().toURL());
|
||||||
|
}
|
||||||
|
|
||||||
if (fileHome != null) {
|
if (fileHome != null) {
|
||||||
File etcFile = new File(fileHome, "etc");
|
File etcFile = new File(fileHome, "etc");
|
||||||
// Adding etc to the classLoader so modules can lookup for their configs
|
// Adding etc to the classLoader so modules can lookup for their configs
|
||||||
|
@ -122,10 +138,10 @@ public class Artemis {
|
||||||
URLClassLoader loader = new URLClassLoader(urls.toArray(new URL[urls.size()]));
|
URLClassLoader loader = new URLClassLoader(urls.toArray(new URL[urls.size()]));
|
||||||
Thread.currentThread().setContextClassLoader(loader);
|
Thread.currentThread().setContextClassLoader(loader);
|
||||||
Class<?> clazz = loader.loadClass("org.apache.activemq.artemis.cli.Artemis");
|
Class<?> clazz = loader.loadClass("org.apache.activemq.artemis.cli.Artemis");
|
||||||
Method method = clazz.getMethod("execute", Boolean.TYPE, Boolean.TYPE, File.class, File.class, args.getClass());
|
Method method = clazz.getMethod("execute", Boolean.TYPE, Boolean.TYPE, File.class, File.class, File.class, args.getClass());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return method.invoke(null, useSystemOut, useSystemOut, fileHome, fileInstance, args);
|
return method.invoke(null, useSystemOut, useSystemOut, fileHome, fileInstance, fileBrokerETC, args);
|
||||||
} catch (InvocationTargetException e) {
|
} catch (InvocationTargetException e) {
|
||||||
throw e.getTargetException();
|
throw e.getTargetException();
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -138,7 +154,7 @@ public class Artemis {
|
||||||
try {
|
try {
|
||||||
urls.add(file.toURI().toURL());
|
urls.add(file.toURI().toURL());
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
logger.log(Level.WARNING, e.getMessage(), e);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,18 +93,26 @@ public class Artemis {
|
||||||
String instance = System.getProperty("artemis.instance");
|
String instance = System.getProperty("artemis.instance");
|
||||||
File fileInstance = instance != null ? new File(instance) : null;
|
File fileInstance = instance != null ? new File(instance) : null;
|
||||||
|
|
||||||
verifyManagementDTO(fileInstance);
|
|
||||||
|
|
||||||
execute(true, true, fileHome, fileInstance, args);
|
String brokerEtc = System.getProperty("artemis.instance.etc");
|
||||||
|
if (brokerEtc != null) {
|
||||||
|
brokerEtc = brokerEtc.replace("\\", "/");
|
||||||
|
} else {
|
||||||
|
brokerEtc = instance + "/etc";
|
||||||
|
}
|
||||||
|
|
||||||
|
File fileBrokerETC = new File(brokerEtc);
|
||||||
|
|
||||||
|
verifyManagementDTO(fileBrokerETC);
|
||||||
|
|
||||||
|
execute(true, true, fileHome, fileInstance, fileBrokerETC, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Notice this has to happen before any Log4j is used.
|
// Notice this has to happen before any Log4j is used.
|
||||||
// otherwise Log4j's JMX will start the JMX before this property was able to tbe set
|
// otherwise Log4j's JMX will start the JMX before this property was able to tbe set
|
||||||
public static void verifyManagementDTO(File fileInstance) {
|
public static void verifyManagementDTO(File etc) {
|
||||||
if (fileInstance != null) {
|
if (etc != null) {
|
||||||
|
|
||||||
File etc = new File(fileInstance, "etc");
|
|
||||||
File management = new File(etc, "management.xml");
|
File management = new File(etc, "management.xml");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -119,16 +127,21 @@ public class Artemis {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object internalExecute(String... args) throws Exception {
|
public static Object internalExecute(String... args) throws Exception {
|
||||||
return internalExecute(null, null, args);
|
return internalExecute(null, null, null, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object execute(File artemisHome, File artemisInstance, List<String> args) throws Exception {
|
public static Object execute(File artemisHome, File artemisInstance, File etcFolder, List<String> args) throws Exception {
|
||||||
return execute(false, false, artemisHome, artemisInstance, args.toArray(new String[args.size()]));
|
return execute(false, false, artemisHome, artemisInstance, etcFolder, args.toArray(new String[args.size()]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object execute(boolean inputEnabled, boolean useSystemOut, File artemisHome, File artemisInstance, String... args) throws Exception {
|
public static Object execute(boolean inputEnabled, boolean useSystemOut, File artemisHome, File artemisInstance, File etcFolder, String... args) throws Exception {
|
||||||
|
|
||||||
verifyManagementDTO(artemisInstance);
|
// using a default etc in case that is not set in the variables
|
||||||
|
if (etcFolder == null && artemisInstance != null) {
|
||||||
|
etcFolder = new File(artemisInstance, "etc");
|
||||||
|
}
|
||||||
|
|
||||||
|
verifyManagementDTO(etcFolder);
|
||||||
|
|
||||||
if (inputEnabled) {
|
if (inputEnabled) {
|
||||||
InputAbstract.enableInput();
|
InputAbstract.enableInput();
|
||||||
|
@ -145,7 +158,7 @@ public class Artemis {
|
||||||
ActionContext.setSystem(context);
|
ActionContext.setSystem(context);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return internalExecute(artemisHome, artemisInstance, args, context);
|
return internalExecute(artemisHome, artemisInstance, etcFolder, args, context);
|
||||||
} catch (ConfigurationException configException) {
|
} catch (ConfigurationException configException) {
|
||||||
context.err.println(configException.getMessage());
|
context.err.println(configException.getMessage());
|
||||||
context.out.println();
|
context.out.println();
|
||||||
|
@ -177,13 +190,13 @@ public class Artemis {
|
||||||
* This method is used to validate exception returns.
|
* This method is used to validate exception returns.
|
||||||
* Useful on test cases
|
* Useful on test cases
|
||||||
*/
|
*/
|
||||||
private static Object internalExecute(File artemisHome, File artemisInstance, String[] args) throws Exception {
|
private static Object internalExecute(File artemisHome, File artemisInstance, File etcFolder, String[] args) throws Exception {
|
||||||
return internalExecute(artemisHome, artemisInstance, args, ActionContext.system());
|
return internalExecute(artemisHome, artemisInstance, etcFolder, args, ActionContext.system());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object internalExecute(File artemisHome, File artemisInstance, String[] args, ActionContext context) throws Exception {
|
public static Object internalExecute(File artemisHome, File artemisInstance, File etcFolder, String[] args, ActionContext context) throws Exception {
|
||||||
Action action = builder(artemisInstance).build().parse(args);
|
Action action = builder(artemisInstance).build().parse(args);
|
||||||
action.setHomeValues(artemisHome, artemisInstance);
|
action.setHomeValues(artemisHome, artemisInstance, etcFolder);
|
||||||
|
|
||||||
if (action.isVerbose()) {
|
if (action.isVerbose()) {
|
||||||
context.out.print("Executing " + action.getClass().getName() + " ");
|
context.out.print("Executing " + action.getClass().getName() + " ");
|
||||||
|
|
|
@ -22,7 +22,7 @@ public interface Action {
|
||||||
|
|
||||||
boolean isVerbose();
|
boolean isVerbose();
|
||||||
|
|
||||||
void setHomeValues(File brokerHome, File brokerInstance);
|
void setHomeValues(File brokerHome, File brokerInstance, File etcFolder);
|
||||||
|
|
||||||
Object execute(ActionContext context) throws Exception;
|
Object execute(ActionContext context) throws Exception;
|
||||||
|
|
||||||
|
|
|
@ -63,13 +63,16 @@ public abstract class ActionAbstract implements Action {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setHomeValues(File brokerHome, File brokerInstance) {
|
public void setHomeValues(File brokerHome, File brokerInstance, File etcFolder) {
|
||||||
if (brokerHome != null) {
|
if (brokerHome != null) {
|
||||||
this.brokerHome = brokerHome.getAbsolutePath();
|
this.brokerHome = brokerHome.getAbsolutePath();
|
||||||
}
|
}
|
||||||
if (brokerInstance != null) {
|
if (brokerInstance != null) {
|
||||||
this.brokerInstance = brokerInstance.getAbsolutePath();
|
this.brokerInstance = brokerInstance.getAbsolutePath();
|
||||||
}
|
}
|
||||||
|
if (etcFolder != null) {
|
||||||
|
this.brokerEtc = etcFolder.getAbsolutePath();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class HelpAction extends Help implements Action {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setHomeValues(File brokerHome, File brokerInstance) {
|
public void setHomeValues(File brokerHome, File brokerInstance, File etcFolder) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class HelpAddress extends Help implements Action {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setHomeValues(File brokerHome, File brokerInstance) {
|
public void setHomeValues(File brokerHome, File brokerInstance, File etc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class HelpCheck extends Help implements Action {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setHomeValues(File brokerHome, File brokerInstance) {
|
public void setHomeValues(File brokerHome, File brokerInstance, File etc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class HelpQueue extends Help implements Action {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setHomeValues(File brokerHome, File brokerInstance) {
|
public void setHomeValues(File brokerHome, File brokerInstance, File etc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class HelpData extends Help implements Action {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setHomeValues(File brokerHome, File brokerInstance) {
|
public void setHomeValues(File brokerHome, File brokerInstance, File etc) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class HelpUser extends Help implements Action {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setHomeValues(File brokerHome, File brokerInstance) {
|
public void setHomeValues(File brokerHome, File brokerInstance, File etcFolder) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class ConnectionAbstractTest {
|
||||||
|
|
||||||
System.setProperty("artemis.instance.etc", brokerInstanceEtc.getAbsolutePath());
|
System.setProperty("artemis.instance.etc", brokerInstanceEtc.getAbsolutePath());
|
||||||
try {
|
try {
|
||||||
connectionAbstract.setHomeValues(null, brokerInstanceEtc.getParentFile());
|
connectionAbstract.setHomeValues(null, brokerInstanceEtc.getParentFile(), null);
|
||||||
|
|
||||||
connectionAbstract.execute(new TestActionContext());
|
connectionAbstract.execute(new TestActionContext());
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ public class ConnectionAbstractTest {
|
||||||
|
|
||||||
System.setProperty("artemis.instance.etc", brokerInstanceEtc.getAbsolutePath());
|
System.setProperty("artemis.instance.etc", brokerInstanceEtc.getAbsolutePath());
|
||||||
try {
|
try {
|
||||||
connectionAbstract.setHomeValues(null, brokerInstanceEtc.getParentFile());
|
connectionAbstract.setHomeValues(null, brokerInstanceEtc.getParentFile(), null);
|
||||||
connectionAbstract.setAcceptor("amqp");
|
connectionAbstract.setAcceptor("amqp");
|
||||||
|
|
||||||
connectionAbstract.execute(new TestActionContext());
|
connectionAbstract.execute(new TestActionContext());
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class TransferTest {
|
||||||
|
|
||||||
System.setProperty("artemis.instance.etc", brokerInstanceEtc.getAbsolutePath());
|
System.setProperty("artemis.instance.etc", brokerInstanceEtc.getAbsolutePath());
|
||||||
try {
|
try {
|
||||||
transfer.setHomeValues(null, brokerInstanceEtc.getParentFile());
|
transfer.setHomeValues(null, brokerInstanceEtc.getParentFile(), null);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
transfer.execute(new TestActionContext());
|
transfer.execute(new TestActionContext());
|
||||||
|
@ -58,7 +58,7 @@ public class TransferTest {
|
||||||
|
|
||||||
System.setProperty("artemis.instance.etc", brokerInstanceEtc.getAbsolutePath());
|
System.setProperty("artemis.instance.etc", brokerInstanceEtc.getAbsolutePath());
|
||||||
try {
|
try {
|
||||||
transfer.setHomeValues(null, brokerInstanceEtc.getParentFile());
|
transfer.setHomeValues(null, brokerInstanceEtc.getParentFile(), null);
|
||||||
transfer.setSourceAcceptor("amqp");
|
transfer.setSourceAcceptor("amqp");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1287,14 +1287,14 @@ public class ArtemisTest extends CliTestBase {
|
||||||
* it will read from the InputStream in the ActionContext. It can't read the password since it's using
|
* it will read from the InputStream in the ActionContext. It can't read the password since it's using
|
||||||
* System.console.readPassword() for that.
|
* System.console.readPassword() for that.
|
||||||
*/
|
*/
|
||||||
assertEquals(Integer.valueOf(100), Artemis.internalExecute(null, null, new String[] {"producer", "--destination", "queue://q1", "--message-count", "100", "--password", "admin"}, context));
|
assertEquals(Integer.valueOf(100), Artemis.internalExecute(null, null, null, new String[] {"producer", "--destination", "queue://q1", "--message-count", "100", "--password", "admin"}, context));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is the same as above except it will prompt the user to re-enter both the URL and the username.
|
* This is the same as above except it will prompt the user to re-enter both the URL and the username.
|
||||||
*/
|
*/
|
||||||
in = new ByteArrayInputStream("tcp://localhost:61616\nadmin\n".getBytes());
|
in = new ByteArrayInputStream("tcp://localhost:61616\nadmin\n".getBytes());
|
||||||
context = new ActionContext(in, System.out, System.err);
|
context = new ActionContext(in, System.out, System.err);
|
||||||
assertEquals(Integer.valueOf(100), Artemis.internalExecute(null, null, new String[] {"producer", "--destination", "queue://q1", "--message-count", "100", "--password", "admin", "--url", "tcp://badhost:11111"}, context));
|
assertEquals(Integer.valueOf(100), Artemis.internalExecute(null, null, null, new String[] {"producer", "--destination", "queue://q1", "--message-count", "100", "--password", "admin", "--url", "tcp://badhost:11111"}, context));
|
||||||
} finally {
|
} finally {
|
||||||
stopServer();
|
stopServer();
|
||||||
}
|
}
|
||||||
|
@ -1318,14 +1318,14 @@ public class ArtemisTest extends CliTestBase {
|
||||||
* it will read from the InputStream in the ActionContext. It can't read the password since it's using
|
* it will read from the InputStream in the ActionContext. It can't read the password since it's using
|
||||||
* System.console.readPassword() for that.
|
* System.console.readPassword() for that.
|
||||||
*/
|
*/
|
||||||
assertTrue((int) Artemis.internalExecute(null, null, new String[] {"queue", "stat", "--password", "admin"}, context) > 0);
|
assertTrue((int) Artemis.internalExecute(null, null, null, new String[] {"queue", "stat", "--password", "admin"}, context) > 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is the same as above except it will prompt the user to re-enter both the URL and the username.
|
* This is the same as above except it will prompt the user to re-enter both the URL and the username.
|
||||||
*/
|
*/
|
||||||
in = new ByteArrayInputStream("tcp://localhost:61616\nadmin\n".getBytes());
|
in = new ByteArrayInputStream("tcp://localhost:61616\nadmin\n".getBytes());
|
||||||
context = new ActionContext(in, System.out, System.err);
|
context = new ActionContext(in, System.out, System.err);
|
||||||
assertTrue((int) Artemis.internalExecute(null, null, new String[] {"queue", "stat", "--password", "admin", "--url", "tcp://badhost:11111"}, context) > 0);
|
assertTrue((int) Artemis.internalExecute(null, null, null, new String[] {"queue", "stat", "--password", "admin", "--url", "tcp://badhost:11111"}, context) > 0);
|
||||||
} finally {
|
} finally {
|
||||||
stopServer();
|
stopServer();
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,7 +154,7 @@ public class CheckTest extends CliTestBase {
|
||||||
"--replicated", "--host", "127.0.0.1", "--default-port", "61626", "--silent", "--no-autotune", "--no-web", "--require-login", "--slave");
|
"--replicated", "--host", "127.0.0.1", "--default-port", "61626", "--silent", "--no-autotune", "--no-web", "--require-login", "--slave");
|
||||||
|
|
||||||
System.setProperty("artemis.instance", masterInstance.getAbsolutePath());
|
System.setProperty("artemis.instance", masterInstance.getAbsolutePath());
|
||||||
Object master = Artemis.execute(false, false, null, masterInstance, "run");
|
Object master = Artemis.execute(false, false, null, masterInstance, null, "run");
|
||||||
ActiveMQServerImpl masterServer = (ActiveMQServerImpl)((Pair)master).getB();
|
ActiveMQServerImpl masterServer = (ActiveMQServerImpl)((Pair)master).getB();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -181,7 +181,7 @@ public class CheckTest extends CliTestBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
LockAbstract.unlock();
|
LockAbstract.unlock();
|
||||||
Object slave = Artemis.execute(false, false, null, slaveInstance, "run");
|
Object slave = Artemis.execute(false, false, null, slaveInstance, null, "run");
|
||||||
ActiveMQServerImpl slaveServer = (ActiveMQServerImpl)((Pair)slave).getB();
|
ActiveMQServerImpl slaveServer = (ActiveMQServerImpl)((Pair)slave).getB();
|
||||||
|
|
||||||
Wait.assertTrue("Backup isn't announced", () -> slaveServer.getBackupManager() != null &&
|
Wait.assertTrue("Backup isn't announced", () -> slaveServer.getBackupManager() != null &&
|
||||||
|
@ -197,7 +197,7 @@ public class CheckTest extends CliTestBase {
|
||||||
nodeCheck.setPeers(2);
|
nodeCheck.setPeers(2);
|
||||||
Assert.assertEquals(3, nodeCheck.execute(context));
|
Assert.assertEquals(3, nodeCheck.execute(context));
|
||||||
} finally {
|
} finally {
|
||||||
Artemis.internalExecute(null, slaveInstance, new String[] {"stop"}, ActionContext.system());
|
Artemis.internalExecute(null, slaveInstance, null, new String[] {"stop"}, ActionContext.system());
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
stopServer();
|
stopServer();
|
||||||
|
|
|
@ -103,7 +103,7 @@ public class OptionsValidationTest extends CliTestBase {
|
||||||
invalidArgs = new String[] {group, command, "--blahblah-" + command, "--rubbish-" + command + "=" + "more-rubbish", "--input=blahblah"};
|
invalidArgs = new String[] {group, command, "--blahblah-" + command, "--rubbish-" + command + "=" + "more-rubbish", "--input=blahblah"};
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Artemis.internalExecute(null, needInstance ? this.artemisInstance : null, invalidArgs, context);
|
Artemis.internalExecute(null, needInstance ? this.artemisInstance : null, null, invalidArgs, context);
|
||||||
fail("cannot detect invalid options");
|
fail("cannot detect invalid options");
|
||||||
} catch (InvalidOptionsError e) {
|
} catch (InvalidOptionsError e) {
|
||||||
assertTrue(e.getMessage().contains("Found unexpected parameters"));
|
assertTrue(e.getMessage().contains("Found unexpected parameters"));
|
||||||
|
|
|
@ -50,6 +50,10 @@ public class ArtemisCLIPlugin extends ArtemisAbstractPlugin {
|
||||||
@Parameter(defaultValue = "${basedir}/target/server0", required = true)
|
@Parameter(defaultValue = "${basedir}/target/server0", required = true)
|
||||||
private File location;
|
private File location;
|
||||||
|
|
||||||
|
|
||||||
|
@Parameter
|
||||||
|
private File etc;
|
||||||
|
|
||||||
@Parameter
|
@Parameter
|
||||||
private String[] args;
|
private String[] args;
|
||||||
|
|
||||||
|
@ -127,7 +131,7 @@ public class ArtemisCLIPlugin extends ArtemisAbstractPlugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Artemis.execute(home, location, useSystemOutput, args);
|
Artemis.execute(home, location, etc, useSystemOutput, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread.sleep(600);
|
Thread.sleep(600);
|
||||||
|
|
|
@ -264,7 +264,7 @@ public class ArtemisCreatePlugin extends ArtemisAbstractPlugin {
|
||||||
commandLineStream.println("# These are the commands used to create " + instance.getName());
|
commandLineStream.println("# These are the commands used to create " + instance.getName());
|
||||||
commandLineStream.println(getCommandline(listCommands));
|
commandLineStream.println(getCommandline(listCommands));
|
||||||
|
|
||||||
Artemis.execute(home, null, useSystemOutput, listCommands);
|
Artemis.execute(home, null, null, useSystemOutput, listCommands);
|
||||||
|
|
||||||
if (configuration != null) {
|
if (configuration != null) {
|
||||||
String[] list = configuration.list();
|
String[] list = configuration.list();
|
||||||
|
|
|
@ -1180,7 +1180,6 @@
|
||||||
</args>
|
</args>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
|
|
||||||
<execution>
|
<execution>
|
||||||
<phase>test-compile</phase>
|
<phase>test-compile</phase>
|
||||||
<id>create-create-nettynative</id>
|
<id>create-create-nettynative</id>
|
||||||
|
@ -1197,6 +1196,22 @@
|
||||||
<configuration>${basedir}/target/classes/servers/nettynative</configuration>
|
<configuration>${basedir}/target/classes/servers/nettynative</configuration>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<phase>test-compile</phase>
|
||||||
|
<id>create-custom-etc</id>
|
||||||
|
<goals>
|
||||||
|
<goal>create</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<allowAnonymous>true</allowAnonymous>
|
||||||
|
<noWeb>true</noWeb>
|
||||||
|
<instance>${basedir}/target/customETC/server</instance>
|
||||||
|
<args>
|
||||||
|
<arg>--etc</arg>
|
||||||
|
<arg>${basedir}/target/customETC/theCustomETC</arg>
|
||||||
|
</args>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -0,0 +1,83 @@
|
||||||
|
/**
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership.
|
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
* (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
* <p>
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* <p>
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.apache.activemq.artemis.tests.smoke.custometc;
|
||||||
|
|
||||||
|
import javax.jms.Connection;
|
||||||
|
import javax.jms.ConnectionFactory;
|
||||||
|
import javax.jms.MessageConsumer;
|
||||||
|
import javax.jms.MessageProducer;
|
||||||
|
import javax.jms.Queue;
|
||||||
|
import javax.jms.Session;
|
||||||
|
import javax.jms.TextMessage;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
|
import org.apache.activemq.artemis.tests.smoke.common.SmokeTestBase;
|
||||||
|
import org.apache.activemq.artemis.tests.util.CFUtil;
|
||||||
|
import org.apache.activemq.artemis.utils.RandomUtil;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class CustomETCTest extends SmokeTestBase {
|
||||||
|
|
||||||
|
public static final String SERVER_NAME_0 = "customETC/server";
|
||||||
|
|
||||||
|
public CustomETCTest() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void before() throws Exception {
|
||||||
|
cleanupData(SERVER_NAME_0);
|
||||||
|
disableCheckThread();
|
||||||
|
startServer(SERVER_NAME_0, 0, 30000);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSimpleSendReceive() throws Exception {
|
||||||
|
|
||||||
|
ConnectionFactory cf = CFUtil.createConnectionFactory("core", "tcp://localhost:61616");
|
||||||
|
try (Connection connection = cf.createConnection()) {
|
||||||
|
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||||
|
Queue queue = session.createQueue(getName());
|
||||||
|
MessageConsumer consumer = session.createConsumer(queue);
|
||||||
|
MessageProducer producer = session.createProducer(queue);
|
||||||
|
String text = RandomUtil.randomString();
|
||||||
|
connection.start();
|
||||||
|
producer.send(session.createTextMessage(text));
|
||||||
|
TextMessage txtMessage = (TextMessage) consumer.receive(5000);
|
||||||
|
Assert.assertNotNull(txtMessage);
|
||||||
|
Assert.assertEquals(text, txtMessage.getText());
|
||||||
|
}
|
||||||
|
|
||||||
|
File logLocation = new File(getServerLocation(SERVER_NAME_0) + "/log/artemis.log");
|
||||||
|
Assert.assertTrue(logLocation.exists());
|
||||||
|
|
||||||
|
AtomicBoolean started = new AtomicBoolean(false);
|
||||||
|
Files.lines(logLocation.toPath()).forEach(line -> {
|
||||||
|
if (line.contains("AMQ221007")) { // server started
|
||||||
|
started.set(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Assert.assertTrue(started.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue