Skip to content

Commit 02964a6

Browse files
mziccardaozarov
authored andcommitted
---
yaml --- r: 4835 b: refs/heads/logging-alpha c: 5e0de55 h: refs/heads/master i: 4833: 19d6523 4831: b91326c
1 parent b27cbf9 commit 02964a6

4 files changed

Lines changed: 31 additions & 7 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ refs/heads/compute-alpha: 969cba2627f1d53d352cc4a5ffe0879dacf65e6c
1212
refs/heads/dns-alpha: 2f90e7e338349287ace33375896907af0f032ca1
1313
refs/heads/dns-alpha-batch: 17442b07867021b85d0452f5f3eda29a3413288f
1414
refs/heads/gcs-nio: 283aeaf15efdcf3621eb6859f05e55ad7764375d
15-
refs/heads/logging-alpha: d18e7bbc505505f00ed0ac666f5f867f3119475a
15+
refs/heads/logging-alpha: 5e0de55a546770228b07fe82029b7d822efe91b7
1616
refs/tags/v0.1.0: a615317f7424ed58621b1f65d5c4d8cbbe8a6ed8
1717
refs/tags/v0.1.1: 7a7f6985fe465e9dd6a075af55493f42b4933be0
1818
refs/tags/v0.1.2: 3eb3fe866ba22487686048f45d927b8c8638ea3f

branches/logging-alpha/gcloud-java-datastore/src/main/java/com/google/cloud/datastore/DatastoreOptions.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ public DatastoreOptions build() {
7575
return new DatastoreOptions(this);
7676
}
7777

78+
/**
79+
* Sets the default namespace to be used by the datastore service.
80+
*/
7881
public Builder namespace(String namespace) {
7982
this.namespace = validateNamespace(namespace);
8083
return this;
@@ -112,6 +115,9 @@ protected DatastoreRpcFactory defaultRpcFactory() {
112115
return DefaultDatastoreRpcFactory.INSTANCE;
113116
}
114117

118+
/**
119+
* Returns the default namespace to be used by the datastore service.
120+
*/
115121
public String namespace() {
116122
return namespace;
117123
}

branches/logging-alpha/gcloud-java-datastore/src/main/java/com/google/cloud/datastore/testing/LocalDatastoreHelper.java

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -556,17 +556,28 @@ private static int findAvailablePort() {
556556
}
557557
}
558558

559+
private DatastoreOptions.Builder optionsBuilder() {
560+
return DatastoreOptions.builder()
561+
.projectId(projectId)
562+
.host("localhost:" + Integer.toString(port))
563+
.authCredentials(AuthCredentials.noAuth())
564+
.retryParams(RetryParams.noRetries());
565+
}
566+
559567
/**
560568
* Returns a {@link DatastoreOptions} instance that sets the host to use the Datastore emulator on
561569
* localhost.
562570
*/
563571
public DatastoreOptions options() {
564-
return DatastoreOptions.builder()
565-
.projectId(projectId)
566-
.host("localhost:" + Integer.toString(port))
567-
.authCredentials(AuthCredentials.noAuth())
568-
.retryParams(RetryParams.noRetries())
569-
.build();
572+
return optionsBuilder().build();
573+
}
574+
575+
/**
576+
* Returns a {@link DatastoreOptions} instance that sets the host to use the Datastore emulator on
577+
* localhost. The default namespace is set to {@code namespace}.
578+
*/
579+
public DatastoreOptions options(String namespace) {
580+
return optionsBuilder().namespace(namespace).build();
570581
}
571582

572583
/**

branches/logging-alpha/gcloud-java-datastore/src/test/java/com/google/cloud/datastore/testing/LocalDatastoreHelperTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.google.cloud.datastore.testing;
1818

19+
import static org.junit.Assert.assertEquals;
1920
import static org.junit.Assert.assertSame;
2021
import static org.junit.Assert.assertTrue;
2122

@@ -31,6 +32,7 @@ public class LocalDatastoreHelperTest {
3132

3233
private static final double TOLERANCE = 0.00001;
3334
private static final String PROJECT_ID_PREFIX = "test-project-";
35+
private static final String NAMESPACE = "namespace";
3436

3537
@Test
3638
public void testCreate() {
@@ -49,5 +51,10 @@ public void testOptions() {
4951
assertTrue(options.projectId().startsWith(PROJECT_ID_PREFIX));
5052
assertTrue(options.host().startsWith("localhost:"));
5153
assertSame(AuthCredentials.noAuth(), options.authCredentials());
54+
options = helper.options(NAMESPACE);
55+
assertTrue(options.projectId().startsWith(PROJECT_ID_PREFIX));
56+
assertTrue(options.host().startsWith("localhost:"));
57+
assertSame(AuthCredentials.noAuth(), options.authCredentials());
58+
assertEquals(NAMESPACE, options.namespace());
5259
}
5360
}

0 commit comments

Comments
 (0)