01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2002-2006, GeoTools Project Managment Committee (PMC)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: */
16: package org.geotools.gml3.bindings;
17:
18: import junit.framework.TestCase;
19: import org.picocontainer.ComponentAdapter;
20: import org.picocontainer.MutablePicoContainer;
21: import org.picocontainer.PicoContainer;
22: import org.picocontainer.defaults.DefaultPicoContainer;
23: import java.lang.reflect.Constructor;
24: import java.util.Iterator;
25: import org.geotools.gml3.GMLConfiguration;
26: import org.geotools.xml.Binding;
27:
28: public class GMLConfigurationTest extends TestCase {
29: public void testBindingTypes() throws Exception {
30: GMLConfiguration configuration = new GMLConfiguration();
31: assertEquals(GML.NAMESPACE, configuration.getNamespaceURI());
32:
33: PicoContainer bindings = new DefaultPicoContainer();
34: bindings = configuration
35: .setupBindings((MutablePicoContainer) bindings);
36:
37: do {
38: for (Iterator i = bindings.getComponentAdapters()
39: .iterator(); i.hasNext();) {
40: ComponentAdapter adapter = (ComponentAdapter) i.next();
41: Class type = adapter.getComponentImplementation();
42:
43: if (Binding.class.isAssignableFrom(type)) {
44: Constructor c = type.getConstructors()[0];
45: Object[] params = new Object[c.getParameterTypes().length];
46:
47: Binding binding = (Binding) c.newInstance(params);
48: assertNotNull(binding.getTarget());
49:
50: if (binding.getTarget().getNamespaceURI().equals(
51: GML.NAMESPACE)) {
52: assertNotNull(binding.getTarget()
53: + " has a null type", binding.getType());
54: }
55: }
56: }
57:
58: bindings = bindings.getParent();
59: } while (bindings != null);
60: }
61: }
|