summaryrefslogtreecommitdiffstats
path: root/standalone-container/src/test/java/com/yahoo/container/standalone/StandaloneContainerTest.java
diff options
context:
space:
mode:
authorOlli Virtanen <olli.virtanen@oath.com>2018-05-31 10:58:25 +0200
committerOlli Virtanen <olli.virtanen@oath.com>2018-05-31 10:58:25 +0200
commit3eefb81679eb3b3da6b782583b060166b39befd7 (patch)
tree77ec82f306f8d5bf6289e460b2adf621e0ad2f16 /standalone-container/src/test/java/com/yahoo/container/standalone/StandaloneContainerTest.java
parent41fafa8edf8c7dda56b30050d5233b17f03babe1 (diff)
Scala code in standalone-container converted to Java
Diffstat (limited to 'standalone-container/src/test/java/com/yahoo/container/standalone/StandaloneContainerTest.java')
-rw-r--r--standalone-container/src/test/java/com/yahoo/container/standalone/StandaloneContainerTest.java74
1 files changed, 74 insertions, 0 deletions
diff --git a/standalone-container/src/test/java/com/yahoo/container/standalone/StandaloneContainerTest.java b/standalone-container/src/test/java/com/yahoo/container/standalone/StandaloneContainerTest.java
new file mode 100644
index 00000000000..6d4abc84dbc
--- /dev/null
+++ b/standalone-container/src/test/java/com/yahoo/container/standalone/StandaloneContainerTest.java
@@ -0,0 +1,74 @@
+// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.container.standalone;
+
+import com.yahoo.vespa.model.AbstractService;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * @author Tony Vaagenes
+ * @author gjoranv
+ * @author ollivir
+ */
+
+public class StandaloneContainerTest {
+ private static final String PLAIN_XML = "<container version=\"1.0\" />";
+
+ @Test
+ public void container_is_allowed_root_element() throws Exception {
+ StandaloneContainer.withContainerModel(PLAIN_XML, root -> null);
+ }
+
+ @Test
+ public void services_is_allowed_root_element() throws Exception {
+ String servicesXml = "<services>" + //
+ "<container version=\"1.0\" />" + //
+ "</services>";
+
+ StandaloneContainer.withContainerModel(servicesXml, root -> null);
+ }
+
+ @Test(expected = Exception.class)
+ public void multiple_container_elements_cannot_be_deployed() throws Exception {
+ String twoContainersXml = "<services>" + //
+ "<container id=\"container-1\" version=\"1.0\" />" + //
+ "<container id=\"container-2\" version=\"1.0\" />" + //
+ "</services>";
+
+ StandaloneContainer.withContainerModel(twoContainersXml, root -> null);
+ }
+
+ @Test
+ public void application_preprocessor_is_run() throws Exception {
+ String servicesXml = "<services xmlns:preprocess=\"properties\">" + //
+ "<preprocess:properties>" + //
+ "<container_id>container-1</container_id>" + //
+ "</preprocess:properties>" + //
+ "<container id=\"${container_id}\" version=\"1.0\" />" + //
+ "</services>";
+
+ StandaloneContainer.withContainerModel(servicesXml, root -> {
+ assertTrue(root.getConfigProducer("container-1/standalone").isPresent());
+ return null;
+ });
+ }
+
+ @Test
+ public void no_default_ports_are_enabled_when_using_http() throws Exception {
+ String xml = "<jdisc version=\"1.0\">" + //
+ "<http>" + //
+ "<server port=\"4000\" id=\"server1\" />" + //
+ "</http>" + //
+ "</jdisc>";
+
+ StandaloneContainer.withContainerModel(xml, root -> {
+ AbstractService container = (AbstractService) root.getConfigProducer("jdisc/standalone").get();
+ System.out.println("portCnt: " + container.getPortCount());
+ System.out.println("numPorts: " + container.getNumPortsAllocated());
+ assertEquals(1, container.getNumPortsAllocated());
+ return null;
+ });
+ }
+}