Skip to content

Commit

Permalink
Fix loose app tests for Windows (#814)
Browse files Browse the repository at this point in the history
* Fix loose app tests for Windows

* Update GHA yml to run loose app tests on Windows
  • Loading branch information
mattbsox authored May 1, 2023
1 parent 27c9434 commit b2061d9
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ jobs:
- name: Run tests with Gradle on Windows
working-directory: C:/ci.gradle
# LibertyTest is excluded because test0_run hangs
run: ./gradlew clean install check -P"test.exclude"="**/Polling*,**/TestLoose*,**/LibertyTest*,**/GenerateFeaturesTest*" -Druntime=${{ matrix.RUNTIME }} -DruntimeVersion="${{ matrix.RUNTIME_VERSION }}" --stacktrace --info --no-daemon
run: ./gradlew clean install check -P"test.exclude"="**/Polling*,**/LibertyTest*,**/GenerateFeaturesTest*" -Druntime=${{ matrix.RUNTIME }} -DruntimeVersion="${{ matrix.RUNTIME_VERSION }}" --stacktrace --info --no-daemon
timeout-minutes: 75
# Copy build reports and upload artifact if build failed
- name: Copy build/report/tests/test for upload
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;

import io.openliberty.tools.common.plugins.util.OSUtil

public class TestLooseApplication extends AbstractIntegrationTest{
static File resourceDir = new File("build/resources/test/sample.servlet")
static File buildDir = new File(integTestDir, "/test-loose-application")
Expand Down Expand Up @@ -87,16 +89,24 @@ public class TestLooseApplication extends AbstractIntegrationTest{

// Check that dependencies are located in the test build dir specified by copyLibsDirectory. Otherwise they would be located in the gradle cache somewhere.
String nodeValue = nodes.item(0).getAttributes().getNamedItem("sourceOnDisk").getNodeValue();
assert nodeValue.endsWith("/commons-text-1.1.jar") && nodeValue.contains("/test-loose-application/build/libs/") : 'archive sourceOnDisk attribute value not correct'

if (OSUtil.isWindows()) {
Assert.assertTrue('archive sourceOnDisk attribute value not correct', nodeValue.endsWith("\\commons-text-1.1.jar") && nodeValue.contains("\\test-loose-application\\build\\libs\\"))
} else {
Assert.assertTrue('archive sourceOnDisk attribute value not correct', nodeValue.endsWith("/commons-text-1.1.jar") && nodeValue.contains("/test-loose-application/build/libs/"))
}

Assert.assertEquals("archive targetInArchive attribute value", "/WEB-INF/lib/commons-lang3-3.5.jar",
nodes.item(1).getAttributes().getNamedItem("targetInArchive").getNodeValue());

// Check that dependencies are located in the test build dir specified by copyLibsDirectory. Otherwise they would be located in the gradle cache somewhere.
nodeValue = nodes.item(1).getAttributes().getNamedItem("sourceOnDisk").getNodeValue();
assert nodeValue.endsWith("/commons-lang3-3.5.jar") && nodeValue.contains("/test-loose-application/build/libs/") : 'archive sourceOnDisk attribute value not correct'

if (OSUtil.isWindows()) {
Assert.assertTrue('archive sourceOnDisk attribute value not correct', nodeValue.endsWith("\\commons-lang3-3.5.jar") && nodeValue.contains("\\test-loose-application\\build\\libs\\"))
} else {
Assert.assertTrue('archive sourceOnDisk attribute value not correct', ("/commons-lang3-3.5.jar") && nodeValue.contains("/test-loose-application/build/libs/"))
}
}

@Test
Expand All @@ -114,6 +124,4 @@ public class TestLooseApplication extends AbstractIntegrationTest{
assert value != null : "keystore_password property not found"

}


}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;

import io.openliberty.tools.common.plugins.util.OSUtil

public class TestLooseApplicationWithWarTask extends AbstractIntegrationTest{
static File resourceDir = new File("build/resources/test/sample.servlet")
static File buildDir = new File(integTestDir, "/test-loose-application-with-war-tasks")
Expand Down Expand Up @@ -86,15 +88,23 @@ public class TestLooseApplicationWithWarTask extends AbstractIntegrationTest{

// Check that dependencies are not located in the test build dir since copyLibsDirectory not set. They will be located in the gradle cache somewhere.
String nodeValue = nodes.item(0).getAttributes().getNamedItem("sourceOnDisk").getNodeValue();
assert nodeValue.endsWith("/commons-text-1.1.jar") && !nodeValue.contains("/test-loose-application-with-war-tasks/") : 'archive sourceOnDisk attribute value not correct'

if (OSUtil.isWindows()) {
Assert.assertTrue('archive sourceOnDisk attribute value not correct', nodeValue.endsWith("\\commons-text-1.1.jar") && !nodeValue.contains("\\test-loose-application-with-war-tasks\\"))
} else {
Assert.assertTrue('archive sourceOnDisk attribute value not correct', nodeValue.endsWith("/commons-text-1.1.jar") && !nodeValue.contains("/test-loose-application-with-war-tasks/"))
}
Assert.assertEquals("archive targetInArchive attribute value", "/WEB-INF/lib/commons-lang3-3.5.jar",
nodes.item(1).getAttributes().getNamedItem("targetInArchive").getNodeValue());

// Check that dependencies are not located in the test build dir since copyLibsDirectory not set. They will be located in the gradle cache somewhere.
nodeValue = nodes.item(1).getAttributes().getNamedItem("sourceOnDisk").getNodeValue();
assert nodeValue.endsWith("/commons-lang3-3.5.jar") && !nodeValue.contains("/test-loose-application-with-war-tasks/") : 'archive sourceOnDisk attribute value not correct'

if (OSUtil.isWindows()) {
Assert.assertTrue('archive sourceOnDisk attribute value not correct', nodeValue.endsWith("\\commons-lang3-3.5.jar") && !nodeValue.contains("\\test-loose-application-with-war-tasks\\"))
} else {
Assert.assertTrue('archive sourceOnDisk attribute value not correct', nodeValue.endsWith("/commons-lang3-3.5.jar") && !nodeValue.contains("/test-loose-application-with-war-tasks/"))
}
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import org.w3c.dom.Node;
import java.net.HttpURLConnection;
import java.net.URL;

import io.openliberty.tools.common.plugins.util.OSUtil

public class TestLooseEarApplication extends AbstractIntegrationTest{
static File resourceDir = new File("build/resources/test/loose-ear-test")
static File buildDir = new File(integTestDir, "/test-loose-ear-application")
Expand Down Expand Up @@ -109,10 +111,13 @@ public class TestLooseEarApplication extends AbstractIntegrationTest{
if (node.getAttributes().getNamedItem("targetInArchive").getNodeValue().equals("/WEB-INF/lib/commons-text-1.1.jar")) {
// Check that dependencies are located in the test build dir specified by copyLibsDirectory. Otherwise they would be located in the gradle cache somewhere.
String nodeValue = node.getAttributes().getNamedItem("sourceOnDisk").getNodeValue();
Assert.assertTrue(nodeValue.endsWith("/commons-text-1.1.jar") && nodeValue.contains("/test-loose-ear-application/ejb-ear/build/libs/"))
if (OSUtil.isWindows()) {
Assert.assertTrue(nodeValue.endsWith("\\commons-text-1.1.jar") && nodeValue.contains("\\test-loose-ear-application\\ejb-ear\\build\\libs\\"))
} else {
Assert.assertTrue(nodeValue.endsWith("/commons-text-1.1.jar") && nodeValue.contains("/test-loose-ear-application/ejb-ear/build/libs/"))
}
}
}

}

@Test
Expand All @@ -129,5 +134,4 @@ public class TestLooseEarApplication extends AbstractIntegrationTest{
throw new AssertionError ("Fail on task libertyStart. "+ e)
}
}

}
}

0 comments on commit b2061d9

Please sign in to comment.