Skip to content

Commit 858e9f2

Browse files
authored
junit5 (#24)
1 parent bc40b10 commit 858e9f2

File tree

8 files changed

+66
-31
lines changed

8 files changed

+66
-31
lines changed

lib/build.gradle

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,18 @@ dependencies {
3535
implementation "io.cloudquery:plugin-pb-java:0.0.5"
3636
implementation "org.apache.arrow:arrow-vector:12.0.1"
3737

38+
testImplementation(platform('org.junit:junit-bom:5.10.0'))
39+
testImplementation('org.junit.jupiter:junit-jupiter:5.10.0')
40+
testImplementation('org.junit.jupiter:junit-jupiter-api:5.10.0')
41+
testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine:5.10.0')
42+
3843
testImplementation 'org.assertj:assertj-core:3.24.2'
3944
}
4045

41-
testing {
42-
suites {
43-
// Configure the built-in test suite
44-
test {
45-
// Use JUnit4 test framework
46-
useJUnit('4.13.2')
47-
}
46+
test {
47+
useJUnitPlatform()
48+
testLogging {
49+
events "passed", "skipped", "failed"
4850
}
4951
}
5052

lib/src/test/java/io/cloudquery/glob/GlobTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package io.cloudquery.glob;
22

3-
import org.junit.Test;
3+
import org.junit.jupiter.api.Test;
44

55
import java.util.List;
66

77
import static io.cloudquery.glob.Glob.GLOB;
8-
import static org.junit.Assert.assertFalse;
9-
import static org.junit.Assert.assertTrue;
8+
import static org.junit.jupiter.api.Assertions.assertFalse;
9+
import static org.junit.jupiter.api.Assertions.assertTrue;
1010

1111
public class GlobTest {
1212
@Test
@@ -75,7 +75,7 @@ public void testGlobs() {
7575
assertGlobMatch(pattern, "this is a ϗѾ test");
7676
}
7777

78-
for(String pattern:List.of(
78+
for (String pattern : List.of(
7979
"test*", // Implicit substring match
8080
"*is", // Partial match
8181
"*no*", // Globs without a match between them
@@ -90,11 +90,11 @@ public void testGlobs() {
9090
}
9191

9292
public void assertGlobMatch(String pattern, String subject) {
93-
assertTrue(String.format("\"%s\" should match \"%s\"", pattern, subject), Glob.match(pattern, subject));
93+
assertTrue(Glob.match(pattern, subject), String.format("\"%s\" should match \"%s\"", pattern, subject));
9494
}
9595

9696
public void assertNotGlobMatch(String pattern, String subject) {
97-
assertFalse(String.format("\"%s\" should not match \"%s\"", pattern, subject), Glob.match(pattern, subject));
97+
assertFalse(Glob.match(pattern, subject), String.format("\"%s\" should not match \"%s\"", pattern, subject));
9898
}
9999

100100
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package io.cloudquery.scalar;
2+
3+
import io.cloudquery.scalar.Binary;
4+
import io.cloudquery.scalar.ValidationException;
5+
6+
import org.junit.jupiter.api.Test;
7+
8+
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
9+
import static org.junit.jupiter.api.Assertions.assertThrows;
10+
11+
12+
public class BinaryTest {
13+
@Test
14+
public void testNew() {
15+
assertDoesNotThrow(() -> {
16+
new Binary();
17+
});
18+
}
19+
20+
@Test
21+
public void testNewWithValidParam() {
22+
assertDoesNotThrow(() -> {
23+
new Binary("abc");
24+
});
25+
}
26+
27+
@Test
28+
public void testNewWithInvalidParam() {
29+
assertThrows(ValidationException.class, () -> {
30+
new Binary(false);
31+
});
32+
}
33+
}

lib/src/test/java/io/cloudquery/schema/TableFilterDFSTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package io.cloudquery.schema;
22

3-
import org.junit.Test;
3+
import org.junit.jupiter.api.Test;
44

55
import java.util.Collections;
66
import java.util.List;
77
import java.util.stream.Stream;
88

99
import static org.assertj.core.api.Assertions.assertThat;
10-
import static org.junit.Assert.assertEquals;
11-
import static org.junit.Assert.assertThrows;
10+
import static org.junit.jupiter.api.Assertions.assertEquals;
11+
import static org.junit.jupiter.api.Assertions.assertThrows;
1212

1313
public class TableFilterDFSTest {
1414
public static final List<Table> BASIC_TABLES = Stream.of("table1", "table2", "table3").map(

lib/src/test/java/io/cloudquery/schema/TableFlattenTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package io.cloudquery.schema;
22

3-
import org.junit.Test;
3+
import org.junit.jupiter.api.Test;
44

55
import java.util.List;
66

7-
import static org.junit.Assert.assertEquals;
7+
import static org.junit.jupiter.api.Assertions.assertEquals;
88

99
public class TableFlattenTest {
1010

lib/src/test/java/io/cloudquery/schema/TableMaxTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package io.cloudquery.schema;
22

3-
import org.junit.Test;
3+
import org.junit.jupiter.api.Test;
44

55
import java.util.Collections;
66
import java.util.List;
77

8-
import static org.junit.Assert.assertEquals;
8+
import static org.junit.jupiter.api.Assertions.assertEquals;
99

1010
public class TableMaxTest {
1111

lib/src/test/java/io/cloudquery/server/AddressTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
package io.cloudquery.server;
22

33
import io.cloudquery.server.AddressConverter.Address;
4-
import org.junit.Assert;
5-
import org.junit.Before;
6-
import org.junit.Test;
4+
import org.junit.jupiter.api.BeforeEach;
5+
import org.junit.jupiter.api.Test;
76

8-
import static org.junit.Assert.assertEquals;
7+
import static org.junit.jupiter.api.Assertions.assertEquals;
8+
import static org.junit.jupiter.api.Assertions.assertThrows;
99

1010
public class AddressTest {
1111

1212
private AddressConverter addressConverter;
1313

14-
@Before
14+
@BeforeEach
1515
public void setUp() {
1616
addressConverter = new AddressConverter();
1717
}
@@ -31,6 +31,6 @@ public void shouldThrowExceptionIfAddressNotFormattedCorrectly() {
3131

3232
AddressConverter addressConverter = new AddressConverter();
3333

34-
Assert.assertThrows(AddressConverter.AddressParseException.class, () -> addressConverter.convert(rawAddress));
34+
assertThrows(AddressConverter.AddressParseException.class, () -> addressConverter.convert(rawAddress));
3535
}
3636
}

lib/src/test/java/io/cloudquery/server/PluginServeTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22

33
import io.cloudquery.plugin.Plugin;
44
import io.cloudquery.server.PluginServe.PluginServeBuilder;
5-
import org.junit.Before;
6-
import org.junit.Ignore;
7-
import org.junit.Test;
5+
import org.junit.jupiter.api.BeforeEach;
6+
import org.junit.jupiter.api.Disabled;
7+
import org.junit.jupiter.api.Test;
88

99
import java.util.List;
1010

1111

12-
@Ignore(value = "blocking tests - only used manually to test the gRPC runs correctly")
12+
@Disabled(value = "blocking tests - only used manually to test the gRPC runs correctly")
1313
public class PluginServeTest {
1414
public static final String URL = "https://sentry.url";
1515

1616
private Plugin plugin;
1717

18-
@Before
18+
@BeforeEach
1919
public void setUp() {
2020
plugin = Plugin.builder("test-plugin", "0.1.0").build();
2121
}

0 commit comments

Comments
 (0)