Skip to content

Commit

Permalink
Merge branch 'main' into test-java-versions
Browse files Browse the repository at this point in the history
  • Loading branch information
eddumelendez authored Dec 3, 2024
2 parents a798d69 + 1eeeba8 commit 080a8c4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.google.cloud.bigtable.data.v2.models.Row;
import com.google.cloud.bigtable.data.v2.models.RowCell;
import com.google.cloud.bigtable.data.v2.models.RowMutation;
import com.google.cloud.bigtable.data.v2.models.TableId;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import org.junit.Rule;
Expand All @@ -23,7 +24,6 @@

import java.io.IOException;
import java.util.List;
import java.util.concurrent.ExecutionException;

import static org.assertj.core.api.Assertions.assertThat;

Expand All @@ -43,28 +43,26 @@ public class BigtableEmulatorContainerTest {

@Test
// testWithEmulatorContainer {
public void testSimple() throws IOException, InterruptedException, ExecutionException {
public void testSimple() throws IOException {
ManagedChannel channel = ManagedChannelBuilder.forTarget(emulator.getEmulatorEndpoint()).usePlaintext().build();

TransportChannelProvider channelProvider = FixedTransportChannelProvider.create(
GrpcTransportChannel.create(channel)
);
NoCredentialsProvider credentialsProvider = NoCredentialsProvider.create();

try {
createTable(channelProvider, credentialsProvider, "test-table");

createTable(channelProvider, credentialsProvider, "test-table");
try (
BigtableDataClient client = BigtableDataClient.create(
BigtableDataSettings
.newBuilderForEmulator(emulator.getHost(), emulator.getEmulatorPort())
.setProjectId(PROJECT_ID)
.setInstanceId(INSTANCE_ID)
.build()
);

client.mutateRow(RowMutation.create("test-table", "1").setCell("name", "firstName", "Ray"));
)
) {
client.mutateRow(RowMutation.create(TableId.of("test-table"), "1").setCell("name", "firstName", "Ray"));

Row row = client.readRow("test-table", "1");
Row row = client.readRow(TableId.of("test-table"), "1");
List<RowCell> cells = row.getCells("name", "firstName");

assertThat(cells).isNotNull().hasSize(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@ public class AbstractPulsar {
protected void testPulsarFunctionality(String pulsarBrokerUrl) throws Exception {
try (
PulsarClient client = PulsarClient.builder().serviceUrl(pulsarBrokerUrl).build();
Consumer consumer = client.newConsumer().topic(TEST_TOPIC).subscriptionName("test-subs").subscribe();
Consumer<byte[]> consumer = client
.newConsumer()
.topic(TEST_TOPIC)
.subscriptionName("test-subs")
.subscribe();
Producer<byte[]> producer = client.newProducer().topic(TEST_TOPIC).create()
) {
producer.send("test containers".getBytes());
CompletableFuture<Message> future = consumer.receiveAsync();
Message message = future.get(5, TimeUnit.SECONDS);
CompletableFuture<Message<byte[]>> future = consumer.receiveAsync();
Message<byte[]> message = future.get(5, TimeUnit.SECONDS);

assertThat(new String(message.getData())).isEqualTo("test containers");
}
Expand Down

0 comments on commit 080a8c4

Please sign in to comment.