From 7ff251dd2cdde621a6faddb4415d00e0f5f3904a Mon Sep 17 00:00:00 2001 From: YukiInu Date: Thu, 7 Dec 2023 12:09:13 +0100 Subject: [PATCH 1/7] updating dvalin, junit 5 and maven plugin version --- pom.xml | 79 +++++++++++-------- .../server/util/GenericModelApiConverter.java | 2 +- .../cinovo/cloudconductor/server/APITest.java | 4 +- .../cloudconductor/server/TestConfig.java | 2 +- .../cloudconductor/server/test/AgentTest.java | 46 +++++------ .../server/test/ConfigTest.java | 43 +++++----- .../cloudconductor/server/test/FileTest.java | 41 +++++----- .../cloudconductor/server/test/HostTest.java | 23 +++--- .../server/test/PackageTest.java | 29 ++++--- .../server/test/SSHKeyTest.java | 43 +++++----- .../server/test/ServiceTest.java | 33 ++++---- .../server/test/TemplateTest.java | 47 ++++++----- .../cloudconductor/server/test/UserTest.java | 31 ++++---- .../server/test/repo/IndexerTest.java | 6 +- 14 files changed, 218 insertions(+), 211 deletions(-) diff --git a/pom.xml b/pom.xml index e605a1be..f9fc1646 100644 --- a/pom.xml +++ b/pom.xml @@ -58,9 +58,10 @@ UTF-8 - 1.34 + 1.35-SNAPSHOT 3.9 - 1.12.467 + 1.12.595 + 5.10.1 @@ -86,12 +87,6 @@ dvalin-jaxrs-jwtauth ${dvalin.version} - - - org.bouncycastle - bcprov-jdk18on - 1.74 - com.amazonaws @@ -103,30 +98,34 @@ org.postgresql postgresql - 42.5.2 + 42.7.0 com.mysql mysql-connector-j - 8.0.33 + 8.2.0 org.hsqldb hsqldb - 2.5.2 + 2.7.2 + jdk8 + test + + + org.junit.jupiter + junit-jupiter + ${junit.version} test - junit - junit - 4.13.2 + org.junit.vintage + junit-vintage-engine + ${junit.version} test - - 3.0.0 - ${project.groupId}.${project.artifactId} @@ -155,18 +154,13 @@ - - org.codehaus.mojo - findbugs-maven-plugin - 2.5.3 - org.apache.maven.plugins maven-compiler-plugin - 3.1 + 3.11.0 1.8 1.8 @@ -175,7 +169,7 @@ org.apache.maven.plugins maven-release-plugin - 2.5 + 2.5.3 -Psonatype-oss-release,webapp true @@ -185,7 +179,7 @@ org.apache.maven.plugins maven-jar-plugin - 2.4 + 3.3.0 @@ -207,7 +201,7 @@ org.apache.maven.plugins maven-dependency-plugin - 2.8 + 3.6.0 copy-dependencies @@ -228,7 +222,7 @@ org.codehaus.mojo exec-maven-plugin - 1.4.0 + 3.1.0 de.cinovo.cloudconductor.server.ServerStarter @@ -240,8 +234,9 @@ + org.apache.maven.plugins maven-assembly-plugin - 2.5.4 + 3.6.0 src/main/assembly/zip.xml false @@ -262,7 +257,7 @@ org.codehaus.mojo exec-maven-plugin - 3.0.0 + 3.1.0 npm install (initialize) @@ -305,7 +300,7 @@ org.codehaus.mojo rpm-maven-plugin - 2.2.0 + 2.3.0 verify @@ -450,7 +445,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.3.1 + 3.6.2 @@ -464,7 +459,7 @@ org.apache.maven.plugins maven-resources-plugin - 3.2.0 + 3.3.1 verify @@ -485,6 +480,26 @@ + + org.apache.maven.plugins + maven-enforcer-plugin + 3.4.1 + + + enforce-maven + + enforce + + + + + [3.2.5,) + + + + + + diff --git a/src/main/java/de/cinovo/cloudconductor/server/util/GenericModelApiConverter.java b/src/main/java/de/cinovo/cloudconductor/server/util/GenericModelApiConverter.java index 539373f4..a6b635da 100644 --- a/src/main/java/de/cinovo/cloudconductor/server/util/GenericModelApiConverter.java +++ b/src/main/java/de/cinovo/cloudconductor/server/util/GenericModelApiConverter.java @@ -141,7 +141,7 @@ private static Method getGetter(Class clazz, String fieldname) throws NoSuchM } private static String capitalize(String name) { - return name != null && name.length() != 0 ? name.substring(0, 1).toUpperCase(Locale.ENGLISH) + name.substring(1) : name; + return name != null && !name.isEmpty() ? name.substring(0, 1).toUpperCase(Locale.ENGLISH) + name.substring(1) : name; } private static HashMap resolveFieldMapFromOrigin(Origin origin, Destination destination) { diff --git a/src/test/java/de/cinovo/cloudconductor/server/APITest.java b/src/test/java/de/cinovo/cloudconductor/server/APITest.java index e2d148c3..6931368b 100644 --- a/src/test/java/de/cinovo/cloudconductor/server/APITest.java +++ b/src/test/java/de/cinovo/cloudconductor/server/APITest.java @@ -19,7 +19,7 @@ import de.cinovo.cloudconductor.api.lib.helper.AuthHandler; import de.taimos.daemon.log4j.Log4jLoggingConfigurer; -import de.taimos.daemon.spring.SpringDaemonTestRunner.RunnerConfiguration; +import de.taimos.daemon.spring.RunnerConfiguration; import de.taimos.httputils.HTTPRequest; import de.taimos.httputils.WS; @@ -36,7 +36,7 @@ @RunnerConfiguration(config = TestConfig.class, svc = "cloudconductor", loggingConfigurer = Log4jLoggingConfigurer.class) public abstract class APITest { - private String token; + private final String token; protected APITest() { this.token = new AuthHandler(this.getCSApi()).auth(); diff --git a/src/test/java/de/cinovo/cloudconductor/server/TestConfig.java b/src/test/java/de/cinovo/cloudconductor/server/TestConfig.java index 75f283a9..6c58d782 100644 --- a/src/test/java/de/cinovo/cloudconductor/server/TestConfig.java +++ b/src/test/java/de/cinovo/cloudconductor/server/TestConfig.java @@ -1,7 +1,7 @@ package de.cinovo.cloudconductor.server; import de.taimos.daemon.spring.Configuration; -import de.taimos.daemon.spring.SpringDaemonTestRunner.RunnerConfig; +import de.taimos.daemon.spring.RunnerConfig; /** * diff --git a/src/test/java/de/cinovo/cloudconductor/server/test/AgentTest.java b/src/test/java/de/cinovo/cloudconductor/server/test/AgentTest.java index 727581e3..6799177e 100644 --- a/src/test/java/de/cinovo/cloudconductor/server/test/AgentTest.java +++ b/src/test/java/de/cinovo/cloudconductor/server/test/AgentTest.java @@ -9,18 +9,18 @@ import de.cinovo.cloudconductor.api.model.PackageVersion; import de.cinovo.cloudconductor.api.model.ServiceStates; import de.cinovo.cloudconductor.server.APITest; -import de.taimos.daemon.spring.SpringDaemonTestRunner; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import de.taimos.daemon.spring.SpringDaemonExtension; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; -@RunWith(SpringDaemonTestRunner.class) -public class AgentTest extends APITest { +@ExtendWith(SpringDaemonExtension.class) +class AgentTest extends APITest { private static final String TEMPLATE = "dev"; @@ -30,19 +30,19 @@ public class AgentTest extends APITest { @Test - public void testPackagesBasic() throws CloudConductorException { + void testPackagesBasic() throws CloudConductorException { AgentHandler agent = new AgentHandler(this.getCSApi(), this.getToken()); AgentOption optionsC = agent.heartBeat(AgentTest.TEMPLATE, AgentTest.HOST_C, null, "asd"); { PackageStateChanges result = agent.notifyPackageState(AgentTest.TEMPLATE, AgentTest.HOST_C, this.getPartiallyInstalled(), optionsC.getUuid()); - Assert.assertEquals(4, result.getToInstall().size()); - Assert.assertFalse(result.getToErase().isEmpty()); - Assert.assertFalse(result.getToUpdate().isEmpty()); + Assertions.assertEquals(4, result.getToInstall().size()); + Assertions.assertFalse(result.getToErase().isEmpty()); + Assertions.assertFalse(result.getToUpdate().isEmpty()); } } @Test - public void testPackageMultiHost() throws CloudConductorException { + void testPackageMultiHost() throws CloudConductorException { AgentHandler agent = new AgentHandler(this.getCSApi(), this.getToken()); AgentOption optionsA = agent.heartBeat(AgentTest.TEMPLATE, AgentTest.HOST_A, null, "asd"); AgentOption optionsB = agent.heartBeat(AgentTest.TEMPLATE, AgentTest.HOST_B, null, "asd2"); @@ -51,31 +51,31 @@ public void testPackageMultiHost() throws CloudConductorException { // block the second host on update agent.notifyPackageState(AgentTest.TEMPLATE, AgentTest.HOST_A, this.getPartiallyInstalled(), optionsA.getUuid()); PackageStateChanges result = agent.notifyPackageState(AgentTest.TEMPLATE, AgentTest.HOST_B, this.getPartiallyInstalled(), optionsB.getUuid()); - Assert.assertTrue(result.getToInstall().isEmpty()); - Assert.assertTrue(result.getToErase().isEmpty()); - Assert.assertTrue(result.getToUpdate().isEmpty()); + Assertions.assertTrue(result.getToInstall().isEmpty()); + Assertions.assertTrue(result.getToErase().isEmpty()); + Assertions.assertTrue(result.getToUpdate().isEmpty()); } { // finalize update on host a PackageStateChanges result = agent.notifyPackageState(AgentTest.TEMPLATE, AgentTest.HOST_A, this.getAllInstalled(), optionsA.getUuid()); - Assert.assertTrue(result.getToInstall().isEmpty()); - Assert.assertTrue(result.getToUpdate().isEmpty()); - Assert.assertTrue(result.getToErase().isEmpty()); + Assertions.assertTrue(result.getToInstall().isEmpty()); + Assertions.assertTrue(result.getToUpdate().isEmpty()); + Assertions.assertTrue(result.getToErase().isEmpty()); agent.notifyServiceState(AgentTest.TEMPLATE, AgentTest.HOST_A, new ServiceStates(new ArrayList<>()), optionsA.getUuid()); } { // finally start update on host b PackageStateChanges result = agent.notifyPackageState(AgentTest.TEMPLATE, AgentTest.HOST_B, this.getPartiallyInstalled(), optionsB.getUuid()); - Assert.assertEquals(4, result.getToInstall().size()); - Assert.assertFalse(result.getToErase().isEmpty()); - Assert.assertFalse(result.getToUpdate().isEmpty()); + Assertions.assertEquals(4, result.getToInstall().size()); + Assertions.assertFalse(result.getToErase().isEmpty()); + Assertions.assertFalse(result.getToUpdate().isEmpty()); } { // finalize update on b PackageStateChanges result = agent.notifyPackageState(AgentTest.TEMPLATE, AgentTest.HOST_B, this.getAllInstalled(), optionsB.getUuid()); - Assert.assertTrue(result.getToInstall().isEmpty()); - Assert.assertTrue(result.getToUpdate().isEmpty()); - Assert.assertTrue(result.getToErase().isEmpty()); + Assertions.assertTrue(result.getToInstall().isEmpty()); + Assertions.assertTrue(result.getToUpdate().isEmpty()); + Assertions.assertTrue(result.getToErase().isEmpty()); } } diff --git a/src/test/java/de/cinovo/cloudconductor/server/test/ConfigTest.java b/src/test/java/de/cinovo/cloudconductor/server/test/ConfigTest.java index 628c2a3d..b0d9c3c8 100644 --- a/src/test/java/de/cinovo/cloudconductor/server/test/ConfigTest.java +++ b/src/test/java/de/cinovo/cloudconductor/server/test/ConfigTest.java @@ -21,10 +21,10 @@ import de.cinovo.cloudconductor.api.lib.manager.ConfigValueHandler; import de.cinovo.cloudconductor.api.model.ConfigValue; import de.cinovo.cloudconductor.server.APITest; -import de.taimos.daemon.spring.SpringDaemonTestRunner; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import de.taimos.daemon.spring.SpringDaemonExtension; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import java.util.Set; @@ -36,71 +36,70 @@ * @author hoegertn * */ -@RunWith(SpringDaemonTestRunner.class) -@SuppressWarnings("javadoc") -public class ConfigTest extends APITest { +@ExtendWith(SpringDaemonExtension.class) +class ConfigTest extends APITest { @Test - public void loadConfigTemplate() throws CloudConductorException { + void loadConfigTemplate() throws CloudConductorException { ConfigValueHandler h = new ConfigValueHandler(this.getCSApi(), this.getToken()); Set config = h.getConfig("dev"); - Assert.assertNotNull(config); + Assertions.assertNotNull(config); } @Test - public void loadConfigService() throws CloudConductorException { + void loadConfigService() throws CloudConductorException { ConfigValueHandler h = new ConfigValueHandler(this.getCSApi(), this.getToken()); Set config = h.getConfig("dev", "service1"); - Assert.assertNotNull(config); + Assertions.assertNotNull(config); } @Test - public void loadConfigKey() throws CloudConductorException { + void loadConfigKey() throws CloudConductorException { ConfigValueHandler h = new ConfigValueHandler(this.getCSApi(), this.getToken()); String config = h.getConfig("dev", "service1", "loggly.tags"); - Assert.assertNotNull(config); - Assert.assertEquals("foo", config); + Assertions.assertNotNull(config); + Assertions.assertEquals("foo", config); } @Test - public void testAddRemove() throws CloudConductorException { + void testAddRemove() throws CloudConductorException { { ConfigValueHandler h = new ConfigValueHandler(this.getCSApi(), this.getToken()); // Check config does not exist for(ConfigValue configValue : h.getConfig("dev")) { - Assert.assertFalse(configValue.getKey().equals("foo")); + Assertions.assertNotEquals("foo", configValue.getKey()); } for(ConfigValue configValue : h.getConfig("dev", "svc")) { - Assert.assertFalse(configValue.getKey().equals("foo")); + Assertions.assertNotEquals("foo", configValue.getKey()); } } { ConfigValueHandler h = new ConfigValueHandler(this.getCSApi(), this.getToken()); // add template level config h.addConfig("dev", "foo", "bar"); - Assert.assertEquals("bar", h.getConfig("dev", "svc", "foo")); + Assertions.assertEquals("bar", h.getConfig("dev", "svc", "foo")); } { ConfigValueHandler h = new ConfigValueHandler(this.getCSApi(), this.getToken()); // add service level config h.addConfig("dev", "svc", "foo", "baz"); - Assert.assertEquals("baz", h.getConfig("dev", "svc", "foo")); + Assertions.assertEquals("baz", h.getConfig("dev", "svc", "foo")); } { ConfigValueHandler h = new ConfigValueHandler(this.getCSApi(), this.getToken()); // remove service level config h.removeConfig("dev", "svc", "foo"); - Assert.assertEquals("bar", h.getConfig("dev", "svc", "foo")); + Assertions.assertEquals("bar", h.getConfig("dev", "svc", "foo")); } { ConfigValueHandler h = new ConfigValueHandler(this.getCSApi(), this.getToken()); // remove template level config h.removeConfig("dev", null, "foo"); for(ConfigValue configValue : h.getConfig("dev")) { - Assert.assertFalse(configValue.getKey().equals("foo")); + Assertions.assertNotEquals("foo", configValue.getKey()); } for(ConfigValue configValue : h.getConfig("dev", "svc")) { - Assert.assertFalse(configValue.getKey().equals("foo")); + Assertions.assertNotEquals("foo", configValue.getKey()); } } } diff --git a/src/test/java/de/cinovo/cloudconductor/server/test/FileTest.java b/src/test/java/de/cinovo/cloudconductor/server/test/FileTest.java index bbc3faf9..1d7d0833 100644 --- a/src/test/java/de/cinovo/cloudconductor/server/test/FileTest.java +++ b/src/test/java/de/cinovo/cloudconductor/server/test/FileTest.java @@ -21,10 +21,10 @@ import de.cinovo.cloudconductor.api.lib.manager.ConfigFileHandler; import de.cinovo.cloudconductor.api.model.ConfigFile; import de.cinovo.cloudconductor.server.APITest; -import de.taimos.daemon.spring.SpringDaemonTestRunner; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import de.taimos.daemon.spring.SpringDaemonExtension; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import java.util.Set; @@ -36,30 +36,29 @@ * @author hoegertn * */ -@RunWith(SpringDaemonTestRunner.class) -@SuppressWarnings("javadoc") -public class FileTest extends APITest { +@ExtendWith(SpringDaemonExtension.class) +class FileTest extends APITest { @Test - public void test() throws CloudConductorException { + void test() throws CloudConductorException { ConfigFileHandler h = new ConfigFileHandler(this.getCSApi(), this.getToken()); { Set set = h.get(); - Assert.assertEquals(1, set.size()); + Assertions.assertEquals(1, set.size()); ConfigFile file = set.iterator().next(); - Assert.assertEquals("file1", file.getName()); - Assert.assertEquals("/root/foo", file.getTargetPath()); - Assert.assertEquals("root", file.getOwner()); + Assertions.assertEquals("file1", file.getName()); + Assertions.assertEquals("/root/foo", file.getTargetPath()); + Assertions.assertEquals("root", file.getOwner()); } { ConfigFile file = h.get("file1"); - Assert.assertEquals("file1", file.getName()); - Assert.assertEquals("/root/foo", file.getTargetPath()); - Assert.assertEquals("root", file.getOwner()); + Assertions.assertEquals("file1", file.getName()); + Assertions.assertEquals("/root/foo", file.getTargetPath()); + Assertions.assertEquals("root", file.getOwner()); } { String data = h.getData("file1"); - Assert.assertEquals("Testfile for root", data); + Assertions.assertEquals("Testfile for root", data); } { ConfigFile cf = new ConfigFile(); @@ -76,20 +75,20 @@ public void test() throws CloudConductorException { h.save(cf); Set set = h.get(); - Assert.assertEquals(2, set.size()); + Assertions.assertEquals(2, set.size()); } { ConfigFile file = h.get("file2"); - Assert.assertEquals("file2", file.getName()); - Assert.assertEquals("/root/bar", file.getTargetPath()); - Assert.assertEquals("root", file.getOwner()); + Assertions.assertEquals("file2", file.getName()); + Assertions.assertEquals("/root/bar", file.getTargetPath()); + Assertions.assertEquals("root", file.getOwner()); } { h.saveData("file2", "Testcontent 2"); } { String data = h.getData("file2"); - Assert.assertEquals("Testcontent 2", data); + Assertions.assertEquals("Testcontent 2", data); } } diff --git a/src/test/java/de/cinovo/cloudconductor/server/test/HostTest.java b/src/test/java/de/cinovo/cloudconductor/server/test/HostTest.java index eb5485df..6ab7246f 100644 --- a/src/test/java/de/cinovo/cloudconductor/server/test/HostTest.java +++ b/src/test/java/de/cinovo/cloudconductor/server/test/HostTest.java @@ -21,10 +21,10 @@ import de.cinovo.cloudconductor.api.lib.manager.HostHandler; import de.cinovo.cloudconductor.api.model.Host; import de.cinovo.cloudconductor.server.APITest; -import de.taimos.daemon.spring.SpringDaemonTestRunner; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import de.taimos.daemon.spring.SpringDaemonExtension; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import java.util.Set; @@ -34,26 +34,25 @@ * * @author hoegertn */ -@RunWith(SpringDaemonTestRunner.class) -@SuppressWarnings("javadoc") -public class HostTest extends APITest { +@ExtendWith(SpringDaemonExtension.class) +class HostTest extends APITest { private static final String HOST1 = "host1"; @Test - public void test1() throws CloudConductorException { + void test1() throws CloudConductorException { HostHandler h = new HostHandler(this.getCSApi(), this.getToken()); { Set hosts = h.get(); - Assert.assertEquals(1, hosts.size()); + Assertions.assertEquals(1, hosts.size()); Host next = hosts.iterator().next(); - Assert.assertEquals(HostTest.HOST1, next.getName()); + Assertions.assertEquals(HostTest.HOST1, next.getName()); } { Host host = h.get("123123-123123-123123"); - Assert.assertNotNull(host); - Assert.assertEquals(HostTest.HOST1, host.getName()); + Assertions.assertNotNull(host); + Assertions.assertEquals(HostTest.HOST1, host.getName()); } } } diff --git a/src/test/java/de/cinovo/cloudconductor/server/test/PackageTest.java b/src/test/java/de/cinovo/cloudconductor/server/test/PackageTest.java index 056863f8..c5bd4abe 100644 --- a/src/test/java/de/cinovo/cloudconductor/server/test/PackageTest.java +++ b/src/test/java/de/cinovo/cloudconductor/server/test/PackageTest.java @@ -22,10 +22,10 @@ import de.cinovo.cloudconductor.api.model.Package; import de.cinovo.cloudconductor.api.model.PackageVersion; import de.cinovo.cloudconductor.server.APITest; -import de.taimos.daemon.spring.SpringDaemonTestRunner; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import de.taimos.daemon.spring.SpringDaemonExtension; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import java.util.Set; @@ -37,33 +37,32 @@ * @author hoegertn * */ -@RunWith(SpringDaemonTestRunner.class) -@SuppressWarnings("javadoc") -public class PackageTest extends APITest { +@ExtendWith(SpringDaemonExtension.class) +class PackageTest extends APITest { @Test - public void testPackages() throws CloudConductorException { + void testPackages() throws CloudConductorException { PackageHandler h = new PackageHandler(this.getCSApi(), this.getToken()); { Set set = h.get(); - Assert.assertEquals(6, set.size()); + Assertions.assertEquals(6, set.size()); } { Package pkg = h.get("nginx"); - Assert.assertEquals("nginx", pkg.getName()); - Assert.assertEquals("Auto-generated from repository selected on 2013-09-04 14:20:08.", pkg.getDescription()); + Assertions.assertEquals("nginx", pkg.getName()); + Assertions.assertEquals("Auto-generated from repository selected on 2013-09-04 14:20:08.", pkg.getDescription()); } } @Test - public void testVersion() throws CloudConductorException { + void testVersion() throws CloudConductorException { PackageHandler h = new PackageHandler(this.getCSApi(), this.getToken()); { Set rpms = h.getRPMS("nginx"); - Assert.assertEquals(1, rpms.size()); + Assertions.assertEquals(1, rpms.size()); PackageVersion pv = rpms.iterator().next(); - Assert.assertEquals("nginx", pv.getName()); - Assert.assertEquals("1.5.3-1", pv.getVersion()); + Assertions.assertEquals("nginx", pv.getName()); + Assertions.assertEquals("1.5.3-1", pv.getVersion()); } } } diff --git a/src/test/java/de/cinovo/cloudconductor/server/test/SSHKeyTest.java b/src/test/java/de/cinovo/cloudconductor/server/test/SSHKeyTest.java index 51476384..0efc8f92 100644 --- a/src/test/java/de/cinovo/cloudconductor/server/test/SSHKeyTest.java +++ b/src/test/java/de/cinovo/cloudconductor/server/test/SSHKeyTest.java @@ -21,10 +21,10 @@ import de.cinovo.cloudconductor.api.lib.manager.SSHKeyHandler; import de.cinovo.cloudconductor.api.model.SSHKey; import de.cinovo.cloudconductor.server.APITest; -import de.taimos.daemon.spring.SpringDaemonTestRunner; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import de.taimos.daemon.spring.SpringDaemonExtension; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import java.util.Set; @@ -36,12 +36,11 @@ * @author hoegertn * */ -@RunWith(SpringDaemonTestRunner.class) -@SuppressWarnings("javadoc") -public class SSHKeyTest extends APITest { +@ExtendWith(SpringDaemonExtension.class) +class SSHKeyTest extends APITest { @Test - public void test() throws CloudConductorException { + void test() throws CloudConductorException { String firstContent = "SSH key content"; String firstOwner = "foobar"; String newContent = "key content 2"; @@ -50,15 +49,15 @@ public void test() throws CloudConductorException { SSHKeyHandler handler = new SSHKeyHandler(this.getCSApi(), this.getToken()); { Set keys = handler.get(); - Assert.assertEquals(1, keys.size()); + Assertions.assertEquals(1, keys.size()); SSHKey key = keys.iterator().next(); - Assert.assertEquals(firstOwner, key.getOwner()); - Assert.assertEquals(firstContent, key.getKey()); + Assertions.assertEquals(firstOwner, key.getOwner()); + Assertions.assertEquals(firstContent, key.getKey()); } { SSHKey load = handler.get(firstOwner); - Assert.assertEquals(firstOwner, load.getOwner()); - Assert.assertEquals(firstContent, load.getKey()); + Assertions.assertEquals(firstOwner, load.getOwner()); + Assertions.assertEquals(firstContent, load.getKey()); } { SSHKey newKey = new SSHKey(newOwner, newContent); @@ -67,31 +66,31 @@ public void test() throws CloudConductorException { } { Set keys2 = handler.get(); - Assert.assertEquals(2, keys2.size()); + Assertions.assertEquals(2, keys2.size()); for (SSHKey sk : keys2) { if (sk.getOwner().equals(firstOwner)) { - Assert.assertEquals(firstContent, sk.getKey()); + Assertions.assertEquals(firstContent, sk.getKey()); } else if (sk.getOwner().equals(newOwner)) { - Assert.assertEquals(newContent, sk.getKey()); + Assertions.assertEquals(newContent, sk.getKey()); } else { - Assert.fail(); + Assertions.fail(); } } } { SSHKey load2 = handler.get(newOwner); - Assert.assertEquals(newOwner, load2.getOwner()); - Assert.assertEquals(newContent, load2.getKey()); + Assertions.assertEquals(newOwner, load2.getOwner()); + Assertions.assertEquals(newContent, load2.getKey()); } { handler.delete(newOwner); } { Set keys = handler.get(); - Assert.assertEquals(1, keys.size()); + Assertions.assertEquals(1, keys.size()); SSHKey key = keys.iterator().next(); - Assert.assertEquals(firstOwner, key.getOwner()); - Assert.assertEquals(firstContent, key.getKey()); + Assertions.assertEquals(firstOwner, key.getOwner()); + Assertions.assertEquals(firstContent, key.getKey()); } } diff --git a/src/test/java/de/cinovo/cloudconductor/server/test/ServiceTest.java b/src/test/java/de/cinovo/cloudconductor/server/test/ServiceTest.java index 7da13723..2d9680fe 100644 --- a/src/test/java/de/cinovo/cloudconductor/server/test/ServiceTest.java +++ b/src/test/java/de/cinovo/cloudconductor/server/test/ServiceTest.java @@ -22,10 +22,10 @@ import de.cinovo.cloudconductor.api.lib.manager.ServiceHandler; import de.cinovo.cloudconductor.api.model.Service; import de.cinovo.cloudconductor.server.APITest; -import de.taimos.daemon.spring.SpringDaemonTestRunner; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import de.taimos.daemon.spring.SpringDaemonExtension; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import java.util.Set; @@ -35,21 +35,20 @@ * * @author hoegertn */ -@RunWith(SpringDaemonTestRunner.class) -@SuppressWarnings("javadoc") -public class ServiceTest extends APITest { +@ExtendWith(SpringDaemonExtension.class) +class ServiceTest extends APITest { @Test - public void test1() throws CloudConductorException { + void test1() throws CloudConductorException { ServiceHandler h = new ServiceHandler(this.getCSApi(), this.getToken()); { Set set = h.get(); - Assert.assertEquals(3, set.size()); + Assertions.assertEquals(3, set.size()); } { Service svc = h.get("nginx"); - Assert.assertEquals("nginx", svc.getName()); - Assert.assertEquals("nginx", svc.getDescription()); + Assertions.assertEquals("nginx", svc.getName()); + Assertions.assertEquals("nginx", svc.getDescription()); } { Service s = new Service(); @@ -59,9 +58,9 @@ public void test1() throws CloudConductorException { s.setInitScript("svc1"); h.save(s); Set set = h.get(); - Assert.assertEquals(4, set.size()); + Assertions.assertEquals(4, set.size()); Service svc = h.get("svc1"); - Assert.assertEquals("svc1", svc.getName()); + Assertions.assertEquals("svc1", svc.getName()); } { Service s = new Service(); @@ -72,16 +71,16 @@ public void test1() throws CloudConductorException { s.setPackages(Sets.newHashSet("jdk")); h.save(s); Set set = h.get(); - Assert.assertEquals(5, set.size()); + Assertions.assertEquals(5, set.size()); Service svc = h.get("svc2"); - Assert.assertEquals("svc2", svc.getName()); - Assert.assertEquals(1, svc.getPackages().size()); + Assertions.assertEquals("svc2", svc.getName()); + Assertions.assertEquals(1, svc.getPackages().size()); } { h.delete("svc1"); h.delete("svc2"); Set set = h.get(); - Assert.assertEquals(3, set.size()); + Assertions.assertEquals(3, set.size()); } } diff --git a/src/test/java/de/cinovo/cloudconductor/server/test/TemplateTest.java b/src/test/java/de/cinovo/cloudconductor/server/test/TemplateTest.java index 31fee643..2ddef723 100644 --- a/src/test/java/de/cinovo/cloudconductor/server/test/TemplateTest.java +++ b/src/test/java/de/cinovo/cloudconductor/server/test/TemplateTest.java @@ -26,10 +26,10 @@ import de.cinovo.cloudconductor.api.model.Service; import de.cinovo.cloudconductor.api.model.Template; import de.cinovo.cloudconductor.server.APITest; -import de.taimos.daemon.spring.SpringDaemonTestRunner; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import de.taimos.daemon.spring.SpringDaemonExtension; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import java.util.ArrayList; import java.util.HashSet; @@ -42,24 +42,23 @@ * * @author hoegertn */ -@RunWith(SpringDaemonTestRunner.class) -@SuppressWarnings("javadoc") -public class TemplateTest extends APITest { +@ExtendWith(SpringDaemonExtension.class) +class TemplateTest extends APITest { private static final String TEMPLATE = "dev"; - private TemplateHandler h = new TemplateHandler(this.getCSApi(), this.getToken()); + private final TemplateHandler h = new TemplateHandler(this.getCSApi(), this.getToken()); @Test - public void testBasic() throws CloudConductorException { + void testBasic() throws CloudConductorException { this.delay(); { Set