You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2007/02/19 23:25:51 UTC
svn commit: r509355 - in
/incubator/tuscany/branches/sca-java-integration/sca:
kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/
services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/
services/databinding/da...
Author: rfeng
Date: Mon Feb 19 14:25:49 2007
New Revision: 509355
URL: http://svn.apache.org/viewvc?view=rev&rev=509355
Log:
[sca-integration-branch] Add exception handler and test cases for JAXB and SDO
Added:
incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/JAXBExceptionHandlerTestCase.java (with props)
incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/fault/
incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/fault/InvalidSymbolFault.java (with props)
incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/fault/InvalidSymbolFault_Exception.java (with props)
incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDOExceptionHandler.java (with props)
incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/test/java/com/
incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/test/java/com/example/
incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/test/java/com/example/stock/
incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/test/java/com/example/stock/sdo/
incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/test/java/com/example/stock/sdo/fault/
incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/test/java/com/example/stock/sdo/fault/InvalidSymbolFault_Exception.java (with props)
incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/test/java/org/apache/tuscany/databinding/sdo/SDOExceptionHandlerTestCase.java (with props)
incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/test/resources/stock.xsd (with props)
Modified:
incubator/tuscany/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/ExceptionHandler.java
incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXBExceptionHandler.java
incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/pom.xml
Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/ExceptionHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/ExceptionHandler.java?view=diff&rev=509355&r1=509354&r2=509355
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/ExceptionHandler.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/ExceptionHandler.java Mon Feb 19 14:25:49 2007
@@ -36,7 +36,7 @@
* @param cause The protocol-specific error
* @return An instance of java exception to represent the fault
*/
- Exception createException(DataType<DataType<?>> exceptionType, String message, Object faultInfo, Throwable cause);
+ Exception createException(DataType<DataType> exceptionType, String message, Object faultInfo, Throwable cause);
/**
* Retrieve the fault info from a java exception
@@ -48,7 +48,7 @@
Object getFaultInfo(Exception exception);
/**
- * Introspect an exception class to figure
+ * Introspect an exception class to figure out the fault data type
*
* @param exceptionType The exception class
* @return The data type for the fault
Modified: incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXBExceptionHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXBExceptionHandler.java?view=diff&rev=509355&r1=509354&r2=509355
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXBExceptionHandler.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXBExceptionHandler.java Mon Feb 19 14:25:49 2007
@@ -50,7 +50,7 @@
* protocol specific fault information
* </ul>
*/
- public Exception createException(DataType<DataType<?>> exceptionType,
+ public Exception createException(DataType<DataType> exceptionType,
String message,
Object faultInfo,
Throwable cause) {
@@ -97,9 +97,7 @@
// only part in
// the fault message references
DataType<QName> faultType = new DataType<QName>(faultBeanClass, element);
- // The logical type of the exception type is the DataType of the
- // fault bean
- return new DataType<DataType<QName>>(exceptionType, faultType);
+ return faultType;
}
}
Added: incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/JAXBExceptionHandlerTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/JAXBExceptionHandlerTestCase.java?view=auto&rev=509355
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/JAXBExceptionHandlerTestCase.java (added)
+++ incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/JAXBExceptionHandlerTestCase.java Mon Feb 19 14:25:49 2007
@@ -0,0 +1,73 @@
+/*
+ * 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.databinding.jaxb;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.databinding.jaxb.fault.InvalidSymbolFault;
+import org.apache.tuscany.databinding.jaxb.fault.InvalidSymbolFault_Exception;
+import org.apache.tuscany.spi.model.DataType;
+
+import junit.framework.TestCase;
+
+/**
+ * Test case for JAXBExceptionHandler
+ */
+public class JAXBExceptionHandlerTestCase extends TestCase {
+ private static final QName ELEMENT = new QName("http://www.example.com/stock", "InvalidSymbolFault");
+ private JAXBExceptionHandler handler;
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ this.handler = new JAXBExceptionHandler();
+ }
+
+ public void testGetFaultType() {
+ DataType<?> dataType = handler.getFaultType(InvalidSymbolFault_Exception.class);
+ assertEquals(InvalidSymbolFault.class, dataType.getPhysical());
+ assertEquals(ELEMENT, dataType.getLogical());
+ }
+
+ public void testCreate() {
+ DataType<?> faultType = handler.getFaultType(InvalidSymbolFault_Exception.class);
+ InvalidSymbolFault fault = new InvalidSymbolFault();
+ fault.setMessage("ABC");
+ fault.setSymbol("IBM0");
+ DataType<DataType> exType = new DataType<DataType>(InvalidSymbolFault_Exception.class, faultType);
+ Exception ex = handler.createException(exType, "Invalid symbol", fault, null);
+ assertTrue(ex instanceof InvalidSymbolFault_Exception);
+ InvalidSymbolFault_Exception exception = (InvalidSymbolFault_Exception)ex;
+ assertEquals("Invalid symbol", exception.getMessage());
+ assertSame(fault, exception.getFaultInfo());
+ }
+
+ public void testGetFaultInfo() {
+ InvalidSymbolFault fault = new InvalidSymbolFault();
+ fault.setMessage("ABC");
+ fault.setSymbol("IBM0");
+ InvalidSymbolFault_Exception exception = new InvalidSymbolFault_Exception("Invalid symbol", fault);
+ Object faultInfo = handler.getFaultInfo(exception);
+ assertSame(fault, faultInfo);
+ }
+
+}
Propchange: incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/JAXBExceptionHandlerTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/JAXBExceptionHandlerTestCase.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/fault/InvalidSymbolFault.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/fault/InvalidSymbolFault.java?view=auto&rev=509355
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/fault/InvalidSymbolFault.java (added)
+++ incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/fault/InvalidSymbolFault.java Mon Feb 19 14:25:49 2007
@@ -0,0 +1,59 @@
+package org.apache.tuscany.databinding.jaxb.fault;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ * <p>
+ * Java class for anonymous complex type.
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {"message", "symbol"})
+@XmlRootElement(name = "InvalidSymbolFault")
+public class InvalidSymbolFault {
+
+ @XmlElement(required = true)
+ protected String message;
+ @XmlElement(required = true)
+ protected String symbol;
+
+ /**
+ * Gets the value of the message property.
+ *
+ * @return possible object is {@link String }
+ */
+ public String getMessage() {
+ return message;
+ }
+
+ /**
+ * Sets the value of the message property.
+ *
+ * @param value allowed object is {@link String }
+ */
+ public void setMessage(String value) {
+ this.message = value;
+ }
+
+ /**
+ * Gets the value of the symbol property.
+ *
+ * @return possible object is {@link String }
+ */
+ public String getSymbol() {
+ return symbol;
+ }
+
+ /**
+ * Sets the value of the symbol property.
+ *
+ * @param value allowed object is {@link String }
+ */
+ public void setSymbol(String value) {
+ this.symbol = value;
+ }
+
+}
Propchange: incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/fault/InvalidSymbolFault.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/fault/InvalidSymbolFault.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/fault/InvalidSymbolFault_Exception.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/fault/InvalidSymbolFault_Exception.java?view=auto&rev=509355
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/fault/InvalidSymbolFault_Exception.java (added)
+++ incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/fault/InvalidSymbolFault_Exception.java Mon Feb 19 14:25:49 2007
@@ -0,0 +1,44 @@
+package org.apache.tuscany.databinding.jaxb.fault;
+
+import javax.xml.ws.WebFault;
+
+/**
+ * This class was generated by the JAXWS SI. JAX-WS RI 2.1-02/02/2007 09:55
+ * AM(vivekp)-FCS Generated source version: 2.1
+ */
+@WebFault(name = "InvalidSymbolFault", targetNamespace = "http://www.example.com/stock")
+public class InvalidSymbolFault_Exception extends Exception {
+
+ /**
+ * Java type that goes as soapenv:Fault detail element.
+ */
+ private InvalidSymbolFault faultInfo;
+
+ /**
+ * @param faultInfo
+ * @param message
+ */
+ public InvalidSymbolFault_Exception(String message, InvalidSymbolFault faultInfo) {
+ super(message);
+ this.faultInfo = faultInfo;
+ }
+
+ /**
+ * @param faultInfo
+ * @param message
+ * @param cause
+ */
+ public InvalidSymbolFault_Exception(String message, InvalidSymbolFault faultInfo, Throwable cause) {
+ super(message, cause);
+ this.faultInfo = faultInfo;
+ }
+
+ /**
+ * @return returns fault bean:
+ * org.apache.tuscany.sca.test.exceptions.impl.jaxb.InvalidSymbolFault
+ */
+ public InvalidSymbolFault getFaultInfo() {
+ return faultInfo;
+ }
+
+}
Propchange: incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/fault/InvalidSymbolFault_Exception.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/fault/InvalidSymbolFault_Exception.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/pom.xml?view=diff&rev=509355&r1=509354&r2=509355
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/pom.xml (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/pom.xml Mon Feb 19 14:25:49 2007
@@ -83,7 +83,7 @@
<version>1.0-incubator-SNAPSHOT</version>
<executions>
<execution>
- <id>generate-sdo</id>
+ <id>generate-po-sdo</id>
<phase>generate-test-sources</phase>
<configuration>
<schemaFile>${basedir}/src/test/resources/ipo.xsd</schemaFile>
@@ -96,6 +96,21 @@
<goal>generate</goal>
</goals>
</execution>
+ <execution>
+ <id>generate-stock-sdo</id>
+ <phase>generate-test-sources</phase>
+ <configuration>
+ <schemaFile>${basedir}/src/test/resources/stock.xsd</schemaFile>
+ <javaPackage>com.example.stock.sdo</javaPackage>
+ <prefix>Stock</prefix>
+ <noNotification>true</noNotification>
+ <noContainer>true</noContainer>
+ <noUnsettable>true</noUnsettable>
+ </configuration>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
</executions>
</plugin>
</plugins>
Added: incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDOExceptionHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDOExceptionHandler.java?view=auto&rev=509355
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDOExceptionHandler.java (added)
+++ incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDOExceptionHandler.java Mon Feb 19 14:25:49 2007
@@ -0,0 +1,112 @@
+/*
+ * 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.databinding.sdo;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.spi.databinding.ExceptionHandler;
+import org.apache.tuscany.spi.model.DataType;
+
+import commonj.sdo.Type;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.impl.HelperProvider;
+
+/**
+ * JAXB implementation of ExceptionHandler
+ *
+ * @version $Rev$ $Date$
+ */
+public class SDOExceptionHandler implements ExceptionHandler {
+ private static final Class[] EMPTY_CLASS_ARRAY = new Class[0];
+
+ // FIXME: Need a way to pass in the HelperContext
+ private HelperContext helperContext = HelperProvider.getDefaultContext();
+
+ /**
+ * <ul>
+ * <li>WrapperException(String message, FaultBean faultInfo) <br>
+ * A constructor where WrapperException is replaced with the name of the
+ * generated wrapper exception and FaultBean is replaced by the name of the
+ * generated fault bean.
+ * <li> WrapperException(String message, FaultBean faultInfo, Throwable
+ * cause) <br>
+ * A constructor whereWrapperException is replaced with the name of the
+ * generated wrapper exception and FaultBean is replaced by the name of the
+ * generated fault bean. The last argument, cause, may be used to convey
+ * protocol specific fault information
+ * </ul>
+ */
+ public Exception createException(DataType<DataType> exceptionType,
+ String message,
+ Object faultInfo,
+ Throwable cause) {
+ Class exceptionClass = (Class)exceptionType.getPhysical();
+ DataType<?> faultBeanType = exceptionType.getLogical();
+ Class faultBeanClass = (Class)faultBeanType.getPhysical();
+ try {
+ Constructor constructor =
+ exceptionClass.getConstructor(new Class[] {String.class, faultBeanClass, Throwable.class});
+ return (Exception)constructor.newInstance(new Object[] {message, faultInfo, cause});
+ } catch (Throwable e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ public Object getFaultInfo(Exception exception) {
+ if (exception == null) {
+ return null;
+ }
+ try {
+ Method method = exception.getClass().getMethod("getFaultInfo", EMPTY_CLASS_ARRAY);
+ return method.invoke(exception, (Object[])null);
+ } catch (Throwable e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ public DataType<?> getFaultType(Class<? extends Exception> exceptionType) {
+ Class faultBeanClass = null;
+ try {
+ Method method = exceptionType.getMethod("getFaultInfo", EMPTY_CLASS_ARRAY);
+ faultBeanClass = method.getReturnType();
+ } catch (NoSuchMethodException e) {
+ faultBeanClass = null;
+ }
+ if (faultBeanClass == null) {
+ return null;
+ }
+
+ Type type = helperContext.getTypeHelper().getType(faultBeanClass);
+ if (type != null) {
+ String ns = type.getURI();
+ String name = helperContext.getXSDHelper().getLocalName(type);
+ QName typeInfo = new QName(ns, name);
+ DataType<QName> faultType = new DataType<QName>(faultBeanClass, typeInfo);
+ return faultType;
+ } else {
+ return null;
+ }
+
+ }
+
+}
Propchange: incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDOExceptionHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDOExceptionHandler.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/test/java/com/example/stock/sdo/fault/InvalidSymbolFault_Exception.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/test/java/com/example/stock/sdo/fault/InvalidSymbolFault_Exception.java?view=auto&rev=509355
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/test/java/com/example/stock/sdo/fault/InvalidSymbolFault_Exception.java (added)
+++ incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/test/java/com/example/stock/sdo/fault/InvalidSymbolFault_Exception.java Mon Feb 19 14:25:49 2007
@@ -0,0 +1,61 @@
+/*
+ * 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 com.example.stock.sdo.fault;
+
+import com.example.stock.sdo.InvalidSymbolFault;
+
+/**
+ * Hand-crafted java exception for SDO fault
+ *
+ */
+public class InvalidSymbolFault_Exception extends Exception {
+ /**
+ * Java type that goes as soapenv:Fault detail element.
+ */
+ private InvalidSymbolFault faultInfo;
+
+ /**
+ * @param faultInfo
+ * @param message
+ */
+ public InvalidSymbolFault_Exception(String message, InvalidSymbolFault faultInfo) {
+ super(message);
+ this.faultInfo = faultInfo;
+ }
+
+ /**
+ * @param faultInfo
+ * @param message
+ * @param cause
+ */
+ public InvalidSymbolFault_Exception(String message, InvalidSymbolFault faultInfo, Throwable cause) {
+ super(message, cause);
+ this.faultInfo = faultInfo;
+ }
+
+ /**
+ * @return returns fault bean:
+ * org.apache.tuscany.sca.test.exceptions.impl.jaxb.InvalidSymbolFault
+ */
+ public InvalidSymbolFault getFaultInfo() {
+ return faultInfo;
+ }
+
+}
Propchange: incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/test/java/com/example/stock/sdo/fault/InvalidSymbolFault_Exception.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/test/java/com/example/stock/sdo/fault/InvalidSymbolFault_Exception.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/test/java/org/apache/tuscany/databinding/sdo/SDOExceptionHandlerTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/test/java/org/apache/tuscany/databinding/sdo/SDOExceptionHandlerTestCase.java?view=auto&rev=509355
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/test/java/org/apache/tuscany/databinding/sdo/SDOExceptionHandlerTestCase.java (added)
+++ incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/test/java/org/apache/tuscany/databinding/sdo/SDOExceptionHandlerTestCase.java Mon Feb 19 14:25:49 2007
@@ -0,0 +1,80 @@
+/*
+ * 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.databinding.sdo;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.spi.model.DataType;
+
+import com.example.stock.sdo.InvalidSymbolFault;
+import com.example.stock.sdo.StockFactory;
+import com.example.stock.sdo.fault.InvalidSymbolFault_Exception;
+import commonj.sdo.impl.HelperProvider;
+
+/**
+ * Test case for SDOExceptionHandler
+ */
+public class SDOExceptionHandlerTestCase extends TestCase {
+ // FIXME: Tuscany SDO impl uses _._type for anonymouse type, by the SDO
+ // spec, it should be same as the
+ // enclosing element/attribute name
+ private static final QName ELEMENT = new QName("http://www.example.com/stock", "InvalidSymbolFault_._type");
+ private SDOExceptionHandler handler;
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ this.handler = new SDOExceptionHandler();
+ StockFactory.INSTANCE.register(HelperProvider.getDefaultContext());
+ }
+
+ public void testGetFaultType() {
+ DataType<?> dataType = handler.getFaultType(InvalidSymbolFault_Exception.class);
+ assertEquals(InvalidSymbolFault.class, dataType.getPhysical());
+ assertEquals(ELEMENT, dataType.getLogical());
+ }
+
+ public void testCreate() {
+ DataType<?> faultType = handler.getFaultType(InvalidSymbolFault_Exception.class);
+ InvalidSymbolFault fault = StockFactory.INSTANCE.createInvalidSymbolFault();
+ fault.setMessage("ABC");
+ fault.setSymbol("IBM0");
+ DataType<DataType> exType = new DataType<DataType>(InvalidSymbolFault_Exception.class, faultType);
+ Exception ex = handler.createException(exType, "Invalid symbol", fault, null);
+ assertTrue(ex instanceof InvalidSymbolFault_Exception);
+ InvalidSymbolFault_Exception exception = (InvalidSymbolFault_Exception)ex;
+ assertEquals("Invalid symbol", exception.getMessage());
+ assertSame(fault, exception.getFaultInfo());
+ }
+
+ public void testGetFaultInfo() {
+ InvalidSymbolFault fault = StockFactory.INSTANCE.createInvalidSymbolFault();
+ fault.setMessage("ABC");
+ fault.setSymbol("IBM0");
+ InvalidSymbolFault_Exception exception = new InvalidSymbolFault_Exception("Invalid symbol", fault);
+ Object faultInfo = handler.getFaultInfo(exception);
+ assertSame(fault, faultInfo);
+ }
+
+}
Propchange: incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/test/java/org/apache/tuscany/databinding/sdo/SDOExceptionHandlerTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/test/java/org/apache/tuscany/databinding/sdo/SDOExceptionHandlerTestCase.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/test/resources/stock.xsd
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/test/resources/stock.xsd?view=auto&rev=509355
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/test/resources/stock.xsd (added)
+++ incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/test/resources/stock.xsd Mon Feb 19 14:25:49 2007
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<schema targetNamespace="http://www.example.com/stock" xmlns="http://www.w3.org/2001/XMLSchema">
+ <!-- Faults -->
+ <element name="InvalidSymbolFault">
+ <complexType>
+ <sequence>
+ <element name="message" minOccurs="1" type="string" />
+ <element name="symbol" minOccurs="1" type="string" />
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="MarketClosedFault" type="string" />
+
+</schema>
\ No newline at end of file
Propchange: incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/test/resources/stock.xsd
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/test/resources/stock.xsd
------------------------------------------------------------------------------
svn:keywords = Rev Date
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org