Skip to content

Commit

Permalink
Merge a63137a into 1f5d8fe
Browse files Browse the repository at this point in the history
  • Loading branch information
allanmckenzie committed Jun 11, 2019
2 parents 1f5d8fe + a63137a commit 68e7029
Show file tree
Hide file tree
Showing 16 changed files with 95 additions and 198 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package uk.gov.justice.services.example.cakeshop.persistence.entity;

import static java.time.ZonedDateTime.now;
import static java.util.UUID.*;
import static java.util.UUID.randomUUID;

import java.time.ZonedDateTime;
import java.util.UUID;
Expand All @@ -28,4 +28,4 @@ public void equalsAndHashCode() {
}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@
<artifactId>core</artifactId>
<version>${framework.version}</version>
</dependency>
<dependency>
<groupId>uk.gov.justice.services</groupId>
<artifactId>shuttering-core</artifactId>
<version>${framework.version}</version>
</dependency>
<dependency>
<groupId>uk.gov.justice.framework-generators</groupId>
<artifactId>rest-adapter-file-service</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@
<groupId>uk.gov.justice.services</groupId>
<artifactId>core</artifactId>
</dependency>
<dependency>
<groupId>uk.gov.justice.services</groupId>
<artifactId>shuttering-core</artifactId>
<version>${framework.version}</version>
</dependency>
<dependency>
<groupId>uk.gov.justice.event-store</groupId>
<artifactId>aggregate-snapshot-service</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@
<artifactId>core</artifactId>
<version>${framework.version}</version>
</dependency>
<dependency>
<groupId>uk.gov.justice.services</groupId>
<artifactId>shuttering-core</artifactId>
<version>${framework.version}</version>
</dependency>
<dependency>
<groupId>uk.gov.justice.framework-generators</groupId>
<artifactId>messaging-adapter-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@
<artifactId>core</artifactId>
<version>${framework.version}</version>
</dependency>
<dependency>
<groupId>uk.gov.justice.services</groupId>
<artifactId>shuttering-core</artifactId>
<version>${framework.version}</version>
</dependency>
<dependency>
<groupId>uk.gov.justice.framework-generators</groupId>
<artifactId>messaging-adapter-core</artifactId>
Expand Down
14 changes: 10 additions & 4 deletions example-context/example-service/example-it/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
</dependency>
<dependency>
<groupId>uk.gov.justice.services</groupId>
<artifactId>jmx</artifactId>
<artifactId>jmx-command-handling</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -224,6 +224,12 @@
<version>${framework.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>uk.gov.justice.services</groupId>
<artifactId>jmx-command-client</artifactId>
<version>${framework.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -297,9 +303,9 @@
</goals>
</execution>
<execution>
<id>shuttering-liquibase</id>
<id>framework-system-liquibase</id>
<configuration>
<changeLogFile>liquibase/shuttering-changelog.xml
<changeLogFile>liquibase/framework-system-changelog.xml
</changeLogFile>
<url>jdbc:postgresql://localhost:5432/frameworkviewstore</url>
</configuration>
Expand Down Expand Up @@ -350,7 +356,7 @@
</dependency>
<dependency>
<groupId>uk.gov.justice.services</groupId>
<artifactId>shuttering-liquibase</artifactId>
<artifactId>framework-system-liquibase</artifactId>
<version>${framework.version}</version>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package uk.gov.justice.services.example.cakeshop.it;

import static java.lang.Integer.valueOf;
import static java.lang.System.getProperty;
import static java.util.Optional.empty;
import static java.util.Optional.of;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import static uk.gov.justice.services.test.utils.common.host.TestHostProvider.getHost;

import uk.gov.justice.services.eventsourcing.repository.jdbc.event.Event;
import uk.gov.justice.services.eventsourcing.repository.jdbc.event.EventJdbcRepository;
Expand All @@ -18,8 +21,9 @@
import uk.gov.justice.services.example.cakeshop.it.helpers.PositionInStreamIterator;
import uk.gov.justice.services.example.cakeshop.it.helpers.RecipeTableInspector;
import uk.gov.justice.services.example.cakeshop.it.helpers.RestEasyClientFactory;
import uk.gov.justice.services.example.cakeshop.it.helpers.SystemCommandMBeanClient;
import uk.gov.justice.services.example.cakeshop.persistence.entity.Recipe;
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.test.utils.core.messaging.Poller;
import uk.gov.justice.services.test.utils.persistence.DatabaseCleaner;

Expand All @@ -45,11 +49,14 @@ public class CakeShopReplayEventsIT {
private final EventStreamJdbcRepository eventStreamJdbcRepository = eventStreamJdbcRepositoryFactory.getEventStreamJdbcRepository(eventStoreDataSource);

private final RecipeTableInspector recipeTableInspector = new RecipeTableInspector(viewStoreDataSource);
private final DatabaseCleaner databaseCleaner = new DatabaseCleaner();

private final Poller poller = new Poller(60, 1000L);

private final SystemCommandMBeanClient systemCommandMBeanClient = new SystemCommandMBeanClient();
private final DatabaseCleaner databaseCleaner = new DatabaseCleaner();
private static final String HOST = getHost();
private static final int PORT = valueOf(getProperty("random.management.port"));

private final SystemCommanderClientFactory systemCommanderClientFactory = new SystemCommanderClientFactory();

private Client client;

Expand All @@ -69,7 +76,6 @@ public void before() {
@After
public void cleanup() {
client.close();
systemCommandMBeanClient.close();
}

@Test
Expand All @@ -92,7 +98,10 @@ public void shouldReplayAndFindRecipesInViewStore() throws Exception {

cleanViewstoreTables();

systemCommandMBeanClient.getMbeanProxy().runCommand(new CatchupCommand());
try (final SystemCommanderClient systemCommanderClient = systemCommanderClientFactory.create(HOST, PORT)) {
systemCommanderClient.getRemote().call(new CatchupCommand());

}

final Optional<Integer> numberOfReplayedRecipesOptional = checkExpectedNumberOfRecipes(numberOfStreams);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package uk.gov.justice.services.example.cakeshop.it;

import static java.lang.Integer.valueOf;
import static java.lang.System.getProperty;
import static java.util.Optional.empty;
import static java.util.Optional.of;
import static org.junit.Assert.fail;
import static uk.gov.justice.services.test.utils.common.host.TestHostProvider.getHost;

import uk.gov.justice.services.eventsourcing.repository.jdbc.event.Event;
import uk.gov.justice.services.eventsourcing.repository.jdbc.event.EventJdbcRepository;
import uk.gov.justice.services.eventsourcing.repository.jdbc.event.EventRepositoryFactory;
import uk.gov.justice.services.eventsourcing.repository.jdbc.event.EventStreamJdbsRepositoryFactory;
import uk.gov.justice.services.eventsourcing.repository.jdbc.event.PublishedEventTableTruncator;
import uk.gov.justice.services.eventsourcing.repository.jdbc.eventstream.EventStreamJdbcRepository;
import uk.gov.justice.services.eventsourcing.repository.jdbc.exception.InvalidPositionException;
import uk.gov.justice.services.eventstore.management.catchup.commands.CatchupCommand;
Expand All @@ -18,7 +20,8 @@
import uk.gov.justice.services.example.cakeshop.it.helpers.PublishedEventCounter;
import uk.gov.justice.services.example.cakeshop.it.helpers.RecipeTableInspector;
import uk.gov.justice.services.example.cakeshop.it.helpers.RestEasyClientFactory;
import uk.gov.justice.services.example.cakeshop.it.helpers.SystemCommandMBeanClient;
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.test.utils.core.messaging.Poller;
import uk.gov.justice.services.test.utils.persistence.DatabaseCleaner;

Expand All @@ -39,15 +42,18 @@ public class CatchupPerformanceIT {
private final DataSource eventStoreDataSource = new DatabaseManager().initEventStoreDb();
private final DataSource viewStoreDataSource = new DatabaseManager().initViewStoreDb();
private final EventJdbcRepository eventJdbcRepository = new EventRepositoryFactory().getEventJdbcRepository(eventStoreDataSource);
private final PublishedEventTableTruncator publishedEventTableTruncator = new PublishedEventTableTruncator(eventStoreDataSource);

private final EventStreamJdbsRepositoryFactory eventStreamJdbcRepositoryFactory = new EventStreamJdbsRepositoryFactory();
private final EventStreamJdbcRepository eventStreamJdbcRepository = eventStreamJdbcRepositoryFactory.getEventStreamJdbcRepository(eventStoreDataSource);

private final RecipeTableInspector recipeTableInspector = new RecipeTableInspector(viewStoreDataSource);
private final PublishedEventCounter publishedEventCounter = new PublishedEventCounter(eventStoreDataSource);

private final SystemCommandMBeanClient systemCommandMBeanClient = new SystemCommandMBeanClient();
private static final String HOST = getHost();
private static final int PORT = valueOf(getProperty("random.management.port"));


private final SystemCommanderClientFactory systemCommanderClientFactory = new SystemCommanderClientFactory();
private final DatabaseCleaner databaseCleaner = new DatabaseCleaner();

private final Poller longPoller = new Poller(1200, 1000L);
Expand All @@ -67,7 +73,6 @@ public void before() {
@After
public void cleanup() {
client.close();
systemCommandMBeanClient.close();
}

@Test
Expand Down Expand Up @@ -169,8 +174,10 @@ private List<UUID> addEventsToEventLog(final int numberOfStreams, final int numb

private void runCatchup() throws Exception {

systemCommandMBeanClient.getMbeanProxy().runCommand(new CatchupCommand());
try (final SystemCommanderClient systemCommanderClient = systemCommanderClientFactory.create(HOST, PORT)) {

systemCommanderClient.getRemote().call(new CatchupCommand());
}
}

private Optional<Integer> checkExpectedNumberOfRecipes(final int numberOfStreams) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package uk.gov.justice.services.example.cakeshop.it;

import static java.lang.Integer.valueOf;
import static java.lang.System.getProperty;
import static java.util.Optional.empty;
import static java.util.Optional.of;
import static java.util.UUID.randomUUID;
Expand All @@ -8,6 +10,7 @@
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import static uk.gov.justice.services.test.utils.common.host.TestHostProvider.getHost;

import uk.gov.justice.services.eventsourcing.repository.jdbc.event.Event;
import uk.gov.justice.services.eventsourcing.repository.jdbc.event.PublishedEvent;
Expand All @@ -16,7 +19,8 @@
import uk.gov.justice.services.example.cakeshop.it.helpers.DatabaseManager;
import uk.gov.justice.services.example.cakeshop.it.helpers.EventFactory;
import uk.gov.justice.services.example.cakeshop.it.helpers.RestEasyClientFactory;
import uk.gov.justice.services.example.cakeshop.it.helpers.SystemCommandMBeanClient;
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.test.utils.core.messaging.Poller;
import uk.gov.justice.services.test.utils.events.TestEventInserter;
import uk.gov.justice.services.test.utils.persistence.DatabaseCleaner;
Expand Down Expand Up @@ -46,7 +50,10 @@ public class RebuildIT {

private final Poller poller = new Poller();

private final SystemCommandMBeanClient systemCommandMBeanClient = new SystemCommandMBeanClient();
private static final String HOST = getHost();
private static final int PORT = valueOf(getProperty("random.management.port"));

private final SystemCommanderClientFactory systemCommanderClientFactory = new SystemCommanderClientFactory();

@Before
public void before() throws Exception {
Expand Down Expand Up @@ -97,7 +104,10 @@ public void shouldRenumberTheEventLogTableAndRebuldPublishedEvents() throws Exce
}

private void invokeRebuild() throws Exception {
systemCommandMBeanClient.getMbeanProxy().runCommand(new RebuildCommand());

try(final SystemCommanderClient systemCommanderClient = systemCommanderClientFactory.create(HOST, PORT)) {
systemCommanderClient.getRemote().call(new RebuildCommand());
}
}

private List<PublishedEvent> getPublishedEvents() {
Expand Down
Loading

0 comments on commit 68e7029

Please sign in to comment.