diff --git a/src/test/java/no/entur/uttu/UttuIntegrationTest.java b/src/test/java/no/entur/uttu/UttuIntegrationTest.java index eac0971c..39df8576 100644 --- a/src/test/java/no/entur/uttu/UttuIntegrationTest.java +++ b/src/test/java/no/entur/uttu/UttuIntegrationTest.java @@ -27,7 +27,7 @@ webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = UttuTestApp.class ) -@ActiveProfiles({ "google-pubsub-emulator", "test" }) +@ActiveProfiles({ "test" }) @EnableAspectJAutoProxy(proxyTargetClass = true) public abstract class UttuIntegrationTest { diff --git a/src/test/java/no/entur/uttu/export/messaging/MessagingServiceTest.java b/src/test/java/no/entur/uttu/export/messaging/MessagingServiceTest.java index df1811d5..cd3884ce 100644 --- a/src/test/java/no/entur/uttu/export/messaging/MessagingServiceTest.java +++ b/src/test/java/no/entur/uttu/export/messaging/MessagingServiceTest.java @@ -24,11 +24,14 @@ import org.entur.pubsub.base.EnturGooglePubSubAdmin; import org.junit.Assert; import org.junit.Test; +import org.junit.After; +import org.junit.Before; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.utility.DockerImageName; public class MessagingServiceTest extends UttuIntegrationTest { - public static final String TEST_CODESPACE = "rut"; public static final String TEST_EXPORT_FILE_NAME = "netex.zip"; @@ -45,6 +48,21 @@ public class MessagingServiceTest extends UttuIntegrationTest { @Value("${export.notify.queue.name:FlexibleLinesExportQueue}") private String queueName; + static GenericContainer pubsubEmulator = new GenericContainer<>(DockerImageName.parse("gcr.io/google.com/cloudsdktool/google-cloud-cli:latest")) + .withCommand("gcloud beta emulators pubsub start --project=test") + .withExposedPorts(8085); + + @Before + public void setUp() { + pubsubEmulator.start(); + } + + @After + public void tearDown() { + pubsubEmulator.stop(); + } + + @Test public void testNotifyExport() { enturGooglePubSubAdmin.createSubscriptionIfMissing(queueName); diff --git a/src/test/resources/application-test.properties b/src/test/resources/application-test.properties index b0707aee..32d4d20a 100644 --- a/src/test/resources/application-test.properties +++ b/src/test/resources/application-test.properties @@ -32,7 +32,7 @@ spring.cloud.gcp.pubsub.project-id=test # Path to credential for accessing the Google Cloud project, using the Spring resource syntax (prefixed with file:) #spring.cloud.gcp.pubsub.credentials.location=file:/path/to/json/file # if this property is present then the client library connects to the PubSub emulator instead of Google Cloud -spring.cloud.gcp.pubsub.emulatorHost=localhost:8088 +spring.cloud.gcp.pubsub.emulatorHost=localhost:8085 # number of parallel pullers for a given Subscriber. Constrained by the number of threads in the executor. spring.cloud.gcp.pubsub.subscriber.parallel-pull-count=1 # number of executor threads (shared by all subscribers)