summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--application/pom.xml5
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/container/search/GUIHandler.java6
-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.java (renamed from container-search-gui/src/test/java/com/yahoo/search/query/gui/GUIHandlerTest.java)3
-rw-r--r--container-search-gui/pom.xml19
-rw-r--r--container-search-gui/src/main/java/com/yahoo/search/query/gui/GUIHandler.java67
-rw-r--r--pom.xml1
10 files changed, 130 insertions, 48 deletions
diff --git a/application/pom.xml b/application/pom.xml
index db298451a8b..0808f2be58e 100644
--- a/application/pom.xml
+++ b/application/pom.xml
@@ -46,6 +46,11 @@
</dependency>
<dependency>
<groupId>com.yahoo.vespa</groupId>
+ <artifactId>container-search-gui</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.yahoo.vespa</groupId>
<artifactId>zkfacade</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/search/GUIHandler.java b/config-model/src/main/java/com/yahoo/vespa/model/container/search/GUIHandler.java
index 3b752335055..025075be8fd 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/container/search/GUIHandler.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/container/search/GUIHandler.java
@@ -1,3 +1,4 @@
+// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.container.search;
import com.yahoo.config.model.producer.AbstractConfigProducer;
@@ -5,6 +6,11 @@ import com.yahoo.container.bundle.BundleInstantiationSpecification;
import com.yahoo.osgi.provider.model.ComponentModel;
import com.yahoo.vespa.model.container.component.Handler;
+
+/**
+ * @author Henrik Høiness
+ */
+
public class GUIHandler extends Handler<AbstractConfigProducer<?>> {
public static final String BUNDLE = "container-search-gui";
public static final String CLASS = "com.yahoo.search.query.gui.GUIHandler";
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-search-gui/src/test/java/com/yahoo/search/query/gui/GUIHandlerTest.java b/container-integration-test/src/test/java/com/yahoo/search/query/gui/GUIHandlerTest.java
index ec515a1bf4a..1c6b9c329fb 100644
--- a/container-search-gui/src/test/java/com/yahoo/search/query/gui/GUIHandlerTest.java
+++ b/container-integration-test/src/test/java/com/yahoo/search/query/gui/GUIHandlerTest.java
@@ -12,7 +12,6 @@ import org.junit.Test;
import java.io.IOException;
-import static org.junit.Assert.assertTrue;
/**
@@ -67,7 +66,7 @@ public class GUIHandlerTest {
Assert.assertEquals("Status code", expectedStatusCode, response.getStatus());
Assert.assertEquals(expectedContentType, response.getHeaders().getFirst("Content-Type"));
if(expectedStartString != null){
- assertTrue(response.getBodyAsString().startsWith(expectedStartString));
+ Assert.assertTrue(response.getBodyAsString().startsWith(expectedStartString));
}
}
diff --git a/container-search-gui/pom.xml b/container-search-gui/pom.xml
index 1e75ccae301..f598758e1de 100644
--- a/container-search-gui/pom.xml
+++ b/container-search-gui/pom.xml
@@ -23,38 +23,27 @@
<dependency>
<groupId>com.yahoo.vespa</groupId>
<artifactId>yolean</artifactId>
- <version>6-SNAPSHOT</version>
+ <version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.yahoo.vespa</groupId>
<artifactId>jdisc_http_service</artifactId>
- <version>6-SNAPSHOT</version>
+ <version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.yahoo.vespa</groupId>
<artifactId>jdisc_core</artifactId>
- <version>6-SNAPSHOT</version>
+ <version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.yahoo.vespa</groupId>
<artifactId>container-core</artifactId>
- <version>6-SNAPSHOT</version>
+ <version>${project.version}</version>
<scope>provided</scope>
</dependency>
- <dependency>
- <groupId>com.yahoo.vespa</groupId>
- <artifactId>application</artifactId>
- <version>6-SNAPSHOT</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
<build>
<plugins>
diff --git a/container-search-gui/src/main/java/com/yahoo/search/query/gui/GUIHandler.java b/container-search-gui/src/main/java/com/yahoo/search/query/gui/GUIHandler.java
index 0f4eebd7fd7..d24ab1e6128 100644
--- a/container-search-gui/src/main/java/com/yahoo/search/query/gui/GUIHandler.java
+++ b/container-search-gui/src/main/java/com/yahoo/search/query/gui/GUIHandler.java
@@ -5,17 +5,13 @@ import com.google.inject.Inject;
import com.yahoo.container.jdisc.HttpRequest;
import com.yahoo.container.jdisc.HttpResponse;
import com.yahoo.container.jdisc.LoggingRequestHandler;
-
-
import com.yahoo.search.query.restapi.ErrorResponse;
import com.yahoo.yolean.Exceptions;
-import java.io.File;
+
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.logging.Level;
/**
@@ -47,71 +43,80 @@ public class GUIHandler extends LoggingRequestHandler {
}
private HttpResponse handleGET(HttpRequest request) {
- com.yahoo.restapi.Path path = new com.yahoo.restapi.Path(request.getUri().getPath());
+ com.yahoo.restapi.Path path = new com.yahoo.restapi.Path(request.getUri().getPath());
if (path.matches("/querybuilder/")) {
return new FileResponse("_includes/index.html");
}
if (!path.matches("/querybuilder/{*}") ) {
- return ErrorResponse.notFoundError("Nothing at " + path);
+ return ErrorResponse.notFoundError("Nothing at path:" + path);
}
String filepath = path.getRest();
- if (!isValidPath(GUIHandler.class.getClassLoader().getResource("gui").getFile()+"/"+filepath)){
- return ErrorResponse.notFoundError("Nothing at " + path);
+ if (!isValidPath(filepath)){
+ return ErrorResponse.notFoundError("Nothing at path:" + filepath);
}
return new FileResponse(filepath);
}
private static boolean isValidPath(String path) {
- File file = new File(path);
- return file.exists();
+ InputStream in = GUIHandler.class.getClassLoader().getResourceAsStream("gui/"+path);
+ boolean isValid = (in != null);
+ if(isValid){
+ try { in.close(); } catch (IOException e) {/* Problem with closing inputstream */}
+ }
+
+ return isValid;
}
private static class FileResponse extends HttpResponse {
- private final Path path;
+ private final String path;
public FileResponse(String relativePath) {
super(200);
- this.path = Paths.get(GUIHandler.class.getClassLoader().getResource("gui").getFile(), relativePath);
+ this.path = relativePath;
}
@Override
public void render(OutputStream out) throws IOException {
- byte[] data = Files.readAllBytes(path);
- out.write(data);
+ InputStream is = GUIHandler.class.getClassLoader().getResourceAsStream("gui/"+this.path);
+ byte[] buf = new byte[1024];
+ int numRead;
+ while ( (numRead = is.read(buf) ) >= 0) {
+ out.write(buf, 0, numRead);
+ }
}
@Override
public String getContentType() {
- if (path.toString().endsWith(".css")) {
+ if (path.endsWith(".css")) {
return "text/css";
- } else if (path.toString().endsWith(".js")) {
+ } else if (path.endsWith(".js")) {
return "application/javascript";
- } else if (path.toString().endsWith(".html")) {
+ } else if (path.endsWith(".html")) {
return "text/html";
- }else if (path.toString().endsWith(".php")) {
+ }else if (path.endsWith(".php")) {
return "text/php";
- }else if (path.toString().endsWith(".svg")) {
+ }else if (path.endsWith(".svg")) {
return "image/svg+xml";
- }else if (path.toString().endsWith(".eot")) {
+ }else if (path.endsWith(".eot")) {
return "application/vnd.ms-fontobject";
- }else if (path.toString().endsWith(".ttf")) {
+ }else if (path.endsWith(".ttf")) {
return "font/ttf";
- }else if (path.toString().endsWith(".woff")) {
+ }else if (path.endsWith(".woff")) {
return "font/woff";
- }else if (path.toString().endsWith(".woff2")) {
+ }else if (path.endsWith(".woff2")) {
return "font/woff2";
- }else if (path.toString().endsWith(".otf")) {
+ }else if (path.endsWith(".otf")) {
return "font/otf";
- }else if (path.toString().endsWith(".png")) {
+ }else if (path.endsWith(".png")) {
return "image/png";
- }else if (path.toString().endsWith(".xml")) {
+ }else if (path.endsWith(".xml")) {
return "application/xml";
- }else if (path.toString().endsWith(".ico")) {
+ }else if (path.endsWith(".ico")) {
return "image/x-icon";
- }else if (path.toString().endsWith(".json")) {
+ }else if (path.endsWith(".json")) {
return "application/json";
- }else if (path.toString().endsWith(".ttf")) {
+ }else if (path.endsWith(".ttf")) {
return "font/ttf";
}
return "text/html";
diff --git a/pom.xml b/pom.xml
index a855c521b2b..33e0ad95f62 100644
--- a/pom.xml
+++ b/pom.xml
@@ -57,6 +57,7 @@
<module>container-dev</module>
<module>container-di</module>
<module>container-disc</module>
+ <module>container-integration-test</module>
<module>container-jersey2</module>
<module>container-messagebus</module>
<module>container-search-and-docproc</module>