-
Notifications
You must be signed in to change notification settings - Fork 23
/
LightblueClientConfigurationTest.java
74 lines (59 loc) · 2.72 KB
/
LightblueClientConfigurationTest.java
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package com.redhat.lightblue.client;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import static org.junit.Assert.assertEquals;
@RunWith(JUnit4.class)
public class LightblueClientConfigurationTest {
@Rule
public ExpectedException expectedException = ExpectedException.none();
@Test
public void shouldCopyAllPropertiesInCopyConstructor() {
LightblueClientConfiguration original = new LightblueClientConfiguration();
original.setUseCertAuth(true);
original.setMetadataServiceURI("metadata");
original.setDataServiceURI("data");
original.setCertPassword("pass");
original.setCertFilePath("certpath");
original.setCaFilePath("capath");
original.setCertAlias("certalias");
LightblueClientConfiguration copy = new LightblueClientConfiguration(original);
assertEquals(true, copy.useCertAuth());
assertEquals("metadata", copy.getMetadataServiceURI());
assertEquals("data", copy.getDataServiceURI());
assertEquals("pass", copy.getCertPassword());
assertEquals("certpath", copy.getCertFilePath());
assertEquals("capath", copy.getCaFilePath());
assertEquals("certalias", copy.getCertAlias());
// make sure they are copies
original.setUseCertAuth(false);
original.setMetadataServiceURI("1metadata");
original.setDataServiceURI("1data");
original.setCertPassword("1pass");
original.setCertFilePath("1certpath");
original.setCaFilePath("1capath");
assertEquals(true, copy.useCertAuth());
assertEquals("metadata", copy.getMetadataServiceURI());
assertEquals("data", copy.getDataServiceURI());
assertEquals("pass", copy.getCertPassword());
assertEquals("certpath", copy.getCertFilePath());
assertEquals("capath", copy.getCaFilePath());
assertEquals("certalias", copy.getCertAlias());
}
@Test
public void getCaFilePathShouldThrowExceptionWhenThereAreMultipleValues() throws Exception {
expectedException.expect(IllegalStateException.class);
expectedException.expectMessage("There are multiple CA cert paths defined, use getCaFilePaths() instead");
LightblueClientConfiguration config = new LightblueClientConfiguration();
config.setCaFilePath("cacert1.pem,cacert2.pem");
config.getCaFilePath();
}
@Test
public void getCaFilePathShouldNotThrowExceptionWhenThereIsOnlyOneValue() throws Exception {
LightblueClientConfiguration config = new LightblueClientConfiguration();
config.setCaFilePath("cacert1.pem");
config.getCaFilePath();
}
}