Skip to content

Commit d66c2e7

Browse files
committed
Test: ServerDescriptionTest cleanups
1 parent 5da4318 commit d66c2e7

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

driver-core/src/test/unit/com/mongodb/connection/ServerDescriptionTest.java

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.mongodb.ServerAddress;
2020
import com.mongodb.Tag;
2121
import com.mongodb.TagSet;
22+
import com.mongodb.internal.connection.Time;
2223
import org.bson.types.ObjectId;
2324
import org.junit.Test;
2425

@@ -49,21 +50,19 @@
4950
public class ServerDescriptionTest {
5051

5152
@Test(expected = IllegalArgumentException.class)
52-
public void testMissingStatus() throws UnknownHostException {
53+
public void testMissingStatus() {
5354
builder().address(new ServerAddress()).type(REPLICA_SET_PRIMARY).build();
5455

5556
}
5657

5758
@Test(expected = IllegalArgumentException.class)
58-
public void testMissingAddress() throws UnknownHostException {
59+
public void testMissingAddress() {
5960
builder().state(CONNECTED).type(REPLICA_SET_PRIMARY).build();
60-
6161
}
6262

6363
@Test
64-
public void testDefaults() throws UnknownHostException {
65-
long currentNanoTime = System.nanoTime();
66-
64+
public void testDefaults() {
65+
long currentNanoTime = Time.nanoTime();
6766
ServerDescription serverDescription = builder().address(new ServerAddress())
6867
.state(CONNECTED)
6968
.build();
@@ -103,7 +102,7 @@ public void testDefaults() throws UnknownHostException {
103102
}
104103

105104
@Test
106-
public void testBuilder() throws UnknownHostException {
105+
public void testBuilder() {
107106
IllegalArgumentException exception = new IllegalArgumentException();
108107
TopologyVersion topologyVersion = new TopologyVersion(new ObjectId(), 42);
109108
ServerDescription serverDescription = builder()
@@ -172,7 +171,7 @@ public void testBuilder() throws UnknownHostException {
172171
}
173172

174173
@Test
175-
public void testObjectOverrides() throws UnknownHostException {
174+
public void testObjectOverrides() {
176175
ServerDescription.Builder builder = createBuilder();
177176
ServerDescription description = builder.build();
178177

@@ -284,7 +283,7 @@ private ServerDescription.Builder createBuilder() {
284283
}
285284

286285
@Test
287-
public void testObjectOverridesWithUnequalException() throws UnknownHostException {
286+
public void testObjectOverridesWithUnequalException() {
288287
ServerDescription.Builder builder1 = builder()
289288
.state(CONNECTING)
290289
.address(new ServerAddress())
@@ -314,7 +313,7 @@ public void testObjectOverridesWithUnequalException() throws UnknownHostExceptio
314313
}
315314

316315
@Test
317-
public void testShortDescription() throws UnknownHostException {
316+
public void testShortDescription() {
318317
assertEquals("{address=127.0.0.1:27017, type=UNKNOWN, TagSet{[Tag{name='dc', value='ny'}, Tag{name='rack', value='1'}]}, "
319318
+ "roundTripTime=5000.0 ms, state=CONNECTED, exception={java.lang.IllegalArgumentException: This is illegal}, "
320319
+ "caused by {java.lang.NullPointerException: This is null}}",
@@ -328,7 +327,7 @@ public void testShortDescription() throws UnknownHostException {
328327
}
329328

330329
@Test
331-
public void testIsPrimaryAndIsSecondary() throws UnknownHostException {
330+
public void testIsPrimaryAndIsSecondary() {
332331
ServerDescription serverDescription = builder()
333332
.address(new ServerAddress())
334333
.type(ServerType.SHARD_ROUTER)
@@ -376,7 +375,7 @@ public void testIsPrimaryAndIsSecondary() throws UnknownHostException {
376375
}
377376

378377
@Test
379-
public void testHasTags() throws UnknownHostException {
378+
public void testHasTags() {
380379
ServerDescription serverDescription = builder()
381380
.address(new ServerAddress())
382381
.type(ServerType.SHARD_ROUTER)
@@ -438,7 +437,7 @@ public void testHasTags() throws UnknownHostException {
438437
}
439438

440439
@Test
441-
public void notOkServerShouldBeCompatible() throws UnknownHostException {
440+
public void notOkServerShouldBeCompatible() {
442441
ServerDescription serverDescription = builder()
443442
.address(new ServerAddress())
444443
.state(CONNECTING)
@@ -450,7 +449,7 @@ public void notOkServerShouldBeCompatible() throws UnknownHostException {
450449
}
451450

452451
@Test
453-
public void serverWithMinWireVersionEqualToDriverMaxWireVersionShouldBeCompatible() throws UnknownHostException {
452+
public void serverWithMinWireVersionEqualToDriverMaxWireVersionShouldBeCompatible() {
454453
ServerDescription serverDescription = builder()
455454
.address(new ServerAddress())
456455
.state(CONNECTING)
@@ -464,7 +463,7 @@ public void serverWithMinWireVersionEqualToDriverMaxWireVersionShouldBeCompatibl
464463
}
465464

466465
@Test
467-
public void serverWithMaxWireVersionEqualToDriverMinWireVersionShouldBeCompatible() throws UnknownHostException {
466+
public void serverWithMaxWireVersionEqualToDriverMinWireVersionShouldBeCompatible() {
468467
ServerDescription serverDescription = builder()
469468
.address(new ServerAddress())
470469
.state(CONNECTING)
@@ -478,7 +477,7 @@ public void serverWithMaxWireVersionEqualToDriverMinWireVersionShouldBeCompatibl
478477
}
479478

480479
@Test
481-
public void serverWithMinWireVersionGreaterThanDriverMaxWireVersionShouldBeIncompatible() throws UnknownHostException {
480+
public void serverWithMinWireVersionGreaterThanDriverMaxWireVersionShouldBeIncompatible() {
482481
ServerDescription serverDescription = builder()
483482
.address(new ServerAddress())
484483
.state(CONNECTING)
@@ -492,7 +491,7 @@ public void serverWithMinWireVersionGreaterThanDriverMaxWireVersionShouldBeIncom
492491
}
493492

494493
@Test
495-
public void serverWithMaxWireVersionLessThanDriverMinWireVersionShouldBeIncompatible() throws UnknownHostException {
494+
public void serverWithMaxWireVersionLessThanDriverMinWireVersionShouldBeIncompatible() {
496495
ServerDescription serverDescription = builder()
497496
.address(new ServerAddress())
498497
.state(CONNECTING)

0 commit comments

Comments
 (0)