-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SDK-354 - Fixing bugs and adding test cases for the AddExclusions goal (
#306)
- Loading branch information
Showing
14 changed files
with
387 additions
and
101 deletions.
There are no files selected for viewing
79 changes: 70 additions & 9 deletions
79
integration-tests/src/test/java/org/openmrs/maven/plugins/AddExclusionIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,88 @@ | ||
package org.openmrs.maven.plugins; | ||
|
||
import org.apache.commons.io.FileUtils; | ||
import org.junit.Test; | ||
import org.openmrs.maven.plugins.model.DistroProperties; | ||
import org.openmrs.maven.plugins.utility.DistroHelper; | ||
|
||
import java.io.File; | ||
|
||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertNull; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
public class AddExclusionIntegrationTest extends AbstractSdkIntegrationTest { | ||
|
||
public DistroProperties getDistroProperties() { | ||
return DistroHelper.getDistroPropertiesFromFile(distroFile); | ||
} | ||
|
||
@Test | ||
public void shouldAddExclusionIfNoParentDefined() throws Exception { | ||
includeDistroPropertiesFile("openmrs-distro.properties"); | ||
assertNotNull(getDistroProperties()); | ||
assertNull(getDistroProperties().getParentDistroArtifact()); | ||
assertTrue(getDistroProperties().getExclusions().isEmpty()); | ||
executeExclusionTask(distroFile, "omod.uicommons"); | ||
assertNotNull(getDistroProperties()); | ||
assertTrue(getDistroProperties().getExclusions().contains("omod.uicommons")); | ||
assertTrue(getLogContents().contains(AddExclusion.WARNING_NO_PARENT_DISTRO)); | ||
} | ||
|
||
@Test | ||
public void shouldAddExclusion() throws Exception { | ||
DistroProperties distroProperties = DistroHelper.getDistroPropertiesFromFile(distroFile); | ||
assertNotNull(distroProperties); | ||
assertFalse(distroProperties.getExclusions().contains("omod.uicommons")); | ||
public void shouldAddExclusionForPropertyContainedInParent() throws Exception { | ||
includeDistroPropertiesFile("openmrs-distro-parent-as-parent.properties"); | ||
assertNotNull(getDistroProperties()); | ||
assertNotNull(getDistroProperties().getParentDistroArtifact()); | ||
assertTrue(getDistroProperties().getExclusions().isEmpty()); | ||
executeExclusionTask(distroFile, "omod.uicommons"); | ||
assertNotNull(getDistroProperties()); | ||
assertTrue(getDistroProperties().getExclusions().contains("omod.uicommons")); | ||
assertFalse(getLogContents().contains(AddExclusion.WARNING_NO_PARENT_DISTRO)); | ||
assertFalse(getLogContents().contains(AddExclusion.WARNING_PROPERTY_NOT_IN_PARENT)); | ||
} | ||
|
||
addTaskParam("distro", distroFile.getAbsolutePath()); | ||
addTaskParam("property", "omod.uicommons"); | ||
executeTask("exclusion"); | ||
@Test | ||
public void shouldAddExclusionForPropertyContainedInDistro() throws Exception { | ||
includeDistroPropertiesFile("openmrs-distro-parent-as-distro.properties"); | ||
assertNotNull(getDistroProperties()); | ||
assertNotNull(getDistroProperties().getParentDistroArtifact()); | ||
assertTrue(getDistroProperties().getExclusions().isEmpty()); | ||
executeExclusionTask(distroFile, "omod.uicommons"); | ||
assertNotNull(getDistroProperties()); | ||
assertTrue(getDistroProperties().getExclusions().contains("omod.uicommons")); | ||
assertFalse(getLogContents().contains(AddExclusion.WARNING_NO_PARENT_DISTRO)); | ||
assertFalse(getLogContents().contains(AddExclusion.WARNING_PROPERTY_NOT_IN_PARENT)); | ||
} | ||
|
||
@Test | ||
public void shouldAddExclusionForPropertyNotContainedInParent() throws Exception { | ||
includeDistroPropertiesFile("openmrs-distro-parent-as-parent.properties"); | ||
assertNotNull(getDistroProperties()); | ||
assertNotNull(getDistroProperties().getParentDistroArtifact()); | ||
assertTrue(getDistroProperties().getExclusions().isEmpty()); | ||
executeExclusionTask(distroFile, "omod.invalidmodulename"); | ||
assertNotNull(getDistroProperties()); | ||
assertTrue(getDistroProperties().getExclusions().contains("omod.invalidmodulename")); | ||
assertFalse(getLogContents().contains(AddExclusion.WARNING_NO_PARENT_DISTRO)); | ||
assertTrue(getLogContents().contains(AddExclusion.WARNING_PROPERTY_NOT_IN_PARENT)); | ||
} | ||
|
||
private String getLogContents() throws Exception { | ||
File logFile = new File(testDirectory, "log.txt"); | ||
assertTrue(logFile.exists()); | ||
return FileUtils.readFileToString(logFile, "UTF-8"); | ||
} | ||
|
||
private void executeExclusionTask(File distroFile, String exclusion) throws Exception { | ||
if (distroFile != null) { | ||
addTaskParam("distro", distroFile.getAbsolutePath()); | ||
} | ||
if (exclusion != null) { | ||
addTaskParam("property", exclusion); | ||
} | ||
executeTask("exclusion"); | ||
assertSuccess(); | ||
distroProperties = DistroHelper.getDistroPropertiesFromFile(distroFile); | ||
assertTrue(distroProperties.getExclusions().contains("omod.uicommons")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
...tion-tests/src/test/resources/integration-test/openmrs-distro-parent-as-distro.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
name=Spa Artifact Example | ||
version=2.5 | ||
distro.referenceapplication=2.6.1 | ||
omod.htmlformentry=3.3.1 | ||
db.h2.supported=false |
8 changes: 8 additions & 0 deletions
8
...tion-tests/src/test/resources/integration-test/openmrs-distro-parent-as-parent.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
name=Spa Artifact Example | ||
version=2.5 | ||
parent.groupId=org.openmrs.distro | ||
parent.artifactId=referenceapplication-package | ||
parent.version=2.6.1 | ||
parent.type=jar | ||
omod.htmlformentry=3.3.1 | ||
db.h2.supported=false |
7 changes: 0 additions & 7 deletions
7
...gration-tests/src/test/resources/integration-test/openmrs-distro-parent-distro.properties
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
...gration-tests/src/test/resources/integration-test/openmrs-distro-spa-artifacts.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,9 @@ | ||
name=Spa Artifact Example | ||
version=1.0.0-SNAPSHOT | ||
|
||
war.openmrs=2.6.9 | ||
|
||
omod.spa=2.0.0 | ||
|
||
spa.artifactId=openmrs-frontend-zl | ||
spa.groupId=org.pih.openmrs | ||
spa.version=1.3.0 | ||
spa.includes=openmrs-frontend-zl-1.3.0 | ||
|
||
db.h2.supported=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.