This repository has been archived by the owner on Feb 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 941a4d9
Showing
3 changed files
with
156 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
.asciidoctor | ||
.classpath | ||
.idea | ||
.mvn/.gradle-enterprise/ | ||
.project | ||
.settings | ||
*.iml | ||
*.log | ||
*-backup.raw | ||
*.bak | ||
*.versionsBackup | ||
*.versionsNew | ||
backup/ | ||
logs/ | ||
target/ | ||
impl/overlays/ | ||
generated/ | ||
impl/tmp/ | ||
# This file is generated by the shade plugin and probably necessary (at this place), cf. https://stackoverflow.com/questions/11314182/maven-shade-plugin-adding-dependency-reduced-pom-xml-to-base-directory/ | ||
converters/dependency-reduced-pom.xml | ||
converters/htdocs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.dukecon</groupId> | ||
<artifactId>dukecon_apitest</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<name>dukecon_apitest</name> | ||
<url>http://www.dukecon.org</url> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.compiler.source>11</maven.compiler.source> | ||
<maven.compiler.target>11</maven.compiler.target> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.rest-assured</groupId> | ||
<artifactId>rest-assured</artifactId> | ||
<version>4.2.0</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter</artifactId> | ||
<version>5.6.2</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --> | ||
<plugins> | ||
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle --> | ||
<plugin> | ||
<artifactId>maven-clean-plugin</artifactId> | ||
<version>3.1.0</version> | ||
</plugin> | ||
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging --> | ||
<plugin> | ||
<artifactId>maven-resources-plugin</artifactId> | ||
<version>3.0.2</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.8.0</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>2.22.1</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>3.0.2</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-install-plugin</artifactId> | ||
<version>2.5.2</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-deploy-plugin</artifactId> | ||
<version>2.8.2</version> | ||
</plugin> | ||
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle --> | ||
<plugin> | ||
<artifactId>maven-site-plugin</artifactId> | ||
<version>3.7.1</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-project-info-reports-plugin</artifactId> | ||
<version>3.0.0</version> | ||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
</build> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package org.dukecon; | ||
|
||
import io.restassured.RestAssured; | ||
import io.restassured.http.ContentType; | ||
import io.restassured.parsing.Parser; | ||
import io.restassured.response.ValidatableResponse; | ||
import org.hamcrest.Matchers; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static io.restassured.RestAssured.when; | ||
import static org.hamcrest.Matchers.notNullValue; | ||
|
||
public class WebResoucesTests { | ||
|
||
@BeforeEach | ||
public void setup() { | ||
RestAssured.baseURI = "https://latest.dukecon.org/javaland/2019"; | ||
RestAssured.port = 443; | ||
RestAssured.registerParser("text/css", Parser.TEXT); | ||
} | ||
|
||
@Test | ||
public void testStaticServerInterface() { | ||
verfyInitJson( | ||
whenUrlOkAndContentTypeMatches("/rest/init.json", ContentType.JSON.toString()) | ||
); | ||
whenUrlOkAndContentTypeMatches("/rest/image-resources.json", ContentType.JSON.toString()); | ||
whenUrlOkAndContentTypeMatches("/rest/conferences/javaland2019", ContentType.JSON.toString()); | ||
whenUrlOkAndContentTypeMatches("/rest/conferences/javaland2019/styles.css", "text/css"); | ||
whenUrlOkAndContentTypeMatches("/img/favicon.ico", "image/x-icon"); | ||
|
||
} | ||
|
||
@Test | ||
public void testDynamicServerInterface() { | ||
whenUrlOkAndContentTypeMatches("/rest/keycloak.json", ContentType.JSON.toString()); | ||
whenUrlOkAndContentTypeMatches("/rest/eventsBooking/javaland2019", ContentType.JSON.toString()); | ||
} | ||
|
||
private void verfyInitJson(ValidatableResponse response) { | ||
response.body("id", Matchers.notNullValue()); | ||
} | ||
|
||
private ValidatableResponse whenUrlOkAndContentTypeMatches(String path, String contentType) { | ||
return when() | ||
.get(path). | ||
then() | ||
.assertThat() | ||
.statusCode(200) | ||
.contentType(contentType) | ||
.body(notNullValue()); | ||
} | ||
|
||
} |