diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..d91ecf65 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,17 @@ +version: 2 +updates: +- package-ecosystem: maven + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 10 + ignore: + - dependency-name: org.testng:testng + versions: + - ">= 7.a" + - "< 8" +- package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" + diff --git a/.github/workflows/cd-config.yml b/.github/workflows/cd-config.yml new file mode 100644 index 00000000..dc7320b4 --- /dev/null +++ b/.github/workflows/cd-config.yml @@ -0,0 +1,43 @@ +name: GitHub CD + +on: + push: + branches: + - main + tags: + - ldp-testsuite-[0-9]+.[0-9]+.[0-9]+ + +jobs: + build: + name: Build environment + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v5 + - name: Set up JDK 8 + uses: actions/setup-java@v5 + with: + distribution: 'adopt' + java-version: 8 + + - name: Build with Maven + run: mvn -B -ntp install -Dgpg.skip -Dmaven.javadoc.skip + + - name: Create staging directory + run: mkdir -p ldp + + - name: Move shaded jar file + run: mv target/ldp-testsuite-*-shaded.jar ldp/ldp-testsuite.jar + + - name: Sync to AWS S3 + uses: jakejarvis/s3-sync-action@v0.5.1 + with: + args: --acl public-read + env: + AWS_S3_BUCKET: ${{ secrets.AWS_BUCKET }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_KEY }} + AWS_REGION: ${{ secrets.AWS_REGION }} + SOURCE_DIR: "ldp" + DEST_DIR: "ldp" + diff --git a/.github/workflows/ci-config.yml b/.github/workflows/ci-config.yml new file mode 100644 index 00000000..c61c222c --- /dev/null +++ b/.github/workflows/ci-config.yml @@ -0,0 +1,27 @@ +name: GitHub CI + +on: + push: + branches: + - main + - ldp-testsuite-[0-9]+.[0-9]+.x + pull_request: + branches: + - main + +jobs: + build: + name: CI environment + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v5 + - name: Set up JDK 8 + uses: actions/setup-java@v5 + with: + distribution: 'adopt' + java-version: 8 + + - name: Build with Maven + run: mvn -B -ntp install -Dgpg.skip -Dmaven.javadoc.skip + diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml new file mode 100644 index 00000000..a6bf4e06 --- /dev/null +++ b/.github/workflows/maven-publish.yml @@ -0,0 +1,27 @@ +name: Maven Package + +on: + release: + types: [created] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v5 + - name: Set up JDK 1.8 + uses: actions/setup-java@v5 + with: + java-version: 1.8 + server-id: github + settings-path: ${{ github.workspace }} + + - name: Build with Maven + run: mvn -B package -Dmaven.javadoc.skip -Dgpg.skip + + - name: Publish to GitHub Packages Apache Maven + run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml -Dgpg.skip -Dmaven.javadoc.skip + env: + GITHUB_TOKEN: ${{ github.token }} diff --git a/README.md b/README.md index 7bff1276..6a19e10f 100644 --- a/README.md +++ b/README.md @@ -1 +1,5 @@ -[Test Suite for Linked Data Platform 1.0](http://w3c.github.io/ldp-testsuite) +# Test Suite for the Linked Data Platform 1.0 + +![Build Status](https://github.com/trellis-ldp/ldp-testsuite/workflows/GitHub%20CI/badge.svg) + +This project is a fork of the [W3C LDP testsuite](http://w3c.github.io/ldp-testsuite). diff --git a/pom.xml b/pom.xml index f24097e7..e334e327 100644 --- a/pom.xml +++ b/pom.xml @@ -1,16 +1,9 @@ - + 4.0.0 - - org.sonatype.oss - oss-parent - 9 - - - org.w3 + org.trellisldp ldp-testsuite - 0.2.0-SNAPSHOT + 0.2.3-SNAPSHOT jar LDP Test Suite @@ -38,10 +31,11 @@ - scm:git:git@github.com:w3c/ldp-testsuite.git - scm:git:git@github.com:w3c/ldp-testsuite.git - git@github.com:w3c/ldp-testsuite.git - + scm:git:git@github.com:trellis-ldp/ldp-testsuite.git + scm:git:git@github.com:trellis-ldp/ldp-testsuite.git + git@github.com:trellis-ldp/ldp-testsuite.git + HEAD + UTF-8 @@ -56,20 +50,40 @@ + + org.apache.maven.plugins + maven-enforcer-plugin + 3.6.2 + + + enforce-maven + + enforce + + + + + 3.1 + + + + + + org.apache.maven.plugins maven-compiler-plugin - 3.1 + 3.14.1 ${project.build.sourceEncoding} - 1.7 - 1.7 + 1.8 + 1.8 org.apache.maven.plugins maven-jar-plugin - 2.4 + 3.4.2 true @@ -86,21 +100,31 @@ org.apache.maven.plugins maven-shade-plugin - 2.2 + 3.6.1 + + + *:* + + META-INF/DUMMY.DSA + META-INF/DUMMY.SF + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + + + true false - + ${app.main.class} ${project.build.sourceEncoding} ${project.build.sourceEncoding} - + @@ -115,7 +139,7 @@ org.apache.maven.plugins maven-source-plugin - 2.2.1 + 3.3.1 attach-sources @@ -129,7 +153,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 2.9.1 + 3.12.0 true @@ -143,27 +167,13 @@ - - org.apache.maven.plugins - maven-gpg-plugin - 1.5 - - - sign-artifacts - verify - - sign - - - - org.apache.maven.plugins maven-deploy-plugin - 2.8.1 + 3.1.4 - deploy + default-deploy deploy deploy @@ -174,14 +184,14 @@ org.apache.maven.plugins maven-surefire-plugin - 2.17 + 3.5.4 true maven-clean-plugin - 2.5 + 3.5.0 @@ -194,7 +204,7 @@ org.codehaus.mojo buildnumber-maven-plugin - 1.1 + 3.2.1 validate @@ -214,27 +224,27 @@ commons-cli commons-cli - 1.4 + 1.10.0 org.apache.commons commons-lang3 - 3.7 + 3.19.0 commons-io commons-io - 2.6 + 2.20.0 org.apache.marmotta marmotta-ldp - 3.3.0 + 3.4.0 org.testng testng - 6.14.2 + 6.14.3 com.jayway.restassured @@ -244,22 +254,22 @@ org.openrdf.sesame sesame-model - 2.7.11 + 4.1.2 org.apache.jena jena-arq - 3.6.0 + 3.17.0 org.rendersnake rendersnake - 1.8 + 1.9.0 org.jboss.resteasy resteasy-jaxrs - 3.5.0.Final + 3.15.6.Final log4j @@ -268,6 +278,14 @@ + + + github + GitHub Packages + https://maven.pkg.github.com/trellis-ldp/ldp-testsuite + + + test-manifest @@ -276,7 +294,7 @@ org.codehaus.mojo exec-maven-plugin - 1.1.1 + 3.6.1 generate-test-manifest-earl diff --git a/src/main/java/org/w3/ldp/paging/testsuite/tests/PagingTest.java b/src/main/java/org/w3/ldp/paging/testsuite/tests/PagingTest.java index 66aa323d..f0477244 100644 --- a/src/main/java/org/w3/ldp/paging/testsuite/tests/PagingTest.java +++ b/src/main/java/org/w3/ldp/paging/testsuite/tests/PagingTest.java @@ -8,6 +8,7 @@ import org.apache.commons.io.output.WriterOutputStream; import org.apache.commons.lang3.StringUtils; +import org.testng.annotations.AfterSuite; import org.testng.annotations.Optional; import org.testng.annotations.Parameters; import org.testng.annotations.Test; @@ -500,4 +501,17 @@ protected RequestSpecification buildBaseRequestSpecification() { return spec; } + @AfterSuite(alwaysRun = true) + public void commonTearDown() { + if (httpLog != null) { + httpLog.println(); + httpLog.flush(); + httpLog.close(); + } + if (skipLog != null) { + skipLog.println(); + skipLog.flush(); + skipLog.close(); + } + } } diff --git a/src/main/java/org/w3/ldp/paging/testsuite/tests/RunPagingTest.java b/src/main/java/org/w3/ldp/paging/testsuite/tests/RunPagingTest.java index 4abe5791..83271e6f 100644 --- a/src/main/java/org/w3/ldp/paging/testsuite/tests/RunPagingTest.java +++ b/src/main/java/org/w3/ldp/paging/testsuite/tests/RunPagingTest.java @@ -16,8 +16,8 @@ public class RunPagingTest { public static void main(String[] args){ Logger.getRootLogger().setLevel(Level.OFF); - options.addOptionGroup(LdpTestSuite.addCommonOptions()); - options.addOptionGroup(LdpTestSuite.addEarlOptions()); + LdpTestSuite.addCommonOptions().getOptions().forEach(options::addOption); + LdpTestSuite.addEarlOptions().getOptions().forEach(options::addOption); // Add classes we want to test final List classes = new ArrayList<>(); diff --git a/src/main/java/org/w3/ldp/testsuite/LdpTestSuite.java b/src/main/java/org/w3/ldp/testsuite/LdpTestSuite.java index c3a79051..079e30a2 100644 --- a/src/main/java/org/w3/ldp/testsuite/LdpTestSuite.java +++ b/src/main/java/org/w3/ldp/testsuite/LdpTestSuite.java @@ -12,7 +12,6 @@ import org.apache.commons.cli.HelpFormatter; import org.apache.commons.cli.Option; import org.apache.commons.cli.OptionBuilder; -import org.apache.commons.cli.OptionGroup; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; import org.apache.commons.lang3.StringUtils; @@ -453,8 +452,8 @@ private static void printEarlUsage(String missingArg) { } @SuppressWarnings("static-access") - public static OptionGroup addCommonOptions() { - OptionGroup common = new OptionGroup(); + public static Options addCommonOptions() { + Options common = new Options(); common.addOption(OptionBuilder.withLongOpt("server") .withDescription("server url to run the test suite").hasArg() .withArgName("server").isRequired().create()); @@ -502,8 +501,8 @@ public static OptionGroup addCommonOptions() { } @SuppressWarnings("static-access") - public static OptionGroup addEarlOptions() { - OptionGroup earl = new OptionGroup(); + public static Options addEarlOptions() { + Options earl = new Options(); // --earl dependent values earl.addOption(OptionBuilder .withLongOpt("software") diff --git a/src/main/java/org/w3/ldp/testsuite/RunLdpTestSuite.java b/src/main/java/org/w3/ldp/testsuite/RunLdpTestSuite.java index f51e3883..043c2cc8 100644 --- a/src/main/java/org/w3/ldp/testsuite/RunLdpTestSuite.java +++ b/src/main/java/org/w3/ldp/testsuite/RunLdpTestSuite.java @@ -13,8 +13,8 @@ public class RunLdpTestSuite { public static void main(String[] args) { Logger.getRootLogger().setLevel(Level.OFF); - options.addOptionGroup(LdpTestSuite.addCommonOptions()); - options.addOptionGroup(LdpTestSuite.addEarlOptions()); + LdpTestSuite.addCommonOptions().getOptions().forEach(options::addOption); + LdpTestSuite.addEarlOptions().getOptions().forEach(options::addOption); addContainerOptions(); addNonRdfOption(); diff --git a/src/main/java/org/w3/ldp/testsuite/annotations/SpecTest.java b/src/main/java/org/w3/ldp/testsuite/annotations/SpecTest.java index cad1d086..82c9af67 100644 --- a/src/main/java/org/w3/ldp/testsuite/annotations/SpecTest.java +++ b/src/main/java/org/w3/ldp/testsuite/annotations/SpecTest.java @@ -33,18 +33,20 @@ public static enum STATUS { /** * WG_CLARIFICATION - requires further clarification from the working group */ - WG_CLARIFICATION + WG_CLARIFICATION } ; /** * The URI of the spec + * @return the specification URI */ public String specRefUri() default "No Specification URI"; /** * The status of the test case, pending or approved + * @return the test case status */ public STATUS approval() default STATUS.WG_PENDING; @@ -59,11 +61,11 @@ public static enum METHOD { AUTOMATED, /** MANUAL - server test but not automated */ - MANUAL, - + MANUAL, + /** CLIENT_ONLY - test is only client-side, this test suite doesn't test it. */ CLIENT_ONLY, - + /** * INDIRECT - other test cases indirectly cover this test case */ @@ -72,6 +74,7 @@ public static enum METHOD { /** * Whether the test case itself has been implemented or not + * @return whether the test case has been implemented */ public METHOD testMethod() default METHOD.NOT_IMPLEMENTED; @@ -81,24 +84,27 @@ public static enum METHOD { * the comment can be used to describe whether the test only * covers part of the spec requirement * ie) Shared specRefUri + * @return the comment */ public String comment() default ""; - + /** * Steps needed to be taken to validate the test. For manual/client tests - * it specify the actions (step) what should be done to verify the result. + * it specify the actions (step) what should be done to verify the result. * For automation tests, it summarized what the automated test does. * @return String[] The steps */ public String[] steps() default {}; - + /** * List out the test class that covers an indirect test. + * @return the class name */ public Class[] coveredByTests() default {}; - + /** * List out the group values that covers the indirect test. + * @return the values for the indirect test */ public String[] coveredByGroups() default {}; diff --git a/src/main/java/org/w3/ldp/testsuite/matcher/HeaderMatchers.java b/src/main/java/org/w3/ldp/testsuite/matcher/HeaderMatchers.java index 52d5cf95..d03ec7b7 100644 --- a/src/main/java/org/w3/ldp/testsuite/matcher/HeaderMatchers.java +++ b/src/main/java/org/w3/ldp/testsuite/matcher/HeaderMatchers.java @@ -106,7 +106,7 @@ protected boolean matchesSafely(String item) { * @return the matcher */ public static Matcher isJsonLdCompatibleContentType() { - return new CustomTypeSafeMatcher("application/ld+json or application/json") { + return new CustomTypeSafeMatcher("application/ld+json") { @Override protected boolean matchesSafely(String item) { return item.equals(MediaTypes.APPLICATION_LD_JSON) || item.equals(MediaTypes.APPLICATION_JSON); diff --git a/src/main/java/org/w3/ldp/testsuite/reporter/LdpTestListener.java b/src/main/java/org/w3/ldp/testsuite/reporter/LdpTestListener.java index bc04fee8..e8ce6a95 100644 --- a/src/main/java/org/w3/ldp/testsuite/reporter/LdpTestListener.java +++ b/src/main/java/org/w3/ldp/testsuite/reporter/LdpTestListener.java @@ -53,13 +53,6 @@ protected void printErrorDetails(ITestResult tr) { errors.append(WordUtils.wrap(description, 78)); errors.append("\n"); } - - Throwable thrown = tr.getThrowable(); - if (thrown != null) { - errors.append("\n"); - errors.append(Utils.stackTrace(thrown, false)[0]); - errors.append("\n"); - } } @Override diff --git a/src/main/java/org/w3/ldp/testsuite/test/BasicContainerTest.java b/src/main/java/org/w3/ldp/testsuite/test/BasicContainerTest.java index 4a4a31a1..e5ebfafe 100644 --- a/src/main/java/org/w3/ldp/testsuite/test/BasicContainerTest.java +++ b/src/main/java/org/w3/ldp/testsuite/test/BasicContainerTest.java @@ -1,6 +1,7 @@ package org.w3.ldp.testsuite.test; import com.jayway.restassured.response.Response; +import org.testng.annotations.AfterSuite; import org.testng.annotations.BeforeClass; import org.testng.annotations.Optional; import org.testng.annotations.Parameters; @@ -88,4 +89,17 @@ protected String getResourceUri() { return basicContainer; } + @AfterSuite(alwaysRun = true) + public void commonTearDown() { + if (httpLog != null) { + httpLog.println(); + httpLog.flush(); + httpLog.close(); + } + if (skipLog != null) { + skipLog.println(); + skipLog.flush(); + skipLog.close(); + } + } } diff --git a/src/main/java/org/w3/ldp/testsuite/test/DirectContainerTest.java b/src/main/java/org/w3/ldp/testsuite/test/DirectContainerTest.java index 724b1d4a..eae0295f 100644 --- a/src/main/java/org/w3/ldp/testsuite/test/DirectContainerTest.java +++ b/src/main/java/org/w3/ldp/testsuite/test/DirectContainerTest.java @@ -5,6 +5,7 @@ import com.jayway.restassured.response.Header; import com.jayway.restassured.response.Response; import org.apache.http.HttpStatus; +import org.testng.annotations.AfterSuite; import org.testng.annotations.BeforeClass; import org.testng.annotations.Optional; import org.testng.annotations.Parameters; @@ -418,4 +419,17 @@ protected String getResourceUri() { return directContainer; } + @AfterSuite(alwaysRun = true) + public void commonTearDown() { + if (httpLog != null) { + httpLog.println(); + httpLog.flush(); + httpLog.close(); + } + if (skipLog != null) { + skipLog.println(); + skipLog.flush(); + skipLog.close(); + } + } } diff --git a/src/main/java/org/w3/ldp/testsuite/test/IndirectContainerTest.java b/src/main/java/org/w3/ldp/testsuite/test/IndirectContainerTest.java index 82459179..a49b88aa 100644 --- a/src/main/java/org/w3/ldp/testsuite/test/IndirectContainerTest.java +++ b/src/main/java/org/w3/ldp/testsuite/test/IndirectContainerTest.java @@ -10,6 +10,7 @@ import com.jayway.restassured.response.Response; import org.apache.http.HttpStatus; +import org.testng.annotations.AfterSuite; import org.testng.annotations.BeforeClass; import org.testng.annotations.Optional; import org.testng.annotations.Parameters; @@ -250,4 +251,17 @@ protected Model getDefaultModel() { return model; } + @AfterSuite(alwaysRun = true) + public void commonTearDown() { + if (httpLog != null) { + httpLog.println(); + httpLog.flush(); + httpLog.close(); + } + if (skipLog != null) { + skipLog.println(); + skipLog.flush(); + skipLog.close(); + } + } } diff --git a/src/main/java/org/w3/ldp/testsuite/test/LdpTest.java b/src/main/java/org/w3/ldp/testsuite/test/LdpTest.java index 6d194f10..efd0d242 100644 --- a/src/main/java/org/w3/ldp/testsuite/test/LdpTest.java +++ b/src/main/java/org/w3/ldp/testsuite/test/LdpTest.java @@ -14,7 +14,6 @@ import org.apache.commons.lang3.StringUtils; import org.apache.marmotta.commons.vocabulary.LDP; import org.jboss.resteasy.plugins.delegates.LinkDelegate; -import org.testng.annotations.AfterSuite; import org.testng.annotations.BeforeSuite; import org.testng.annotations.Optional; import org.testng.annotations.Parameters; @@ -69,7 +68,8 @@ public abstract class LdpTest { /** * Builds a model from a turtle representation in a file - * @param path + * @param path the path + * @return the model */ protected Model readModel(String path) { Model model = null; @@ -106,8 +106,11 @@ protected Model readModel(String path) { * at the beginning of the test suite, so postModel static field * will be assigned once too. * + * @param outputDir the output directory * @param postTtl the resource with Turtle content to use for POST requests * @param httpLogging whether to log HTTP request and response details on errors + * @param skipLogging whether to skip logging + * @throws IOException if an I/O exception occurs during setup */ @BeforeSuite(alwaysRun = true) @Parameters({"output", "postTtl", "httpLogging", "skipLogging"}) @@ -122,7 +125,7 @@ public void commonSetup(@Optional String outputDir, @Optional String postTtl, @O if (outputDir == null || outputDir.length() == 0) outputDir = LdpTestSuite.OUTPUT_DIR; - + File dir = new File(outputDir); dir.mkdirs(); @@ -152,20 +155,6 @@ public void commonSetup(@Optional String outputDir, @Optional String postTtl, @O } - @AfterSuite(alwaysRun = true) - public void commonTearDown() { - if (httpLog != null) { - httpLog.println(); - httpLog.flush(); - httpLog.close(); - } - if (skipLog != null) { - skipLog.println(); - skipLog.flush(); - skipLog.close(); - } - } - /** * An absolute requirement of the specification. * @@ -237,9 +226,9 @@ protected Model getDefaultModel() { * don't always match the request-URI. This attempts to resolve to the appropriate * resource for the request-URI. This method is used to determine which subject * URI should be used to assign new triples to for tests such as PUT. - * - * @param model - * @param location + * + * @param model the model + * @param location the location * @return Resource primary from model */ protected Resource getPrimaryTopic(Model model, String location) { @@ -292,6 +281,7 @@ protected boolean restrictionsOnPostContent() { * @param response * the HTTP response * @see RFC 5988 + * @return whether the expected link header is present */ protected boolean containsLinkHeader( String linkContext, diff --git a/src/main/java/org/w3/ldp/testsuite/test/MemberResourceTest.java b/src/main/java/org/w3/ldp/testsuite/test/MemberResourceTest.java index e67cc6c5..5fd0382e 100644 --- a/src/main/java/org/w3/ldp/testsuite/test/MemberResourceTest.java +++ b/src/main/java/org/w3/ldp/testsuite/test/MemberResourceTest.java @@ -102,5 +102,15 @@ public void deleteTestResource() { if (container != null) { buildBaseRequestSpecification().delete(memberResource); } + if (httpLog != null) { + httpLog.println(); + httpLog.flush(); + httpLog.close(); + } + if (skipLog != null) { + skipLog.println(); + skipLog.flush(); + skipLog.close(); + } } } diff --git a/src/main/java/org/w3/ldp/testsuite/test/NonRDFSourceTest.java b/src/main/java/org/w3/ldp/testsuite/test/NonRDFSourceTest.java index 4e82989f..4d45200c 100644 --- a/src/main/java/org/w3/ldp/testsuite/test/NonRDFSourceTest.java +++ b/src/main/java/org/w3/ldp/testsuite/test/NonRDFSourceTest.java @@ -215,7 +215,7 @@ public void testPostResourceGetMetadataAndBinary() throws IOException { String location = response.getHeader(LOCATION); try { - String associatedRdfSource = getFirstLinkForRelation(location, LINK_REL_DESCRIBEDBY, container, response); + String associatedRdfSource = getFirstLinkForRelation(location, LINK_REL_DESCRIBEDBY, location, response); Assert.assertNotNull(associatedRdfSource, "No Link response header with relation \"describedby\" " + "and anchor parameter matching the newly-created resource URI"); @@ -364,7 +364,7 @@ public void testDeleteNonRDFSourceDeletesAssociatedResource() throws IOException boolean deleted = false; try { - String associatedRdfSource = getFirstLinkForRelation(location, LINK_REL_DESCRIBEDBY, container, postResponse); + String associatedRdfSource = getFirstLinkForRelation(location, LINK_REL_DESCRIBEDBY, location, postResponse); Assert.assertNotNull(associatedRdfSource, "No Link response header with relation \"describedby\" " + "and anchor parameter matching the newly-created resource URI"); @@ -434,7 +434,7 @@ public void testOptionsHasSameLinkHeader() throws IOException { String location = postResponse.getHeader(LOCATION); try { - String associatedRdfSource = getFirstLinkForRelation(location, LINK_REL_DESCRIBEDBY, container, postResponse); + String associatedRdfSource = getFirstLinkForRelation(location, LINK_REL_DESCRIBEDBY, location, postResponse); Assert.assertNotNull(associatedRdfSource, "No Link response header with relation \"describedby\" " + "and anchor parameter matching the newly-created resource URI");