summaryrefslogtreecommitdiffstats
path: root/tags/java-M1-20060518/java/sca/databinding/sdo/src
diff options
context:
space:
mode:
Diffstat (limited to 'tags/java-M1-20060518/java/sca/databinding/sdo/src')
-rw-r--r--tags/java-M1-20060518/java/sca/databinding/sdo/src/main/java/org/apache/tuscany/databinding/sdo/ImportSDOLoader.java106
-rw-r--r--tags/java-M1-20060518/java/sca/databinding/sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDOObjectFactory.java45
-rw-r--r--tags/java-M1-20060518/java/sca/databinding/sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDOXMLHelper.java264
-rw-r--r--tags/java-M1-20060518/java/sca/databinding/sdo/src/main/resources/system.fragment25
-rw-r--r--tags/java-M1-20060518/java/sca/databinding/sdo/src/test/java/org/apache/tuscany/databinding/sdo/ImportSDOLoaderTestCase.java59
-rw-r--r--tags/java-M1-20060518/java/sca/databinding/sdo/src/test/java/org/apache/tuscany/databinding/sdo/LoaderTestSupport.java82
-rw-r--r--tags/java-M1-20060518/java/sca/databinding/sdo/src/test/java/org/apache/tuscany/databinding/sdo/SDOXMLHelperTestCase.java141
-rw-r--r--tags/java-M1-20060518/java/sca/databinding/sdo/src/test/resources/org/apache/tuscany/databinding/sdo/CreditScoreDocLit.wsdl76
-rw-r--r--tags/java-M1-20060518/java/sca/databinding/sdo/src/test/resources/org/apache/tuscany/databinding/sdo/CreditScoreDocLitWrapped.wsdl78
-rw-r--r--tags/java-M1-20060518/java/sca/databinding/sdo/src/test/resources/org/apache/tuscany/databinding/sdo/helloworld.wsdl106
10 files changed, 0 insertions, 982 deletions
diff --git a/tags/java-M1-20060518/java/sca/databinding/sdo/src/main/java/org/apache/tuscany/databinding/sdo/ImportSDOLoader.java b/tags/java-M1-20060518/java/sca/databinding/sdo/src/main/java/org/apache/tuscany/databinding/sdo/ImportSDOLoader.java
deleted file mode 100644
index 519d256036..0000000000
--- a/tags/java-M1-20060518/java/sca/databinding/sdo/src/main/java/org/apache/tuscany/databinding/sdo/ImportSDOLoader.java
+++ /dev/null
@@ -1,106 +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.databinding.sdo;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-
-import commonj.sdo.helper.XSDHelper;
-import org.apache.tuscany.common.resource.ResourceLoader;
-import org.apache.tuscany.core.config.ConfigurationLoadException;
-import org.apache.tuscany.core.config.SidefileLoadException;
-import org.apache.tuscany.core.loader.LoaderContext;
-import org.apache.tuscany.core.loader.StAXUtil;
-import org.apache.tuscany.core.loader.assembly.AbstractLoader;
-import org.apache.tuscany.core.loader.assembly.AssemblyConstants;
-import org.apache.tuscany.model.assembly.AssemblyContext;
-import org.apache.tuscany.model.assembly.AssemblyObject;
-import org.apache.tuscany.sdo.util.SDOUtil;
-import org.osoa.sca.annotations.Scope;
-
-/**
- * Loader that handles <import.sdo> elements.
- *
- * @version $Rev$ $Date$
- */
-@Scope("MODULE")
-public class ImportSDOLoader extends AbstractLoader {
- public static final QName IMPORT_SDO = new QName(AssemblyConstants.SCA_NAMESPACE, "import.sdo");
-
- public QName getXMLType() {
- return IMPORT_SDO;
- }
-
- public AssemblyObject load(XMLStreamReader reader, LoaderContext loaderContext) throws XMLStreamException, ConfigurationLoadException {
- assert IMPORT_SDO.equals(reader.getName());
- importFactory(reader, loaderContext);
- importWSDLOrXSD(reader, loaderContext);
- StAXUtil.skipToEndElement(reader);
- return null;
- }
-
- private void importFactory(XMLStreamReader reader, LoaderContext loaderContext) throws ConfigurationLoadException {
- String factoryName = reader.getAttributeValue(null, "factory");
- if (factoryName != null) {
- ResourceLoader resourceLoader = loaderContext.getResourceLoader();
- ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
- try {
- // set TCCL as SDO needs it
- Thread.currentThread().setContextClassLoader(resourceLoader.getClassLoader());
- Class<?> factoryClass = resourceLoader.loadClass(factoryName);
- SDOUtil.registerStaticTypes(factoryClass);
- } catch (ClassNotFoundException e) {
- throw new ConfigurationLoadException(e.getMessage(), e);
- } finally {
- Thread.currentThread().setContextClassLoader(oldCL);
- }
- }
- }
-
- @SuppressWarnings("deprecation")
- private void importWSDLOrXSD(XMLStreamReader reader, LoaderContext loaderContext) throws ConfigurationLoadException {
- String location = reader.getAttributeValue(null, "wsdlLocation");
- if (location == null)
- location = reader.getAttributeValue(null, "schemaLocation");
- if (location != null) {
- ResourceLoader resourceLoader = loaderContext.getResourceLoader();
- URL wsdlURL = resourceLoader.getResource(location);
- ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
- try {
-// Thread.currentThread().setContextClassLoader(resourceLoader.getClassLoader());
- InputStream xsdInputStream = wsdlURL.openStream();
- try {
- AssemblyContext context = registry.getContext();
- XSDHelper xsdHelper = SDOUtil.createXSDHelper(context.getTypeHelper());
- xsdHelper.define(xsdInputStream, null);
- } finally {
- xsdInputStream.close();
- }
- } catch (IOException e) {
- SidefileLoadException sfe = new SidefileLoadException(e.getMessage());
- sfe.setResourceURI(location);
- throw sfe;
- } finally {
- Thread.currentThread().setContextClassLoader(oldCL);
- }
- }
- }
-}
diff --git a/tags/java-M1-20060518/java/sca/databinding/sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDOObjectFactory.java b/tags/java-M1-20060518/java/sca/databinding/sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDOObjectFactory.java
deleted file mode 100644
index 0f0cc13fd8..0000000000
--- a/tags/java-M1-20060518/java/sca/databinding/sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDOObjectFactory.java
+++ /dev/null
@@ -1,45 +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.databinding.sdo;
-
-import commonj.sdo.DataObject;
-import commonj.sdo.helper.CopyHelper;
-import org.apache.tuscany.core.builder.ObjectFactory;
-import org.apache.tuscany.core.injection.ObjectCreationException;
-
-/**
- * Creates new instances of an SDO
- *
- * @version $Rev$ $Date$
- */
-public class SDOObjectFactory implements ObjectFactory<DataObject> {
-
- private DataObject dataObject;
-
- public SDOObjectFactory(DataObject dataObject) {
- this.dataObject = dataObject;
- }
-
- public DataObject getInstance() throws ObjectCreationException {
- return CopyHelper.INSTANCE.copy(dataObject);
- }
-
- public void releaseInstance(DataObject instance) {
- }
-
-}
-
diff --git a/tags/java-M1-20060518/java/sca/databinding/sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDOXMLHelper.java b/tags/java-M1-20060518/java/sca/databinding/sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDOXMLHelper.java
deleted file mode 100644
index d732676c76..0000000000
--- a/tags/java-M1-20060518/java/sca/databinding/sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDOXMLHelper.java
+++ /dev/null
@@ -1,264 +0,0 @@
-/**
- *
- * Copyright 2005 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.databinding.sdo;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.util.List;
-
-import javax.xml.namespace.QName;
-
-import org.apache.tuscany.core.wire.InvocationRuntimeException;
-import org.apache.tuscany.sdo.util.SDOUtil;
-import org.osoa.sca.ServiceRuntimeException;
-
-import commonj.sdo.DataObject;
-import commonj.sdo.Property;
-import commonj.sdo.Type;
-import commonj.sdo.helper.DataFactory;
-import commonj.sdo.helper.TypeHelper;
-import commonj.sdo.helper.XMLDocument;
-import commonj.sdo.helper.XMLHelper;
-import commonj.sdo.helper.XSDHelper;
-
-/**
- * Utility methods to convert between XML byte arrays, SDO DataObjects, and Java objects.
- *
- * Most of these methods rely on the schemas having been registered with XSDHelper.define
- */
-public final class SDOXMLHelper {
-
- private SDOXMLHelper() {
- // utility class, never contructed
- }
-
- /**
- * Deserialize an XML byte array into Java Objects
- *
- * @param xmlBytes
- * the byte array containing the XML
- * @param isWrapped
- *
- * @return the array of deserialized Java objects
- * @deprecated TUSCANY-333 use the method that takes a ClassLoader
- */
- public static Object[] toObjects(TypeHelper typeHelper, byte[] xmlBytes, boolean isWrapped) {
- DataObject dataObject = toDataObject(typeHelper, xmlBytes);
- return toObjects(dataObject, isWrapped);
- }
-
- /**
- * Convert a typed DataObject to Java objects
- *
- * @param dataObject
- * @param isWrapped
- * @return the array of Objects from the DataObject
- */
- public static Object[] toObjects(DataObject dataObject, boolean isWrapped) {
- if (isWrapped) {
- List ips = dataObject.getInstanceProperties();
- Object[] os = new Object[ips.size()];
- for (int i = 0; i < ips.size(); i++) {
- os[i] = dataObject.get((Property) ips.get(i));
- }
- return os;
- } else {
- Object object = dataObject;
- Type type = dataObject.getType();
- if (type.isSequenced()) {
- object = dataObject.getSequence().getValue(0);
- }
- return new Object[] { object };
- }
- }
-
- /**
- * Serializes objects to an XML byte array
- *
- * @param os
- * @param typeNS
- * @param typeName
- * @return a byte array containing the XML
- * @deprecated TUSCANY-333 use the method that takes a ClassLoader
- */
- public static byte[] toXMLBytes(TypeHelper typeHelper, Object[] os, QName elementQName, boolean isWrapped) {
- DataObject dataObject = toDataObject(typeHelper, os, elementQName, isWrapped);
- return toXMLbytes(typeHelper, dataObject, elementQName);
- }
-
- /**
- * Convert a DataObject to an XML byte array
- *
- * @param dataObject
- * @param typeNS
- * @param typeName
- * @return a byte array containing the XML bytes
- * @deprecated TUSCANY-333 use the method that takes a ClassLoader
- */
- public static byte[] toXMLbytes(TypeHelper typeHelper, DataObject dataObject, QName elementQName) {
- try {
-
- ByteArrayOutputStream pos = new ByteArrayOutputStream();
- XMLHelper xmlHelper = SDOUtil.createXMLHelper(typeHelper);
- xmlHelper.save(dataObject, elementQName.getNamespaceURI(), elementQName.getLocalPart(), pos);
- pos.close();
-
- return pos.toByteArray();
-
- } catch (IOException e) {
- throw new ServiceRuntimeException(e);
- }
- }
-
- /**
- * Deserialize an XML byte array into a DataObject
- *
- * @param xmlBytes
- * @return a DataObject
- * @deprecated TUSCANY-333 use the method that takes a ClassLoader
- */
- public static DataObject toDataObject(TypeHelper typeHelper, byte[] xmlBytes) {
- try {
-
- XMLHelper xmlHelper = SDOUtil.createXMLHelper(typeHelper);
- XMLDocument document = xmlHelper.load(new ByteArrayInputStream(xmlBytes));
-
- return document.getRootObject();
-
- } catch (IOException e) {
- throw new ServiceRuntimeException(e);
- }
- }
-
- /**
- * Convert objects to typed DataObject
- *
- * @param typeNS
- * @param typeName
- * @param os
- * @return the DataObject
- * @deprecated TUSCANY-333 use the method that takes a ClassLoader
- */
- public static DataObject toDataObject(TypeHelper typeHelper, Object[] os, QName elementQName, boolean isWrapped) {
- XSDHelper xsdHelper = SDOUtil.createXSDHelper(typeHelper);
-
- Property property = xsdHelper.getGlobalProperty(elementQName.getNamespaceURI(), elementQName.getLocalPart(), true);
- if (null == property) {
- throw new InvocationRuntimeException("Type '" + elementQName.toString() + "' not found in registered SDO types.");
- }
- if (isWrapped) {
- DataFactory dataFactory = SDOUtil.createDataFactory(typeHelper);
- DataObject dataObject = dataFactory.create(property.getType());
- List ips = dataObject.getInstanceProperties();
- for (int i = 0; i < ips.size(); i++) {
- dataObject.set(i, os[i]);
- }
- return dataObject;
- } else {
- Object value = os[0];
- Type type = property.getType();
- if (!type.isDataType()) {
- return (DataObject) value;
- } else {
- return SDOUtil.createDataTypeWrapper(type, value);
- }
- }
- }
-
-// ---
-
- public static DataObject toDataObject(ClassLoader classLoader, TypeHelper typeHelper, Object[] os, QName elementQName, boolean isWrapped) {
- ClassLoader tccl = Thread.currentThread().getContextClassLoader();
- try {
- if (tccl != classLoader) {
- Thread.currentThread().setContextClassLoader(classLoader);
- }
-
- return toDataObject(typeHelper, os, elementQName, isWrapped);
-
- } finally {
- if (tccl != classLoader) {
- Thread.currentThread().setContextClassLoader(tccl);
- }
- }
- }
-
- public static DataObject toDataObject(ClassLoader classLoader, TypeHelper typeHelper, byte[] xmlBytes) {
- ClassLoader tccl = Thread.currentThread().getContextClassLoader();
- try {
- if (tccl != classLoader) {
- Thread.currentThread().setContextClassLoader(classLoader);
- }
-
- return toDataObject(typeHelper, xmlBytes);
-
- } finally {
- if (tccl != classLoader) {
- Thread.currentThread().setContextClassLoader(tccl);
- }
- }
- }
-
- public static byte[] toXMLbytes(ClassLoader classLoader, TypeHelper typeHelper, DataObject dataObject, QName elementQName) {
- ClassLoader tccl = Thread.currentThread().getContextClassLoader();
- try {
- if (tccl != classLoader) {
- Thread.currentThread().setContextClassLoader(classLoader);
- }
-
- return toXMLbytes(typeHelper, dataObject, elementQName);
-
- } finally {
- if (tccl != classLoader) {
- Thread.currentThread().setContextClassLoader(tccl);
- }
- }
- }
-
- public static byte[] toXMLBytes(ClassLoader classLoader, TypeHelper typeHelper, Object[] os, QName elementQName, boolean isWrapped) {
- ClassLoader tccl = Thread.currentThread().getContextClassLoader();
- try {
- if (tccl != classLoader) {
- Thread.currentThread().setContextClassLoader(classLoader);
- }
-
- return toXMLBytes(typeHelper, os, elementQName, isWrapped);
-
- } finally {
- if (tccl != classLoader) {
- Thread.currentThread().setContextClassLoader(tccl);
- }
- }
- }
-
- public static Object[] toObjects(ClassLoader classLoader, TypeHelper typeHelper, byte[] xmlBytes, boolean isWrapped) {
- ClassLoader tccl = Thread.currentThread().getContextClassLoader();
- try {
- if (tccl != classLoader) {
- Thread.currentThread().setContextClassLoader(classLoader);
- }
-
- return toObjects(typeHelper, xmlBytes, isWrapped);
-
- } finally {
- if (tccl != classLoader) {
- Thread.currentThread().setContextClassLoader(tccl);
- }
- }
- }
-}
diff --git a/tags/java-M1-20060518/java/sca/databinding/sdo/src/main/resources/system.fragment b/tags/java-M1-20060518/java/sca/databinding/sdo/src/main/resources/system.fragment
deleted file mode 100644
index a963af3e2e..0000000000
--- a/tags/java-M1-20060518/java/sca/databinding/sdo/src/main/resources/system.fragment
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="ASCII"?>
-<!--
- Copyright (c) 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.
- -->
-<moduleFragment xmlns="http://www.osoa.org/xmlns/sca/0.9" xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9"
- xmlns:tuscany="http://org.apache.tuscany/xmlns/system/0.9"
- name="org.apache.tuscany.databinding.sdo">
-
- <component name="org.apache.tuscany.databinding.sdo.ImportSDOLoader">
- <tuscany:implementation.system class="org.apache.tuscany.databinding.sdo.ImportSDOLoader"/>
- </component>
-
-</moduleFragment>
diff --git a/tags/java-M1-20060518/java/sca/databinding/sdo/src/test/java/org/apache/tuscany/databinding/sdo/ImportSDOLoaderTestCase.java b/tags/java-M1-20060518/java/sca/databinding/sdo/src/test/java/org/apache/tuscany/databinding/sdo/ImportSDOLoaderTestCase.java
deleted file mode 100644
index 31815a97b4..0000000000
--- a/tags/java-M1-20060518/java/sca/databinding/sdo/src/test/java/org/apache/tuscany/databinding/sdo/ImportSDOLoaderTestCase.java
+++ /dev/null
@@ -1,59 +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.databinding.sdo;
-
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-
-import org.apache.tuscany.core.config.ConfigurationLoadException;
-
-/**
- * @version $Rev$ $Date$
- */
-public class ImportSDOLoaderTestCase extends LoaderTestSupport {
- private ImportSDOLoader loader;
-
- public void testMinimal() throws XMLStreamException, ConfigurationLoadException {
- String xml = "<import.sdo xmlns='http://www.osoa.org/xmlns/sca/0.9'/>";
- XMLStreamReader reader = getReader(xml);
- assertNull(loader.load(reader, null));
- }
-
- public void testFactory() throws XMLStreamException, ConfigurationLoadException {
- String xml = "<import.sdo xmlns='http://www.osoa.org/xmlns/sca/0.9' factory='org.apache.tuscany.databinding.sdo.ImportSDOLoaderTestCase$MockFactory'/>";
- XMLStreamReader reader = getReader(xml);
- assertFalse(inited);
- assertNull(loader.load(reader, loaderContext));
- assertTrue(inited);
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- loader = new ImportSDOLoader();
- }
-
- private static boolean inited = false;
-
- public static class MockFactory {
- public static Object INSTANCE;
-
- static {
- ImportSDOLoaderTestCase.inited = true;
- }
- }
-}
-
diff --git a/tags/java-M1-20060518/java/sca/databinding/sdo/src/test/java/org/apache/tuscany/databinding/sdo/LoaderTestSupport.java b/tags/java-M1-20060518/java/sca/databinding/sdo/src/test/java/org/apache/tuscany/databinding/sdo/LoaderTestSupport.java
deleted file mode 100644
index 821a7220dd..0000000000
--- a/tags/java-M1-20060518/java/sca/databinding/sdo/src/test/java/org/apache/tuscany/databinding/sdo/LoaderTestSupport.java
+++ /dev/null
@@ -1,82 +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.databinding.sdo;
-
-import java.io.StringReader;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.namespace.QName;
-
-import junit.framework.TestCase;
-import org.apache.tuscany.core.system.assembly.SystemAssemblyFactory;
-import org.apache.tuscany.core.system.assembly.impl.SystemAssemblyFactoryImpl;
-import org.apache.tuscany.core.loader.LoaderContext;
-import org.apache.tuscany.core.loader.assembly.*;
-import org.apache.tuscany.core.loader.impl.StAXLoaderRegistryImpl;
-import org.apache.tuscany.common.resource.ResourceLoader;
-import org.apache.tuscany.common.resource.impl.ResourceLoaderImpl;
-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(org.apache.tuscany.databinding.sdo.LoaderTestSupport.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-20060518/java/sca/databinding/sdo/src/test/java/org/apache/tuscany/databinding/sdo/SDOXMLHelperTestCase.java b/tags/java-M1-20060518/java/sca/databinding/sdo/src/test/java/org/apache/tuscany/databinding/sdo/SDOXMLHelperTestCase.java
deleted file mode 100644
index b72fa93046..0000000000
--- a/tags/java-M1-20060518/java/sca/databinding/sdo/src/test/java/org/apache/tuscany/databinding/sdo/SDOXMLHelperTestCase.java
+++ /dev/null
@@ -1,141 +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.databinding.sdo;
-
-import java.net.URL;
-
-import javax.xml.namespace.QName;
-
-import junit.framework.TestCase;
-
-import org.apache.tuscany.sdo.util.DataObjectUtil;
-import org.apache.tuscany.sdo.util.SDOUtil;
-
-import commonj.sdo.DataObject;
-import commonj.sdo.helper.DataFactory;
-import commonj.sdo.helper.TypeHelper;
-import commonj.sdo.helper.XSDHelper;
-
-public class SDOXMLHelperTestCase extends TestCase {
-
- private TypeHelper typeHelper;
-
- public static final QName GREETING_QN = new QName("http://helloworldaxis.samples.tuscany.apache.org", "getGreetings");
-
- private static final String GREETING_NAME = "petra";
-
- private static final String GREETING_XML = "<helloworldaxis:in0>petra</helloworldaxis:in0>";
-
- private DataObject greetingDOB;
-
- private byte[] greetingXML;
-
- private ClassLoader appCL;
-
- public static final QName DOCLIT_QN = new QName("http://www.example.org/creditscore/doclit/", "getCreditScoreRequest");
-
- // private static final Object[] CUSTOMER = { "111-22-3333", "John", "Smith" };
-
- private DataObject nonWrappedDOB;
-
- public void testXMLBytes1() {
- byte[] xmlBytes = SDOXMLHelper.toXMLbytes(appCL, typeHelper, greetingDOB, GREETING_QN);
- assertNotNull(xmlBytes);
- assertTrue(new String(xmlBytes).contains("<helloworldaxis:in0>petra</helloworldaxis:in0>"));
- }
-
- public void testXMLBytes2() {
- byte[] xmlBytes = SDOXMLHelper.toXMLBytes(appCL, typeHelper, new Object[] { GREETING_NAME }, GREETING_QN, true);
- assertNotNull(xmlBytes);
- assertTrue(new String(xmlBytes).contains(GREETING_XML));
- }
-
- // TODO: nonwrapped doesn't work
- // public void testXMLBytes3() {
- // byte[] xmlBytes = SDOXMLHelper.toXMLBytes(typeHelper, CUSTOMER, DOCLIT_QN, false);
- // assertNotNull(xmlBytes);
- // assertTrue(new String(xmlBytes).contains(DOC_LIT_XML));
- // }
-
- public void testToDataObject1() {
- DataObject dataObject = SDOXMLHelper.toDataObject(appCL, typeHelper, greetingXML);
- assertNotNull(dataObject);
- assertEquals(GREETING_NAME, dataObject.getString(0));
- }
-
- public void testToDataObject2() {
- DataObject dataObject = SDOXMLHelper.toDataObject(appCL, typeHelper, new Object[] { GREETING_NAME }, GREETING_QN, true);
- assertNotNull(dataObject);
- assertEquals(GREETING_NAME, dataObject.getString(0));
- }
-
- // TODO: nonwrapped doesn't work
- // public void testToDataObject3() {
- // DataObject dataObject = SDOXMLHelper.toDataObject(typeHelper, CUSTOMER, DOCLIT_QN, false);
- // assertNotNull(dataObject);
- // assertEquals(CUSTOMER[0], dataObject.getString(0));
- // assertEquals(CUSTOMER[1], dataObject.getString(1));
- // assertEquals(CUSTOMER[2], dataObject.getString(2));
- // }
-
- public void testToObjects1() {
- Object[] os = SDOXMLHelper.toObjects(appCL, typeHelper, greetingXML, true);
- assertNotNull(os);
- assertEquals(1, os.length);
- assertEquals(GREETING_NAME, os[0]);
- }
-
- public void testToObjects2() {
- Object[] os = SDOXMLHelper.toObjects(greetingDOB, true);
- assertNotNull(os);
- assertEquals(1, os.length);
- assertEquals(GREETING_NAME, os[0]);
- }
-
- public void testToObjects3() {
- Object[] os = SDOXMLHelper.toObjects(nonWrappedDOB, false);
- assertNotNull(os);
- // assertEquals(3, os.length); TODO: non-wrapped doesn't seem to work
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- DataObjectUtil.initRuntime();
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- try {
- appCL = getClass().getClassLoader();
- Thread.currentThread().setContextClassLoader(appCL);
- typeHelper = SDOUtil.createTypeHelper();
- XSDHelper xsdHelper = SDOUtil.createXSDHelper(typeHelper);
- URL url = getClass().getResource("helloworld.wsdl");
- xsdHelper.define(url.openStream(), null);
- url = getClass().getResource("CreditScoreDocLit.wsdl");
- xsdHelper.define(url.openStream(), null);
- greetingDOB = SDOXMLHelper.toDataObject(appCL, typeHelper, new Object[] { GREETING_NAME }, GREETING_QN, true);
- greetingXML = SDOXMLHelper.toXMLBytes(appCL, typeHelper, new Object[] { GREETING_NAME }, GREETING_QN, true);
-
- DataFactory dataFactory = SDOUtil.createDataFactory(typeHelper);
- nonWrappedDOB = dataFactory.create("http://www.example.org/creditscore/doclit/", "Customer");
- nonWrappedDOB.setString(0, "111-22-3333");
- nonWrappedDOB.setString(1, "John");
- nonWrappedDOB.setString(2, "Smith");
-
- } finally {
- Thread.currentThread().setContextClassLoader(cl);
- }
- }
-}
diff --git a/tags/java-M1-20060518/java/sca/databinding/sdo/src/test/resources/org/apache/tuscany/databinding/sdo/CreditScoreDocLit.wsdl b/tags/java-M1-20060518/java/sca/databinding/sdo/src/test/resources/org/apache/tuscany/databinding/sdo/CreditScoreDocLit.wsdl
deleted file mode 100644
index 09d1a58589..0000000000
--- a/tags/java-M1-20060518/java/sca/databinding/sdo/src/test/resources/org/apache/tuscany/databinding/sdo/CreditScoreDocLit.wsdl
+++ /dev/null
@@ -1,76 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright (c) 2005 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.
- -->
-<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
- xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
- xmlns:tns="http://www.example.org/creditscore/doclit/"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="CreditScore"
- targetNamespace="http://www.example.org/creditscore/doclit/">
- <wsdl:types>
- <xsd:schema
- targetNamespace="http://www.example.org/creditscore/doclit/"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <xsd:element name="getCreditScoreRequest" type="tns:Customer" />
- <xsd:complexType name="Customer">
- <xsd:sequence>
- <xsd:element name="ssn" type="xsd:string" />
- <xsd:element name="firstName" type="xsd:string" />
- <xsd:element name="lastName" type="xsd:string" />
- </xsd:sequence>
- </xsd:complexType>
- <xsd:element name="getCreditScoreResponse" type="tns:CreditReport"/>
- <xsd:complexType name="CreditReport">
- <xsd:sequence>
- <xsd:element name="score" type="xsd:int"/>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:schema>
- </wsdl:types>
- <wsdl:message name="getCreditScoreResponse">
- <wsdl:part element="tns:getCreditScoreResponse"
- name="getCreditScoreResponse" />
- </wsdl:message>
- <wsdl:message name="getCreditScoreRequest">
- <wsdl:part element="tns:getCreditScoreRequest"
- name="getCreditScoreRequest" />
- </wsdl:message>
- <wsdl:portType name="CreditScoreDocLit">
- <wsdl:operation name="getCreditScore">
- <wsdl:input message="tns:getCreditScoreRequest" />
- <wsdl:output message="tns:getCreditScoreResponse" />
- </wsdl:operation>
- </wsdl:portType>
- <wsdl:binding name="CreditScoreDocLitSOAP" type="tns:CreditScoreDocLit">
- <soap:binding style="document"
- transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="getCreditScore">
- <soap:operation
- soapAction="http://www.example.org/creditscore/doclit/getCreditScore" />
- <wsdl:input>
- <soap:body parts="getCreditScoreRequest" use="literal" />
- </wsdl:input>
- <wsdl:output>
- <soap:body parts="getCreditScoreResponse" use="literal" />
- </wsdl:output>
- </wsdl:operation>
- </wsdl:binding>
- <wsdl:service name="CreditScore">
- <wsdl:port binding="tns:CreditScoreDocLitSOAP"
- name="CreditScoreDocLitSOAP">
- <soap:address location="http://www.example.org/" />
- </wsdl:port>
- </wsdl:service>
-</wsdl:definitions>
diff --git a/tags/java-M1-20060518/java/sca/databinding/sdo/src/test/resources/org/apache/tuscany/databinding/sdo/CreditScoreDocLitWrapped.wsdl b/tags/java-M1-20060518/java/sca/databinding/sdo/src/test/resources/org/apache/tuscany/databinding/sdo/CreditScoreDocLitWrapped.wsdl
deleted file mode 100644
index 3952c74809..0000000000
--- a/tags/java-M1-20060518/java/sca/databinding/sdo/src/test/resources/org/apache/tuscany/databinding/sdo/CreditScoreDocLitWrapped.wsdl
+++ /dev/null
@@ -1,78 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright (c) 2005 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.
- -->
-<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
- xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
- xmlns:tns="http://www.example.org/creditscore/doclitwrapped/"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="CreditScore"
- targetNamespace="http://www.example.org/creditscore/doclitwrapped/">
- <wsdl:types>
- <xsd:schema
- targetNamespace="http://www.example.org/creditscore/doclitwrapped/"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <xsd:element name="getCreditScoreResponse">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="score" type="xsd:int" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="getCreditScore">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="ssn" type="xsd:string" />
- <xsd:element name="firstName" type="xsd:string" />
- <xsd:element name="lastName" type="xsd:string" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:schema>
- </wsdl:types>
- <wsdl:message name="getCreditScoreResponse">
- <wsdl:part element="tns:getCreditScoreResponse"
- name="getCreditScoreResponse" />
- </wsdl:message>
- <wsdl:message name="getCreditScoreRequest">
- <wsdl:part element="tns:getCreditScore"
- name="getCreditScoreRequest" />
- </wsdl:message>
- <wsdl:portType name="CreditScoreDocLitWrapped">
- <wsdl:operation name="getCreditScore">
- <wsdl:input message="tns:getCreditScoreRequest" />
- <wsdl:output message="tns:getCreditScoreResponse" />
- </wsdl:operation>
- </wsdl:portType>
- <wsdl:binding name="CreditScoreDocLitWrappedSOAP" type="tns:CreditScoreDocLitWrapped">
- <soap:binding style="document"
- transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="getCreditScore">
- <soap:operation
- soapAction="http://www.example.org/creditscore/doclitwrapped/getCreditScore" />
- <wsdl:input>
- <soap:body parts="getCreditScoreRequest" use="literal" />
- </wsdl:input>
- <wsdl:output>
- <soap:body parts="getCreditScoreResponse" use="literal" />
- </wsdl:output>
- </wsdl:operation>
- </wsdl:binding>
- <wsdl:service name="CreditScore">
- <wsdl:port binding="tns:CreditScoreDocLitWrappedSOAP"
- name="CreditScoreDocLitWrappedSOAP">
- <soap:address location="http://localhost:8080/CreditScoreService/services/CreditScoreDocLitWrappedSOAP"/>
- </wsdl:port>
- </wsdl:service>
-</wsdl:definitions>
diff --git a/tags/java-M1-20060518/java/sca/databinding/sdo/src/test/resources/org/apache/tuscany/databinding/sdo/helloworld.wsdl b/tags/java-M1-20060518/java/sca/databinding/sdo/src/test/resources/org/apache/tuscany/databinding/sdo/helloworld.wsdl
deleted file mode 100644
index e9312949d3..0000000000
--- a/tags/java-M1-20060518/java/sca/databinding/sdo/src/test/resources/org/apache/tuscany/databinding/sdo/helloworld.wsdl
+++ /dev/null
@@ -1,106 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright (c) 2005 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.
- -->
-<wsdl:definitions targetNamespace="http://helloworldaxis.samples.tuscany.apache.org" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://helloworldaxis.samples.tuscany.apache.org" xmlns:intf="http://helloworldaxis.samples.tuscany.apache.org" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="stockquote">
- <!--WSDL created by Apache Axis version: 1.2.1
-Built on Jun 14, 2005 (09:15:57 EDT)-->
- <wsdl:types>
- <schema elementFormDefault="qualified" targetNamespace="http://helloworldaxis.samples.tuscany.apache.org" xmlns="http://www.w3.org/2001/XMLSchema">
- <element name="getGreetings">
- <complexType>
- <sequence>
- <element name="in0" type="xsd:string"/>
- </sequence>
- </complexType>
- </element>
- <element name="getGreetingsResponse">
- <complexType>
- <sequence>
- <element name="getGreetingsReturn" type="xsd:string"/>
- </sequence>
- </complexType>
- </element>
- </schema>
- </wsdl:types>
-
- <wsdl:message name="getGreetingsRequest">
-
- <wsdl:part element="impl:getGreetings" name="parameters"/>
-
- </wsdl:message>
-
- <wsdl:message name="getGreetingsResponse">
-
- <wsdl:part element="impl:getGreetingsResponse" name="parameters"/>
-
- </wsdl:message>
-
- <wsdl:portType name="HelloWorldServiceImpl">
-
- <wsdl:operation name="getGreetings">
-
- <wsdl:input message="impl:getGreetingsRequest" name="getGreetingsRequest"/>
-
- <wsdl:output message="impl:getGreetingsResponse" name="getGreetingsResponse"/>
-
- </wsdl:operation>
-
- </wsdl:portType>
-
- <wsdl:binding name="helloworldSoapBinding" type="impl:HelloWorldServiceImpl">
-
- <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
-
- <wsdl:operation name="getGreetings">
-
- <wsdlsoap:operation soapAction=""/>
-
- <wsdl:input name="getGreetingsRequest">
-
- <wsdlsoap:body use="literal"/>
-
- </wsdl:input>
-
- <wsdl:output name="getGreetingsResponse">
-
- <wsdlsoap:body use="literal"/>
-
- </wsdl:output>
-
- </wsdl:operation>
-
- </wsdl:binding>
-
- <wsdl:service name="HelloWorldServiceImplService">
-
- <wsdl:port binding="impl:helloworldSoapBinding" name="helloworld">
-
- <!-- Tuscany SCA Service -->
-<!--
- <wsdlsoap:address location="http://localhost:8080/tuscany-samples-helloworldws-service/services/HelloWorldService"/>
--->
- <wsdlsoap:address location="http://localhost:9876/tuscany-samples-helloworldws-service/services/HelloWorldService"/>
-
- <!-- Axis Web Service -->
- <!--
- <wsdlsoap:address location="http://localhost:8081/helloworldaxissvc/services/helloworld"/>
- -->
-
- </wsdl:port>
-
- </wsdl:service>
-
-</wsdl:definitions>