01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */package org.apache.cxf.bus.extension;
19:
20: import java.io.InputStream;
21: import java.util.Collection;
22: import java.util.List;
23:
24: import org.junit.Assert;
25: import org.junit.Test;
26:
27: public class ExtensionFragmentParserTest extends Assert {
28:
29: @Test
30: public void testGetExtensions() {
31: InputStream is = ExtensionFragmentParserTest.class
32: .getResourceAsStream("extension1.xml");
33: List<Extension> extensions = new ExtensionFragmentParser()
34: .getExtensions(is);
35: assertEquals("Unexpected number of Extension elements.", 3,
36: extensions.size());
37:
38: Extension e = extensions.get(0);
39: assertTrue("Extension is deferred.", !e.isDeferred());
40: assertEquals("Unexpected class name.",
41: "org.apache.cxf.foo.FooImpl", e.getClassname());
42: Collection<String> namespaces = e.getNamespaces();
43: for (String ns : namespaces) {
44: assertTrue("Unexpected namespace.",
45: "http://cxf.apache.org/a/b/c".equals(ns)
46: || "http://cxf.apache.org/d/e/f".equals(ns));
47: }
48: assertEquals("Unexpected number of namespace elements.", 2,
49: namespaces.size());
50:
51: e = extensions.get(1);
52: assertTrue("Extension is not deferred.", e.isDeferred());
53: assertEquals("Unexpected implementation class name.",
54: "java.lang.Boolean", e.getClassname());
55: namespaces = e.getNamespaces();
56: for (String ns : namespaces) {
57: assertEquals("Unexpected namespace.",
58: "http://cxf.apache.org/x/y/z", ns);
59: }
60: assertEquals("Unexpected number of namespace elements.", 1,
61: namespaces.size());
62: }
63: }
|