diff options
Diffstat (limited to 'tags/java-M1-final/java/sca/core/src/test/java/org/apache/tuscany/core/loader/assembly')
10 files changed, 0 insertions, 757 deletions
diff --git a/tags/java-M1-final/java/sca/core/src/test/java/org/apache/tuscany/core/loader/assembly/ComponentLoaderTestCase.java b/tags/java-M1-final/java/sca/core/src/test/java/org/apache/tuscany/core/loader/assembly/ComponentLoaderTestCase.java deleted file mode 100644 index 37056b3283..0000000000 --- a/tags/java-M1-final/java/sca/core/src/test/java/org/apache/tuscany/core/loader/assembly/ComponentLoaderTestCase.java +++ /dev/null @@ -1,151 +0,0 @@ -/** - * - * Copyright 2006 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.tuscany.core.loader.assembly; - -import java.util.List; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.core.builder.ObjectFactory; -import org.apache.tuscany.core.config.ComponentTypeIntrospector; -import org.apache.tuscany.core.config.ConfigurationException; -import org.apache.tuscany.core.config.ConfigurationLoadException; -import org.apache.tuscany.core.extension.config.ImplementationProcessor; -import org.apache.tuscany.core.config.impl.Java5ComponentTypeIntrospector; -import org.apache.tuscany.core.config.processor.ProcessorUtils; -import org.apache.tuscany.core.injection.SingletonObjectFactory; -import org.apache.tuscany.core.loader.StAXPropertyFactory; -import org.apache.tuscany.core.loader.impl.StringParserPropertyFactory; -import org.apache.tuscany.core.system.assembly.SystemImplementation; -import org.apache.tuscany.model.assembly.Component; -import org.apache.tuscany.model.assembly.ConfiguredProperty; -import org.apache.tuscany.model.assembly.Property; -import org.apache.tuscany.model.assembly.AtomicComponent; - -/** - * @version $Rev$ $Date$ - */ -public class ComponentLoaderTestCase extends LoaderTestSupport { - private ComponentLoader loader; - private ComponentTypeIntrospector introspector; - - public void testStringProperty() throws XMLStreamException, ConfigurationLoadException { - String xml = "<properties><propString>HelloWorld</propString></properties>"; - Component component = createFooComponent(); - loadProperties(xml, component); - ConfiguredProperty prop = component.getConfiguredProperty("propString"); - assertEquals("HelloWorld", prop.getValue()); - } - - public void testIntProperty() throws XMLStreamException, ConfigurationLoadException { - String xml = "<properties><propInt>1234</propInt></properties>"; - Component component = createFooComponent(); - loadProperties(xml, component); - ConfiguredProperty prop = component.getConfiguredProperty("propInt"); - assertEquals(1234, prop.getValue()); - } - - public void testIntegerProperty() throws XMLStreamException, ConfigurationLoadException { - String xml = "<properties><propInteger>1234</propInteger></properties>"; - Component component = createFooComponent(); - loadProperties(xml, component); - ConfiguredProperty prop = component.getConfiguredProperty("propInteger"); - assertEquals(Integer.valueOf(1234), prop.getValue()); - } - - public void testCustomProperty() throws XMLStreamException, ConfigurationLoadException { - String xml = "<properties><propFoo factory='" + FooFactory.class.getName() + "'><name>Hello</name></propFoo></properties>"; - Component component = createFooComponent(); - loadProperties(xml, component); - ConfiguredProperty prop = component.getConfiguredProperty("propFoo"); - Foo instance = (Foo) prop.getValue(); - assertEquals("Hello", instance.name); - } - - private void loadProperties(String xml, Component component) throws XMLStreamException, ConfigurationLoadException { - XMLStreamReader reader = getReader(xml); - loader.loadProperties(reader, resourceLoader, component); - component.initialize(modelContext); - } - - private Component createFooComponent() { - SystemImplementation impl = assemblyFactory.createSystemImplementation(); - impl.setImplementationClass(ServiceImpl.class); - try { - impl.setComponentType(introspector.introspect(ServiceImpl.class)); - } catch (ConfigurationException e) { - throw new AssertionError(); - } - impl.initialize(null); - AtomicComponent component = assemblyFactory.createSimpleComponent(); - component.setImplementation(impl); - return component; - } - - protected void setUp() throws Exception { - super.setUp(); - loader = new ComponentLoader(); - loader.setFactory(assemblyFactory); - loader.setDefaultPropertyFactory(new StringParserPropertyFactory()); - introspector = ProcessorUtils.createCoreIntrospector(assemblyFactory); - } - - public static interface Service { - } - - public static class ServiceImpl implements Service { - public String propString; - public int propInt; - public Integer propInteger; - public Foo propFoo; - } - - public static class Foo { - public Foo() { - } - - private String name; - private Foo foo; - - public void setName(String val) { - name = val; - } - - public void setFoo(Foo val) { - foo = val; - } -/* - - private MyJaxBThing jaxBThing; - - public void setMyJaxBThing(MyJaxBThing thing) { - jaxBthing = thing; - } -*/ - } - - public static class FooFactory implements StAXPropertyFactory<Foo> { - public ObjectFactory<Foo> createObjectFactory(XMLStreamReader reader, Property property) throws XMLStreamException, ConfigurationLoadException { - reader.nextTag(); - String name = reader.getElementText(); - reader.next(); - Foo foo = new Foo(); - foo.setName(name); - return new SingletonObjectFactory<Foo>(foo); - } - } -} diff --git a/tags/java-M1-final/java/sca/core/src/test/java/org/apache/tuscany/core/loader/assembly/ComponentTypeLoaderTestCase.java b/tags/java-M1-final/java/sca/core/src/test/java/org/apache/tuscany/core/loader/assembly/ComponentTypeLoaderTestCase.java deleted file mode 100644 index 43b5bec143..0000000000 --- a/tags/java-M1-final/java/sca/core/src/test/java/org/apache/tuscany/core/loader/assembly/ComponentTypeLoaderTestCase.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * - * Copyright 2005 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.tuscany.core.loader.assembly; - -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.core.config.ConfigurationLoadException; -import org.apache.tuscany.model.assembly.ComponentType; -import org.apache.tuscany.model.assembly.Service; - -/** - * @version $Rev$ $Date$ - */ -public class ComponentTypeLoaderTestCase extends LoaderTestSupport { - - public void testMinimal() throws XMLStreamException, ConfigurationLoadException { - XMLStreamReader reader = getReader("<componentType xmlns='http://www.osoa.org/xmlns/sca/0.9'><service name='service1'/></componentType>"); - ComponentType type = (ComponentType) registry.load(reader, loaderContext); - type.initialize(null); - assertNotNull(type); - assertEquals(1, type.getServices().size()); - Service service = type.getService("service1"); - assertEquals("service1", service.getName()); - assertEquals(XMLStreamConstants.END_DOCUMENT, reader.next()); - } - - protected void setUp() throws Exception { - super.setUp(); - registerLoader(new ComponentTypeLoader()); - registerLoader(new ServiceLoader()); - } - -} diff --git a/tags/java-M1-final/java/sca/core/src/test/java/org/apache/tuscany/core/loader/assembly/EntryPointLoaderTestCase.java b/tags/java-M1-final/java/sca/core/src/test/java/org/apache/tuscany/core/loader/assembly/EntryPointLoaderTestCase.java deleted file mode 100644 index 8f207261fb..0000000000 --- a/tags/java-M1-final/java/sca/core/src/test/java/org/apache/tuscany/core/loader/assembly/EntryPointLoaderTestCase.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * - * Copyright 2006 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.tuscany.core.loader.assembly; - -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.core.config.ConfigurationLoadException; -import static org.apache.tuscany.core.loader.assembly.AssemblyConstants.ENTRY_POINT; -import org.apache.tuscany.model.assembly.ConfiguredService; -import org.apache.tuscany.model.assembly.EntryPoint; -import org.apache.tuscany.model.types.java.JavaServiceContract; - -/** - * @version $Rev$ $Date$ - */ -public class EntryPointLoaderTestCase extends LoaderTestSupport { - - public void testMinimal() throws XMLStreamException, ConfigurationLoadException { - String xml = "<entryPoint xmlns='http://www.osoa.org/xmlns/sca/0.9' name='test'></entryPoint>"; - XMLStreamReader reader = getReader(xml); - EntryPoint ep = (EntryPoint) registry.load(reader, loaderContext); - reader.require(XMLStreamConstants.END_ELEMENT, ENTRY_POINT.getNamespaceURI(), ENTRY_POINT.getLocalPart()); - assertEquals(XMLStreamConstants.END_DOCUMENT, reader.next()); - assertNotNull(ep); - assertEquals("test", ep.getName()); - } - - public void testInterface() throws XMLStreamException, ConfigurationLoadException { - String interfaceName = MockService.class.getName(); - String xml = "<entryPoint xmlns='http://www.osoa.org/xmlns/sca/0.9' name='test'><interface.java interface='" + interfaceName + "'/></entryPoint>"; - XMLStreamReader reader = getReader(xml); - EntryPoint ep = (EntryPoint) registry.load(reader, loaderContext); - reader.require(XMLStreamConstants.END_ELEMENT, ENTRY_POINT.getNamespaceURI(), ENTRY_POINT.getLocalPart()); - assertEquals(XMLStreamConstants.END_DOCUMENT, reader.next()); - assertNotNull(ep); - assertEquals("test", ep.getName()); - ConfiguredService configuredService = ep.getConfiguredService(); - JavaServiceContract serviceContract = (JavaServiceContract) configuredService.getPort().getServiceContract(); - assertEquals(interfaceName, serviceContract.getInterfaceName()); - } - - protected void setUp() throws Exception { - super.setUp(); - registerLoader(new EntryPointLoader()); - registerLoader(new InterfaceJavaLoader()); - } -} diff --git a/tags/java-M1-final/java/sca/core/src/test/java/org/apache/tuscany/core/loader/assembly/ExternalServiceLoaderTestCase.java b/tags/java-M1-final/java/sca/core/src/test/java/org/apache/tuscany/core/loader/assembly/ExternalServiceLoaderTestCase.java deleted file mode 100644 index 1fc5b367d5..0000000000 --- a/tags/java-M1-final/java/sca/core/src/test/java/org/apache/tuscany/core/loader/assembly/ExternalServiceLoaderTestCase.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * - * Copyright 2006 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.tuscany.core.loader.assembly; - -import static org.apache.tuscany.core.loader.assembly.AssemblyConstants.EXTERNAL_SERVICE; - -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamConstants; - -import org.apache.tuscany.core.config.ConfigurationLoadException; -import org.apache.tuscany.model.assembly.ConfiguredService; -import org.apache.tuscany.model.assembly.ExternalService; -import org.apache.tuscany.model.types.java.JavaServiceContract; - -/** - * @version $Rev$ $Date$ - */ -public class ExternalServiceLoaderTestCase extends LoaderTestSupport { - - public void testMinimal() throws XMLStreamException, ConfigurationLoadException { - String xml = "<externalService xmlns='http://www.osoa.org/xmlns/sca/0.9' name='test'></externalService>"; - XMLStreamReader reader = getReader(xml); - ExternalService es = (ExternalService) registry.load(reader, loaderContext); - assertNotNull(es); - assertEquals("test", es.getName()); - reader.require(XMLStreamConstants.END_ELEMENT, EXTERNAL_SERVICE.getNamespaceURI(), EXTERNAL_SERVICE.getLocalPart()); - assertEquals(XMLStreamConstants.END_DOCUMENT, reader.next()); - } - - public void testInterface() throws XMLStreamException, ConfigurationLoadException { - String interfaceName = MockService.class.getName(); - String xml = "<externalService xmlns='http://www.osoa.org/xmlns/sca/0.9' name='test'><interface.java interface='" + interfaceName + "'/></externalService>"; - XMLStreamReader reader = getReader(xml); - ExternalService es = (ExternalService) registry.load(reader, loaderContext); - reader.require(XMLStreamConstants.END_ELEMENT, EXTERNAL_SERVICE.getNamespaceURI(), EXTERNAL_SERVICE.getLocalPart()); - assertEquals(XMLStreamConstants.END_DOCUMENT, reader.next()); - assertNotNull(es); - assertEquals("test", es.getName()); - ConfiguredService configuredService = es.getConfiguredService(); - JavaServiceContract serviceContract = (JavaServiceContract) configuredService.getPort().getServiceContract(); - assertEquals(interfaceName, serviceContract.getInterfaceName()); - } - - protected void setUp() throws Exception { - super.setUp(); - registerLoader(new ExternalServiceLoader()); - registerLoader(new InterfaceJavaLoader()); - } -} diff --git a/tags/java-M1-final/java/sca/core/src/test/java/org/apache/tuscany/core/loader/assembly/InterfaceWSDLLoaderInterfaceStylesTestCase.java b/tags/java-M1-final/java/sca/core/src/test/java/org/apache/tuscany/core/loader/assembly/InterfaceWSDLLoaderInterfaceStylesTestCase.java deleted file mode 100644 index 8b4f840f71..0000000000 --- a/tags/java-M1-final/java/sca/core/src/test/java/org/apache/tuscany/core/loader/assembly/InterfaceWSDLLoaderInterfaceStylesTestCase.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * - * Copyright 2006 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.tuscany.core.loader.assembly; - -import static org.apache.tuscany.core.loader.assembly.AssemblyConstants.INTERFACE_WSDL; - -import java.io.InputStream; -import java.net.URL; - -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.common.resource.ResourceLoader; -import org.apache.tuscany.common.resource.impl.ResourceLoaderImpl; -import org.apache.tuscany.core.loader.impl.WSDLDefinitionRegistryImpl; -import org.apache.tuscany.model.types.wsdl.WSDLServiceContract; -import org.apache.tuscany.sdo.util.SDOUtil; - -import commonj.sdo.helper.XSDHelper; - -/** - * @version $Rev$ $Date$ - */ -public class InterfaceWSDLLoaderInterfaceStylesTestCase extends LoaderTestSupport { - private WSDLDefinitionRegistryImpl wsdlRegistry; - private ResourceLoader resourceLoader; - private ClassLoader oldCL; - - public void testInterface() throws Exception { - wsdlRegistry.loadDefinition("http://www.interfacestyles.org", getClass().getResource("interfacestyles.wsdl"), resourceLoader); - String xml = "<interface.wsdl xmlns='http://www.osoa.org/xmlns/sca/0.9' interface='http://www.interfacestyles.org#TestInterfaceStylesService'></interface.wsdl>"; - XMLStreamReader reader = getReader(xml); - WSDLServiceContract sc = (WSDLServiceContract) registry.load(reader, loaderContext); - reader.require(XMLStreamConstants.END_ELEMENT, INTERFACE_WSDL.getNamespaceURI(), INTERFACE_WSDL.getLocalPart()); - assertEquals(XMLStreamConstants.END_DOCUMENT, reader.next()); - assertNotNull(sc); - - sc.initialize(modelContext); - - Class scInterface = sc.getInterface(); - assertNotNull(scInterface); - - assertNotNull(scInterface.getMethod("getAccountReportWrapped0", new Class[0])); - assertNotNull(scInterface.getMethod("getAccountReportWrapped1", new Class[] {String.class})); - assertNotNull(scInterface.getMethod("getAccountReportWrappedN", new Class[] {String.class, int.class})); - assertNotNull(scInterface.getMethod("getAccountReportBare0", new Class[0])); - assertNotNull(scInterface.getMethod("getAccountReportBare1Simple", new Class[]{String.class})); - assertNotNull(scInterface.getMethod("getAccountReportBare1Complex", new Class[]{Object.class})); - - } - - protected void setUp() throws Exception { - oldCL = Thread.currentThread().getContextClassLoader(); - Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); - resourceLoader = new ResourceLoaderImpl(getClass().getClassLoader()); - super.setUp(); - - wsdlRegistry = new WSDLDefinitionRegistryImpl(); - wsdlRegistry.setMonitor(NULL_MONITOR); - URL wsdlURL = getClass().getResource("interfacestyles.wsdl"); - wsdlRegistry.loadDefinition("http://www.interfacestyles.org", wsdlURL, resourceLoader); - InterfaceWSDLLoader loader = new InterfaceWSDLLoader(); - loader.setWsdlRegistry(wsdlRegistry); - registerLoader(loader); - - InputStream xsdInputStream = wsdlURL.openStream(); - try { - XSDHelper xsdHelper = SDOUtil.createXSDHelper(modelContext.getTypeHelper()); - xsdHelper.define(xsdInputStream, null); - } finally { - xsdInputStream.close(); - } - } - - protected void tearDown() throws Exception { - Thread.currentThread().setContextClassLoader(oldCL); - super.tearDown(); - } - - private static final WSDLDefinitionRegistryImpl.Monitor NULL_MONITOR = new WSDLDefinitionRegistryImpl.Monitor() { - public void readingWSDL(String namespace, URL location) { - } - - public void cachingDefinition(String namespace, URL location) { - } - }; -} diff --git a/tags/java-M1-final/java/sca/core/src/test/java/org/apache/tuscany/core/loader/assembly/InterfaceWSDLLoaderTestCase.java b/tags/java-M1-final/java/sca/core/src/test/java/org/apache/tuscany/core/loader/assembly/InterfaceWSDLLoaderTestCase.java deleted file mode 100644 index f97f13a1f7..0000000000 --- a/tags/java-M1-final/java/sca/core/src/test/java/org/apache/tuscany/core/loader/assembly/InterfaceWSDLLoaderTestCase.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * - * Copyright 2006 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.tuscany.core.loader.assembly; - -import java.net.URL; -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.common.resource.ResourceLoader; -import org.apache.tuscany.common.resource.impl.ResourceLoaderImpl; -import org.apache.tuscany.core.config.ConfigurationLoadException; -import static org.apache.tuscany.core.loader.assembly.AssemblyConstants.INTERFACE_WSDL; -import org.apache.tuscany.core.loader.impl.WSDLDefinitionRegistryImpl; -import org.apache.tuscany.model.types.wsdl.WSDLServiceContract; - -/** - * @version $Rev$ $Date$ - */ -public class InterfaceWSDLLoaderTestCase extends LoaderTestSupport { - private WSDLDefinitionRegistryImpl wsdlRegistry; - private ResourceLoader resourceLoader; - - public void testMinimal() throws XMLStreamException, ConfigurationLoadException { - String xml = "<interface.wsdl xmlns='http://www.osoa.org/xmlns/sca/0.9'></interface.wsdl>"; - XMLStreamReader reader = getReader(xml); - WSDLServiceContract sc = (WSDLServiceContract) registry.load(reader, loaderContext); - reader.require(XMLStreamConstants.END_ELEMENT, INTERFACE_WSDL.getNamespaceURI(), INTERFACE_WSDL.getLocalPart()); - assertEquals(XMLStreamConstants.END_DOCUMENT, reader.next()); - assertNotNull(sc); - } - - public void testInterface() throws Exception { - wsdlRegistry.loadDefinition("http://www.example.org", getClass().getResource("example.wsdl"), resourceLoader); - String xml = "<interface.wsdl xmlns='http://www.osoa.org/xmlns/sca/0.9' interface='http://www.example.org#HelloWorld'></interface.wsdl>"; - XMLStreamReader reader = getReader(xml); - WSDLServiceContract sc = (WSDLServiceContract) registry.load(reader, loaderContext); - reader.require(XMLStreamConstants.END_ELEMENT, INTERFACE_WSDL.getNamespaceURI(), INTERFACE_WSDL.getLocalPart()); - assertEquals(XMLStreamConstants.END_DOCUMENT, reader.next()); - assertNotNull(sc); - } - - public void testInterfaceWithLocation() throws Exception { - wsdlRegistry.loadDefinition("http://www.example.org", getClass().getResource("example.wsdl"), resourceLoader); - String xml = "<interface.wsdl xmlns='http://www.osoa.org/xmlns/sca/0.9' xmlns:wsdli='http://www.w3.org/2006/01/wsdl-instance' " + - "wsdli:wsdlLocation='http://www.example.org " + getClass().getResource("example.wsdl") + "' "+ - "interface='http://www.example.org#HelloWorld'"+ - "></interface.wsdl>"; - XMLStreamReader reader = getReader(xml); - WSDLServiceContract sc = (WSDLServiceContract) registry.load(reader, loaderContext); - reader.require(XMLStreamConstants.END_ELEMENT, INTERFACE_WSDL.getNamespaceURI(), INTERFACE_WSDL.getLocalPart()); - assertEquals(XMLStreamConstants.END_DOCUMENT, reader.next()); - assertNotNull(sc); - } - - protected void setUp() throws Exception { - super.setUp(); - wsdlRegistry = new WSDLDefinitionRegistryImpl(); - wsdlRegistry.setMonitor(NULL_MONITOR); - resourceLoader = new ResourceLoaderImpl(getClass().getClassLoader()); - wsdlRegistry.loadDefinition("http://www.example.org", getClass().getResource("example.wsdl"), resourceLoader); - InterfaceWSDLLoader loader = new InterfaceWSDLLoader(); - loader.setWsdlRegistry(wsdlRegistry); - registerLoader(loader); - } - - private static final WSDLDefinitionRegistryImpl.Monitor NULL_MONITOR = new WSDLDefinitionRegistryImpl.Monitor() { - public void readingWSDL(String namespace, URL location) { - } - - public void cachingDefinition(String namespace, URL location) { - } - }; -} diff --git a/tags/java-M1-final/java/sca/core/src/test/java/org/apache/tuscany/core/loader/assembly/LoaderTestSupport.java b/tags/java-M1-final/java/sca/core/src/test/java/org/apache/tuscany/core/loader/assembly/LoaderTestSupport.java deleted file mode 100644 index 4e2aea5e83..0000000000 --- a/tags/java-M1-final/java/sca/core/src/test/java/org/apache/tuscany/core/loader/assembly/LoaderTestSupport.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * - * Copyright 2006 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.tuscany.core.loader.assembly; - -import java.io.StringReader; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.namespace.QName; - -import junit.framework.TestCase; - -import org.apache.tuscany.common.resource.ResourceLoader; -import org.apache.tuscany.common.resource.impl.ResourceLoaderImpl; -import org.apache.tuscany.core.system.assembly.SystemAssemblyFactory; -import org.apache.tuscany.core.system.assembly.impl.SystemAssemblyFactoryImpl; -import org.apache.tuscany.core.loader.impl.StAXLoaderRegistryImpl; -import org.apache.tuscany.core.loader.LoaderContext; -import org.apache.tuscany.model.assembly.AssemblyContext; -import org.apache.tuscany.model.assembly.impl.AssemblyContextImpl; - -/** - * Base class for loader tests with common fixture elements. - * - * @version $Rev$ $Date$ - */ -public abstract class LoaderTestSupport extends TestCase { - protected SystemAssemblyFactory assemblyFactory; - protected ResourceLoader resourceLoader; - protected LoaderContext loaderContext; - protected AssemblyContext modelContext; - protected XMLInputFactory xmlFactory; - protected StAXLoaderRegistryImpl registry; - - protected static final StAXLoaderRegistryImpl.Monitor NULL_MONITOR = new StAXLoaderRegistryImpl.Monitor() { - public void registeringLoader(QName xmlType) { - } - - public void unregisteringLoader(QName xmlType) { - } - - public void elementLoad(QName xmlType) { - } - }; - - protected void setUp() throws Exception { - super.setUp(); - assemblyFactory = new SystemAssemblyFactoryImpl(); - resourceLoader = new ResourceLoaderImpl(getClass().getClassLoader()); - loaderContext = new LoaderContext(resourceLoader); - modelContext = new AssemblyContextImpl(assemblyFactory, null, resourceLoader); - xmlFactory = XMLInputFactory.newInstance(); - registry = new StAXLoaderRegistryImpl(); - registry.setMonitor(NULL_MONITOR); - } - - protected XMLStreamReader getReader(String xml) throws XMLStreamException { - XMLStreamReader reader = xmlFactory.createXMLStreamReader(new StringReader(xml)); - reader.next(); - return reader; - } - - protected void registerLoader(AbstractLoader<?> loader) { - loader.setFactory(assemblyFactory); - loader.setRegistry(registry); - loader.start(); - } -} diff --git a/tags/java-M1-final/java/sca/core/src/test/java/org/apache/tuscany/core/loader/assembly/MockService.java b/tags/java-M1-final/java/sca/core/src/test/java/org/apache/tuscany/core/loader/assembly/MockService.java deleted file mode 100644 index c1ea3dbc1e..0000000000 --- a/tags/java-M1-final/java/sca/core/src/test/java/org/apache/tuscany/core/loader/assembly/MockService.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * - * Copyright 2006 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.tuscany.core.loader.assembly; - -/** - * @version $Rev$ $Date$ - */ -public interface MockService { -} diff --git a/tags/java-M1-final/java/sca/core/src/test/java/org/apache/tuscany/core/loader/assembly/WSDLDefinitionRegistryTestCase.java b/tags/java-M1-final/java/sca/core/src/test/java/org/apache/tuscany/core/loader/assembly/WSDLDefinitionRegistryTestCase.java deleted file mode 100644 index 5543a41f91..0000000000 --- a/tags/java-M1-final/java/sca/core/src/test/java/org/apache/tuscany/core/loader/assembly/WSDLDefinitionRegistryTestCase.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * - * Copyright 2006 The Apache Software Foundation or its licensors as applicable - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.tuscany.core.loader.assembly; - -import java.net.URL; -import java.io.IOException; - -import javax.wsdl.Definition; -import javax.wsdl.WSDLException; -import javax.xml.namespace.QName; - -import junit.framework.TestCase; -import org.apache.tuscany.core.loader.impl.WSDLDefinitionRegistryImpl; -import org.apache.tuscany.common.resource.ResourceLoader; -import org.apache.tuscany.common.resource.impl.ResourceLoaderImpl; - -/** - * @version $Rev$ $Date$ - */ -public class WSDLDefinitionRegistryTestCase extends TestCase { - private static final String NS = "http://www.example.org"; - private WSDLDefinitionRegistryImpl wsdlRegistry; - private ResourceLoader rl; - - - public void testLoadFromAbsoluteWSDLLocation() { - try { - Definition def = wsdlRegistry.loadDefinition(NS + ' ' + rl.getResource("org/apache/tuscany/core/loader/assembly/example.wsdl"), rl); - assertNotNull(def.getPortType(new QName(NS, "HelloWorld"))); - } catch (IOException e) { - fail(e.getMessage()); - } catch (WSDLException e) { - fail(e.getMessage()); - } - } - - public void testLoadFromRelativeWSDLLocation() { - try { - Definition def = wsdlRegistry.loadDefinition(NS + " org/apache/tuscany/core/loader/assembly/example.wsdl", rl); - assertNotNull(def.getPortType(new QName(NS, "HelloWorld"))); - } catch (IOException e) { - fail(e.getMessage()); - } catch (WSDLException e) { - fail(e.getMessage()); - } - } - - protected void setUp() throws Exception { - super.setUp(); - wsdlRegistry = new WSDLDefinitionRegistryImpl(); - wsdlRegistry.setMonitor(NULL_MONITOR); - rl = new ResourceLoaderImpl(getClass().getClassLoader()); - } - - private static final WSDLDefinitionRegistryImpl.Monitor NULL_MONITOR = new WSDLDefinitionRegistryImpl.Monitor() { - public void readingWSDL(String namespace, URL location) { - } - - public void cachingDefinition(String namespace, URL location) { - } - }; -} diff --git a/tags/java-M1-final/java/sca/core/src/test/java/org/apache/tuscany/core/loader/assembly/WireLoaderTestCase.java b/tags/java-M1-final/java/sca/core/src/test/java/org/apache/tuscany/core/loader/assembly/WireLoaderTestCase.java deleted file mode 100644 index 3a0331150d..0000000000 --- a/tags/java-M1-final/java/sca/core/src/test/java/org/apache/tuscany/core/loader/assembly/WireLoaderTestCase.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * - * Copyright 2005 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.tuscany.core.loader.assembly; - -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.core.config.ConfigurationLoadException; -import org.apache.tuscany.model.assembly.Wire; - -/** - * @version $Rev$ $Date$ - */ -public class WireLoaderTestCase extends LoaderTestSupport { - - public void testMinimal() throws XMLStreamException, ConfigurationLoadException { - String xml = "<wire xmlns='http://www.osoa.org/xmlns/sca/0.9'><source.uri>foo/fooService</source.uri><target.uri>bar</target.uri></wire>"; - XMLStreamReader reader = getReader(xml); - Wire wire = (Wire) registry.load(reader, loaderContext); - reader.require(XMLStreamConstants.END_ELEMENT, AssemblyConstants.WIRE.getNamespaceURI(), AssemblyConstants.WIRE.getLocalPart()); - assertEquals(XMLStreamConstants.END_DOCUMENT, reader.next()); - assertNotNull(wire); - assertEquals("foo", wire.getSource().getPartName()); - assertEquals("fooService", wire.getSource().getServiceName()); - assertEquals("bar", wire.getTarget().getPartName()); - } - - public void testCompound() throws XMLStreamException, ConfigurationLoadException { - String xml = "<wire xmlns='http://www.osoa.org/xmlns/sca/0.9'><source.uri>foo/fooService</source.uri><target.uri>bar/bazService</target.uri></wire>"; - XMLStreamReader reader = getReader(xml); - Wire wire = (Wire) registry.load(reader, loaderContext); - reader.require(XMLStreamConstants.END_ELEMENT, AssemblyConstants.WIRE.getNamespaceURI(), AssemblyConstants.WIRE.getLocalPart()); - assertEquals(XMLStreamConstants.END_DOCUMENT, reader.next()); - assertNotNull(wire); - assertEquals("foo", wire.getSource().getPartName()); - assertEquals("fooService", wire.getSource().getServiceName()); - assertEquals("bar", wire.getTarget().getPartName()); - assertEquals("bazService", wire.getTarget().getServiceName()); - } - - protected void setUp() throws Exception { - super.setUp(); - registerLoader(new WireLoader()); - } -} |