|
1 | 1 | package org.w3.ldp.paging.testsuite.tests;
|
2 | 2 |
|
| 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; |
3 | 13 | import org.testng.annotations.Test;
|
4 | 14 | import org.w3.ldp.testsuite.annotations.SpecTest;
|
5 | 15 | import org.w3.ldp.testsuite.annotations.SpecTest.METHOD;
|
6 | 16 | import org.w3.ldp.testsuite.annotations.SpecTest.STATUS;
|
7 | 17 | import org.w3.ldp.testsuite.test.LdpTest;
|
8 | 18 |
|
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{ |
10 | 24 |
|
11 | 25 | public static final String PAGING = "PAGING";
|
12 | 26 | 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() {
|
446 | 460 | + "page-ordering values for which [sparql11-query] does not use collations.")
|
447 | 461 | @SpecTest(
|
448 | 462 | specRefUri = SPEC_URI + "#ldpc-sortcollation",
|
449 |
| - testMethod = METHOD.NOT_IMPLEMENTED, |
| 463 | + testMethod = METHOD.AUTOMATED, |
450 | 464 | approval = STATUS.WG_PENDING)
|
451 | 465 | public void testRestrictCollation() {
|
452 | 466 | // TODO: Impl testRestrictCollation
|
453 | 467 | // "Covers only part of the specification
|
454 | 468 | // requirement. testSortCollation covers the rest."
|
455 | 469 | }
|
456 | 470 |
|
| 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 | + |
457 | 503 | }
|
0 commit comments