File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -126,6 +126,7 @@ public void requestDone(){
126126 */
127127 @ Override
128128 public void requestEnsureConnection (){
129+ checkMaster ( false , true );
129130 _myPort .get ().requestEnsureConnection ();
130131 }
131132
Original file line number Diff line number Diff line change 1919import org .testng .annotations .Test ;
2020
2121import java .net .UnknownHostException ;
22+ import java .util .Arrays ;
2223
2324public class DBTest extends TestCase {
2425
@@ -119,6 +120,27 @@ public void testReadPreferenceObedience() {
119120 assertEquals (ReadPreference .primary (), _db .getCommandReadPreference (obj , ReadPreference .secondary ()));
120121 }
121122
123+ @ Test (groups = {"basic" })
124+ public void testEnsureConnection () throws UnknownHostException {
125+
126+ Mongo m = new Mongo (Arrays .asList (new ServerAddress ("localhost" )));
127+
128+ if (isStandalone (m )) {
129+ return ;
130+ }
131+ try {
132+ DB db = m .getDB ("com_mongodb_unittest_DBTest" );
133+ db .requestStart ();
134+ try {
135+ db .requestEnsureConnection ();
136+ } finally {
137+ db .requestDone ();
138+ }
139+ } finally {
140+ m .close ();
141+ }
142+ }
143+
122144 /*public static class Person extends DBObject {
123145
124146 public Person(){
You can’t perform that action at this time.
0 commit comments