blob: c281cd0eabcda13b299521ccd936f7ec5bbb65ad (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.container.standalone
import org.junit.Test
import org.junit.Assert.assertThat
import org.hamcrest.CoreMatchers.is
import org.hamcrest.Matchers.{arrayContaining}
/**
* @author lulf
* @author tonytv
* @since 5.
*/
class CloudConfigYinstVariablesTest {
def convert = CloudConfigYinstVariables.configServerConverter.convert _
@Test
def test_configserver_parsing {
val parsed = convert("myhost.mydomain.com")
assertThat(parsed.length, is(1))
}
@Test
def port_can_be_configured {
val parsed = convert("myhost:123")
val port: Int = parsed(0).port.get()
assertThat(port, is(123))
}
@Test
def multiple_spaces_are_supported {
val parsed = convert("test1 test2")
assertThat(parsed.size, is(2))
val hostNames = parsed.map(_.hostName)
assertThat(hostNames, arrayContaining("test1", "test2"))
}
@Test(expected = classOf[IllegalArgumentException])
def missing_port_gives_exception {
convert("myhost:")
}
@Test(expected = classOf[IllegalArgumentException])
def non_numeric_port_gives_exception {
convert("myhost:non-numeric")
}
@Test
def string_arrays_are_split_on_spaces {
val parsed = convert("/home/vespa/foo /home/vespa/bar ")
assertThat(parsed.size, is(2))
}
@Test
def string_arrays_are_split_on_comma {
val parsed = convert("/home/vespa/foo,/home/vespa/bar,")
assertThat(parsed.size, is(2))
}
}
|