Skip to content

Commit

Permalink
Update to junit 5 and disable wildcard imports (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
pkwarren authored Nov 8, 2023
1 parent 9db47f6 commit 8c0a268
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 13 deletions.
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[*]
charset = utf-8

[*.java]
ij_java_class_count_to_use_import_on_demand = 999
ij_java_use_single_class_imports = true
7 changes: 6 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ allprojects {
java {
importOrder()
removeUnusedImports()
replaceRegex("Remove wildcard imports", "import\\s+[^\\*\\s]+\\*;(\\r\\n|\\r|\\n)", "$1")
googleJavaFormat()
endWithNewline()
trimTrailingWhitespace()
Expand All @@ -215,6 +216,9 @@ allprojects {
}
}
}
tasks.withType<Test>().configureEach {
useJUnitPlatform()
}
}

mavenPublishing {
Expand Down Expand Up @@ -272,7 +276,8 @@ dependencies {
implementation(libs.jakarta.mail.api)

testImplementation(libs.assertj)
testImplementation(libs.junit)
testImplementation(platform(libs.junit.bom))
testImplementation("org.junit.jupiter:junit-jupiter")

errorprone(libs.errorprone)
}
3 changes: 2 additions & 1 deletion conformance/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ dependencies {
implementation(libs.protobuf.java)

implementation(libs.assertj)
implementation(libs.junit)
implementation(platform(libs.junit.bom))
testImplementation("org.junit.jupiter:junit-jupiter")

errorprone(libs.errorprone)
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package build.buf.protovalidate;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

import build.buf.protovalidate.exceptions.ExecutionException;
import build.buf.protovalidate.exceptions.ValidationException;
Expand Down Expand Up @@ -47,14 +48,14 @@
import com.google.protobuf.Duration;
import com.google.protobuf.Timestamp;
import java.util.Arrays;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class ValidatorTest {

private Validator validator;

@Before
@BeforeEach
public void setUp() {
Config config = Config.newBuilder().build();
validator = new Validator(config);
Expand Down Expand Up @@ -219,10 +220,10 @@ public void strictRepeatedMin() throws Exception {
assertThat(validate.getViolations()).hasSize(1);
}

@Test(expected = ExecutionException.class)
public void testDynRuntimeError() throws Exception {
@Test
public void testDynRuntimeError() {
DynRuntimeError invalid = DynRuntimeError.newBuilder().setA(123).build();
validator.validate(invalid);
assertThatThrownBy(() -> validator.validate(invalid)).isInstanceOf(ExecutionException.class);
}

@Test
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
assertj = "3.24.2"
cel = "0.3.21"
ipaddress = "5.4.0"
junit = "4.13.2"
junit = "5.10.1"
# When updating, make sure to update buf.gen.yaml and src/test/resources/proto/buf.gen.*.yaml versions to match
# and regenerate code with 'make generate'.
protobuf = "3.25.0"
Expand All @@ -15,7 +15,7 @@ errorprone = { module = "com.google.errorprone:error_prone_core", version = "2.2
guava = { module = "com.google.guava:guava", version = "32.1.3-jre" }
ipaddress = { module = "com.github.seancfoley:ipaddress", version.ref = "ipaddress" }
jakarta-mail-api = { module = "jakarta.mail:jakarta.mail-api", version = "2.1.2" }
junit = { module = "junit:junit", version.ref = "junit" }
junit-bom = { module = "org.junit:junit-bom", version.ref = "junit" }
maven-plugin = { module = "com.vanniktech:gradle-maven-publish-plugin", version = "0.25.3" }
mail = { module = "javax.mail:mail", version = "1.4.7"}
nullaway = { module = "com.uber.nullaway:nullaway", version = "0.10.16" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import com.google.protobuf.Message;
import java.util.Collections;
import java.util.List;
import org.junit.Test;
import org.junit.jupiter.api.Test;

/**
* protovalidate-java contains protoc generated classes for the <a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.junit.Test;
import org.junit.jupiter.api.Test;

/**
* This test mimics the behavior when performing validation with protovalidate on a file descriptor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import com.google.common.collect.ImmutableMap;
import java.util.List;
import java.util.Map;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.projectnessie.cel.Ast;
import org.projectnessie.cel.Env;
import org.projectnessie.cel.Library;
Expand Down

0 comments on commit 8c0a268

Please sign in to comment.