Skip to content
Permalink
Browse files

Migrate from JUnit4 to JUnit5

  • Loading branch information...
Flowdalic committed Sep 16, 2019
1 parent 4384e38 commit c9d296970e21029c1822cb12ad55e9dc84bafc45
Showing with 227 additions and 168 deletions.
  1. +0 −1 build.gradle
  2. +1 −1 ...android21/src/test/java/org/minidns/dnsserverlookup/android21/AndroidUsingLinkPropertiesTest.java
  3. +1 −1 minidns-async/src/test/java/org/minidns/source/async/AsyncNetworkDataSourceTest.java
  4. +5 −5 minidns-client/src/test/java/org/minidns/DnsClientTest.java
  5. +2 −2 minidns-client/src/test/java/org/minidns/DnsWorld.java
  6. +8 −12 minidns-client/src/test/java/org/minidns/LruCacheTest.java
  7. +2 −2 minidns-client/src/test/java/org/minidns/dnsserverlookup/AndroidUsingExecTest.java
  8. +4 −4 minidns-client/src/test/java/org/minidns/source/NetworkDataSourceTest.java
  9. +4 −4 minidns-core/src/test/java/org/minidns/Assert.java
  10. +3 −3 minidns-core/src/test/java/org/minidns/dnslabel/DnsLabelTest.java
  11. +6 −6 minidns-core/src/test/java/org/minidns/dnsmessage/DnsMessageTest.java
  12. +12 −7 minidns-core/src/test/java/org/minidns/dnsname/DnsNameTest.java
  13. +14 −10 minidns-core/src/test/java/org/minidns/record/RecordsTest.java
  14. +3 −3 minidns-core/src/test/java/org/minidns/record/TLSATest.java
  15. +2 −2 minidns-core/src/test/java/org/minidns/util/Base32Test.java
  16. +2 −2 minidns-core/src/test/java/org/minidns/util/Base64Test.java
  17. +2 −2 minidns-core/src/test/java/org/minidns/util/InetAddressUtilTest.java
  18. +3 −3 minidns-core/src/test/java/org/minidns/util/NameUtilTest.java
  19. +3 −3 minidns-core/src/test/java/org/minidns/util/SrvUtilTest.java
  20. +1 −1 minidns-dane-java7/src/test/java/org/minidns/dane/java7/DaneJava7Test.java
  21. +52 −23 minidns-dnssec/src/test/java/org/minidns/dnssec/DnssecClientTest.java
  22. +6 −6 minidns-dnssec/src/test/java/org/minidns/dnssec/VerifierTest.java
  23. +2 −5 minidns-dnssec/src/test/java/org/minidns/dnssec/algorithms/AlgorithmTest.java
  24. +2 −2 minidns-dnssec/src/test/java/org/minidns/dnssec/algorithms/DigestTest.java
  25. +18 −9 minidns-dnssec/src/test/java/org/minidns/dnssec/algorithms/DsaSingatureVerifierTest.java
  26. +23 −6 minidns-dnssec/src/test/java/org/minidns/dnssec/algorithms/RsaSignatureVerifierTest.java
  27. +20 −21 minidns-dnssec/src/test/java/org/minidns/dnssec/algorithms/SignatureVerifierTest.java
  28. +1 −1 minidns-hla/src/test/java/org/minidns/hla/MiniDnsHlaTest.java
  29. +1 −0 minidns-integration-test/build.gradle
  30. +1 −1 minidns-integration-test/src/main/java/org/minidns/integrationtest/AsyncApiTest.java
  31. +3 −3 minidns-integration-test/src/main/java/org/minidns/integrationtest/CoreTest.java
  32. +1 −1 minidns-integration-test/src/main/java/org/minidns/integrationtest/DnssecTest.java
  33. +4 −4 minidns-integration-test/src/main/java/org/minidns/integrationtest/HlaTest.java
  34. +3 −3 minidns-integration-test/src/main/java/org/minidns/integrationtest/IterativeDnssecTest.java
  35. +1 −1 minidns-integration-test/src/main/java/org/minidns/integrationtest/NsidTest.java
  36. +1 −1 minidns-integration-test/src/test/java/org/minidns/integrationtest/IntegrationTestTest.java
  37. +9 −6 minidns-iterative-resolver/src/test/java/org/minidns/iterative/IterativeDnsClientTest.java
  38. +1 −1 minidns-repl/src/test/java/org/minidns/minidnsrepl/ReplTest.java
@@ -140,7 +140,6 @@ allprojects {
dependencies {
testImplementation "org.junit.jupiter:junit-jupiter-api:$junitVersion"
testImplementation "org.junit.jupiter:junit-jupiter-params:$junitVersion"
testImplementation "org.junit.vintage:junit-vintage-engine:$junitVersion"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion"
}

@@ -10,7 +10,7 @@
*/
package org.minidns.dnsserverlookup.android21;

import org.junit.Test;
import org.junit.jupiter.api.Test;

public class AndroidUsingLinkPropertiesTest {

@@ -10,7 +10,7 @@
*/
package org.minidns.source.async;

import org.junit.Test;
import org.junit.jupiter.api.Test;

public class AsyncNetworkDataSourceTest {

@@ -23,7 +23,7 @@
import org.minidns.record.Record.TYPE;
import org.minidns.source.AbstractDnsDataSource;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.net.InetAddress;
@@ -33,10 +33,10 @@
import static org.minidns.DnsWorld.a;
import static org.minidns.DnsWorld.applyStubRecords;
import static org.minidns.DnsWorld.record;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class DnsClientTest {

@@ -52,8 +52,8 @@
import java.util.List;
import java.util.Map;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

public class DnsWorld extends AbstractDnsDataSource {
private List<PreparedResponse> answers = new ArrayList<>();
@@ -10,8 +10,7 @@
*/
package org.minidns;

import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import org.minidns.cache.LruCache;
import org.minidns.dnsmessage.DnsMessage;
@@ -22,21 +21,16 @@
import static org.minidns.DnsWorld.a;
import static org.minidns.DnsWorld.ns;
import static org.minidns.DnsWorld.record;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;

public class LruCacheTest {

private LruCache lruCache;

@Before
public void setUp() throws Exception {
lruCache = new LruCache(5);
}

@Test
public void testOutdatedCacheEntry() {
LruCache lruCache = new LruCache(5);

Question q = new Question("", Record.TYPE.A);
TestWorldDnsQueryResult result = createSampleMessage(q, 1);
DnsMessage question = q.asQueryMessage();
@@ -50,6 +44,8 @@ public void testOutdatedCacheEntry() {

@Test
public void testOverfilledCache() {
LruCache lruCache = new LruCache(5);

Question firstQuestion = new Question("", Record.TYPE.A);
lruCache.put(firstQuestion.asQueryMessage(), createSampleMessage(firstQuestion));
assertNotNull(lruCache.get(firstQuestion.asQueryMessage()));
@@ -10,7 +10,7 @@
*/
package org.minidns.dnsserverlookup;

import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.BufferedReader;
import java.io.IOException;
@@ -19,7 +19,7 @@
import java.net.UnknownHostException;
import java.util.Set;

import org.junit.Test;
import org.junit.jupiter.api.Test;

public class AndroidUsingExecTest {

@@ -10,16 +10,16 @@
*/
package org.minidns.source;

import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.minidns.dnsmessage.DnsMessage;
import org.minidns.dnsqueryresult.DnsQueryResult;

import java.io.IOException;
import java.net.InetAddress;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class NetworkDataSourceTest {

@@ -10,8 +10,8 @@
*/
package org.minidns;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.ArrayList;
import java.util.Arrays;
@@ -26,9 +26,9 @@ public static void assertCsEquals(CharSequence expected, CharSequence actual) {

public static void assertCsEquals(String message, CharSequence expected, CharSequence actual) {
if (expected != null && actual != null) {
assertEquals(message, expected.toString(), actual.toString());
assertEquals(expected.toString(), actual.toString(), message);
} else {
assertEquals(message, expected, actual);
assertEquals(expected, actual, message);
}
}

@@ -10,10 +10,10 @@
*/
package org.minidns.dnslabel;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import org.minidns.idna.MiniDnsIdna;

@@ -34,8 +34,6 @@
import org.minidns.record.SRV;
import org.minidns.record.TXT;

import org.junit.Test;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -48,12 +46,14 @@
import java.util.TimeZone;
import java.util.TreeMap;

import org.junit.jupiter.api.Test;

import static org.minidns.Assert.assertArrayContentEquals;
import static org.minidns.Assert.assertCsEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class DnsMessageTest {

@@ -11,14 +11,15 @@
package org.minidns.dnsname;

import static org.minidns.Assert.assertCsEquals;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import org.minidns.dnslabel.DnsLabel;

@@ -61,14 +62,18 @@ public void testStripToParts() {
assertCsEquals(DnsName.from("."), DnsName.from("www.example.com").stripToLabels(0));
}

@Test(expected = IllegalArgumentException.class)
@Test
public void testStripToPartsIllegal() {
DnsName.from("").stripToLabels(1);
assertThrows(IllegalArgumentException.class, () ->
DnsName.from("").stripToLabels(1)
);
}

@Test(expected = IllegalArgumentException.class)
@Test
public void testStripToPartsIllegalLong() {
DnsName.from("example.com").stripToLabels(3);
assertThrows(IllegalArgumentException.class, () ->
DnsName.from("example.com").stripToLabels(3)
);
}

@Test
@@ -14,8 +14,7 @@
import org.minidns.constants.DnssecConstants.SignatureAlgorithm;
import org.minidns.record.NSEC3.HashAlgorithm;
import org.minidns.record.Record.TYPE;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
@@ -27,8 +26,9 @@
import static org.minidns.Assert.assertCsEquals;
import static org.minidns.Assert.assertArrayContentEquals;

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

/**
* These are some tests for all records.
@@ -42,31 +42,35 @@
public void testARecord() throws Exception {
A a = new A(new byte[] {127, 0, 0, 1});
assertEquals("127.0.0.1", a.toString());
Assert.assertEquals(TYPE.A, a.getType());
assertEquals(TYPE.A, a.getType());
byte[] ab = a.toByteArray();
a = A.parse(new DataInputStream(new ByteArrayInputStream(ab)));
assertArrayEquals(new byte[] {127, 0, 0, 1}, a.getIp());
}

@Test(expected = IllegalArgumentException.class)
@Test
public void testARecordInvalidIp() throws Exception {
new A(new byte[42]);
assertThrows(IllegalArgumentException.class, () ->
new A(new byte[42])
);
}

@Test
public void testAAAARecord() throws Exception {
AAAA aaaa = new AAAA(new byte[] {0x20, 0x01, 0x0d, (byte) 0xb8, (byte) 0x85, (byte) 0xa3, 0x08, (byte) 0xd3, 0x13, 0x19, (byte) 0x8a, 0x2e, 0x03, 0x70, 0x73, 0x44});
// Note: there are multiple valid representations of the IPv6 address due to optional reductions.
assertEquals("2001:db8:85a3:8d3:1319:8a2e:370:7344", aaaa.toString());
Assert.assertEquals(TYPE.AAAA, aaaa.getType());
assertEquals(TYPE.AAAA, aaaa.getType());
byte[] aaaab = aaaa.toByteArray();
aaaa = AAAA.parse(new DataInputStream(new ByteArrayInputStream(aaaab)));
assertArrayEquals(new byte[] {0x20, 0x01, 0x0d, (byte) 0xb8, (byte) 0x85, (byte) 0xa3, 0x08, (byte) 0xd3, 0x13, 0x19, (byte) 0x8a, 0x2e, 0x03, 0x70, 0x73, 0x44}, aaaa.getIp());
}

@Test(expected = IllegalArgumentException.class)
@Test
public void testAAAARecordInvalidIp() throws Exception {
new AAAA(new byte[42]);
assertThrows(IllegalArgumentException.class, () ->
new AAAA(new byte[42])
);
}

@Test
@@ -10,10 +10,10 @@
*/
package org.minidns.record;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

import org.junit.Test;
import org.junit.jupiter.api.Test;

public class TLSATest {

@@ -10,9 +10,9 @@
*/
package org.minidns.util;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class Base32Test {
@Test
@@ -10,9 +10,9 @@
*/
package org.minidns.util;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class Base64Test {
@Test
@@ -10,12 +10,12 @@
*/
package org.minidns.util;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

import java.net.Inet4Address;
import java.net.Inet6Address;

import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.minidns.dnsname.DnsName;

public class InetAddressUtilTest {
@@ -10,10 +10,10 @@
*/
package org.minidns.util;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class NameUtilTest {

0 comments on commit c9d2969

Please sign in to comment.
You can’t perform that action at this time.