Skip to content

Commit fb945c2

Browse files
committed
Fixed DOC-10858
1 parent ec6cdab commit fb945c2

File tree

4 files changed

+43
-11
lines changed

4 files changed

+43
-11
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (c) 2020 Couchbase, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/*
18+
Extension of managing_connections
19+
file: howtos/pages/managing-connections.adoc line: 277
20+
*/
21+
22+
import java.time.Duration;
23+
24+
import com.couchbase.client.java.Bucket;
25+
import com.couchbase.client.java.Cluster;
26+
import com.couchbase.client.java.Collection;
27+
28+
// tag::managing_connections_9[]
29+
public class ClusterExample {
30+
public static void main(String... args) throws Exception {
31+
Cluster cluster = Cluster.connect("127.0.0.1", "Administrator", "password");
32+
cluster.waitUntilReady(Duration.ofSeconds(10));
33+
Bucket bucket = cluster.bucket("travel-sample");
34+
Collection collection = bucket.defaultCollection();
35+
}
36+
}
37+
// end::managing_connections_9[]

modules/howtos/examples/managing_connections.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,10 @@ public void managing_connections_8() throws Exception { // file: howtos/pages/ma
6969
// end::managing_connections_8[]
7070
}
7171

72-
public void managing_connections_9() throws Exception { // file: howtos/pages/managing-connections.adoc line: 252
73-
// tag::managing_connections_9[]
74-
Cluster cluster = Cluster.connect("127.0.0.1", "Administrator", "password");
75-
cluster.waitUntilReady(Duration.ofSeconds(10));
76-
Bucket bucket = cluster.bucket("travel-sample");
77-
Collection collection = bucket.defaultCollection();
78-
// end::managing_connections_9[]
79-
}
80-
8172
public static void main(String[] args) throws Exception {
8273
managing_connections obj = new managing_connections();
8374
obj.init();
8475
obj.managing_connections_5();
8576
obj.managing_connections_8();
86-
obj.managing_connections_9();
8777
}
8878
}

modules/howtos/pages/managing-connections.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ Or more fully:
274274

275275
[source,java]
276276
----
277-
include::example$managing_connections.java[tag=managing_connections_9,indent=0]
277+
include::example$ClusterExample.java[tag=managing_connections_9,indent=0]
278278
----
279279

280280
If you are working at the _Bucket_ level, then the https://docs.couchbase.com/sdk-api/couchbase-java-client/com/couchbase/client/java/Bucket.html#waitUntilReady-java.time.Duration-[Bucket-level `waitUntilReady`] does the same as the Cluster-level version,

modules/test/test-howtos.bats

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ load 'test_helper'
2222
assert_success
2323
}
2424

25+
@test "[howtos] - ClusterExample.java" {
26+
runExample ClusterExample
27+
assert_success
28+
}
29+
2530
@test "[howtos] - CollectingInformationAndLogging.java" {
2631
runExample CollectingInformationAndLogging
2732
assert_success

0 commit comments

Comments
 (0)