Skip to content

Commit f496798

Browse files
authored
Extract gcloud-maven-plugin, bigtable-emulator (googleapis#6452)
* Extract gcloud-maven-plugin to https://github.com/googleapis/java-gcloud-maven-plugin * extract bigtable emulator to https://github.com/googleapis/java-bigtable-emulator
1 parent 9476314 commit f496798

13 files changed

Lines changed: 3 additions & 1584 deletions

File tree

google-cloud-bom/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@
272272
<dependency>
273273
<groupId>com.google.cloud</groupId>
274274
<artifactId>google-cloud-bigtable-emulator</artifactId>
275-
<version>0.114.1-alpha-SNAPSHOT</version><!-- {x-version-update:google-cloud-bigtable-emulator:current} -->
275+
<version>0.114.0-alpha</version>
276276
</dependency>
277277
<dependency>
278278
<groupId>com.google.cloud</groupId>
Lines changed: 1 addition & 159 deletions
Original file line numberDiff line numberDiff line change
@@ -1,161 +1,3 @@
11
# Google Cloud Java Emulator for Bigtable
22

3-
A Java wrapper for the [Cloud Bigtable][cloud-bigtable] emulator. This
4-
wrapper bundles the native Bigtable emulator and exposes a simple Java
5-
interface to ease writing tests. Please note that this wrapper is under
6-
heavy development and APIs may change in the future.
7-
8-
[![Kokoro CI](http://storage.googleapis.com/cloud-devrel-public/java/badges/google-cloud-java/master.svg)](http://storage.googleapis.com/cloud-devrel-public/java/badges/google-cloud-java/master.html)
9-
[![Maven](https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-bigtable-emulator.svg)](https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-bigtable-emulator.svg)
10-
[![Codacy Badge](https://api.codacy.com/project/badge/grade/9da006ad7c3a4fe1abd142e77c003917)](https://www.codacy.com/app/mziccard/google-cloud-java)
11-
12-
## Quickstart
13-
14-
[//]: # ({x-version-update-start:google-cloud-bom:released})
15-
If you are using Maven, add this to your pom.xml file
16-
```xml
17-
<dependencyManagement>
18-
<dependencies>
19-
<dependency>
20-
<groupId>com.google.cloud</groupId>
21-
<artifactId>google-cloud-bom</artifactId>
22-
<version>0.114.0-alpha</version>
23-
<type>pom</type>
24-
<scope>import</scope>
25-
</dependency>
26-
</dependencies>
27-
</dependencyManagement>
28-
29-
<dependencies>
30-
<dependency>
31-
<groupId>com.google.cloud</groupId>
32-
<artifactId>google-cloud-bigtable</artifactId>
33-
</dependency>
34-
35-
<dependency>
36-
<groupId>com.google.cloud</groupId>
37-
<artifactId>google-cloud-bigtable-emulator</artifactId>
38-
<scope>test</scope>
39-
</dependency>
40-
41-
<dependency>
42-
<groupId>junit</groupId>
43-
<artifactId>junit</artifactId>
44-
<version>4.12</version>
45-
<scope>test</scope>
46-
</dependency>
47-
</dependencies>
48-
```
49-
50-
If you are using Gradle, add this to your dependencies
51-
```Groovy
52-
compile 'com.google.cloud:google-cloud-bigtable:0.114.0-alpha'
53-
testCompile 'com.google.cloud:google-cloud-bigtable-emulator:0.114.0-alpha'
54-
testCompile 'junit:junit:4.12'
55-
```
56-
If you are using SBT, add this to your dependencies
57-
```Scala
58-
libraryDependencies += "com.google.cloud" % "google-cloud-bigtable" % "0.114.0-alpha"
59-
libraryDependencies += "com.google.cloud" % "google-cloud-bigtable-emulator" % "0.114.0-alpha" % Test
60-
libraryDependencies += "junit" % "junit" % "4.12" % Test
61-
```
62-
[//]: # ({x-version-update-end})
63-
64-
## Getting Started
65-
66-
Here is a code snippet showing a simple JUnit test. Add the following imports
67-
at the top of your file:
68-
69-
```java
70-
import com.google.api.core.ApiFuture;
71-
import com.google.api.gax.core.NoCredentialsProvider;
72-
import com.google.api.gax.grpc.GrpcTransportChannel;
73-
import com.google.api.gax.rpc.FixedTransportChannelProvider;
74-
import com.google.cloud.bigtable.admin.v2.BigtableTableAdminClient;
75-
import com.google.cloud.bigtable.admin.v2.BigtableTableAdminSettings;
76-
import com.google.cloud.bigtable.admin.v2.models.CreateTableRequest;
77-
import com.google.cloud.bigtable.data.v2.BigtableDataClient;
78-
import com.google.cloud.bigtable.data.v2.BigtableDataSettings;
79-
import com.google.cloud.bigtable.data.v2.models.Row;
80-
import com.google.cloud.bigtable.data.v2.models.RowMutation;
81-
import com.google.cloud.bigtable.emulator.v2.BigtableEmulatorRule;
82-
import java.io.IOException;
83-
import java.util.concurrent.ExecutionException;
84-
import org.junit.Assert;
85-
import org.junit.Before;
86-
import org.junit.Rule;
87-
import org.junit.Test;
88-
import org.junit.runner.RunWith;
89-
import org.junit.runners.JUnit4;
90-
```
91-
92-
Then, to make a query to Bigtable, use the following code:
93-
```java
94-
@RunWith(JUnit4.class)
95-
public class ExampleTest {
96-
// Initialize the emulator Rule
97-
@Rule
98-
public final BigtableEmulatorRule bigtableEmulator = BigtableEmulatorRule.create();
99-
100-
// Clients that will be connected to the emulator
101-
private BigtableTableAdminClient tableAdminClient;
102-
private BigtableDataClient dataClient;
103-
104-
@Before
105-
public void setUp() throws IOException {
106-
// Initialize the clients to connect to the emulator
107-
BigtableTableAdminSettings.Builder tableAdminSettings = BigtableTableAdminSettings.newBuilderForEmulator(bigtableEmulator.getPort());
108-
tableAdminClient = BigtableTableAdminClient.create(tableAdminSettings.build());
109-
110-
BigtableDataSettings.Builder dataSettings = BigtableDataSettings.newBuilderForEmulator(bigtableEmulator.getPort());
111-
dataClient = BigtableDataClient.create(dataSettings.build());
112-
113-
// Create a test table that can be used in tests
114-
tableAdminClient.createTable(
115-
CreateTableRequest.of("fake-table")
116-
.addFamily("cf")
117-
);
118-
}
119-
120-
@Test
121-
public void testWriteRead() throws ExecutionException, InterruptedException {
122-
ApiFuture<Void> mutateFuture = dataClient.mutateRowAsync(
123-
RowMutation.create("fake-table", "fake-key")
124-
.setCell("cf", "col", "value")
125-
);
126-
127-
mutateFuture.get();
128-
129-
ApiFuture<Row> rowFuture = dataClient.readRowAsync("fake-table", "fake-key");
130-
131-
Assert.assertEquals("value", rowFuture.get().getCells().get(0).getValue().toStringUtf8());
132-
}
133-
}
134-
```
135-
136-
## Java Versions
137-
138-
Java 7 or above is required for using this emulator.
139-
140-
## Versioning
141-
142-
This library follows [Semantic Versioning](http://semver.org/).
143-
144-
It is currently in major version zero (`0.y.z`), which means that anything may
145-
change at any time and the public API should not be considered stable.
146-
147-
## Contributing
148-
149-
Contributions to this library are always welcome and highly encouraged.
150-
151-
See [CONTRIBUTING] for more information on how to get started and [DEVELOPING] for a layout of the
152-
codebase.
153-
154-
## License
155-
156-
Apache 2.0 - See [LICENSE] for more information.
157-
158-
[CONTRIBUTING]:https://github.com/googleapis/google-cloud-java/blob/master/CONTRIBUTING.md
159-
[LICENSE]: https://github.com/googleapis/google-cloud-java/blob/master/LICENSE
160-
[cloud-bigtable]: https://cloud.google.com/bigtable/
161-
3+
This client has moved to https://github.com/googleapis/java-bigtable-emulator

0 commit comments

Comments
 (0)