// Copyright 2017 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.container.standalone.StandaloneContainerTest._
import com.yahoo.vespa.model.AbstractService
import org.junit.Assert._
import org.junit.Test
import scala.util.Try
/**
* @author tonytv
* @author gjoranv
*/
class StandaloneContainerTest {
@Test
def container_is_allowed_root_element() {
StandaloneContainer.withContainerModel(plainXml) { root => }
}
@Test
def services_is_allowed_root_element() {
val servicesXml =
StandaloneContainer.withContainerModel(servicesXml) { root => }
}
@Test
def multiple_container_elements_cannot_be_deployed() {
val twoContainersXml =
assertTrue(
Try {
StandaloneContainer.withContainerModel(twoContainersXml) { root => }
}.isFailure)
}
@Test
def application_preprocessor_is_run() {
val servicesXml =
container-1
StandaloneContainer.withContainerModel(servicesXml) {
root =>
assertTrue(root.getConfigProducer("container-1/standalone").isPresent)
}
}
@Test
def no_default_ports_are_enabled_when_using_http() {
val xml =
StandaloneContainer.withContainerModel(xml) { root =>
val container = root.getConfigProducer("jdisc/standalone").get().asInstanceOf[AbstractService]
println("portCnt: " + container.getPortCount)
println("numPorts: " + container.getNumPortsAllocated)
assertEquals(1, container.getNumPortsAllocated)
}
}
}
object StandaloneContainerTest {
val plainXml =
}