From fb3dd9a9095abc40027318b1712d0184f6d60e73 Mon Sep 17 00:00:00 2001 From: antelder Date: Fri, 30 Oct 2009 08:00:47 +0000 Subject: Delete old M4 branch and start again to pick up all the recent trunk changes git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@831223 13f79535-47bb-0310-9956-ffa450edef68 --- .../xml/BluePrintComponentsProcessorTestCase.java | 89 ------------- .../osgi/xml/OSGiComponentProcessorTestCase.java | 89 ------------- .../osgi/xml/OSGiReadImplTestCase.java | 139 --------------------- .../osgi/xml/ServiceDescriptionsTestCase.java | 108 ---------------- .../implementation/osgi/xml/TestModelResolver.java | 105 ---------------- 5 files changed, 530 deletions(-) delete mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/BluePrintComponentsProcessorTestCase.java delete mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiComponentProcessorTestCase.java delete mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java delete mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsTestCase.java delete mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/TestModelResolver.java (limited to 'branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation') diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/BluePrintComponentsProcessorTestCase.java b/branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/BluePrintComponentsProcessorTestCase.java deleted file mode 100644 index 224467181b..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/BluePrintComponentsProcessorTestCase.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.implementation.osgi.xml; - -import java.io.StringReader; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.sca.assembly.ComponentType; -import org.apache.tuscany.sca.contribution.processor.ProcessorContext; -import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; -import org.apache.tuscany.sca.core.DefaultFactoryExtensionPoint; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * - */ -public class BluePrintComponentsProcessorTestCase { - private static final String xml = - "" + "" - + "" - + "" - + "" - + "" - + "" - + "" - + "" - + "" - + "" - + "" - + "" - + "" - + "" - + "" - + "" - + "" - + ""; - private static XMLStreamReader reader; - - /** - * @throws java.lang.Exception - */ - @BeforeClass - public static void setUpBeforeClass() throws Exception { - XMLInputFactory factory = XMLInputFactory.newInstance(); - reader = factory.createXMLStreamReader(new StringReader(xml)); - } - - @Test - public void testLoad() throws Exception { - BluePrintComponentsProcessor processor = - new BluePrintComponentsProcessor(new DefaultFactoryExtensionPoint(new DefaultExtensionPointRegistry())); - ComponentType ct = processor.read(reader, new ProcessorContext()); - Assert.assertEquals(1, ct.getServices().size()); - Assert.assertEquals(4, ct.getReferences().size()); - } - - /** - * @throws java.lang.Exception - */ - @AfterClass - public static void tearDownAfterClass() throws Exception { - if (reader != null) { - reader.close(); - } - } - -} diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiComponentProcessorTestCase.java b/branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiComponentProcessorTestCase.java deleted file mode 100644 index ef49121c2c..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiComponentProcessorTestCase.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.implementation.osgi.xml; - -import java.io.StringReader; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.sca.assembly.ComponentType; -import org.apache.tuscany.sca.contribution.processor.ProcessorContext; -import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; -import org.apache.tuscany.sca.core.DefaultFactoryExtensionPoint; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * - */ -public class OSGiComponentProcessorTestCase { - private static final String xml = - "" + "" - + "" - + "" - + "" - + "" - + "" - + "" - + "" - + "" - + ""; - - private static XMLStreamReader reader; - - /** - * @throws java.lang.Exception - */ - @BeforeClass - public static void setUpBeforeClass() throws Exception { - XMLInputFactory factory = XMLInputFactory.newInstance(); - reader = factory.createXMLStreamReader(new StringReader(xml)); - } - - @Test - public void testLoad() throws Exception { - ExtensionPointRegistry registry = new DefaultExtensionPointRegistry(); - OSGiComponentProcessor processor = - new OSGiComponentProcessor(new DefaultFactoryExtensionPoint(registry)); - ComponentType ct = processor.read(reader, new ProcessorContext(registry)); - Assert.assertEquals(1, ct.getServices().size()); - Assert.assertEquals(4, ct.getReferences().size()); - } - - /** - * @throws java.lang.Exception - */ - @AfterClass - public static void tearDownAfterClass() throws Exception { - if (reader != null) { - reader.close(); - } - } - -} diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java b/branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java deleted file mode 100644 index 6b59b498fc..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.implementation.osgi.xml; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.io.StringWriter; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; - -import org.apache.tuscany.sca.assembly.ComponentType; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.ProcessorContext; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; -import org.apache.tuscany.sca.implementation.osgi.OSGiImplementation; -import org.apache.tuscany.sca.implementation.osgi.OSGiProperty; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * Test reading OSGi implementations. - * - * @version $Rev$ $Date$ - */ -public class OSGiReadImplTestCase { - - private static XMLInputFactory inputFactory; - private static XMLOutputFactory outputFactory; - private static StAXArtifactProcessor staxProcessor; - private static ProcessorContext context; - - @BeforeClass - public static void setUp() throws Exception { - DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); - context = new ProcessorContext(extensionPoints); - inputFactory = XMLInputFactory.newInstance(); - outputFactory = XMLOutputFactory.newInstance(); - outputFactory.setProperty("javax.xml.stream.isRepairingNamespaces", Boolean.TRUE); - StAXArtifactProcessorExtensionPoint staxProcessors = - new DefaultStAXArtifactProcessorExtensionPoint(extensionPoints); - staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null); - } - - @Test - public void testReadComposite() throws Exception { - InputStream is = getClass().getClassLoader().getResourceAsStream("osgitest.composite"); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - Composite composite = (Composite)staxProcessor.read(reader, context); - assertNotNull(composite); - } - - @Test - public void testReadAndResolveComposite() throws Exception { - InputStream is = getClass().getClassLoader().getResourceAsStream("osgitest.composite"); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - Composite composite = (Composite)staxProcessor.read(reader, context); - assertNotNull(composite); - - is = getClass().getClassLoader().getResourceAsStream("OSGI-INF/sca/bundle.componentType"); - reader = inputFactory.createXMLStreamReader(is); - ComponentType componentType = (ComponentType)staxProcessor.read(reader, context); - - assertEquals(1, componentType.getServices().size()); - Object prop1 = componentType.getServices().get(0).getExtensions().get(0); - assertTrue(prop1 instanceof OSGiProperty); - OSGiProperty osgiProp1 = (OSGiProperty)prop1; - assertEquals("1", osgiProp1.getValue()); - assertEquals("prop1", osgiProp1.getName()); - - assertEquals(4, componentType.getReferences().size()); - Object prop2 = componentType.getReferences().get(0).getExtensions().get(1); - assertTrue(prop2 instanceof OSGiProperty); - OSGiProperty osgiProp2 = (OSGiProperty)prop2; - assertEquals("ABC", osgiProp2.getValue()); - assertEquals("prop2", osgiProp2.getName()); - - ModelResolver resolver = new TestModelResolver(getClass().getClassLoader()); - staxProcessor.resolve(componentType, resolver, context); - resolver.addModel(componentType, context); - - staxProcessor.resolve(composite, resolver, context); - } - - @Test - public void testReadOSGiImplementation() throws Exception { - - String str = - "" + ""; - ByteArrayInputStream is = new ByteArrayInputStream(str.getBytes()); - - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - reader.nextTag(); - - OSGiImplementation osgiImpl = (OSGiImplementation)staxProcessor.read(reader, context); - - assertEquals(osgiImpl.getBundleSymbolicName(), "osgi.test"); - assertEquals(osgiImpl.getBundleVersion(), "1.0.0"); - - StringWriter sw = new StringWriter(); - XMLStreamWriter writer = outputFactory.createXMLStreamWriter(sw); - staxProcessor.write(osgiImpl, writer, context); - writer.flush(); - Assert.assertTrue(sw.toString().contains("bundleSymbolicName=\"osgi.test\" bundleVersion=\"1.0.0\"")); - } - -} diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsTestCase.java b/branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsTestCase.java deleted file mode 100644 index 1b28373f5b..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsTestCase.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.implementation.osgi.xml; - -import java.io.StringReader; -import java.util.List; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.ProcessorContext; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; -import org.apache.tuscany.sca.implementation.osgi.ServiceDescription; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * - */ -public class ServiceDescriptionsTestCase { - private static final String xml = - "" - + "" - + "" - + "" - + "sca:SOAP sca:HTTP" - + "sca" - + "" - + "OSGI-INF/sca/bundle.componentType" - + "" - + "" - + "addService" - + "" - + "" - + "" - + "" - + "sca:SOAP sca:HTTP" - + "sca" - + "" - + "OSGI-INF/sca/bundle.componentType" - + "" - + "" - + "subtractService" - + "" - + "" - + ""; - - private static ServiceDescriptionsProcessor processor; - private static XMLStreamReader reader; - - private static ProcessorContext context; - - @BeforeClass - public static void setUp() throws Exception { - DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); - context = new ProcessorContext(extensionPoints); - - XMLInputFactory factory = XMLInputFactory.newInstance(); - StAXArtifactProcessorExtensionPoint staxProcessors = - extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); - StAXArtifactProcessor staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, factory, null); - - processor = new ServiceDescriptionsProcessor(extensionPoints, staxProcessor); - - reader = factory.createXMLStreamReader(new StringReader(xml)); - } - - @Test - public void testLoad() throws Exception { - List descriptions = processor.read(reader, context); - Assert.assertEquals(2, descriptions.size()); - System.out.println(descriptions); - } - - /** - * @throws java.lang.Exception - */ - @AfterClass - public static void tearDownAfterClass() throws Exception { - if (reader != null) { - reader.close(); - } - } - -} diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/TestModelResolver.java b/branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/TestModelResolver.java deleted file mode 100644 index 17fef8a05c..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/TestModelResolver.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.implementation.osgi.xml; - -import java.lang.ref.WeakReference; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.tuscany.sca.assembly.ComponentType; -import org.apache.tuscany.sca.assembly.Property; -import org.apache.tuscany.sca.contribution.processor.ProcessorContext; -import org.apache.tuscany.sca.contribution.resolver.ClassReference; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.implementation.osgi.impl.OSGiImplementationImpl; - -/** - * A default implementation of an artifact resolver, based on a map. - * - * @version $Rev$ $Date$ - */ -public class TestModelResolver implements ModelResolver { - private static final long serialVersionUID = -7826976465762296634L; - - private Map map = new HashMap(); - - private WeakReference classLoader; - - public TestModelResolver(ClassLoader classLoader) { - this.classLoader = new WeakReference(classLoader); - } - - public T resolveModel(Class modelClass, T unresolved, ProcessorContext context) { - Object resolved = map.get(unresolved); - if (resolved != null) { - - if (unresolved instanceof OSGiImplementationImpl && !(resolved instanceof OSGiImplementationImpl)) { - - OSGiImplementationImpl impl = ((OSGiImplementationImpl)unresolved); - ComponentType componentType = (ComponentType)resolved; - - List properties = componentType.getProperties(); - for (Property property : properties) { - impl.getProperties().add(property); - } - impl.setUnresolved(false); - return unresolved; - } - - // Return the resolved object - return modelClass.cast(resolved); - - } else if (unresolved instanceof ClassReference) { - - // Load a class on demand - ClassReference classReference = (ClassReference)unresolved; - Class clazz; - try { - clazz = Class.forName(classReference.getClassName(), true, classLoader.get()); - } catch (ClassNotFoundException e) { - - // Return the unresolved object - return unresolved; - } - - // Store a new ClassReference wrapping the loaded class - resolved = new ClassReference(clazz); - map.put(resolved, resolved); - - // Return the resolved ClassReference - return modelClass.cast(resolved); - - } else { - - // Return the unresolved object - return unresolved; - } - } - - public void addModel(Object resolved, ProcessorContext context) { - map.put(resolved, resolved); - } - - public Object removeModel(Object resolved, ProcessorContext context) { - return map.remove(resolved); - } - -} -- cgit v1.2.3