Skip to content

Commit 23fa60c

Browse files
committed
bump mockito to support jdk21, IC-2024.2 runs tests with it regardless
Signed-off-by: Andre Dietisheim <[email protected]>
1 parent ce7e878 commit 23fa60c

File tree

4 files changed

+68
-11
lines changed

4 files changed

+68
-11
lines changed

build.gradle.kts

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
12
import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
23
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
34
import org.jetbrains.intellij.platform.gradle.models.ProductRelease
@@ -59,9 +60,8 @@ dependencies {
5960
// for unit tests
6061
testImplementation(libs.junit)
6162
testImplementation(libs.assertj.core)
62-
testImplementation(libs.mockito.inline)
63+
testImplementation(libs.mockito.core)
6364
testImplementation(libs.opentest4j) // known issue: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-faq.html#missing-opentest4j-dependency-in-test-framework
64-
6565
}
6666

6767
tasks {
@@ -73,6 +73,9 @@ tasks {
7373
useJUnit()
7474
systemProperty("tools.dl.path", temporaryDir)
7575
jvmArgs("-Djava.awt.headless=true")
76+
testLogging {
77+
exceptionFormat = TestExceptionFormat.FULL
78+
}
7679
}
7780

7881
withType<Test> {

gradle/libs.versions.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ commons-lang3 = "3.12.0"
77
commons-exec = "1.3"
88
common-lang = "3.9.4"
99
assertj-core = "3.22.0"
10-
mockito-inline = "4.5.1"
10+
mockito-core = "5.14.2"
1111
opentest4j = "1.3.0"
1212

1313
# plugins
@@ -22,7 +22,7 @@ kubernetes-httpclient-okhttp = { group = "io.fabric8", name = "kubernetes-httpcl
2222
jackson-core = { group = "com.fasterxml.jackson.core", name = "jackson-core", version.ref = "jackson-core" }
2323
commons-lang3 = { group = "org.apache.commons", name = "commons-lang3", version.ref = "commons-lang3" }
2424
assertj-core = { group = "org.assertj", name = "assertj-core", version.ref = "assertj-core" }
25-
mockito-inline = { group = "org.mockito", name = "mockito-inline", version.ref = "mockito-inline" }
25+
mockito-core = { group = "org.mockito", name = "mockito-core", version.ref = "mockito-core" }
2626
commons-exec = { group = "org.apache.commons", name = "commons-exec", version.ref = "commons-exec" }
2727
common-lang = { group = "com.twelvemonkeys.common", name = "common-lang", version.ref = "common-lang" }
2828
opentest4j = { group = "org.opentest4j", name = "opentest4j", version.ref = "opentest4j" }

src/main/java/com/redhat/devtools/intellij/common/utils/ConfigHelper.java

+60-6
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ public class ConfigHelper {
3535
*/
3636
public static boolean areEqual(Config thisConfig, Config thatConfig) {
3737
return areEqualCurrentContext(thisConfig, thatConfig)
38-
&& areEqualToken(thisConfig, thatConfig);
38+
&& areEqualCluster(thisConfig, thatConfig)
39+
&& areEqualAuthInfo(thisConfig, thatConfig);
3940
}
4041

4142
/**
@@ -108,20 +109,73 @@ private static boolean areEqualContext(NamedContext thisContext, NamedContext th
108109
* @see NamedContext
109110
* @see Context
110111
*/
111-
private static boolean areEqualContext(Context thisContext, Context thatContext) {
112+
public static boolean areEqualContext(Context thisContext, Context thatContext) {
112113
if (thisContext == null) {
113114
return thatContext == null;
114115
} else if (thatContext == null) {
115116
return false;
116117
}
117118

118-
if (!Objects.equals(thisContext.getCluster(), thatContext.getCluster())){
119+
return Objects.equals(thisContext.getCluster(), thatContext.getCluster())
120+
&& Objects.equals(thisContext.getNamespace(), thatContext.getNamespace())
121+
&& Objects.equals(thisContext.getUser(), thatContext.getUser());
122+
}
123+
124+
public static boolean areEqualCluster(Config thisConfig, Config thatConfig) {
125+
if (thisConfig == null) {
126+
return thatConfig == null;
127+
} else if (thatConfig == null) {
119128
return false;
120-
} else if (!Objects.equals(thisContext.getNamespace(), thatContext.getNamespace())){
129+
}
130+
131+
return Objects.equals(thisConfig.getMasterUrl(), thatConfig.getMasterUrl())
132+
&& areEqualTrustCerts(thisConfig, thatConfig)
133+
&& areEqualProxy(thisConfig, thatConfig)
134+
&& areEqualAuthInfo(thisConfig, thatConfig);
135+
}
136+
137+
private static boolean areEqualProxy(Config thisConfig, Config thatConfig) {
138+
if (thisConfig == null) {
139+
return thatConfig == null;
140+
} else if (thatConfig == null) {
121141
return false;
122-
} else {
123-
return Objects.equals(thisContext.getUser(), thatContext.getUser());
124142
}
143+
144+
return Objects.equals(thisConfig.getHttpProxy(), thatConfig.getHttpProxy())
145+
&& Objects.equals(thisConfig.getHttpsProxy(), thatConfig.getHttpsProxy())
146+
&& Objects.equals(thisConfig.getProxyUsername(), thatConfig.getProxyUsername())
147+
&& Objects.equals(thisConfig.getProxyPassword(), thatConfig.getProxyPassword());
148+
}
149+
150+
private static boolean areEqualTrustCerts(Config thisConfig, Config thatConfig) {
151+
if (thisConfig == null) {
152+
return thatConfig == null;
153+
} else if (thatConfig == null) {
154+
return false;
155+
}
156+
157+
return thisConfig.isTrustCerts() == thatConfig.isTrustCerts()
158+
&& thisConfig.isDisableHostnameVerification() == thatConfig.isDisableHostnameVerification()
159+
&& Objects.equals(thisConfig.getCaCertData(), thatConfig.getCaCertData())
160+
&& Objects.equals(thisConfig.getCaCertFile(), thatConfig.getCaCertFile());
161+
}
162+
163+
public static boolean areEqualAuthInfo(Config thisConfig, Config thatConfig) {
164+
if (thisConfig == null) {
165+
return thatConfig == null;
166+
} else if (thatConfig == null) {
167+
return false;
168+
}
169+
170+
return Objects.equals(thisConfig.getClientCertFile(), thatConfig.getClientCertFile())
171+
&& Objects.equals(thisConfig.getClientCertData(), thatConfig.getClientCertData())
172+
&& Objects.equals(thisConfig.getClientKeyFile(), thatConfig.getClientKeyFile())
173+
&& Objects.equals(thisConfig.getClientKeyData(), thatConfig.getClientKeyData())
174+
&& Objects.equals(thisConfig.getClientKeyAlgo(), thatConfig.getClientKeyAlgo())
175+
&& Objects.equals(thisConfig.getUsername(), thatConfig.getUsername())
176+
&& Objects.equals(thisConfig.getPassword(), thatConfig.getPassword())
177+
&& areEqualProxy(thisConfig, thatConfig)
178+
&& areEqualToken(thisConfig, thatConfig);
125179
}
126180

127181
/**

src/main/java/com/redhat/devtools/intellij/common/utils/ConfigWatcher.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ private void watch(Consumer<io.fabric8.kubernetes.client.Config> listener, Watch
133133
key.pollEvents().forEach((event) -> {
134134
Path changed = getAbsolutePath(directory, (Path) event.context());
135135
if (isConfigPath(changed)) {
136-
Config config = new ConfigBuilder().build();
136+
Config config = Config.autoConfigure(null);
137137
listener.accept(config);
138138
}
139139
});

0 commit comments

Comments
 (0)