Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions google-cloud-pubsub/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,18 @@

<!-- Test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
package com.google.cloud.pubsub.it;

import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assume.assumeTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.jupiter.api.Assumptions.assumeTrue;

import com.google.api.gax.rpc.PermissionDeniedException;
import com.google.auto.value.AutoValue;
Expand All @@ -40,9 +41,12 @@
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import org.junit.*;
import org.junit.rules.Timeout;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;

@Timeout(value = 300)
public class ITPubSubTest {

private static final String NAME_SUFFIX = UUID.randomUUID().toString();
Expand All @@ -55,8 +59,6 @@ public class ITPubSubTest {

private static final int MAX_INBOUND_MESSAGE_SIZE = 20 * 1024 * 1024;

@Rule public Timeout globalTimeout = Timeout.seconds(300);

@AutoValue
abstract static class MessageAndConsumer {
abstract PubsubMessage message();
Expand All @@ -81,14 +83,14 @@ static MessageAndConsumerWithResponse create(
}
}

@BeforeClass
@BeforeAll
public static void setupClass() throws Exception {
topicAdminClient = TopicAdminClient.create();
subscriptionAdminClient = SubscriptionAdminClient.create();
projectId = ServiceOptions.getDefaultProjectId();
}

@AfterClass
@AfterAll
public static void tearDownClass() {
topicAdminClient.close();
subscriptionAdminClient.close();
Expand Down Expand Up @@ -171,7 +173,7 @@ public void testVPCPushSubscriber() {
10,
false));
subscriptionAdminClient.deleteSubscription(subscriptionName);
Assert.fail("No exception raised");
fail("No exception raised");
} catch (PermissionDeniedException e) {
// expected
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
package com.google.cloud.pubsub.v1;

import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.ArgumentMatchers.eq;
Expand All @@ -32,8 +35,8 @@
import java.time.Duration;
import java.util.*;
import java.util.concurrent.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;

Expand Down Expand Up @@ -90,7 +93,7 @@ public class MessageDispatcherTest {
private LinkedBlockingQueue<AckReplyConsumer> consumers;
private LinkedBlockingQueue<AckReplyConsumerWithResponse> consumersWithResponse;

@Before
@BeforeEach
public void setUp() {
systemExecutor = new FakeScheduledExecutorService();
clock = new FakeClock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
import static com.google.cloud.pubsub.v1.OpenCensusUtil.OPEN_CENSUS_MESSAGE_TRANSFORM;
import static com.google.cloud.pubsub.v1.OpenCensusUtil.TAG_CONTEXT_KEY;
import static com.google.cloud.pubsub.v1.OpenCensusUtil.TRACE_CONTEXT_KEY;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.fail;

import com.google.common.base.Stopwatch;
import com.google.protobuf.ByteString;
Expand All @@ -43,8 +43,8 @@
import java.util.Collection;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

/** Tests for {@link OpenCensusUtil}. */
public class OpenCensusUtilTest {
Expand All @@ -54,7 +54,7 @@ public class OpenCensusUtilTest {
private static final TagValue TEST_TAG_VAL = TagValue.create("TEST_TAG_VAL");
private static final String TEST_PARENT_LINK_NAME = "TEST_PARENT_LINK";

@BeforeClass
@BeforeAll
public static void configureOpenCensus() {
Tracing.getExportComponent().getRunningSpanStore().setMaxNumberOfSpans(5);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

package com.google.cloud.pubsub.v1;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import com.google.protobuf.ByteString;
import com.google.pubsub.v1.PubsubMessage;
Expand All @@ -37,7 +37,7 @@
import io.opentelemetry.sdk.trace.data.StatusData;
import java.util.Arrays;
import java.util.List;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class OpenTelemetryTest {
private static final TopicName FULL_TOPIC_NAME =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
package com.google.cloud.pubsub.v1;

import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

import com.google.api.core.ApiFuture;
import com.google.api.gax.batching.BatchingSettings;
Expand Down Expand Up @@ -62,13 +63,10 @@
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import org.easymock.EasyMock;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

@RunWith(JUnit4.class)
public class PublisherImplTest {

private static final ProjectTopicName TEST_TOPIC =
Expand All @@ -93,7 +91,7 @@ public class PublisherImplTest {

private Server testServer;

@Before
@BeforeEach
public void setUp() throws Exception {
testPublisherServiceImpl = new FakePublisherServiceImpl();

Expand All @@ -106,7 +104,7 @@ public void setUp() throws Exception {
fakeExecutor = new FakeScheduledExecutorService();
}

@After
@AfterEach
public void tearDown() throws Exception {
testServer.shutdownNow().awaitTermination();
testChannel.shutdown();
Expand Down Expand Up @@ -162,7 +160,6 @@ public void testPublishByNumBatchedMessages() throws Exception {
ApiFuture<String> publishFuture3 = sendTestMessage(publisher, "C");

// Note we are not advancing time but message should still get published

assertEquals("1", publishFuture1.get());
assertEquals("2", publishFuture2.get());

Expand Down Expand Up @@ -698,7 +695,7 @@ public void testPublishFailureRetries() throws Exception {
shutdownTestPublisher(publisher);
}

@Test(expected = ExecutionException.class)
@Test
public void testPublishFailureRetries_retriesDisabled() throws Exception {
Publisher publisher =
getTestPublisherBuilder()
Expand All @@ -715,7 +712,7 @@ public void testPublishFailureRetries_retriesDisabled() throws Exception {
ApiFuture<String> publishFuture1 = sendTestMessage(publisher, "A");

try {
publishFuture1.get();
assertThrows(ExecutionException.class, () -> publishFuture1.get());
} finally {
assertSame(testPublisherServiceImpl.getCapturedRequests().size(), 1);
shutdownTestPublisher(publisher);
Expand Down Expand Up @@ -771,7 +768,7 @@ public void testPublishFailureRetries_maxRetriesSetUnlimited() throws Exception
assertTrue(publisher.awaitTermination(1, TimeUnit.MINUTES));
}

@Test(expected = ExecutionException.class)
@Test
public void testPublishFailureRetries_nonRetryableFailsImmediately() throws Exception {
Publisher publisher =
getTestPublisherBuilder()
Expand All @@ -791,7 +788,7 @@ public void testPublishFailureRetries_nonRetryableFailsImmediately() throws Exce
ApiFuture<String> publishFuture1 = sendTestMessage(publisher, "A");

try {
publishFuture1.get();
assertThrows(ExecutionException.class, () -> publishFuture1.get());
} finally {
assertTrue(testPublisherServiceImpl.getCapturedRequests().size() >= 1);
publisher.shutdown();
Expand Down
Loading
Loading