Skip to content
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

Fix loose app tests for Windows #814

Merged
merged 2 commits into from
May 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
cherylking marked this conversation as resolved.
Show resolved Hide resolved
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{

cherylking marked this conversation as resolved.
Show resolved Hide resolved
// 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")) {
cherylking marked this conversation as resolved.
Show resolved Hide resolved
// 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)
}
}

}
}