Project

General

Profile

1
package eu.dnetlib.soap.cxf;
2

    
3
import static org.junit.Assert.assertEquals;
4
import static org.mockito.Mockito.when;
5

    
6
import org.junit.Before;
7
import org.junit.Test;
8
import org.junit.runner.RunWith;
9
import org.mockito.junit.MockitoJUnitRunner;
10

    
11
/**
12
 * test StandaloneCxfEndpointReferenceBuilderTest.
13
 * 
14
 * @author marko
15
 * 
16
 */
17
@RunWith(MockitoJUnitRunner.class)
18
public class StandaloneCxfEndpointReferenceBuilderTest extends CxfEndpointReferenceBuilderTest {
19

    
20
	/**
21
	 * some constant url prefix.
22
	 */
23
	private static final String HTTP_TEST_COM = "http://test.com";
24

    
25
	/**
26
	 * class under test.
27
	 */
28
	private transient StandaloneCxfEndpointReferenceBuilder builder;
29

    
30
	/**
31
	 * {@inheritDoc}
32
	 * 
33
	 * @see eu.dnetlib.soap.cxf.CxfEndpointReferenceBuilderTest#setUp()
34
	 */
35
	@Override
36
	@Before
37
	public void setUp() {
38
		super.setUp();
39
		builder = new StandaloneCxfEndpointReferenceBuilder();
40
	}
41

    
42
	/**
43
	 * test computeAddress.
44
	 */
45
	@Test
46
	public void testGetAddress() {
47
		assertEquals("no base, http", "http://localhost/something", builder.getAddress(getEndpoint()));
48

    
49
		when(getEndpointInfo().getAddress()).thenReturn("/localPath");
50
		assertEquals("no base, no http", "/localPath", builder.getAddress(getEndpoint()));
51

    
52
		builder.setBaseAddress("http://somebase");
53
		assertEquals("base, no http", "http://somebase/localPath", builder.getAddress(getEndpoint()));
54
	}
55

    
56
	/**
57
	 * make code coverage happy.
58
	 */
59
	@Test
60
	public void testGetBaseAddress() {
61
		builder.setBaseAddress(HTTP_TEST_COM);
62
		assertEquals("testing setter", HTTP_TEST_COM, builder.getBaseAddress());
63
	}
64

    
65
	/**
66
	 * make code coverage happy.
67
	 */
68
	@Test
69
	public void testSetBaseAddress() {
70
		builder.setBaseAddress(HTTP_TEST_COM);
71
		assertEquals("testing setter", HTTP_TEST_COM, builder.getBaseAddress());
72
	}
73

    
74
}
(2-2/2)