1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.ws.server.endpoint.support;
18
19 import java.lang.reflect.Method;
20 import javax.xml.XMLConstants;
21 import javax.xml.namespace.NamespaceContext;
22
23 import org.springframework.ws.server.endpoint.annotation.Namespace;
24 import org.springframework.ws.server.endpoint.annotation.Namespaces;
25
26 import org.junit.Test;
27
28 import static org.junit.Assert.assertEquals;
29
30 @Namespaces({@Namespace(prefix = "prefix1", uri = "class1"), @Namespace(uri = "class2")})
31 public class NamespaceUtilsTest {
32
33 @Test
34 public void getNamespaceContextMethod() throws NoSuchMethodException {
35 Method method = getClass().getMethod("method");
36 NamespaceContext namespaceContext = NamespaceUtils.getNamespaceContext(method);
37 assertEquals("method1", namespaceContext.getNamespaceURI("prefix1"));
38 assertEquals("method2", namespaceContext.getNamespaceURI(XMLConstants.DEFAULT_NS_PREFIX));
39
40 }
41
42 @Test
43 public void getNamespaceContextClass() throws NoSuchMethodException {
44 Method method = getClass().getMethod("getNamespaceContextClass");
45 NamespaceContext namespaceContext = NamespaceUtils.getNamespaceContext(method);
46 assertEquals("class1", namespaceContext.getNamespaceURI("prefix1"));
47 assertEquals("class2", namespaceContext.getNamespaceURI(XMLConstants.DEFAULT_NS_PREFIX));
48
49 }
50
51 @Namespaces({@Namespace(prefix = "prefix1", uri = "method1"), @Namespace(uri = "method2")})
52 public void method() {
53
54 }
55
56 }