Skip to content

Commit

Permalink
bump mockito to support jdk21, IC-2024.2 runs tests with it regardless
Browse files Browse the repository at this point in the history
Signed-off-by: Andre Dietisheim <[email protected]>
  • Loading branch information
adietish committed Dec 20, 2024
1 parent ce7e878 commit 23fa60c
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 11 deletions.
7 changes: 5 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
import org.jetbrains.intellij.platform.gradle.models.ProductRelease
Expand Down Expand Up @@ -59,9 +60,8 @@ dependencies {
// for unit tests
testImplementation(libs.junit)
testImplementation(libs.assertj.core)
testImplementation(libs.mockito.inline)
testImplementation(libs.mockito.core)
testImplementation(libs.opentest4j) // known issue: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-faq.html#missing-opentest4j-dependency-in-test-framework

}

tasks {
Expand All @@ -73,6 +73,9 @@ tasks {
useJUnit()
systemProperty("tools.dl.path", temporaryDir)
jvmArgs("-Djava.awt.headless=true")
testLogging {
exceptionFormat = TestExceptionFormat.FULL
}
}

withType<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 @@ -7,7 +7,7 @@ commons-lang3 = "3.12.0"
commons-exec = "1.3"
common-lang = "3.9.4"
assertj-core = "3.22.0"
mockito-inline = "4.5.1"
mockito-core = "5.14.2"
opentest4j = "1.3.0"

# plugins
Expand All @@ -22,7 +22,7 @@ kubernetes-httpclient-okhttp = { group = "io.fabric8", name = "kubernetes-httpcl
jackson-core = { group = "com.fasterxml.jackson.core", name = "jackson-core", version.ref = "jackson-core" }
commons-lang3 = { group = "org.apache.commons", name = "commons-lang3", version.ref = "commons-lang3" }
assertj-core = { group = "org.assertj", name = "assertj-core", version.ref = "assertj-core" }
mockito-inline = { group = "org.mockito", name = "mockito-inline", version.ref = "mockito-inline" }
mockito-core = { group = "org.mockito", name = "mockito-core", version.ref = "mockito-core" }
commons-exec = { group = "org.apache.commons", name = "commons-exec", version.ref = "commons-exec" }
common-lang = { group = "com.twelvemonkeys.common", name = "common-lang", version.ref = "common-lang" }
opentest4j = { group = "org.opentest4j", name = "opentest4j", version.ref = "opentest4j" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public class ConfigHelper {
*/
public static boolean areEqual(Config thisConfig, Config thatConfig) {
return areEqualCurrentContext(thisConfig, thatConfig)
&& areEqualToken(thisConfig, thatConfig);
&& areEqualCluster(thisConfig, thatConfig)
&& areEqualAuthInfo(thisConfig, thatConfig);
}

/**
Expand Down Expand Up @@ -108,20 +109,73 @@ private static boolean areEqualContext(NamedContext thisContext, NamedContext th
* @see NamedContext
* @see Context
*/
private static boolean areEqualContext(Context thisContext, Context thatContext) {
public static boolean areEqualContext(Context thisContext, Context thatContext) {
if (thisContext == null) {
return thatContext == null;
} else if (thatContext == null) {
return false;
}

if (!Objects.equals(thisContext.getCluster(), thatContext.getCluster())){
return Objects.equals(thisContext.getCluster(), thatContext.getCluster())
&& Objects.equals(thisContext.getNamespace(), thatContext.getNamespace())
&& Objects.equals(thisContext.getUser(), thatContext.getUser());
}

public static boolean areEqualCluster(Config thisConfig, Config thatConfig) {
if (thisConfig == null) {
return thatConfig == null;
} else if (thatConfig == null) {
return false;
} else if (!Objects.equals(thisContext.getNamespace(), thatContext.getNamespace())){
}

return Objects.equals(thisConfig.getMasterUrl(), thatConfig.getMasterUrl())
&& areEqualTrustCerts(thisConfig, thatConfig)
&& areEqualProxy(thisConfig, thatConfig)
&& areEqualAuthInfo(thisConfig, thatConfig);
}

private static boolean areEqualProxy(Config thisConfig, Config thatConfig) {
if (thisConfig == null) {
return thatConfig == null;
} else if (thatConfig == null) {
return false;
} else {
return Objects.equals(thisContext.getUser(), thatContext.getUser());
}

return Objects.equals(thisConfig.getHttpProxy(), thatConfig.getHttpProxy())
&& Objects.equals(thisConfig.getHttpsProxy(), thatConfig.getHttpsProxy())
&& Objects.equals(thisConfig.getProxyUsername(), thatConfig.getProxyUsername())
&& Objects.equals(thisConfig.getProxyPassword(), thatConfig.getProxyPassword());
}

private static boolean areEqualTrustCerts(Config thisConfig, Config thatConfig) {
if (thisConfig == null) {
return thatConfig == null;
} else if (thatConfig == null) {
return false;
}

return thisConfig.isTrustCerts() == thatConfig.isTrustCerts()
&& thisConfig.isDisableHostnameVerification() == thatConfig.isDisableHostnameVerification()
&& Objects.equals(thisConfig.getCaCertData(), thatConfig.getCaCertData())
&& Objects.equals(thisConfig.getCaCertFile(), thatConfig.getCaCertFile());
}

public static boolean areEqualAuthInfo(Config thisConfig, Config thatConfig) {
if (thisConfig == null) {
return thatConfig == null;
} else if (thatConfig == null) {
return false;
}

return Objects.equals(thisConfig.getClientCertFile(), thatConfig.getClientCertFile())
&& Objects.equals(thisConfig.getClientCertData(), thatConfig.getClientCertData())
&& Objects.equals(thisConfig.getClientKeyFile(), thatConfig.getClientKeyFile())
&& Objects.equals(thisConfig.getClientKeyData(), thatConfig.getClientKeyData())
&& Objects.equals(thisConfig.getClientKeyAlgo(), thatConfig.getClientKeyAlgo())
&& Objects.equals(thisConfig.getUsername(), thatConfig.getUsername())
&& Objects.equals(thisConfig.getPassword(), thatConfig.getPassword())
&& areEqualProxy(thisConfig, thatConfig)
&& areEqualToken(thisConfig, thatConfig);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ private void watch(Consumer<io.fabric8.kubernetes.client.Config> listener, Watch
key.pollEvents().forEach((event) -> {
Path changed = getAbsolutePath(directory, (Path) event.context());
if (isConfigPath(changed)) {
Config config = new ConfigBuilder().build();
Config config = Config.autoConfigure(null);
listener.accept(config);
}
});
Expand Down

0 comments on commit 23fa60c

Please sign in to comment.