Skip to content

Commit

Permalink
ARTEMIS-5118 Expose HelperCreate on the CLI Jar
Browse files Browse the repository at this point in the history
  • Loading branch information
clebertsuconic committed Oct 22, 2024
1 parent 4f6c8cd commit 02e0b14
Show file tree
Hide file tree
Showing 67 changed files with 168 additions and 161 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.activemq.artemis.utils.cli.helper;
package org.apache.activemq.artemis.cli.commands.helper;

import java.io.File;
import java.lang.invoke.MethodHandles;
Expand All @@ -27,8 +27,6 @@ public class HelperBase {

private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());

public static final String ARTEMIS_HOME_PROPERTY = "artemis.distribution.output";

File artemisHome;
File artemisInstance;

Expand All @@ -37,10 +35,12 @@ public class HelperBase {
logger.debug("using artemisHome as {}", artemisHome);
}

public static File getHome() {
return getHome(ARTEMIS_HOME_PROPERTY);
HelperBase(File artemisHome) {
setArtemisHome(artemisHome);
logger.debug("using artemisHome as {}", artemisHome);
}


public static File getHome(String homeProperty) {
String valueHome = System.getProperty(homeProperty);
if (valueHome == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.activemq.artemis.utils.cli.helper;
package org.apache.activemq.artemis.cli.commands.helper;

import java.io.File;
import java.io.IOException;
Expand All @@ -36,14 +36,14 @@
* You may use by creating a new instance, filling the properties, and calling the method create */
public class HelperCreate extends HelperBase {

public HelperCreate() {
super(ARTEMIS_HOME_PROPERTY);
}

public HelperCreate(String homeProperty) {
super(homeProperty);
}

public HelperCreate(File artemisHome) {
super(artemisHome);
}

private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());

private File configuration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.apache.activemq.artemis.api.core.management.QueueControl;
import org.apache.activemq.artemis.api.core.management.SimpleManagement;
import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
import org.apache.activemq.artemis.cli.commands.helper.HelperCreate;
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.apache.activemq.artemis.util.ServerUtil;
Expand All @@ -65,6 +66,12 @@ public class RealServerTestBase extends ActiveMQTestBase {

public static final String basedir = System.getProperty("basedir");

public static final String ARTEMIS_HOME_PROPERTY = "artemis.distribution.output";

public static HelperCreate helperCreate() {
return new HelperCreate(ARTEMIS_HOME_PROPERTY);
}

@AfterEach
public void after() throws Exception {
// close ServerLocators before killing the server otherwise they'll hang and delay test termination
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import org.apache.activemq.artemis.utils.SpawnedVMSupport;
import org.apache.activemq.artemis.utils.TestParameters;
import org.apache.activemq.artemis.utils.Wait;
import org.apache.activemq.artemis.utils.cli.helper.HelperBase;
import org.apache.activemq.artemis.cli.commands.helper.HelperBase;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -184,12 +184,12 @@ private void upgrade(File home, File instance) throws Exception {

@Test
public void testRollUpgrade_2_30() throws Exception {
testRollUpgrade(new File(TWO_THIRTY), HelperBase.getHome());
testRollUpgrade(new File(TWO_THIRTY), HelperBase.getHome(ARTEMIS_HOME_PROPERTY));
}

@Test
public void testRollUpgrade_2_36() throws Exception {
testRollUpgrade(new File(TWO_THIRTY_SIX), HelperBase.getHome());
testRollUpgrade(new File(TWO_THIRTY_SIX), HelperBase.getHome(ARTEMIS_HOME_PROPERTY));
}

// Define a System Property TEST_ROLLED_DISTRIBUTION towards the Artemis Home of your choice and this will
Expand All @@ -200,7 +200,7 @@ public void testRollUpgrade_Provided_Distribution() throws Exception {
String distribution = TestParameters.testProperty("ROLLED", "DISTRIBUTION", null);
assumeTrue(distribution != null);

String distributionUpgrading = TestParameters.testProperty("ROLLED", "DISTRIBUTION_UPGRADE", HelperBase.getHome().getAbsolutePath());
String distributionUpgrading = TestParameters.testProperty("ROLLED", "DISTRIBUTION_UPGRADE", HelperBase.getHome(ARTEMIS_HOME_PROPERTY).getAbsolutePath());
testRollUpgrade(new File(distribution), new File(distributionUpgrading));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import org.apache.activemq.artemis.tests.smoke.common.SmokeTestBase;
import org.apache.activemq.artemis.tests.util.CFUtil;
import org.apache.activemq.artemis.utils.Wait;
import org.apache.activemq.artemis.utils.cli.helper.HelperCreate;
import org.apache.activemq.artemis.cli.commands.helper.HelperCreate;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
Expand All @@ -61,13 +61,13 @@ public static void createServers() throws Exception {
deleteDirectory(server0Location);

if (!server0Location.exists()) {
HelperCreate cliCreateServer = new HelperCreate();
HelperCreate cliCreateServer = helperCreate();
cliCreateServer.setRole("amq").setUser("artemis").setPassword("artemis").setNoWeb(true).setConfiguration("./src/main/resources/servers/bridgeTransfer/serverA").setArtemisInstance(server0Location);
cliCreateServer.createServer();
}

if (!server1Location.exists()) {
HelperCreate cliCreateServer = new HelperCreate();
HelperCreate cliCreateServer = helperCreate();
cliCreateServer.setRole("amq").setUser("artemis").setPassword("artemis").setNoWeb(true).setConfiguration("./src/main/resources/servers/bridgeTransfer/serverB").setArtemisInstance(server1Location);
cliCreateServer.createServer();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

import org.apache.activemq.artemis.tests.smoke.common.SmokeTestBase;
import org.apache.activemq.artemis.util.ServerUtil;
import org.apache.activemq.artemis.utils.cli.helper.HelperCreate;
import org.apache.activemq.artemis.cli.commands.helper.HelperCreate;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -51,13 +51,13 @@ public static void createServers() throws Exception {


{
HelperCreate cliCreateServer = new HelperCreate();
HelperCreate cliCreateServer = helperCreate();
cliCreateServer.setAllowAnonymous(false).setUser("A").setPassword("A").setNoWeb(true).setConfiguration("./src/main/resources/servers/brokerConnect/bridgeSecurityA").setArtemisInstance(server0Location);
cliCreateServer.createServer();
}

{
HelperCreate cliCreateServer = new HelperCreate();
HelperCreate cliCreateServer = helperCreate();
cliCreateServer.setAllowAnonymous(false).setUser("A").setPassword("A").setNoWeb(true).setConfiguration("./src/main/resources/servers/brokerConnect/bridgeSecurityB").setArtemisInstance(server1Location);
cliCreateServer.createServer();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import org.apache.activemq.artemis.tests.smoke.common.SmokeTestBase;
import org.apache.activemq.artemis.tests.util.CFUtil;
import org.apache.activemq.artemis.util.ServerUtil;
import org.apache.activemq.artemis.utils.cli.helper.HelperCreate;
import org.apache.activemq.artemis.cli.commands.helper.HelperCreate;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -52,13 +52,13 @@ public static void createServers() throws Exception {
deleteDirectory(server0Location);

{
HelperCreate cliCreateServer = new HelperCreate();
HelperCreate cliCreateServer = helperCreate();
cliCreateServer.setAllowAnonymous(false).setUser("A").setPassword("A").setNoWeb(true).setConfiguration("./src/main/resources/servers/brokerConnect/mirrorSecurityA").setArtemisInstance(server0Location);
cliCreateServer.createServer();
}

{
HelperCreate cliCreateServer = new HelperCreate();
HelperCreate cliCreateServer = helperCreate();
cliCreateServer.setAllowAnonymous(false).setUser("B").setPassword("B").setNoWeb(true).setPortOffset(1).setConfiguration("./src/main/resources/servers/brokerConnect/mirrorSecurityB").setArtemisInstance(server1Location);
cliCreateServer.createServer();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import org.apache.activemq.artemis.tests.util.CFUtil;
import org.apache.activemq.artemis.util.ServerUtil;
import org.apache.activemq.artemis.utils.Wait;
import org.apache.activemq.artemis.utils.cli.helper.HelperCreate;
import org.apache.activemq.artemis.cli.commands.helper.HelperCreate;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -79,7 +79,7 @@ private static void createServer(String serverName,
File serverLocation = getFileServerLocation(serverName);
deleteDirectory(serverLocation);

HelperCreate cliCreateServer = new HelperCreate();
HelperCreate cliCreateServer = helperCreate();
cliCreateServer.setAllowAnonymous(true).setNoWeb(true).setArtemisInstance(serverLocation);
cliCreateServer.setMessageLoadBalancing("ON_DEMAND");
cliCreateServer.setClustered(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import org.apache.activemq.artemis.tests.smoke.common.SmokeTestBase;
import org.apache.activemq.artemis.tests.util.CFUtil;
import org.apache.activemq.artemis.util.ServerUtil;
import org.apache.activemq.artemis.utils.cli.helper.HelperCreate;
import org.apache.activemq.artemis.cli.commands.helper.HelperCreate;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -52,13 +52,13 @@ public static void createServers() throws Exception {
deleteDirectory(server0Location);

{
HelperCreate cliCreateServer = new HelperCreate();
HelperCreate cliCreateServer = helperCreate();
cliCreateServer.setAllowAnonymous(true).setUser("A").setPassword("A").setRole("amq").setNoWeb(true).setConfiguration("./src/main/resources/servers/brokerConnect/federationA").setArtemisInstance(server0Location);
cliCreateServer.createServer();
}

{
HelperCreate cliCreateServer = new HelperCreate();
HelperCreate cliCreateServer = helperCreate();
cliCreateServer.setAllowAnonymous(true).setUser("B").setPassword("B").setRole("amq").setNoWeb(true).setPortOffset(1).setConfiguration("./src/main/resources/servers/brokerConnect/federationB").setArtemisInstance(server1Location);
cliCreateServer.createServer();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
import java.io.FileOutputStream;
import java.io.PrintStream;

import org.apache.activemq.artemis.cli.commands.helper.HelperCreate;
import org.apache.activemq.artemis.cli.commands.tools.PrintData;
import org.apache.activemq.artemis.tests.smoke.common.SmokeTestBase;
import org.apache.activemq.artemis.tests.util.CFUtil;
import org.apache.activemq.artemis.util.ServerUtil;
import org.apache.activemq.artemis.utils.cli.helper.HelperCreate;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -65,13 +65,13 @@ public static void createServers() throws Exception {
deleteDirectory(server0Location);

{
HelperCreate cliCreateServer = new HelperCreate();
HelperCreate cliCreateServer = helperCreate();
cliCreateServer.setAllowAnonymous(false).setUser("A").setPassword("A").setNoWeb(true).setConfiguration("./src/main/resources/servers/brokerConnect/mirrorSecurityA").setArtemisInstance(server0Location);
cliCreateServer.createServer();
}

{
HelperCreate cliCreateServer = new HelperCreate();
HelperCreate cliCreateServer = helperCreate();
cliCreateServer.setAllowAnonymous(false).setUser("B").setPassword("B").setNoWeb(true).setPortOffset(1).setConfiguration("./src/main/resources/servers/brokerConnect/mirrorSecurityB").setArtemisInstance(server1Location);
cliCreateServer.createServer();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import org.apache.activemq.artemis.util.ServerUtil;
import org.apache.activemq.artemis.utils.FileUtil;
import org.apache.activemq.artemis.utils.Wait;
import org.apache.activemq.artemis.utils.cli.helper.HelperCreate;
import org.apache.activemq.artemis.cli.commands.helper.HelperCreate;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -110,7 +110,7 @@ private static void createMirroredServer(String serverName,
File serverLocation = getFileServerLocation(serverName);
deleteDirectory(serverLocation);

HelperCreate cliCreateServer = new HelperCreate();
HelperCreate cliCreateServer = helperCreate();
cliCreateServer.setAllowAnonymous(true).setArtemisInstance(serverLocation);
cliCreateServer.setNoWeb(true);
cliCreateServer.setArgs("--no-stomp-acceptor", "--no-hornetq-acceptor", "--no-mqtt-acceptor", "--no-amqp-acceptor", "--max-hops", "1", "--name", DC1_NODE);
Expand Down Expand Up @@ -174,7 +174,7 @@ private static void createMirroredBackupServer(String serverName,
File serverLocation = getFileServerLocation(serverName);
deleteDirectory(serverLocation);

HelperCreate cliCreateServer = new HelperCreate();
HelperCreate cliCreateServer = helperCreate();
cliCreateServer.setAllowAnonymous(true).setArtemisInstance(serverLocation);
cliCreateServer.setMessageLoadBalancing("ON_DEMAND");
cliCreateServer.setArgs("--no-stomp-acceptor", "--no-hornetq-acceptor", "--no-mqtt-acceptor", "--no-amqp-acceptor", "--max-hops", "1", "--name", DC1_NODE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import org.apache.activemq.artemis.tests.util.CFUtil;
import org.apache.activemq.artemis.util.ServerUtil;
import org.apache.activemq.artemis.utils.Wait;
import org.apache.activemq.artemis.utils.cli.helper.HelperCreate;
import org.apache.activemq.artemis.cli.commands.helper.HelperCreate;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -64,13 +64,13 @@ public static void createServers() throws Exception {
deleteDirectory(server0Location);

{
HelperCreate cliCreateServer = new HelperCreate();
HelperCreate cliCreateServer = helperCreate();
cliCreateServer.setAllowAnonymous(true).setRole("amq").setUser("admin").setPassword("admin").setNoWeb(true).setConfiguration("./src/main/resources/servers/mirrored-subscriptions/broker1").setArtemisInstance(server0Location);
cliCreateServer.createServer();
}

{
HelperCreate cliCreateServer = new HelperCreate();
HelperCreate cliCreateServer = helperCreate();
cliCreateServer.setAllowAnonymous(true).setRole("amq").setUser("admin").setPassword("admin").setNoWeb(true).setConfiguration("./src/main/resources/servers/mirrored-subscriptions/broker2").setArtemisInstance(server1Location);
cliCreateServer.createServer();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import org.apache.activemq.artemis.tests.util.CFUtil;
import org.apache.activemq.artemis.utils.Wait;
import org.apache.activemq.artemis.util.ServerUtil;
import org.apache.activemq.artemis.utils.cli.helper.HelperCreate;
import org.apache.activemq.artemis.cli.commands.helper.HelperCreate;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -61,13 +61,13 @@ public static void createServers() throws Exception {
deleteDirectory(server0Location);

if (!server0Location.exists()) {
HelperCreate cliCreateServer = new HelperCreate();
HelperCreate cliCreateServer = helperCreate();
cliCreateServer.setAllowAnonymous(true).setRole("amq").setUser("artemis").setPassword("artemis").setNoWeb(true).setConfiguration("./src/main/resources/servers/brokerConnect/pagedA").setArtemisInstance(server0Location);
cliCreateServer.createServer();
}

if (!server1Location.exists()) {
HelperCreate cliCreateServer = new HelperCreate();
HelperCreate cliCreateServer = helperCreate();
cliCreateServer.setAllowAnonymous(true).setRole("amq").setUser("artemis").setPassword("artemis").setNoWeb(true).setConfiguration("./src/main/resources/servers/brokerConnect/pagedB").setArtemisInstance(server1Location);
cliCreateServer.createServer();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
import org.apache.activemq.artemis.util.ServerUtil;
import org.apache.activemq.artemis.utils.RandomUtil;
import org.apache.activemq.artemis.utils.Wait;
import org.apache.activemq.artemis.utils.cli.helper.HelperCreate;
import org.apache.activemq.artemis.cli.commands.helper.HelperCreate;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -72,13 +72,13 @@ public static void createServers() throws Exception {
deleteDirectory(server0Location);

{
HelperCreate cliCreateServer = new HelperCreate();
HelperCreate cliCreateServer = helperCreate();
cliCreateServer.setSharedStore(true).setBackup(false).setSharedStore(true).setDataFolder("./target/check-test/data").setFailoverOnShutdown(true).setStaticCluster("tcp://localhost:61716").setArtemisInstance(server0Location);
cliCreateServer.createServer();
}

{
HelperCreate cliCreateServer = new HelperCreate();
HelperCreate cliCreateServer = helperCreate();
cliCreateServer.setSharedStore(true).setBackup(true).setSharedStore(true).setDataFolder("./target/check-test/data").setFailoverOnShutdown(true).setStaticCluster("tcp://localhost:61616").setPortOffset(100).setArtemisInstance(server1Location);
cliCreateServer.createServer();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import org.apache.activemq.artemis.tests.util.CFUtil;
import org.apache.activemq.artemis.util.ServerUtil;
import org.apache.activemq.artemis.utils.Wait;
import org.apache.activemq.artemis.utils.cli.helper.HelperCreate;
import org.apache.activemq.artemis.cli.commands.helper.HelperCreate;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -51,14 +51,14 @@ public static void createServers() throws Exception {
deleteDirectory(server0Location);

{
HelperCreate cliCreateServer = new HelperCreate();
HelperCreate cliCreateServer = helperCreate();
cliCreateServer.setRole("amq").setUser("artemis").setPassword("artemis").setAllowAnonymous(true).setNoWeb(true).
setArtemisInstance(server0Location).setClustered(true).
setStaticCluster("tcp://localhost:61716").setArgs("--name", "cluster1", "--max-hops", "1", "--queues", "testQueue");
cliCreateServer.createServer();
}
{
HelperCreate cliCreateServer = new HelperCreate();
HelperCreate cliCreateServer = helperCreate();
cliCreateServer.setRole("amq").setUser("artemis").setPassword("artemis").setAllowAnonymous(true).setNoWeb(true).setPortOffset(100).
setArtemisInstance(server1Location).setClustered(true).
setStaticCluster("tcp://localhost:61616").setArgs("--name", "cluster2", "--max-hops", "1", "--queues", "testQueue");
Expand Down
Loading

0 comments on commit 02e0b14

Please sign in to comment.