aboutsummaryrefslogtreecommitdiffstats
path: root/container-integration-test
diff options
context:
space:
mode:
authorgjoranv <gjoranv@gmail.com>2018-07-12 14:01:28 +0200
committergjoranv <gv@oath.com>2018-07-12 14:36:17 +0200
commita1af151124df05dd6307487dd06fc3c22525edab (patch)
tree411a8a1c0cd12a4ce23da642ac6ea04a737ede81 /container-integration-test
parentf7b9c0261930c81132c66e3f174b8c468894b92f (diff)
Reapply "Adding handler and binding when services.xml has <search>-field"
Diffstat (limited to 'container-integration-test')
-rw-r--r--container-integration-test/.gitignore31
-rw-r--r--container-integration-test/OWNERS1
-rw-r--r--container-integration-test/README1
-rw-r--r--container-integration-test/pom.xml44
-rw-r--r--container-integration-test/src/test/java/com/yahoo/search/query/gui/GUIHandlerTest.java84
5 files changed, 161 insertions, 0 deletions
diff --git a/container-integration-test/.gitignore b/container-integration-test/.gitignore
new file mode 100644
index 00000000000..7f4ebc3a7c6
--- /dev/null
+++ b/container-integration-test/.gitignore
@@ -0,0 +1,31 @@
+.classpath
+.project
+.settings
+/.cache
+/.classpath
+/.emacs.desktop
+/.nbintdb
+/.project
+/.settings
+/.version
+/QueryAccessLog*
+/accessLog.log
+/build
+/bundles
+/libexec
+/nbproject
+/pom.xml.build
+/prelude.iml
+/prelude.ipr
+/prelude.iws
+/staging
+/target
+/temp
+/testLogFileG.txt
+/testLogs
+/test_yapache_access_log
+/testlogsG
+/testng.out.log
+/tmp
+null.log
+tmp
diff --git a/container-integration-test/OWNERS b/container-integration-test/OWNERS
new file mode 100644
index 00000000000..6faef1015fb
--- /dev/null
+++ b/container-integration-test/OWNERS
@@ -0,0 +1 @@
+gjoranv \ No newline at end of file
diff --git a/container-integration-test/README b/container-integration-test/README
new file mode 100644
index 00000000000..c10341c3d8e
--- /dev/null
+++ b/container-integration-test/README
@@ -0,0 +1 @@
+Test for JDisc-components
diff --git a/container-integration-test/pom.xml b/container-integration-test/pom.xml
new file mode 100644
index 00000000000..4b4d5de21eb
--- /dev/null
+++ b/container-integration-test/pom.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0"?>
+<!-- Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -->
+<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>
+ <parent>
+ <groupId>com.yahoo.vespa</groupId>
+ <artifactId>parent</artifactId>
+ <version>6-SNAPSHOT</version>
+ <relativePath>../parent/pom.xml</relativePath>
+ </parent>
+ <artifactId>container-integration-test</artifactId>
+ <packaging>jar</packaging>
+ <version>6-SNAPSHOT</version>
+ <dependencies>
+ <dependency>
+ <groupId>com.yahoo.vespa</groupId>
+ <artifactId>container-search-gui</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.yahoo.vespa</groupId>
+ <artifactId>application</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+</project> \ No newline at end of file
diff --git a/container-integration-test/src/test/java/com/yahoo/search/query/gui/GUIHandlerTest.java b/container-integration-test/src/test/java/com/yahoo/search/query/gui/GUIHandlerTest.java
new file mode 100644
index 00000000000..5fd73afe800
--- /dev/null
+++ b/container-integration-test/src/test/java/com/yahoo/search/query/gui/GUIHandlerTest.java
@@ -0,0 +1,84 @@
+// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.search.query.gui;
+
+import com.yahoo.application.Networking;
+import com.yahoo.application.container.JDisc;
+import com.yahoo.application.container.handler.Request;
+import com.yahoo.application.container.handler.Response;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import java.io.IOException;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+
+/**
+ * @author Henrik Høiness
+ */
+
+public class GUIHandlerTest {
+
+ private JDisc container;
+
+ @Before
+ public void startContainer() {
+ container = JDisc.fromServicesXml(servicesXml(), Networking.disable);
+ }
+
+ @After
+ public void stopContainer() {
+ /*
+ try {
+ Thread.sleep(100_000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }*/
+ container.close();
+ }
+
+ @Test
+ public void testRequest() throws Exception {
+ assertResponse("/querybuilder/", "<!-- Copyright 2018 Yahoo Holdings.","text/html; charset=UTF-8", 200);
+ }
+
+ @Test
+ public void testContentTypes() throws Exception{
+ assertResponse("/querybuilder/_includes/css/vespa.css", "/**","text/css; charset=UTF-8", 200);
+ assertResponse("/querybuilder/js/agency.js", "/*!","application/javascript; charset=UTF-8", 200);
+ assertResponse("/querybuilder/img/reload.svg", "<?xml","image/svg+xml; charset=UTF-8", 200);
+ assertResponse("/querybuilder/img/Vespa-V2.png", null,"image/png; charset=UTF-8", 200);
+ }
+
+ @Test
+ public void testInvalidPath() throws Exception{
+ assertResponse("/querybuilder/invalid_filepath", "{\"error-code\":\"NOT_FOUND\",\"message\":\"Nothing at path","application/json; charset=UTF-8", 404);
+ }
+
+
+ private void assertResponse(String path, String expectedStartString, String expectedContentType, int expectedStatusCode) throws IOException {
+ assertResponse(Request.Method.GET, path, expectedStartString,expectedContentType, expectedStatusCode);
+ }
+
+ private void assertResponse(Request.Method method, String path, String expectedStartString, String expectedContentType, int expectedStatusCode) throws IOException {
+ Response response = container.handleRequest(new Request("http://localhost:8080" + path, new byte[0], method));
+ assertEquals("Status code", expectedStatusCode, response.getStatus());
+ assertEquals(expectedContentType, response.getHeaders().getFirst("Content-Type"));
+ if(expectedStartString != null){
+ assertTrue(response.getBodyAsString().startsWith(expectedStartString));
+ }
+ }
+
+ private String servicesXml() {
+ return "<jdisc version='1.0'>\n" +
+ " <handler id='com.yahoo.search.query.gui.GUIHandler'>\n" +
+ " <binding>http://*/querybuilder/*</binding>\n" +
+ " </handler>\n" +
+ " <http>\n" +
+ " <server id='default' port='8080'/>\n" +
+ " </http>\n" +
+ "</jdisc>";
+ }
+
+} \ No newline at end of file