From a3cabd99dfb2e39f95954ea5e462150197b82784 Mon Sep 17 00:00:00 2001 From: Michael Seaton Date: Mon, 18 Nov 2024 15:14:09 -0500 Subject: [PATCH] SDK-357 - Follow maven recommended best practices for unit and integration tests (#309) --- integration-tests/pom.xml | 24 +++++++++++++++++++ ...ntegrationTest.java => AbstractSdkIT.java} | 3 +-- ...pendencyTest.java => AddDependencyIT.java} | 4 +--- ...tegrationTest.java => AddExclusionIT.java} | 2 +- ...ntegrationTest.java => BuildDistroIT.java} | 2 +- ...BuildIntegrationTest.java => BuildIT.java} | 2 +- ...CloneIntegrationTest.java => CloneIT.java} | 2 +- ...egrationTest.java => CreateProjectIT.java} | 2 +- ...ployIntegrationTest.java => DeployIT.java} | 3 +-- ...FetchIntegrationTest.java => FetchIT.java} | 2 +- .../{PullIntegrationTest.java => PullIT.java} | 2 +- ...dencyTest.java => RemoveDependencyIT.java} | 2 +- ...ResetIntegrationTest.java => ResetIT.java} | 11 +-------- ...SetupIntegrationTest.java => SetupIT.java} | 4 ++-- pom.xml | 8 +++++-- 15 files changed, 44 insertions(+), 29 deletions(-) rename integration-tests/src/test/java/org/openmrs/maven/plugins/{AbstractSdkIntegrationTest.java => AbstractSdkIT.java} (99%) rename integration-tests/src/test/java/org/openmrs/maven/plugins/{AddDependencyTest.java => AddDependencyIT.java} (97%) rename integration-tests/src/test/java/org/openmrs/maven/plugins/{AddExclusionIntegrationTest.java => AddExclusionIT.java} (98%) rename integration-tests/src/test/java/org/openmrs/maven/plugins/{BuildDistroIntegrationTest.java => BuildDistroIT.java} (98%) rename integration-tests/src/test/java/org/openmrs/maven/plugins/{BuildIntegrationTest.java => BuildIT.java} (96%) rename integration-tests/src/test/java/org/openmrs/maven/plugins/{CloneIntegrationTest.java => CloneIT.java} (95%) rename integration-tests/src/test/java/org/openmrs/maven/plugins/{CreateProjectIntegrationTest.java => CreateProjectIT.java} (98%) rename integration-tests/src/test/java/org/openmrs/maven/plugins/{DeployIntegrationTest.java => DeployIT.java} (98%) rename integration-tests/src/test/java/org/openmrs/maven/plugins/{FetchIntegrationTest.java => FetchIT.java} (97%) rename integration-tests/src/test/java/org/openmrs/maven/plugins/{PullIntegrationTest.java => PullIT.java} (97%) rename integration-tests/src/test/java/org/openmrs/maven/plugins/{RemoveDependencyTest.java => RemoveDependencyIT.java} (93%) rename integration-tests/src/test/java/org/openmrs/maven/plugins/{ResetIntegrationTest.java => ResetIT.java} (63%) rename integration-tests/src/test/java/org/openmrs/maven/plugins/{SetupIntegrationTest.java => SetupIT.java} (99%) diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index 582e7a6c4..5e557da6b 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -47,4 +47,28 @@ semver4j + + + + integration-tests + + + + org.apache.maven.plugins + maven-failsafe-plugin + 3.1.2 + + + + integration-test + verify + + + + + + + + + diff --git a/integration-tests/src/test/java/org/openmrs/maven/plugins/AbstractSdkIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/maven/plugins/AbstractSdkIT.java similarity index 99% rename from integration-tests/src/test/java/org/openmrs/maven/plugins/AbstractSdkIntegrationTest.java rename to integration-tests/src/test/java/org/openmrs/maven/plugins/AbstractSdkIT.java index 5a81f35a6..a9f8bbeac 100644 --- a/integration-tests/src/test/java/org/openmrs/maven/plugins/AbstractSdkIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/maven/plugins/AbstractSdkIT.java @@ -1,7 +1,6 @@ package org.openmrs.maven.plugins; import org.apache.commons.io.FileUtils; -import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; import org.apache.maven.it.VerificationException; import org.apache.maven.it.Verifier; @@ -48,7 +47,7 @@ @RunWith(BlockJUnit4ClassRunner.class) -public abstract class AbstractSdkIntegrationTest { +public abstract class AbstractSdkIT { /** * contains name of directory in project's target dir, where integration tests are conducted diff --git a/integration-tests/src/test/java/org/openmrs/maven/plugins/AddDependencyTest.java b/integration-tests/src/test/java/org/openmrs/maven/plugins/AddDependencyIT.java similarity index 97% rename from integration-tests/src/test/java/org/openmrs/maven/plugins/AddDependencyTest.java rename to integration-tests/src/test/java/org/openmrs/maven/plugins/AddDependencyIT.java index dd6292432..de67c1b01 100644 --- a/integration-tests/src/test/java/org/openmrs/maven/plugins/AddDependencyTest.java +++ b/integration-tests/src/test/java/org/openmrs/maven/plugins/AddDependencyIT.java @@ -4,13 +4,11 @@ import org.openmrs.maven.plugins.model.DistroProperties; import org.openmrs.maven.plugins.utility.DistroHelper; -import java.io.File; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -public class AddDependencyTest extends AbstractSdkIntegrationTest { +public class AddDependencyIT extends AbstractSdkIT { @Test public void shouldAddOmodDependency() throws Exception { diff --git a/integration-tests/src/test/java/org/openmrs/maven/plugins/AddExclusionIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/maven/plugins/AddExclusionIT.java similarity index 98% rename from integration-tests/src/test/java/org/openmrs/maven/plugins/AddExclusionIntegrationTest.java rename to integration-tests/src/test/java/org/openmrs/maven/plugins/AddExclusionIT.java index 003c08cf0..5fb02863e 100644 --- a/integration-tests/src/test/java/org/openmrs/maven/plugins/AddExclusionIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/maven/plugins/AddExclusionIT.java @@ -12,7 +12,7 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; -public class AddExclusionIntegrationTest extends AbstractSdkIntegrationTest { +public class AddExclusionIT extends AbstractSdkIT { public DistroProperties getDistroProperties() { return DistroHelper.getDistroPropertiesFromFile(distroFile); diff --git a/integration-tests/src/test/java/org/openmrs/maven/plugins/BuildDistroIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/maven/plugins/BuildDistroIT.java similarity index 98% rename from integration-tests/src/test/java/org/openmrs/maven/plugins/BuildDistroIntegrationTest.java rename to integration-tests/src/test/java/org/openmrs/maven/plugins/BuildDistroIT.java index b95b681ff..56d2f8de4 100644 --- a/integration-tests/src/test/java/org/openmrs/maven/plugins/BuildDistroIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/maven/plugins/BuildDistroIT.java @@ -2,7 +2,7 @@ import org.junit.Test; -public class BuildDistroIntegrationTest extends AbstractSdkIntegrationTest { +public class BuildDistroIT extends AbstractSdkIT { @Test public void testBuildDistroFromDistroFile() throws Exception { diff --git a/integration-tests/src/test/java/org/openmrs/maven/plugins/BuildIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/maven/plugins/BuildIT.java similarity index 96% rename from integration-tests/src/test/java/org/openmrs/maven/plugins/BuildIntegrationTest.java rename to integration-tests/src/test/java/org/openmrs/maven/plugins/BuildIT.java index b879d1abc..aecce120e 100644 --- a/integration-tests/src/test/java/org/openmrs/maven/plugins/BuildIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/maven/plugins/BuildIT.java @@ -8,7 +8,7 @@ import java.io.File; -public class BuildIntegrationTest extends AbstractSdkIntegrationTest { +public class BuildIT extends AbstractSdkIT { private String serverId; diff --git a/integration-tests/src/test/java/org/openmrs/maven/plugins/CloneIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/maven/plugins/CloneIT.java similarity index 95% rename from integration-tests/src/test/java/org/openmrs/maven/plugins/CloneIntegrationTest.java rename to integration-tests/src/test/java/org/openmrs/maven/plugins/CloneIT.java index f65e41bfa..3ba86dc7e 100644 --- a/integration-tests/src/test/java/org/openmrs/maven/plugins/CloneIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/maven/plugins/CloneIT.java @@ -11,7 +11,7 @@ import static org.hamcrest.CoreMatchers.hasItem; import static org.hamcrest.MatcherAssert.assertThat; -public class CloneIntegrationTest extends AbstractSdkIntegrationTest { +public class CloneIT extends AbstractSdkIT { @Test public void clone_shouldCloneRepository() throws Exception { diff --git a/integration-tests/src/test/java/org/openmrs/maven/plugins/CreateProjectIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/maven/plugins/CreateProjectIT.java similarity index 98% rename from integration-tests/src/test/java/org/openmrs/maven/plugins/CreateProjectIntegrationTest.java rename to integration-tests/src/test/java/org/openmrs/maven/plugins/CreateProjectIT.java index 974ff87f5..9112f5fa4 100644 --- a/integration-tests/src/test/java/org/openmrs/maven/plugins/CreateProjectIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/maven/plugins/CreateProjectIT.java @@ -5,7 +5,7 @@ import org.junit.Before; import org.junit.Test; -public class CreateProjectIntegrationTest extends AbstractSdkIntegrationTest { +public class CreateProjectIT extends AbstractSdkIT { Model model; diff --git a/integration-tests/src/test/java/org/openmrs/maven/plugins/DeployIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/maven/plugins/DeployIT.java similarity index 98% rename from integration-tests/src/test/java/org/openmrs/maven/plugins/DeployIntegrationTest.java rename to integration-tests/src/test/java/org/openmrs/maven/plugins/DeployIT.java index 69bedf426..cb87c0c7d 100644 --- a/integration-tests/src/test/java/org/openmrs/maven/plugins/DeployIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/maven/plugins/DeployIT.java @@ -1,6 +1,5 @@ package org.openmrs.maven.plugins; -import org.junit.After; import org.junit.Before; import org.junit.Test; import org.openmrs.maven.plugins.model.Artifact; @@ -16,7 +15,7 @@ import static org.openmrs.maven.plugins.SdkMatchers.hasUserOwa; import static org.openmrs.maven.plugins.SdkMatchers.serverHasVersion; -public class DeployIntegrationTest extends AbstractSdkIntegrationTest { +public class DeployIT extends AbstractSdkIT { private static String testServerId; diff --git a/integration-tests/src/test/java/org/openmrs/maven/plugins/FetchIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/maven/plugins/FetchIT.java similarity index 97% rename from integration-tests/src/test/java/org/openmrs/maven/plugins/FetchIntegrationTest.java rename to integration-tests/src/test/java/org/openmrs/maven/plugins/FetchIT.java index c7c17a0ee..6829dc2e8 100644 --- a/integration-tests/src/test/java/org/openmrs/maven/plugins/FetchIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/maven/plugins/FetchIT.java @@ -5,7 +5,7 @@ import java.io.File; -public class FetchIntegrationTest extends AbstractSdkIntegrationTest{ +public class FetchIT extends AbstractSdkIT { private final static String FETCH_DIRECTORY_NAME = "fetch"; diff --git a/integration-tests/src/test/java/org/openmrs/maven/plugins/PullIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/maven/plugins/PullIT.java similarity index 97% rename from integration-tests/src/test/java/org/openmrs/maven/plugins/PullIntegrationTest.java rename to integration-tests/src/test/java/org/openmrs/maven/plugins/PullIT.java index cb8b0239b..602a0dda7 100644 --- a/integration-tests/src/test/java/org/openmrs/maven/plugins/PullIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/maven/plugins/PullIT.java @@ -11,7 +11,7 @@ import java.io.File; -public class PullIntegrationTest extends AbstractSdkIntegrationTest { +public class PullIT extends AbstractSdkIT { private static final String OPENMRS_MODULE_IDGEN = "openmrs-module-idgen"; private static final String PULL_GOAL = "pull"; diff --git a/integration-tests/src/test/java/org/openmrs/maven/plugins/RemoveDependencyTest.java b/integration-tests/src/test/java/org/openmrs/maven/plugins/RemoveDependencyIT.java similarity index 93% rename from integration-tests/src/test/java/org/openmrs/maven/plugins/RemoveDependencyTest.java rename to integration-tests/src/test/java/org/openmrs/maven/plugins/RemoveDependencyIT.java index ff914ec0b..56006bb86 100644 --- a/integration-tests/src/test/java/org/openmrs/maven/plugins/RemoveDependencyTest.java +++ b/integration-tests/src/test/java/org/openmrs/maven/plugins/RemoveDependencyIT.java @@ -8,7 +8,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -public class RemoveDependencyTest extends AbstractSdkIntegrationTest { +public class RemoveDependencyIT extends AbstractSdkIT { @Test public void shouldRemoveExistingDependency() throws Exception { diff --git a/integration-tests/src/test/java/org/openmrs/maven/plugins/ResetIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/maven/plugins/ResetIT.java similarity index 63% rename from integration-tests/src/test/java/org/openmrs/maven/plugins/ResetIntegrationTest.java rename to integration-tests/src/test/java/org/openmrs/maven/plugins/ResetIT.java index 5604dc245..584489c04 100644 --- a/integration-tests/src/test/java/org/openmrs/maven/plugins/ResetIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/maven/plugins/ResetIT.java @@ -1,17 +1,8 @@ package org.openmrs.maven.plugins; -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.MatcherAssert.assertThat; - -import java.nio.charset.StandardCharsets; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.UUID; - -import org.apache.commons.io.FileUtils; import org.junit.Test; -public class ResetIntegrationTest extends AbstractSdkIntegrationTest { +public class ResetIT extends AbstractSdkIT { @Test public void reset_shouldResetExistingServer() throws Exception { diff --git a/integration-tests/src/test/java/org/openmrs/maven/plugins/SetupIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/maven/plugins/SetupIT.java similarity index 99% rename from integration-tests/src/test/java/org/openmrs/maven/plugins/SetupIntegrationTest.java rename to integration-tests/src/test/java/org/openmrs/maven/plugins/SetupIT.java index 2e0954d69..fce980a33 100644 --- a/integration-tests/src/test/java/org/openmrs/maven/plugins/SetupIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/maven/plugins/SetupIT.java @@ -23,11 +23,11 @@ import static org.openmrs.maven.plugins.SdkMatchers.hasPropertyEqualTo; import static org.openmrs.maven.plugins.SdkMatchers.hasPropertyThatContains; import static org.openmrs.maven.plugins.SdkMatchers.hasPropertyThatNotContains; -import static org.openmrs.maven.plugins.SdkMatchers.serverHasName; import static org.openmrs.maven.plugins.SdkMatchers.serverHasDebugPort; +import static org.openmrs.maven.plugins.SdkMatchers.serverHasName; import static org.openmrs.maven.plugins.SdkMatchers.serverHasVersion; -public class SetupIntegrationTest extends AbstractSdkIntegrationTest { +public class SetupIT extends AbstractSdkIT { @Test public void setup_shouldInstallRefapp2_3_1() throws Exception{ diff --git a/pom.xml b/pom.xml index ad36cdc90..cdad7b6a0 100644 --- a/pom.xml +++ b/pom.xml @@ -530,6 +530,10 @@ maven-gpg-plugin 3.1.0 + org.apache.maven.plugins maven-surefire-plugin @@ -550,7 +554,7 @@ org.apache.maven.plugins maven-source-plugin - 3.3.0 + 3.2.1 attach-sources @@ -563,7 +567,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.5.0 + 3.4.1 attach-javadocs