summaryrefslogtreecommitdiffstats
path: root/jdisc_container_maven_archetype_application
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@yahoo-inc.com>2016-06-15 23:09:44 +0200
committerJon Bratseth <bratseth@yahoo-inc.com>2016-06-15 23:09:44 +0200
commit72231250ed81e10d66bfe70701e64fa5fe50f712 (patch)
tree2728bba1131a6f6e5bdf95afec7d7ff9358dac50 /jdisc_container_maven_archetype_application
Publish
Diffstat (limited to 'jdisc_container_maven_archetype_application')
-rw-r--r--jdisc_container_maven_archetype_application/.gitignore2
-rw-r--r--jdisc_container_maven_archetype_application/OWNERS1
-rw-r--r--jdisc_container_maven_archetype_application/pom.xml40
-rw-r--r--jdisc_container_maven_archetype_application/src/main/resources/META-INF/maven/archetype-metadata.xml36
-rw-r--r--jdisc_container_maven_archetype_application/src/main/resources/archetype-resources/pom.xml80
-rw-r--r--jdisc_container_maven_archetype_application/src/main/resources/archetype-resources/src/main/application/hosts.xml7
-rw-r--r--jdisc_container_maven_archetype_application/src/main/resources/archetype-resources/src/main/application/package.json12
-rw-r--r--jdisc_container_maven_archetype_application/src/main/resources/archetype-resources/src/main/application/services.xml21
-rw-r--r--jdisc_container_maven_archetype_application/src/main/resources/archetype-resources/src/main/java/ExampleProcessor.java35
-rw-r--r--jdisc_container_maven_archetype_application/src/main/resources/archetype-resources/src/main/java/StringData.java20
-rw-r--r--jdisc_container_maven_archetype_application/src/main/resources/archetype-resources/src/main/resources/configdefinitions/example-processor.def3
-rw-r--r--jdisc_container_maven_archetype_application/src/main/resources/archetype-resources/src/test/java/ApplicationMain.java27
-rw-r--r--jdisc_container_maven_archetype_application/src/main/resources/archetype-resources/src/test/java/ApplicationTest.java29
-rw-r--r--jdisc_container_maven_archetype_application/src/main/resources/archetype-resources/src/test/java/ExampleProcessorTest.java29
-rw-r--r--jdisc_container_maven_archetype_application/src/test/resources/projects/basic/archetype.properties4
-rw-r--r--jdisc_container_maven_archetype_application/src/test/resources/projects/basic/goal.txt1
16 files changed, 347 insertions, 0 deletions
diff --git a/jdisc_container_maven_archetype_application/.gitignore b/jdisc_container_maven_archetype_application/.gitignore
new file mode 100644
index 00000000000..12251442258
--- /dev/null
+++ b/jdisc_container_maven_archetype_application/.gitignore
@@ -0,0 +1,2 @@
+/target
+/pom.xml.build
diff --git a/jdisc_container_maven_archetype_application/OWNERS b/jdisc_container_maven_archetype_application/OWNERS
new file mode 100644
index 00000000000..3b2ba1ede81
--- /dev/null
+++ b/jdisc_container_maven_archetype_application/OWNERS
@@ -0,0 +1 @@
+gjoranv
diff --git a/jdisc_container_maven_archetype_application/pom.xml b/jdisc_container_maven_archetype_application/pom.xml
new file mode 100644
index 00000000000..cfa57ae5857
--- /dev/null
+++ b/jdisc_container_maven_archetype_application/pom.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright 2016 Yahoo Inc. 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>
+ <!-- Package name must contain _maven_archetype -->
+ <artifactId>jdisc_container_maven_archetype_application</artifactId>
+ <version>6-SNAPSHOT</version>
+ <packaging>maven-archetype</packaging>
+ <build>
+ <extensions>
+ <extension>
+ <groupId>org.apache.maven.archetype</groupId>
+ <artifactId>archetype-packaging</artifactId>
+ </extension>
+ </extensions>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>archetype-resources/pom.xml</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>false</filtering>
+ <excludes>
+ <exclude>archetype-resources/pom.xml</exclude>
+ </excludes>
+ </resource>
+ </resources>
+ </build>
+</project>
diff --git a/jdisc_container_maven_archetype_application/src/main/resources/META-INF/maven/archetype-metadata.xml b/jdisc_container_maven_archetype_application/src/main/resources/META-INF/maven/archetype-metadata.xml
new file mode 100644
index 00000000000..b2885c6a40b
--- /dev/null
+++ b/jdisc_container_maven_archetype_application/src/main/resources/META-INF/maven/archetype-metadata.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -->
+<archetype-descriptor
+ name="sample-container-plugin"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0
+ http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd"
+ xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <fileSets>
+ <fileSet filtered="true" packaged="true" encoding="UTF-8">
+ <directory>src/main/java</directory>
+ <includes>
+ <include>**/*.java</include>
+ </includes>
+ </fileSet>
+ <fileSet filtered="true" packaged="true" encoding="UTF-8">
+ <directory>src/test/java</directory>
+ <includes>
+ <include>**/*.java</include>
+ </includes>
+ </fileSet>
+ <fileSet filtered="true" encoding="UTF-8">
+ <directory>src/main/application</directory>
+ <includes>
+ <include>**/*.xml</include>
+ <include>**/*.json</include>
+ </includes>
+ </fileSet>
+ <fileSet filtered="true" encoding="UTF-8">
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>**/*.def</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+</archetype-descriptor>
diff --git a/jdisc_container_maven_archetype_application/src/main/resources/archetype-resources/pom.xml b/jdisc_container_maven_archetype_application/src/main/resources/archetype-resources/pom.xml
new file mode 100644
index 00000000000..6d67c36a0d8
--- /dev/null
+++ b/jdisc_container_maven_archetype_application/src/main/resources/archetype-resources/pom.xml
@@ -0,0 +1,80 @@
+<?xml version="1.0"?>
+<!-- Copyright 2016 Yahoo Inc. 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>
+ <groupId>\${groupId}</groupId>
+ <artifactId>\${artifactId}</artifactId>
+ <version>\${version}</version>
+ <packaging>container-plugin</packaging>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.10</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.yahoo.vespa</groupId>
+ <artifactId>application</artifactId>
+ <version>${vespa_version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.yahoo.vespa</groupId>
+ <artifactId>container-dev</artifactId>
+ <version>${vespa_version}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.5.1</version>
+ <configuration>
+ <optimize>true</optimize>
+ <showDeprecation>true</showDeprecation>
+ <showWarnings>true</showWarnings>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.13</version>
+ <configuration>
+ <systemPropertyVariables>
+ <isMavenSurefirePlugin>true</isMavenSurefirePlugin>
+ </systemPropertyVariables>
+ <redirectTestOutputToFile>\${test.hide}</redirectTestOutputToFile>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>com.yahoo.vespa</groupId>
+ <artifactId>vespa-application-maven-plugin</artifactId>
+ <version>${vespa_version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>packageApplication</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>com.yahoo.vespa</groupId>
+ <artifactId>bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <test.hide>true</test.hide>
+ </properties>
+</project>
diff --git a/jdisc_container_maven_archetype_application/src/main/resources/archetype-resources/src/main/application/hosts.xml b/jdisc_container_maven_archetype_application/src/main/resources/archetype-resources/src/main/application/hosts.xml
new file mode 100644
index 00000000000..3ab86a21aef
--- /dev/null
+++ b/jdisc_container_maven_archetype_application/src/main/resources/archetype-resources/src/main/application/hosts.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!-- Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -->
+<hosts>
+ <host name="localhost">
+ <alias>node1</alias>
+ </host>
+</hosts>
diff --git a/jdisc_container_maven_archetype_application/src/main/resources/archetype-resources/src/main/application/package.json b/jdisc_container_maven_archetype_application/src/main/resources/archetype-resources/src/main/application/package.json
new file mode 100644
index 00000000000..b6ed9f0efd5
--- /dev/null
+++ b/jdisc_container_maven_archetype_application/src/main/resources/archetype-resources/src/main/application/package.json
@@ -0,0 +1,12 @@
+{
+ "name": "${artifactId}",
+ "version": "${version}",
+ "dependencies": {
+ "connect": ">=0.2.4"
+ },
+ "yahoo": {
+ "dist-package" : {
+ "tag-name-with-userid" : true
+ }
+ }
+}
diff --git a/jdisc_container_maven_archetype_application/src/main/resources/archetype-resources/src/main/application/services.xml b/jdisc_container_maven_archetype_application/src/main/resources/archetype-resources/src/main/application/services.xml
new file mode 100644
index 00000000000..11d74a8133f
--- /dev/null
+++ b/jdisc_container_maven_archetype_application/src/main/resources/archetype-resources/src/main/application/services.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!-- Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -->
+<services version="1.0">
+ <admin version="2.0">
+ <adminserver hostalias="node1"/>
+ </admin>
+ <jdisc version="1.0">
+ <processing>
+ <chain id="default">
+ <processor id="${package}.ExampleProcessor" bundle="${artifactId}">
+ <config name="example.example-processor">
+ <message>Hello, services!</message>
+ </config>
+ </processor>
+ </chain>
+ </processing>
+ <nodes>
+ <node hostalias="node1"/>
+ </nodes>
+ </jdisc>
+</services>
diff --git a/jdisc_container_maven_archetype_application/src/main/resources/archetype-resources/src/main/java/ExampleProcessor.java b/jdisc_container_maven_archetype_application/src/main/resources/archetype-resources/src/main/java/ExampleProcessor.java
new file mode 100644
index 00000000000..d13efa7b884
--- /dev/null
+++ b/jdisc_container_maven_archetype_application/src/main/resources/archetype-resources/src/main/java/ExampleProcessor.java
@@ -0,0 +1,35 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package ${package};
+
+import com.google.inject.Inject;
+import com.yahoo.example.ExampleProcessorConfig;
+import com.yahoo.processing.Processor;
+import com.yahoo.processing.Request;
+import com.yahoo.processing.Response;
+import com.yahoo.processing.execution.Execution;
+
+public class ExampleProcessor extends Processor {
+
+ private final String message;
+
+ @Inject
+ public ExampleProcessor(ExampleProcessorConfig config) {
+ this.message = config.message();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Response process(Request request, Execution execution) {
+ // process the request
+ request.properties().set("foo", "bar");
+
+ // pass it down the chain to get a response
+ Response response = execution.process(request);
+
+ // process the response
+ response.data().add(new StringData(request, message));
+
+ // return the response up the chain
+ return response;
+ }
+}
diff --git a/jdisc_container_maven_archetype_application/src/main/resources/archetype-resources/src/main/java/StringData.java b/jdisc_container_maven_archetype_application/src/main/resources/archetype-resources/src/main/java/StringData.java
new file mode 100644
index 00000000000..6215dc3c39e
--- /dev/null
+++ b/jdisc_container_maven_archetype_application/src/main/resources/archetype-resources/src/main/java/StringData.java
@@ -0,0 +1,20 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package ${package};
+
+import com.yahoo.processing.Request;
+import com.yahoo.processing.response.AbstractData;
+
+public class StringData extends AbstractData {
+
+ private final String string;
+
+ public StringData(Request request, String string) {
+ super(request);
+ this.string = string;
+ }
+
+ @Override
+ public String toString() {
+ return string;
+ }
+} \ No newline at end of file
diff --git a/jdisc_container_maven_archetype_application/src/main/resources/archetype-resources/src/main/resources/configdefinitions/example-processor.def b/jdisc_container_maven_archetype_application/src/main/resources/archetype-resources/src/main/resources/configdefinitions/example-processor.def
new file mode 100644
index 00000000000..1028451c312
--- /dev/null
+++ b/jdisc_container_maven_archetype_application/src/main/resources/archetype-resources/src/main/resources/configdefinitions/example-processor.def
@@ -0,0 +1,3 @@
+# Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+namespace=example
+message string default=""
diff --git a/jdisc_container_maven_archetype_application/src/main/resources/archetype-resources/src/test/java/ApplicationMain.java b/jdisc_container_maven_archetype_application/src/main/resources/archetype-resources/src/test/java/ApplicationMain.java
new file mode 100644
index 00000000000..c6148866a62
--- /dev/null
+++ b/jdisc_container_maven_archetype_application/src/main/resources/archetype-resources/src/test/java/ApplicationMain.java
@@ -0,0 +1,27 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package ${package};
+
+import com.yahoo.application.Networking;
+import org.junit.Test;
+
+import java.nio.file.FileSystems;
+
+import static org.junit.Assume.assumeTrue;
+
+public class ApplicationMain {
+
+ @Test
+ public void runFromMaven() throws Exception {
+ assumeTrue(Boolean.valueOf(System.getProperty("isMavenSurefirePlugin")));
+ main(null);
+ }
+
+ public static void main(String[] args) throws Exception {
+ try (com.yahoo.application.Application app = com.yahoo.application.Application.fromApplicationPackage(
+ FileSystems.getDefault().getPath("src/main/application"),
+ Networking.enable)) {
+ app.getClass(); // throws NullPointerException
+ Thread.sleep(Long.MAX_VALUE);
+ }
+ }
+} \ No newline at end of file
diff --git a/jdisc_container_maven_archetype_application/src/main/resources/archetype-resources/src/test/java/ApplicationTest.java b/jdisc_container_maven_archetype_application/src/main/resources/archetype-resources/src/test/java/ApplicationTest.java
new file mode 100644
index 00000000000..d80f4572cf0
--- /dev/null
+++ b/jdisc_container_maven_archetype_application/src/main/resources/archetype-resources/src/test/java/ApplicationTest.java
@@ -0,0 +1,29 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package ${package};
+
+import com.yahoo.application.Application;
+import com.yahoo.application.Networking;
+import com.yahoo.application.container.Processing;
+import com.yahoo.component.ComponentSpecification;
+import com.yahoo.processing.Request;
+import com.yahoo.processing.Response;
+import org.junit.Test;
+
+import java.nio.file.FileSystems;
+
+import static org.junit.Assert.assertThat;
+import static org.junit.internal.matchers.StringContains.containsString;
+
+public class ApplicationTest {
+
+ @Test
+ public void requireThatResultContainsHelloWorld() throws Exception {
+ try (Application app = Application.fromApplicationPackage(
+ FileSystems.getDefault().getPath("src/main/application"),
+ Networking.disable)) {
+ Processing processing = app.getJDisc("jdisc").processing();
+ Response response = processing.process(ComponentSpecification.fromString("default"), new Request());
+ assertThat(response.data().get(0).toString(), containsString("Hello, services!"));
+ }
+ }
+}
diff --git a/jdisc_container_maven_archetype_application/src/main/resources/archetype-resources/src/test/java/ExampleProcessorTest.java b/jdisc_container_maven_archetype_application/src/main/resources/archetype-resources/src/test/java/ExampleProcessorTest.java
new file mode 100644
index 00000000000..aa11a3529eb
--- /dev/null
+++ b/jdisc_container_maven_archetype_application/src/main/resources/archetype-resources/src/test/java/ExampleProcessorTest.java
@@ -0,0 +1,29 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package ${package};
+
+import com.yahoo.component.chain.Chain;
+import com.yahoo.example.ExampleProcessorConfig;
+import com.yahoo.processing.Processor;
+import com.yahoo.processing.Request;
+import com.yahoo.processing.Response;
+import com.yahoo.processing.execution.Execution;
+import org.junit.Test;
+
+import static org.junit.Assert.assertThat;
+import static org.junit.matchers.JUnitMatchers.containsString;
+
+public class ExampleProcessorTest {
+
+ @Test
+ public void requireThatResultContainsHelloWorld() {
+ ExampleProcessorConfig.Builder config = new ExampleProcessorConfig.Builder().message("Hello, processor!");
+ Processor processor = new ExampleProcessor(new ExampleProcessorConfig(config));
+
+ Response response = newExecution(processor).process(new Request());
+ assertThat(response.data().get(0).toString(), containsString("Hello, processor!"));
+ }
+
+ private static Execution newExecution(Processor... processors) {
+ return Execution.createRoot(new Chain<>(processors), 0, Execution.Environment.createEmpty());
+ }
+}
diff --git a/jdisc_container_maven_archetype_application/src/test/resources/projects/basic/archetype.properties b/jdisc_container_maven_archetype_application/src/test/resources/projects/basic/archetype.properties
new file mode 100644
index 00000000000..fe86ff801b8
--- /dev/null
+++ b/jdisc_container_maven_archetype_application/src/test/resources/projects/basic/archetype.properties
@@ -0,0 +1,4 @@
+version=98.76.54
+groupId=com.yahoo.vespa.testGroupId
+artifactId=jdisc-container-application-archetype-it
+package=com.yahoo.test.jdisc.container
diff --git a/jdisc_container_maven_archetype_application/src/test/resources/projects/basic/goal.txt b/jdisc_container_maven_archetype_application/src/test/resources/projects/basic/goal.txt
new file mode 100644
index 00000000000..ba3bd787383
--- /dev/null
+++ b/jdisc_container_maven_archetype_application/src/test/resources/projects/basic/goal.txt
@@ -0,0 +1 @@
+package