-
Notifications
You must be signed in to change notification settings - Fork 218
feat: introduce JUnit5 extension #545
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
26a52ea
0380945
a144f01
04a12d3
39ba19a
ab6a4f2
fad4baf
f46f3d5
d3c5921
0cc3a32
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package io.javaoperatorsdk.operator.api.config; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class BaseConfigurationService extends AbstractConfigurationService { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't get this class. Why are we creating loggers this way? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This class is just used to be able to have a non-abstract implementation that can be used in the junit extension. I'm debating whether to just put the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oki, |
||
|
||
private static final String LOGGER_NAME = "Default ConfigurationService implementation"; | ||
private static final Logger logger = LoggerFactory.getLogger(LOGGER_NAME); | ||
|
||
public BaseConfigurationService(Version version) { | ||
super(version); | ||
} | ||
|
||
@Override | ||
protected void logMissingControllerWarning(String controllerKey, String controllersNameMessage) { | ||
logger.warn("Configuration for controller '{}' was not found. {}", controllerKey, | ||
controllersNameMessage); | ||
} | ||
|
||
public String getLoggerName() { | ||
return LOGGER_NAME; | ||
} | ||
|
||
protected Logger getLogger() { | ||
return logger; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>java-operator-sdk</artifactId> | ||
<groupId>io.javaoperatorsdk</groupId> | ||
<version>1.9.7-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>operator-framework-junit-5</artifactId> | ||
<name>Operator SDK - Framework - JUnit 5 extension</name> | ||
|
||
<properties> | ||
<maven.compiler.source>11</maven.compiler.source> | ||
<maven.compiler.target>11</maven.compiler.target> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.javaoperatorsdk</groupId> | ||
<artifactId>operator-framework-core</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-engine</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.assertj</groupId> | ||
<artifactId>assertj-core</artifactId> | ||
<version>3.20.2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.awaitility</groupId> | ||
<artifactId>awaitility</artifactId> | ||
<version>4.1.0</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package io.javaoperatorsdk.operator.junit; | ||
|
||
import io.fabric8.kubernetes.client.KubernetesClient; | ||
|
||
public interface HasKubernetesClient { | ||
KubernetesClient getKubernetesClient(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package io.javaoperatorsdk.operator.junit; | ||
|
||
import io.fabric8.kubernetes.client.KubernetesClient; | ||
|
||
public interface KubernetesClientAware extends HasKubernetesClient { | ||
void setKubernetesClient(KubernetesClient kubernetesClient); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to my understanding, why is this better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The benefit is minimal, indeed, just to be able to not pull SLF4J when using
AbstractConfigurationService
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, isn't this a little bit over-engineering? We use SLF4J everywhere, and it's quite an industry standard
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other issue is also that the previous version hardcoded the name of the logger, which might not have been appropriate depending on the actual implementation being executed (for example, even the Quarkus implementation would have logged something with
Default ConfigurationService implementation
logger name).