This repository has been archived by the owner on Nov 18, 2022. It is now read-only.
/
Configuration_Test.java
86 lines (64 loc) · 2.48 KB
/
Configuration_Test.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
75
76
77
78
79
80
81
82
83
84
85
86
package com.eclipsesource.jaxrs.publisher.internal;
import static org.mockito.Matchers.anyLong;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import java.util.Dictionary;
import java.util.Hashtable;
import org.junit.Before;
import org.junit.Test;
import org.osgi.service.cm.ConfigurationException;
public class Configuration_Test {
private JAXRSConnector connector;
private Configuration config;
@Before
public void setUp() {
connector = mock( JAXRSConnector.class );
config = new Configuration( connector );
}
@Test
public void testUpdateWithNull() throws Exception {
config.updated( null );
verify( connector, never() ).updateConfiguration( anyString(), eq(false), anyLong() );
}
@Test
public void testUpdateWithPath() throws Exception {
config.updated( createProperties( "/test" ) );
verify( connector ).updateConfiguration( "/test" , false, 4 );
}
@Test
public void testUpdateWithPath2() throws Exception {
config.updated( createProperties( "/test2" ) );
verify( connector ).updateConfiguration( "/test2" , false, 4 );
}
@Test
public void testUpdateWithDisabledWadl() throws Exception {
config.updated( createProperties( "/test", true ) );
verify( connector ).updateConfiguration( "/test" , true, 4 );
}
@Test
public void testUpdateWithPublishInterval() throws Exception {
config.updated( createProperties( "/test", true ) );
verify( connector ).updateConfiguration( "/test" , true, 4 );
}
@Test( expected = ConfigurationException.class )
public void testUpdateWithInvalidPath() throws Exception {
config.updated( createProperties( "test" ) );
}
@Test( expected = ConfigurationException.class )
public void testUpdateWithEmptyProperties() throws Exception {
config.updated( new Hashtable<String, Object>() );
}
private Dictionary<String, ?> createProperties( String path ) {
return createProperties( path, false);
}
private Dictionary<String, ?> createProperties( String path, Boolean disableWadl) {
Hashtable<String, Object> properties = new Hashtable<String, Object>();
properties.put( Configuration.ROOT_PROPERTY, path );
properties.put( Configuration.WADL_DISABLE_PROPERTY, disableWadl );
properties.put( Configuration.PUBLISH_INTERVAL, "4" );
return properties;
}
}