From e968235642a1b29594845ba7a8e73bd8d6856065 Mon Sep 17 00:00:00 2001 From: amckenzie Date: Thu, 18 Jul 2019 11:25:35 +0100 Subject: [PATCH] Update to use test JMX client --- .../example-service/example-it/pom.xml | 6 ++++ .../cakeshop/it/CatchupPerformanceIT.java | 14 ++++---- .../example/cakeshop/it/IndexerCatchUpIT.java | 15 ++++---- .../cakeshop/it/ListSystemCommandsIT.java | 16 +++++---- .../example/cakeshop/it/RebuildIT.java | 15 ++++---- .../example/cakeshop/it/ShutteringIT.java | 35 +++++++++++-------- .../example-service/example-single/pom.xml | 5 +++ pom.xml | 6 ++-- 8 files changed, 70 insertions(+), 42 deletions(-) diff --git a/example-context/example-service/example-it/pom.xml b/example-context/example-service/example-it/pom.xml index 4d78b847..da482c94 100644 --- a/example-context/example-service/example-it/pom.xml +++ b/example-context/example-service/example-it/pom.xml @@ -173,6 +173,12 @@ ${framework.version} test + + uk.gov.justice.services + test-utils-jmx + ${framework.version} + test + diff --git a/example-context/example-service/example-it/src/test/java/uk/gov/justice/services/example/cakeshop/it/CatchupPerformanceIT.java b/example-context/example-service/example-it/src/test/java/uk/gov/justice/services/example/cakeshop/it/CatchupPerformanceIT.java index f4b5b2d4..bfc25485 100644 --- a/example-context/example-service/example-it/src/test/java/uk/gov/justice/services/example/cakeshop/it/CatchupPerformanceIT.java +++ b/example-context/example-service/example-it/src/test/java/uk/gov/justice/services/example/cakeshop/it/CatchupPerformanceIT.java @@ -23,7 +23,8 @@ import uk.gov.justice.services.example.cakeshop.it.helpers.RestEasyClientFactory; import uk.gov.justice.services.jmx.api.command.CatchupCommand; import uk.gov.justice.services.jmx.system.command.client.SystemCommanderClient; -import uk.gov.justice.services.jmx.system.command.client.SystemCommanderClientFactory; +import uk.gov.justice.services.jmx.system.command.client.TestSystemCommanderClientFactory; +import uk.gov.justice.services.jmx.system.command.client.connection.JmxParameters; import uk.gov.justice.services.jmx.system.command.client.connection.JmxParametersBuilder; import uk.gov.justice.services.test.utils.core.messaging.Poller; import uk.gov.justice.services.test.utils.persistence.DatabaseCleaner; @@ -55,8 +56,7 @@ public class CatchupPerformanceIT { private static final String HOST = getHost(); private static final int PORT = valueOf(getProperty("random.management.port")); - - private final SystemCommanderClientFactory systemCommanderClientFactory = new SystemCommanderClientFactory(); + private final TestSystemCommanderClientFactory systemCommanderClientFactory = new TestSystemCommanderClientFactory(); private final DatabaseCleaner databaseCleaner = new DatabaseCleaner(); private final Poller longPoller = new Poller(1200, 1000L); @@ -167,13 +167,15 @@ private void addEventsToEventLog(final int numberOfStreams, final int numberOfEv private void runCatchup() throws Exception { - final JmxParametersBuilder jmxParameters = jmxParameters() + final String contextName = "example-single"; + final JmxParameters jmxParameters = jmxParameters() .withHost(HOST) - .withPort(PORT); + .withPort(PORT) + .build(); try (final SystemCommanderClient systemCommanderClient = systemCommanderClientFactory.create(jmxParameters)) { - systemCommanderClient.getRemote().call(new CatchupCommand()); + systemCommanderClient.getRemote(contextName).call(new CatchupCommand()); } } diff --git a/example-context/example-service/example-it/src/test/java/uk/gov/justice/services/example/cakeshop/it/IndexerCatchUpIT.java b/example-context/example-service/example-it/src/test/java/uk/gov/justice/services/example/cakeshop/it/IndexerCatchUpIT.java index f62f6111..c3f3d818 100644 --- a/example-context/example-service/example-it/src/test/java/uk/gov/justice/services/example/cakeshop/it/IndexerCatchUpIT.java +++ b/example-context/example-service/example-it/src/test/java/uk/gov/justice/services/example/cakeshop/it/IndexerCatchUpIT.java @@ -24,7 +24,8 @@ import uk.gov.justice.services.example.cakeshop.it.helpers.RestEasyClientFactory; import uk.gov.justice.services.jmx.api.command.IndexerCatchupCommand; import uk.gov.justice.services.jmx.system.command.client.SystemCommanderClient; -import uk.gov.justice.services.jmx.system.command.client.SystemCommanderClientFactory; +import uk.gov.justice.services.jmx.system.command.client.TestSystemCommanderClientFactory; +import uk.gov.justice.services.jmx.system.command.client.connection.JmxParameters; import uk.gov.justice.services.jmx.system.command.client.connection.JmxParametersBuilder; import uk.gov.justice.services.test.utils.core.messaging.Poller; import uk.gov.justice.services.test.utils.persistence.DatabaseCleaner; @@ -58,7 +59,7 @@ public class IndexerCatchUpIT { private static final String HOST = getHost(); private static final int PORT = valueOf(getProperty("random.management.port")); - private final SystemCommanderClientFactory systemCommanderClientFactory = new SystemCommanderClientFactory(); + private final TestSystemCommanderClientFactory testSystemCommanderClientFactory = new TestSystemCommanderClientFactory(); private final DatabaseCleaner databaseCleaner = new DatabaseCleaner(); private final Poller longPoller = new Poller(1200, 1000L); @@ -162,13 +163,15 @@ private List addEventsToEventLog(final int numberOfStreams) throws Invalid private void runCatchup() throws Exception { - final JmxParametersBuilder jmxParameters = jmxParameters() + final String contextName = "example-single"; + final JmxParameters jmxParameters = jmxParameters() .withHost(HOST) - .withPort(PORT); + .withPort(PORT) + .build(); - try (final SystemCommanderClient systemCommanderClient = systemCommanderClientFactory.create(jmxParameters)) { + try (final SystemCommanderClient systemCommanderClient = testSystemCommanderClientFactory.create(jmxParameters)) { - systemCommanderClient.getRemote().call(new IndexerCatchupCommand()); + systemCommanderClient.getRemote(contextName).call(new IndexerCatchupCommand()); } } diff --git a/example-context/example-service/example-it/src/test/java/uk/gov/justice/services/example/cakeshop/it/ListSystemCommandsIT.java b/example-context/example-service/example-it/src/test/java/uk/gov/justice/services/example/cakeshop/it/ListSystemCommandsIT.java index e4fc6ff0..4a0d2caf 100644 --- a/example-context/example-service/example-it/src/test/java/uk/gov/justice/services/example/cakeshop/it/ListSystemCommandsIT.java +++ b/example-context/example-service/example-it/src/test/java/uk/gov/justice/services/example/cakeshop/it/ListSystemCommandsIT.java @@ -16,8 +16,8 @@ import uk.gov.justice.services.jmx.api.command.SystemCommand; import uk.gov.justice.services.jmx.api.command.UnshutterSystemCommand; import uk.gov.justice.services.jmx.system.command.client.SystemCommanderClient; -import uk.gov.justice.services.jmx.system.command.client.SystemCommanderClientFactory; -import uk.gov.justice.services.jmx.system.command.client.connection.JmxParametersBuilder; +import uk.gov.justice.services.jmx.system.command.client.TestSystemCommanderClientFactory; +import uk.gov.justice.services.jmx.system.command.client.connection.JmxParameters; import java.util.List; @@ -29,18 +29,20 @@ public class ListSystemCommandsIT { private static final int PORT = valueOf(getProperty("random.management.port")); - private final SystemCommanderClientFactory systemCommanderClientFactory = new SystemCommanderClientFactory(); + private final TestSystemCommanderClientFactory testSystemCommanderClientFactory = new TestSystemCommanderClientFactory(); @Test public void shouldListAllSystemCommands() throws Exception { - final JmxParametersBuilder jmxParameters = jmxParameters() + final String contextName = "example-single"; + final JmxParameters jmxParameters = jmxParameters() .withHost(HOST) - .withPort(PORT); + .withPort(PORT) + .build(); - try (final SystemCommanderClient systemCommanderClient = systemCommanderClientFactory.create(jmxParameters.build())) { + try (final SystemCommanderClient systemCommanderClient = testSystemCommanderClientFactory.create(jmxParameters)) { - final List systemCommands = systemCommanderClient.getRemote().listCommands(); + final List systemCommands = systemCommanderClient.getRemote(contextName).listCommands(); assertThat(systemCommands.size(), is(6)); assertThat(systemCommands, hasItem(new PingSystemCommand())); diff --git a/example-context/example-service/example-it/src/test/java/uk/gov/justice/services/example/cakeshop/it/RebuildIT.java b/example-context/example-service/example-it/src/test/java/uk/gov/justice/services/example/cakeshop/it/RebuildIT.java index dd686ec0..8e936513 100644 --- a/example-context/example-service/example-it/src/test/java/uk/gov/justice/services/example/cakeshop/it/RebuildIT.java +++ b/example-context/example-service/example-it/src/test/java/uk/gov/justice/services/example/cakeshop/it/RebuildIT.java @@ -21,7 +21,8 @@ import uk.gov.justice.services.example.cakeshop.it.helpers.RestEasyClientFactory; import uk.gov.justice.services.jmx.api.command.RebuildCommand; import uk.gov.justice.services.jmx.system.command.client.SystemCommanderClient; -import uk.gov.justice.services.jmx.system.command.client.SystemCommanderClientFactory; +import uk.gov.justice.services.jmx.system.command.client.TestSystemCommanderClientFactory; +import uk.gov.justice.services.jmx.system.command.client.connection.JmxParameters; import uk.gov.justice.services.jmx.system.command.client.connection.JmxParametersBuilder; import uk.gov.justice.services.test.utils.core.messaging.Poller; import uk.gov.justice.services.test.utils.events.TestEventInserter; @@ -55,7 +56,7 @@ public class RebuildIT { private static final String HOST = getHost(); private static final int PORT = valueOf(getProperty("random.management.port")); - private final SystemCommanderClientFactory systemCommanderClientFactory = new SystemCommanderClientFactory(); + private final TestSystemCommanderClientFactory testSystemCommanderClientFactory = new TestSystemCommanderClientFactory(); @Before public void before() throws Exception { @@ -107,12 +108,14 @@ public void shouldRenumberTheEventLogTableAndRebuldPublishedEvents() throws Exce private void invokeRebuild() throws Exception { - final JmxParametersBuilder jmxParameters = jmxParameters() + final String contextName = "example-single"; + final JmxParameters jmxParameters = jmxParameters() .withHost(HOST) - .withPort(PORT); + .withPort(PORT) + .build(); - try(final SystemCommanderClient systemCommanderClient = systemCommanderClientFactory.create(jmxParameters)) { - systemCommanderClient.getRemote().call(new RebuildCommand()); + try(final SystemCommanderClient systemCommanderClient = testSystemCommanderClientFactory.create(jmxParameters)) { + systemCommanderClient.getRemote(contextName).call(new RebuildCommand()); } } diff --git a/example-context/example-service/example-it/src/test/java/uk/gov/justice/services/example/cakeshop/it/ShutteringIT.java b/example-context/example-service/example-it/src/test/java/uk/gov/justice/services/example/cakeshop/it/ShutteringIT.java index 5cec8088..049d65af 100644 --- a/example-context/example-service/example-it/src/test/java/uk/gov/justice/services/example/cakeshop/it/ShutteringIT.java +++ b/example-context/example-service/example-it/src/test/java/uk/gov/justice/services/example/cakeshop/it/ShutteringIT.java @@ -26,7 +26,8 @@ import uk.gov.justice.services.jmx.api.command.UnshutterSystemCommand; import uk.gov.justice.services.jmx.api.mbean.SystemCommanderMBean; import uk.gov.justice.services.jmx.system.command.client.SystemCommanderClient; -import uk.gov.justice.services.jmx.system.command.client.SystemCommanderClientFactory; +import uk.gov.justice.services.jmx.system.command.client.TestSystemCommanderClientFactory; +import uk.gov.justice.services.jmx.system.command.client.connection.JmxParameters; import uk.gov.justice.services.jmx.system.command.client.connection.JmxParametersBuilder; import uk.gov.justice.services.test.utils.persistence.DatabaseCleaner; @@ -55,7 +56,7 @@ public class ShutteringIT { private static final String HOST = getHost(); private static final int PORT = valueOf(getProperty("random.management.port")); - private final SystemCommanderClientFactory systemCommanderClientFactory = new SystemCommanderClientFactory(); + private final TestSystemCommanderClientFactory testSystemCommanderClientFactory = new TestSystemCommanderClientFactory(); private final DatabaseCleaner databaseCleaner = new DatabaseCleaner(); @Before @@ -74,13 +75,15 @@ public void cleanup() throws Exception { //invoke unshuttering - Always ensure unshutter is invoked as we cannot guarantee order of execution for other Cakeshop ITs - final JmxParametersBuilder jmxParameters = jmxParameters() + final String contextName = "example-single"; + final JmxParameters jmxParameters = jmxParameters() .withHost(HOST) - .withPort(PORT); - try (final SystemCommanderClient systemCommanderClient = systemCommanderClientFactory.create(jmxParameters)) { + .withPort(PORT) + .build(); + try (final SystemCommanderClient systemCommanderClient = testSystemCommanderClientFactory.create(jmxParameters)) { systemCommanderClient - .getRemote() + .getRemote(contextName) .call(new UnshutterSystemCommand()); } } @@ -89,11 +92,13 @@ public void cleanup() throws Exception { public void shouldNotReturnRecipesAfterShuttering() throws Exception { //invoke shuttering - final JmxParametersBuilder jmxParameters = jmxParameters() + final String contextName = "example-single"; + final JmxParameters jmxParameters = jmxParameters() .withHost(HOST) - .withPort(PORT); - try (final SystemCommanderClient systemCommanderClient = systemCommanderClientFactory.create(jmxParameters)) { - systemCommanderClient.getRemote().call(new ShutterSystemCommand()); + .withPort(PORT) + .build(); + try (final SystemCommanderClient systemCommanderClient = testSystemCommanderClientFactory.create(jmxParameters)) { + systemCommanderClient.getRemote(contextName).call(new ShutterSystemCommand()); } //add 2 recipes @@ -109,12 +114,14 @@ public void shouldNotReturnRecipesAfterShuttering() throws Exception { @Test public void shouldQueryForRecipesAfterUnShuttering() throws Exception { - final JmxParametersBuilder jmxParameters = jmxParameters() + final String contextName = "example-single"; + final JmxParameters jmxParameters = jmxParameters() .withHost(HOST) - .withPort(PORT); - try (final SystemCommanderClient systemCommanderClient = systemCommanderClientFactory.create(jmxParameters)) { + .withPort(PORT) + .build(); + try (final SystemCommanderClient systemCommanderClient = testSystemCommanderClientFactory.create(jmxParameters)) { - final SystemCommanderMBean systemCommander = systemCommanderClient.getRemote(); + final SystemCommanderMBean systemCommander = systemCommanderClient.getRemote(contextName); //invoke shuttering systemCommander.call(new ShutterSystemCommand()); diff --git a/example-context/example-service/example-single/pom.xml b/example-context/example-service/example-single/pom.xml index 2330a714..da55e7a1 100644 --- a/example-context/example-service/example-single/pom.xml +++ b/example-context/example-service/example-single/pom.xml @@ -75,6 +75,11 @@ yaml ${project.version} + + uk.gov.justice.services + jmx-api + ${framework.version} + diff --git a/pom.xml b/pom.xml index 5f81d7e3..0143e989 100644 --- a/pom.xml +++ b/pom.xml @@ -32,9 +32,9 @@ cake-shop 4.0.1 - 6.0.0-RC7 - 2.0.0-RC7 - 2.0.0-RC5 + 6.0.0-RC8 + 2.0.0-RC8 + 2.0.0-RC6 1.17.10 2.4.0