Skip to content
This repository was archived by the owner on Jan 23, 2024. It is now read-only.

Commit c6810e3

Browse files
committed
Make PagingTest concrete class so it can be run from Eclipse TestNG runner
1 parent 1296381 commit c6810e3

File tree

1 file changed

+48
-2
lines changed

1 file changed

+48
-2
lines changed

src/main/java/org/w3/ldp/paging/testsuite/tests/PagingTest.java

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
11
package org.w3.ldp.paging.testsuite.tests;
22

3+
import static com.jayway.restassured.config.LogConfig.logConfig;
4+
5+
import java.io.IOException;
6+
import java.io.PrintStream;
7+
import java.util.Map;
8+
9+
import org.apache.commons.io.output.WriterOutputStream;
10+
import org.apache.commons.lang3.StringUtils;
11+
import org.testng.annotations.Optional;
12+
import org.testng.annotations.Parameters;
313
import org.testng.annotations.Test;
414
import org.w3.ldp.testsuite.annotations.SpecTest;
515
import org.w3.ldp.testsuite.annotations.SpecTest.METHOD;
616
import org.w3.ldp.testsuite.annotations.SpecTest.STATUS;
717
import org.w3.ldp.testsuite.test.LdpTest;
818

9-
public abstract class PagingTest extends LdpTest{
19+
import com.google.common.collect.ImmutableMap;
20+
import com.jayway.restassured.RestAssured;
21+
import com.jayway.restassured.specification.RequestSpecification;
22+
23+
public class PagingTest extends LdpTest{
1024

1125
public static final String PAGING = "PAGING";
1226
public static final String SPEC_URI = "https://dvcs.w3.org/hg/ldpwg/raw-file/default/ldp-paging.html";
@@ -446,12 +460,44 @@ public void testSortCollation() {
446460
+ "page-ordering values for which [sparql11-query] does not use collations.")
447461
@SpecTest(
448462
specRefUri = SPEC_URI + "#ldpc-sortcollation",
449-
testMethod = METHOD.NOT_IMPLEMENTED,
463+
testMethod = METHOD.AUTOMATED,
450464
approval = STATUS.WG_PENDING)
451465
public void testRestrictCollation() {
452466
// TODO: Impl testRestrictCollation
453467
// "Covers only part of the specification
454468
// requirement. testSortCollation covers the rest."
455469
}
456470

471+
protected Map<String,String> auth;
472+
473+
@Parameters("auth")
474+
public PagingTest(@Optional String auth) throws IOException {
475+
if (StringUtils.isNotBlank(auth) && auth.contains(":")) {
476+
String[] split = auth.split(":");
477+
if (split.length == 2 && StringUtils.isNotBlank(split[0]) && StringUtils.isNotBlank(split[1])) {
478+
this.auth = ImmutableMap.of("username", split[0], "password", split[1]);
479+
}
480+
} else {
481+
this.auth = null;
482+
}
483+
}
484+
485+
@Override
486+
protected RequestSpecification buildBaseRequestSpecification() {
487+
RequestSpecification spec = RestAssured.given();
488+
if (auth != null) {
489+
spec.auth().preemptive().basic(auth.get("username"), auth.get("password"));
490+
}
491+
492+
if (httpLog != null) {
493+
spec.config(RestAssured
494+
.config()
495+
.logConfig(logConfig()
496+
.enableLoggingOfRequestAndResponseIfValidationFails()
497+
.defaultStream(new PrintStream(new WriterOutputStream(httpLog)))
498+
.enablePrettyPrinting(true)));
499+
}
500+
return spec;
501+
}
502+
457503
}

0 commit comments

Comments
 (0)