19
19
import com .mongodb .ServerAddress ;
20
20
import com .mongodb .Tag ;
21
21
import com .mongodb .TagSet ;
22
+ import com .mongodb .internal .connection .Time ;
22
23
import org .bson .types .ObjectId ;
23
24
import org .junit .Test ;
24
25
49
50
public class ServerDescriptionTest {
50
51
51
52
@ Test (expected = IllegalArgumentException .class )
52
- public void testMissingStatus () throws UnknownHostException {
53
+ public void testMissingStatus () {
53
54
builder ().address (new ServerAddress ()).type (REPLICA_SET_PRIMARY ).build ();
54
55
55
56
}
56
57
57
58
@ Test (expected = IllegalArgumentException .class )
58
- public void testMissingAddress () throws UnknownHostException {
59
+ public void testMissingAddress () {
59
60
builder ().state (CONNECTED ).type (REPLICA_SET_PRIMARY ).build ();
60
-
61
61
}
62
62
63
63
@ Test
64
- public void testDefaults () throws UnknownHostException {
65
- long currentNanoTime = System .nanoTime ();
66
-
64
+ public void testDefaults () {
65
+ long currentNanoTime = Time .nanoTime ();
67
66
ServerDescription serverDescription = builder ().address (new ServerAddress ())
68
67
.state (CONNECTED )
69
68
.build ();
@@ -103,7 +102,7 @@ public void testDefaults() throws UnknownHostException {
103
102
}
104
103
105
104
@ Test
106
- public void testBuilder () throws UnknownHostException {
105
+ public void testBuilder () {
107
106
IllegalArgumentException exception = new IllegalArgumentException ();
108
107
TopologyVersion topologyVersion = new TopologyVersion (new ObjectId (), 42 );
109
108
ServerDescription serverDescription = builder ()
@@ -172,7 +171,7 @@ public void testBuilder() throws UnknownHostException {
172
171
}
173
172
174
173
@ Test
175
- public void testObjectOverrides () throws UnknownHostException {
174
+ public void testObjectOverrides () {
176
175
ServerDescription .Builder builder = createBuilder ();
177
176
ServerDescription description = builder .build ();
178
177
@@ -284,7 +283,7 @@ private ServerDescription.Builder createBuilder() {
284
283
}
285
284
286
285
@ Test
287
- public void testObjectOverridesWithUnequalException () throws UnknownHostException {
286
+ public void testObjectOverridesWithUnequalException () {
288
287
ServerDescription .Builder builder1 = builder ()
289
288
.state (CONNECTING )
290
289
.address (new ServerAddress ())
@@ -314,7 +313,7 @@ public void testObjectOverridesWithUnequalException() throws UnknownHostExceptio
314
313
}
315
314
316
315
@ Test
317
- public void testShortDescription () throws UnknownHostException {
316
+ public void testShortDescription () {
318
317
assertEquals ("{address=127.0.0.1:27017, type=UNKNOWN, TagSet{[Tag{name='dc', value='ny'}, Tag{name='rack', value='1'}]}, "
319
318
+ "roundTripTime=5000.0 ms, state=CONNECTED, exception={java.lang.IllegalArgumentException: This is illegal}, "
320
319
+ "caused by {java.lang.NullPointerException: This is null}}" ,
@@ -328,7 +327,7 @@ public void testShortDescription() throws UnknownHostException {
328
327
}
329
328
330
329
@ Test
331
- public void testIsPrimaryAndIsSecondary () throws UnknownHostException {
330
+ public void testIsPrimaryAndIsSecondary () {
332
331
ServerDescription serverDescription = builder ()
333
332
.address (new ServerAddress ())
334
333
.type (ServerType .SHARD_ROUTER )
@@ -376,7 +375,7 @@ public void testIsPrimaryAndIsSecondary() throws UnknownHostException {
376
375
}
377
376
378
377
@ Test
379
- public void testHasTags () throws UnknownHostException {
378
+ public void testHasTags () {
380
379
ServerDescription serverDescription = builder ()
381
380
.address (new ServerAddress ())
382
381
.type (ServerType .SHARD_ROUTER )
@@ -438,7 +437,7 @@ public void testHasTags() throws UnknownHostException {
438
437
}
439
438
440
439
@ Test
441
- public void notOkServerShouldBeCompatible () throws UnknownHostException {
440
+ public void notOkServerShouldBeCompatible () {
442
441
ServerDescription serverDescription = builder ()
443
442
.address (new ServerAddress ())
444
443
.state (CONNECTING )
@@ -450,7 +449,7 @@ public void notOkServerShouldBeCompatible() throws UnknownHostException {
450
449
}
451
450
452
451
@ Test
453
- public void serverWithMinWireVersionEqualToDriverMaxWireVersionShouldBeCompatible () throws UnknownHostException {
452
+ public void serverWithMinWireVersionEqualToDriverMaxWireVersionShouldBeCompatible () {
454
453
ServerDescription serverDescription = builder ()
455
454
.address (new ServerAddress ())
456
455
.state (CONNECTING )
@@ -464,7 +463,7 @@ public void serverWithMinWireVersionEqualToDriverMaxWireVersionShouldBeCompatibl
464
463
}
465
464
466
465
@ Test
467
- public void serverWithMaxWireVersionEqualToDriverMinWireVersionShouldBeCompatible () throws UnknownHostException {
466
+ public void serverWithMaxWireVersionEqualToDriverMinWireVersionShouldBeCompatible () {
468
467
ServerDescription serverDescription = builder ()
469
468
.address (new ServerAddress ())
470
469
.state (CONNECTING )
@@ -478,7 +477,7 @@ public void serverWithMaxWireVersionEqualToDriverMinWireVersionShouldBeCompatibl
478
477
}
479
478
480
479
@ Test
481
- public void serverWithMinWireVersionGreaterThanDriverMaxWireVersionShouldBeIncompatible () throws UnknownHostException {
480
+ public void serverWithMinWireVersionGreaterThanDriverMaxWireVersionShouldBeIncompatible () {
482
481
ServerDescription serverDescription = builder ()
483
482
.address (new ServerAddress ())
484
483
.state (CONNECTING )
@@ -492,7 +491,7 @@ public void serverWithMinWireVersionGreaterThanDriverMaxWireVersionShouldBeIncom
492
491
}
493
492
494
493
@ Test
495
- public void serverWithMaxWireVersionLessThanDriverMinWireVersionShouldBeIncompatible () throws UnknownHostException {
494
+ public void serverWithMaxWireVersionLessThanDriverMinWireVersionShouldBeIncompatible () {
496
495
ServerDescription serverDescription = builder ()
497
496
.address (new ServerAddress ())
498
497
.state (CONNECTING )
0 commit comments