You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by "Ron Gavlin (JIRA)" <tu...@ws.apache.org> on 2007/10/11 16:49:50 UTC

[jira] Created: (TUSCANY-1842) IOException loading DataGraph containing a deleted dataObject whose property type extends a complexType w/simple integer content

IOException loading DataGraph containing a deleted dataObject whose property type extends a complexType w/simple integer content
--------------------------------------------------------------------------------------------------------------------------------

                 Key: TUSCANY-1842
                 URL: https://issues.apache.org/jira/browse/TUSCANY-1842
             Project: Tuscany
          Issue Type: Bug
          Components: Java SDO Implementation
    Affects Versions: Java-SDO-Next
         Environment: Windows XP, Sun JDK 1.5.0_09
            Reporter: Ron Gavlin
            Priority: Critical
             Fix For: Java-SDO-Next


In the test method, testComplexTypeWithSimpleContentExtensionChangeSummary() listed below, a DataGraph is created with a dataObject whose property type extends a complexType with simple integer content. After the dataObject is deleted, an attempt is made to save and load the DataGraph. While the DataGraph is being loaded, an unsuccessful attempt is made to convert a zero-length string into a BigInteger. 

Any suggestions on how to best fix this are most welcome.

Thanks,

- Ron

==============================
substitutionWithExtensionValues.xsd
============================== 

<schema xmlns="http://www.w3.org/2001/XMLSchema"
	targetNamespace="http://www.example.com/substitutionEV"
	xmlns:sev="http://www.example.com/substitutionEV">
	<!--
		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.    
	-->
	<element name="results" type="sev:ResultsType" />

	<element name="result" type="sev:ResultType" />
	<element name="myResult" type="sev:MyResultType"
		substitutionGroup="sev:result" />

	<complexType name="ResultsType">
		<sequence>
			<element name="id" type="sev:IdType" />
			<element ref="sev:result" minOccurs="0"
				maxOccurs="unbounded" />
			<element name="comment" type="sev:CommentType" />
		</sequence>
	</complexType>

	<complexType name="ResultType">
		<sequence>
			<element name="id" type="sev:IdType" />
			<element name="name" type="string" />
			<element name="value" type="sev:ValueType" />
		</sequence>
	</complexType>

	<complexType name="MyResultType">
		<complexContent>
			<extension base="sev:ResultType" />
		</complexContent>
	</complexType>

	<simpleType name="IdType">
		<restriction base="sev:AsciiStringType">
			<maxLength value="32" />
			<pattern value="[0-9a-fA-F]*" />
		</restriction>
	</simpleType>

	<simpleType name="AsciiStringType">
		<restriction base="string">
			<pattern value="\p{IsBasicLatin}*" />
		</restriction>
	</simpleType>

	<complexType name="ValueType">
		<simpleContent>
			<extension base="sev:Integer32Bit" />
		</simpleContent>
	</complexType>

	<complexType name="Integer32Bit">
		<simpleContent>
			<restriction base="integer">
				<minInclusive value="0" />
				<maxInclusive value="4290000000" />
			</restriction>
		</simpleContent>
	</complexType>
	
	<complexType name="CommentType">
		<simpleContent>
			<extension base="sev:AsciiStringType">
				<attribute name="language" use="optional">
					<simpleType>
						<restriction base="string">
							<enumeration value="English" />
							<enumeration value="French" />
							<enumeration value="Spanish" />
						</restriction>
					</simpleType>
				</attribute>
			</extension>
		</simpleContent>
	</complexType>

	<complexType name="MyCommentType">
		<simpleContent>
			<restriction base="sev:CommentType">
				<minLength value="0" />
				<maxLength value="40" />
			</restriction>
		</simpleContent>
	</complexType>

	<complexType name="StringBasedCommentType">
		<simpleContent>
			<restriction base="string">
				<minLength value="0" />
				<maxLength value="40" />
			</restriction>
		</simpleContent>
	</complexType>

</schema>

==============================
substitutionWithExtensionValues2.xsd
==============================

<schema xmlns="http://www.w3.org/2001/XMLSchema"
	targetNamespace="http://www.example.com/substitutionEV2"
	xmlns:sev2="http://www.example.com/substitutionEV2"
	xmlns:sev="http://www.example.com/substitutionEV">
	<!--
		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.    
	-->

	<import namespace="http://www.example.com/substitutionEV"
		schemaLocation="substitutionWithExtensionValues.xsd" />

	<element name="allResults" type="sev2:AllResultsType" />

	<complexType name="AllResultsType">
		<sequence>
			<element name="id" type="sev2:Id2Type" />
			<element name="results" minOccurs="0" maxOccurs="unbounded"
				type="sev2:Results2Type" />
			<element name="comment" type="sev2:Comment2Type" />
		</sequence>
	</complexType>

	<complexType name="Results2Type">
		<complexContent>
			<extension base="sev:ResultsType"></extension>
		</complexContent>
	</complexType>

	<simpleType name="Id2Type">
		<restriction base="sev:IdType">
			<maxLength value="10" />
		</restriction>
	</simpleType>

	<complexType name="Comment2Type">
		<simpleContent>
			<restriction base="sev:CommentType">
				<minLength value="0" />
				<maxLength value="20" />
			</restriction>
		</simpleContent>
	</complexType>

</schema>

==============================
substitutionWithExtensionValues1.xml
==============================

<?xml version="1.0" encoding="ASCII"?>
<sev2:allResults xmlns:sev2="http://www.example.com/substitutionEV2">
	<sev2:id>ZZZZZZZZZZZZZZZZZZZZ</sev2:id>
	<sev:results xmlns:sev="http://www.example.com/substitutionEV">
		<sev:id>00000000000000000000</sev:id>
		<sev:result>
			<sev:id>11111111111111111111</sev:id>
			<sev:name>name1</sev:name>
			<sev:value>1</sev:value>
		</sev:result>
		<sev:myResult>
			<sev:id>22222222222222222222</sev:id>
			<sev:name>myName2</sev:name>
			<sev:value>2</sev:value>
		</sev:myResult>
		<sev:comment>comment0</sev:comment>
	</sev:results>
	<sev:results xmlns:sev="http://www.example.com/substitutionEV">
		<sev:id>AAAAAAAAAAAAAAAAAAAA</sev:id>
		<sev:myResult>
			<sev:id>BBBBBBBBBBBBBBBBBBBB</sev:id>
			<sev:name>myNameB</sev:name>
			<sev:value>11</sev:value>
		</sev:myResult>
		<sev:comment>commentA</sev:comment>
	</sev:results>
	<sev2:comment language="English">
		commentZZZZZZZZZZZZZZZZZZ
	</sev2:comment>
</sev2:allResults>

==============================
SubstitutionWithExtensionValuesTestCase.java
============================== 

/**
 *
 *  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.sdo.test;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.List;

import junit.framework.TestCase;

import org.apache.tuscany.sdo.api.SDOUtil;
import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.util.Diagnostician;
import org.eclipse.emf.ecore.util.ExtendedMetaData;

import com.example.substitution.ev.SEVFactory;
import com.example.substitution.ev.impl.SEVFactoryImpl;

import commonj.sdo.DataGraph;
import commonj.sdo.DataObject;
import commonj.sdo.Property;
import commonj.sdo.Type;
import commonj.sdo.helper.HelperContext;
import commonj.sdo.helper.TypeHelper;
import commonj.sdo.impl.HelperProvider;

public final class SubstitutionWithExtensionValuesTestCase extends TestCase 
{
  private static String sev2NamespaceURI;
  private HelperContext hc;
  private DataObject dataObject;
  
  protected void setUp() throws Exception {
    super.setUp();
    hc = HelperProvider.getDefaultContext();
    registerSEV(hc, true);
    
    InputStream inputStream = null;
    URL url = getClass().getResource("/substitutionWithExtensionValues2.xsd");
    inputStream = url.openStream();
    List sev2TypeList = hc.getXSDHelper().define(inputStream, url.toString());
    inputStream.close();
    
    inputStream = getClass().getResourceAsStream("/substitutionWithExtensionValues1.xml");
    dataObject = hc.getXMLHelper().load(inputStream).getRootObject();
    inputStream.close();
    
    if (sev2NamespaceURI == null)
    {
      sev2NamespaceURI = ((Type) sev2TypeList.get(0)).getURI();
    }
  }
  
  private void registerSEV(HelperContext hc, boolean useStaticRegistration) throws IOException
  {
    if (useStaticRegistration)
    {
      SEVFactory.INSTANCE.register(hc);
    }
    else
    {
      InputStream inputStream = null;
      URL url = getClass().getResource("/substitutionWithExtensionValues.xsd");
      inputStream = url.openStream();
      hc.getXSDHelper().define(inputStream, url.toString());
      inputStream.close();
    }
  }

  public void testComplexTypeWithSubstitutionExtension() throws IOException 
  {
    TypeHelper typeHelper = hc.getTypeHelper();
    
    Type resultsType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "ResultsType");
    Type results2Type = typeHelper.getType(sev2NamespaceURI, "Results2Type");
    assertTrue("Results2 type does not report Results as a base type", 
        results2Type.getBaseTypes().contains(resultsType));
    
    assertEquals("results.1/myResult.0/id has unexpected value", 
        "BBBBBBBBBBBBBBBBBBBB", dataObject.getString("results.1/myResult.0/id"));
  }
  
  public void testComplexTypeWithSimpleContentExtensionMetaData() 
  {
    TypeHelper typeHelper = hc.getTypeHelper();
    
    Type stringBasedCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "StringBasedCommentType");
    Type commentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "CommentType");
    Type myCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "MyCommentType");
    Type _myCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "_MyCommentType");
    Type comment2Type = typeHelper.getType(sev2NamespaceURI, "Comment2Type");
    Type _comment2Type = typeHelper.getType(sev2NamespaceURI, "_Comment2Type");
    assertTrue("MyComment type does not report Comment as a base type", 
        myCommentType.getBaseTypes().contains(commentType));
    assertTrue("Comment2 type does not report Comment as a base type", 
        comment2Type.getBaseTypes().contains(commentType));
    
    // Test length facets - resort to EMF APIs until Tuscany SDO exposes these directly
    ExtendedMetaData extendedMetaData = ExtendedMetaData.INSTANCE;

    EStructuralFeature simpleFeature = null;
    EDataType commentSimpleType = null;
    
    simpleFeature = extendedMetaData.getSimpleFeature((EClass) stringBasedCommentType);
    commentSimpleType = (EDataType)simpleFeature.getEType();
    assertEquals(40, extendedMetaData.getMaxLengthFacet(commentSimpleType));
    
    // FIXME Work-around EMF's lack of support for re-definable features - SEE TUSCANY-1832
    commentSimpleType = (EDataType) _myCommentType;
    assertEquals(40, extendedMetaData.getMaxLengthFacet(commentSimpleType));
    
    // FIXME Work-around EMF's lack of support for re-definable features - SEE TUSCANY-1832
    commentSimpleType = (EDataType) _comment2Type;
    assertEquals(20, extendedMetaData.getMaxLengthFacet(commentSimpleType));
  }

  public void testComplexTypeWithSimpleContentExtensionChangeSummary() throws IOException 
  {
    DataGraph dg = SDOUtil.createDataGraph();
    SDOUtil.setRootObject(dg, dataObject);
    dg.getChangeSummary().beginLogging();
    dataObject.getDataObject("results.1/myResult.0").delete();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    SDOUtil.saveDataGraph(dg, baos, null);
    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    SDOUtil.loadDataGraph(bais, null, hc);
  }    
  
  public void testSimpleTypeExtension() 
  {
    TypeHelper typeHelper = hc.getTypeHelper();
    
    Type asciiStringType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "AsciiStringType");
    Type idType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "IdType");
    assertTrue("IdType does not report AsciiStringType as a base type", 
        idType.getBaseTypes().contains(asciiStringType));
    
    Diagnostic diagnostic = Diagnostician.INSTANCE.validate((EObject) dataObject);
    String diagnosticMsg = diagnostic.getChildren().toString();

    Type id2Type = typeHelper.getType(sev2NamespaceURI, "Id2Type");
    assertTrue("Id2Type does not report IdType as a base type", 
        id2Type.getBaseTypes().contains(idType));
    assertTrue("EMF validation should have reported Id pattern match failure", 
        diagnosticMsg.indexOf("Id") > 0);
  }
}

STACKTRACE:

org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Value '' is not legal. (file:///C:/development/working/1/tuscany-sdo/sdo/tools-test/all.datagraph, 27, 48)
	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.handleErrors(XMLLoadImpl.java:83)
	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:193)
	at org.apache.tuscany.sdo.util.DataGraphResourceFactoryImpl$DataGraphResourceImpl$LoadImpl.load(DataGraphResourceFactoryImpl.java:455)
	at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:179)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1094)
	at org.apache.tuscany.sdo.helper.SDOHelperImpl.loadDataGraph(SDOHelperImpl.java:139)
	at org.apache.tuscany.sdo.helper.SDOHelperImpl.loadDataGraph(SDOHelperImpl.java:157)
	at org.apache.tuscany.sdo.api.SDOUtil.loadDataGraph(SDOUtil.java:150)
	at org.apache.tuscany.sdo.test.SubstitutionWithExtensionValuesTestCase.testComplexTypeWithSimpleContentExtensionChangeSummary(SubstitutionWithExtensionValuesTestCase.java:150)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at junit.framework.TestCase.runTest(TestCase.java:154)
	at junit.framework.TestCase.runBare(TestCase.java:127)
	at junit.framework.TestResult$1.protect(TestResult.java:106)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at junit.framework.TestResult.run(TestResult.java:109)
	at junit.framework.TestCase.run(TestCase.java:118)
	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: org.eclipse.emf.ecore.xmi.IllegalValueException: Value '' is not legal. (file:///C:/development/working/1/tuscany-sdo/sdo/tools-test/all.datagraph, 27, 48)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2421)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2406)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.endElement(XMLHandler.java:1347)
	at org.apache.tuscany.sdo.util.DataGraphResourceFactoryImpl$DataGraphResourceImpl$LoadImpl$1.endElement(DataGraphResourceFactoryImpl.java:627)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:633)
	at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:221)
	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:322)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1693)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
	at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:183)
	... 23 more
Caused by: java.lang.NumberFormatException: Zero length BigInteger
	at java.math.BigInteger.<init>(BigInteger.java:275)
	at java.math.BigInteger.<init>(BigInteger.java:447)
	at org.eclipse.emf.ecore.xml.type.impl.XMLTypeFactoryImpl.createInteger(XMLTypeFactoryImpl.java:832)
	at org.apache.tuscany.sdo.model.impl.ModelFactoryImpl.createIntegerFromString(ModelFactoryImpl.java:2086)
	at com.example.substitution.ev.impl.SEVFactoryImpl.create_Integer32BitFromString(SEVFactoryImpl.java:754)
	at com.example.substitution.ev.impl.SEVFactoryImpl.createFromString(SEVFactoryImpl.java:143)
	at org.apache.tuscany.sdo.impl.FactoryBase$SDOEFactoryImpl.createFromString(FactoryBase.java:286)
	at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createFromString(XMLHelperImpl.java:1489)
	at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHelperImpl.java:1053)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2416)
	... 37 more


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


[jira] Resolved: (TUSCANY-1842) IOException loading DataGraph containing a deleted dataObject with a property whose type extends a complexType w/simple integer content

Posted by "Kelvin Goodson (JIRA)" <tu...@ws.apache.org>.
     [ https://issues.apache.org/jira/browse/TUSCANY-1842?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kelvin Goodson resolved TUSCANY-1842.
-------------------------------------

    Resolution: Fixed

Applied patch, many thanks Ron.

> IOException loading DataGraph containing a deleted dataObject with a property whose type extends a complexType w/simple integer content
> ---------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: TUSCANY-1842
>                 URL: https://issues.apache.org/jira/browse/TUSCANY-1842
>             Project: Tuscany
>          Issue Type: Bug
>          Components: Java SDO Implementation
>    Affects Versions: Java-SDO-Next
>         Environment: Windows XP, Sun JDK 1.5.0_09
>            Reporter: Ron Gavlin
>            Priority: Critical
>             Fix For: Java-SDO-Next
>
>         Attachments: 1842data.zip, tuscany-sdo.TUSCANY-1842.patch
>
>
> In the test method, testComplexTypeWithSimpleContentExtensionChangeSummary() listed below, a DataGraph is created with a dataObject whose property type extends a complexType with simple integer content. After the dataObject is deleted, an attempt is made to save and load the DataGraph. While the DataGraph is being loaded, an unsuccessful attempt is made to convert a zero-length string into a BigInteger. 
> Any suggestions on how to best fix this are most welcome.
> Thanks,
> - Ron
> ==============================
> substitutionWithExtensionValues.xsd
> ============================== 
> <schema xmlns="http://www.w3.org/2001/XMLSchema"
> 	targetNamespace="http://www.example.com/substitutionEV"
> 	xmlns:sev="http://www.example.com/substitutionEV">
> 	<!--
> 		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.    
> 	-->
> 	<element name="results" type="sev:ResultsType" />
> 	<element name="result" type="sev:ResultType" />
> 	<element name="myResult" type="sev:MyResultType"
> 		substitutionGroup="sev:result" />
> 	<complexType name="ResultsType">
> 		<sequence>
> 			<element name="id" type="sev:IdType" />
> 			<element ref="sev:result" minOccurs="0"
> 				maxOccurs="unbounded" />
> 			<element name="comment" type="sev:CommentType" />
> 		</sequence>
> 	</complexType>
> 	<complexType name="ResultType">
> 		<sequence>
> 			<element name="id" type="sev:IdType" />
> 			<element name="name" type="string" />
> 			<element name="value" type="sev:ValueType" />
> 		</sequence>
> 	</complexType>
> 	<complexType name="MyResultType">
> 		<complexContent>
> 			<extension base="sev:ResultType" />
> 		</complexContent>
> 	</complexType>
> 	<simpleType name="IdType">
> 		<restriction base="sev:AsciiStringType">
> 			<maxLength value="32" />
> 			<pattern value="[0-9a-fA-F]*" />
> 		</restriction>
> 	</simpleType>
> 	<simpleType name="AsciiStringType">
> 		<restriction base="string">
> 			<pattern value="\p{IsBasicLatin}*" />
> 		</restriction>
> 	</simpleType>
> 	<complexType name="ValueType">
> 		<simpleContent>
> 			<extension base="sev:Integer32Bit" />
> 		</simpleContent>
> 	</complexType>
> 	<complexType name="Integer32Bit">
> 		<simpleContent>
> 			<restriction base="integer">
> 				<minInclusive value="0" />
> 				<maxInclusive value="4290000000" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> 	
> 	<complexType name="CommentType">
> 		<simpleContent>
> 			<extension base="sev:AsciiStringType">
> 				<attribute name="language" use="optional">
> 					<simpleType>
> 						<restriction base="string">
> 							<enumeration value="English" />
> 							<enumeration value="French" />
> 							<enumeration value="Spanish" />
> 						</restriction>
> 					</simpleType>
> 				</attribute>
> 			</extension>
> 		</simpleContent>
> 	</complexType>
> 	<complexType name="MyCommentType">
> 		<simpleContent>
> 			<restriction base="sev:CommentType">
> 				<minLength value="0" />
> 				<maxLength value="40" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> 	<complexType name="StringBasedCommentType">
> 		<simpleContent>
> 			<restriction base="string">
> 				<minLength value="0" />
> 				<maxLength value="40" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> </schema>
> ==============================
> substitutionWithExtensionValues2.xsd
> ==============================
> <schema xmlns="http://www.w3.org/2001/XMLSchema"
> 	targetNamespace="http://www.example.com/substitutionEV2"
> 	xmlns:sev2="http://www.example.com/substitutionEV2"
> 	xmlns:sev="http://www.example.com/substitutionEV">
> 	<!--
> 		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.    
> 	-->
> 	<import namespace="http://www.example.com/substitutionEV"
> 		schemaLocation="substitutionWithExtensionValues.xsd" />
> 	<element name="allResults" type="sev2:AllResultsType" />
> 	<complexType name="AllResultsType">
> 		<sequence>
> 			<element name="id" type="sev2:Id2Type" />
> 			<element name="results" minOccurs="0" maxOccurs="unbounded"
> 				type="sev2:Results2Type" />
> 			<element name="comment" type="sev2:Comment2Type" />
> 		</sequence>
> 	</complexType>
> 	<complexType name="Results2Type">
> 		<complexContent>
> 			<extension base="sev:ResultsType"></extension>
> 		</complexContent>
> 	</complexType>
> 	<simpleType name="Id2Type">
> 		<restriction base="sev:IdType">
> 			<maxLength value="10" />
> 		</restriction>
> 	</simpleType>
> 	<complexType name="Comment2Type">
> 		<simpleContent>
> 			<restriction base="sev:CommentType">
> 				<minLength value="0" />
> 				<maxLength value="20" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> </schema>
> ==============================
> substitutionWithExtensionValues1.xml
> ==============================
> <?xml version="1.0" encoding="ASCII"?>
> <sev2:allResults xmlns:sev2="http://www.example.com/substitutionEV2">
> 	<sev2:id>ZZZZZZZZZZZZZZZZZZZZ</sev2:id>
> 	<sev:results xmlns:sev="http://www.example.com/substitutionEV">
> 		<sev:id>00000000000000000000</sev:id>
> 		<sev:result>
> 			<sev:id>11111111111111111111</sev:id>
> 			<sev:name>name1</sev:name>
> 			<sev:value>1</sev:value>
> 		</sev:result>
> 		<sev:myResult>
> 			<sev:id>22222222222222222222</sev:id>
> 			<sev:name>myName2</sev:name>
> 			<sev:value>2</sev:value>
> 		</sev:myResult>
> 		<sev:comment>comment0</sev:comment>
> 	</sev:results>
> 	<sev:results xmlns:sev="http://www.example.com/substitutionEV">
> 		<sev:id>AAAAAAAAAAAAAAAAAAAA</sev:id>
> 		<sev:myResult>
> 			<sev:id>BBBBBBBBBBBBBBBBBBBB</sev:id>
> 			<sev:name>myNameB</sev:name>
> 			<sev:value>11</sev:value>
> 		</sev:myResult>
> 		<sev:comment>commentA</sev:comment>
> 	</sev:results>
> 	<sev2:comment language="English">
> 		commentZZZZZZZZZZZZZZZZZZ
> 	</sev2:comment>
> </sev2:allResults>
> ==============================
> SubstitutionWithExtensionValuesTestCase.java
> ============================== 
> /**
>  *
>  *  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.sdo.test;
> import java.io.ByteArrayInputStream;
> import java.io.ByteArrayOutputStream;
> import java.io.IOException;
> import java.io.InputStream;
> import java.net.URL;
> import java.util.List;
> import junit.framework.TestCase;
> import org.apache.tuscany.sdo.api.SDOUtil;
> import org.eclipse.emf.common.util.Diagnostic;
> import org.eclipse.emf.ecore.EClass;
> import org.eclipse.emf.ecore.EDataType;
> import org.eclipse.emf.ecore.EObject;
> import org.eclipse.emf.ecore.EStructuralFeature;
> import org.eclipse.emf.ecore.util.Diagnostician;
> import org.eclipse.emf.ecore.util.ExtendedMetaData;
> import com.example.substitution.ev.SEVFactory;
> import com.example.substitution.ev.impl.SEVFactoryImpl;
> import commonj.sdo.DataGraph;
> import commonj.sdo.DataObject;
> import commonj.sdo.Property;
> import commonj.sdo.Type;
> import commonj.sdo.helper.HelperContext;
> import commonj.sdo.helper.TypeHelper;
> import commonj.sdo.impl.HelperProvider;
> public final class SubstitutionWithExtensionValuesTestCase extends TestCase 
> {
>   private static String sev2NamespaceURI;
>   private HelperContext hc;
>   private DataObject dataObject;
>   
>   protected void setUp() throws Exception {
>     super.setUp();
>     hc = HelperProvider.getDefaultContext();
>     registerSEV(hc, true);
>     
>     InputStream inputStream = null;
>     URL url = getClass().getResource("/substitutionWithExtensionValues2.xsd");
>     inputStream = url.openStream();
>     List sev2TypeList = hc.getXSDHelper().define(inputStream, url.toString());
>     inputStream.close();
>     
>     inputStream = getClass().getResourceAsStream("/substitutionWithExtensionValues1.xml");
>     dataObject = hc.getXMLHelper().load(inputStream).getRootObject();
>     inputStream.close();
>     
>     if (sev2NamespaceURI == null)
>     {
>       sev2NamespaceURI = ((Type) sev2TypeList.get(0)).getURI();
>     }
>   }
>   
>   private void registerSEV(HelperContext hc, boolean useStaticRegistration) throws IOException
>   {
>     if (useStaticRegistration)
>     {
>       SEVFactory.INSTANCE.register(hc);
>     }
>     else
>     {
>       InputStream inputStream = null;
>       URL url = getClass().getResource("/substitutionWithExtensionValues.xsd");
>       inputStream = url.openStream();
>       hc.getXSDHelper().define(inputStream, url.toString());
>       inputStream.close();
>     }
>   }
>   public void testComplexTypeWithSubstitutionExtension() throws IOException 
>   {
>     TypeHelper typeHelper = hc.getTypeHelper();
>     
>     Type resultsType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "ResultsType");
>     Type results2Type = typeHelper.getType(sev2NamespaceURI, "Results2Type");
>     assertTrue("Results2 type does not report Results as a base type", 
>         results2Type.getBaseTypes().contains(resultsType));
>     
>     assertEquals("results.1/myResult.0/id has unexpected value", 
>         "BBBBBBBBBBBBBBBBBBBB", dataObject.getString("results.1/myResult.0/id"));
>   }
>   
>   public void testComplexTypeWithSimpleContentExtensionMetaData() 
>   {
>     TypeHelper typeHelper = hc.getTypeHelper();
>     
>     Type stringBasedCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "StringBasedCommentType");
>     Type commentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "CommentType");
>     Type myCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "MyCommentType");
>     Type _myCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "_MyCommentType");
>     Type comment2Type = typeHelper.getType(sev2NamespaceURI, "Comment2Type");
>     Type _comment2Type = typeHelper.getType(sev2NamespaceURI, "_Comment2Type");
>     assertTrue("MyComment type does not report Comment as a base type", 
>         myCommentType.getBaseTypes().contains(commentType));
>     assertTrue("Comment2 type does not report Comment as a base type", 
>         comment2Type.getBaseTypes().contains(commentType));
>     
>     // Test length facets - resort to EMF APIs until Tuscany SDO exposes these directly
>     ExtendedMetaData extendedMetaData = ExtendedMetaData.INSTANCE;
>     EStructuralFeature simpleFeature = null;
>     EDataType commentSimpleType = null;
>     
>     simpleFeature = extendedMetaData.getSimpleFeature((EClass) stringBasedCommentType);
>     commentSimpleType = (EDataType)simpleFeature.getEType();
>     assertEquals(40, extendedMetaData.getMaxLengthFacet(commentSimpleType));
>     
>     // FIXME Work-around EMF's lack of support for re-definable features - SEE TUSCANY-1832
>     commentSimpleType = (EDataType) _myCommentType;
>     assertEquals(40, extendedMetaData.getMaxLengthFacet(commentSimpleType));
>     
>     // FIXME Work-around EMF's lack of support for re-definable features - SEE TUSCANY-1832
>     commentSimpleType = (EDataType) _comment2Type;
>     assertEquals(20, extendedMetaData.getMaxLengthFacet(commentSimpleType));
>   }
>   public void testComplexTypeWithSimpleContentExtensionChangeSummary() throws IOException 
>   {
>     DataGraph dg = SDOUtil.createDataGraph();
>     SDOUtil.setRootObject(dg, dataObject);
>     dg.getChangeSummary().beginLogging();
>     dataObject.getDataObject("results.1/myResult.0").delete();
>     ByteArrayOutputStream baos = new ByteArrayOutputStream();
>     SDOUtil.saveDataGraph(dg, baos, null);
>     ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
>     SDOUtil.loadDataGraph(bais, null, hc);
>   }    
>   
>   public void testSimpleTypeExtension() 
>   {
>     TypeHelper typeHelper = hc.getTypeHelper();
>     
>     Type asciiStringType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "AsciiStringType");
>     Type idType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "IdType");
>     assertTrue("IdType does not report AsciiStringType as a base type", 
>         idType.getBaseTypes().contains(asciiStringType));
>     
>     Diagnostic diagnostic = Diagnostician.INSTANCE.validate((EObject) dataObject);
>     String diagnosticMsg = diagnostic.getChildren().toString();
>     Type id2Type = typeHelper.getType(sev2NamespaceURI, "Id2Type");
>     assertTrue("Id2Type does not report IdType as a base type", 
>         id2Type.getBaseTypes().contains(idType));
>     assertTrue("EMF validation should have reported Id pattern match failure", 
>         diagnosticMsg.indexOf("Id") > 0);
>   }
> }
> STACKTRACE:
> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Value '' is not legal. (file:///C:/development/working/1/tuscany-sdo/sdo/tools-test/all.datagraph, 27, 48)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.handleErrors(XMLLoadImpl.java:83)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:193)
> 	at org.apache.tuscany.sdo.util.DataGraphResourceFactoryImpl$DataGraphResourceImpl$LoadImpl.load(DataGraphResourceFactoryImpl.java:455)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:179)
> 	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1094)
> 	at org.apache.tuscany.sdo.helper.SDOHelperImpl.loadDataGraph(SDOHelperImpl.java:139)
> 	at org.apache.tuscany.sdo.helper.SDOHelperImpl.loadDataGraph(SDOHelperImpl.java:157)
> 	at org.apache.tuscany.sdo.api.SDOUtil.loadDataGraph(SDOUtil.java:150)
> 	at org.apache.tuscany.sdo.test.SubstitutionWithExtensionValuesTestCase.testComplexTypeWithSimpleContentExtensionChangeSummary(SubstitutionWithExtensionValuesTestCase.java:150)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:585)
> 	at junit.framework.TestCase.runTest(TestCase.java:154)
> 	at junit.framework.TestCase.runBare(TestCase.java:127)
> 	at junit.framework.TestResult$1.protect(TestResult.java:106)
> 	at junit.framework.TestResult.runProtected(TestResult.java:124)
> 	at junit.framework.TestResult.run(TestResult.java:109)
> 	at junit.framework.TestCase.run(TestCase.java:118)
> 	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
> 	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
> Caused by: org.eclipse.emf.ecore.xmi.IllegalValueException: Value '' is not legal. (file:///C:/development/working/1/tuscany-sdo/sdo/tools-test/all.datagraph, 27, 48)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2421)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2406)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.endElement(XMLHandler.java:1347)
> 	at org.apache.tuscany.sdo.util.DataGraphResourceFactoryImpl$DataGraphResourceImpl$LoadImpl$1.endElement(DataGraphResourceFactoryImpl.java:627)
> 	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:633)
> 	at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:221)
> 	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:322)
> 	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1693)
> 	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
> 	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
> 	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
> 	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
> 	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
> 	at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:183)
> 	... 23 more
> Caused by: java.lang.NumberFormatException: Zero length BigInteger
> 	at java.math.BigInteger.<init>(BigInteger.java:275)
> 	at java.math.BigInteger.<init>(BigInteger.java:447)
> 	at org.eclipse.emf.ecore.xml.type.impl.XMLTypeFactoryImpl.createInteger(XMLTypeFactoryImpl.java:832)
> 	at org.apache.tuscany.sdo.model.impl.ModelFactoryImpl.createIntegerFromString(ModelFactoryImpl.java:2086)
> 	at com.example.substitution.ev.impl.SEVFactoryImpl.create_Integer32BitFromString(SEVFactoryImpl.java:754)
> 	at com.example.substitution.ev.impl.SEVFactoryImpl.createFromString(SEVFactoryImpl.java:143)
> 	at org.apache.tuscany.sdo.impl.FactoryBase$SDOEFactoryImpl.createFromString(FactoryBase.java:286)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createFromString(XMLHelperImpl.java:1489)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHelperImpl.java:1053)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2416)
> 	... 37 more
> SAVED PROBLEMATIC DATA GRAPH
> <?xml version="1.0" encoding="ASCII"?>
> <sdo:datagraph xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sdo="commonj.sdo"
>     xmlns:sdo_1="http://www.apache.org/tuscany/2005/SDO" xmlns:sev="http://www.example.com/substitutionEV"
>     xmlns:sev2="http://www.example.com/substitutionEV2">
>   <changeSummary xmlns=""
>       logging="true">
>     <objectChanges key="#//@eRootObject/@results.1">
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="resultGroup">
>         <listChanges index="0">
>           <featureMapEntryValues featureName="myResult" referenceValue="#//@eChangeSummary/@objectsToAttach.0"/>
>         </listChanges>
>       </value>
>     </objectChanges>
>     <objectChanges key="#//@eChangeSummary/@objectsToAttach.0">
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="value" set="false"
>           referenceValue="#//@eChangeSummary/@objectsToAttach.1"/>
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="id" dataValue="BBBBBBBBBBBBBBBBBBBB"
>           set="false"/>
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="name" dataValue="myNameB"
>           set="false"/>
>     </objectChanges>
>     <objectChanges key="#//@eChangeSummary/@objectsToAttach.1">
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="value" dataValue="11"
>           set="false"/>
>     </objectChanges>
>     <objectsToAttach xsi:type="sev:MyResultType"/>
>     <objectsToAttach xsi:type="sev:ValueType"/>
>   </changeSummary>
>   <sev2:AllResultsType>
>     <id>ZZZZZZZZZZZZZZZZZZZZ</id>
>     <results>
>       <id>00000000000000000000</id>
>       <sev:result>
>         <id>11111111111111111111</id>
>         <name>name1</name>
>         <value>1</value>
>       </sev:result>
>       <sev:myResult>
>         <id>22222222222222222222</id>
>         <name>myName2</name>
>         <value>2</value>
>       </sev:myResult>
>       <comment>comment0</comment>
>     </results>
>     <results>
>       <id>AAAAAAAAAAAAAAAAAAAA</id>
>       <comment>commentA</comment>
>     </results>
>     <comment language="English">
> 		commentZZZZZZZZZZZZZZZZZZ
> 	</comment>
>   </sev2:AllResultsType>
> </sdo:datagraph>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


[jira] Updated: (TUSCANY-1842) IOException loading DataGraph containing a deleted dataObject with a property whose type extends a complexType w/simple integer content

Posted by "Ron Gavlin (JIRA)" <tu...@ws.apache.org>.
     [ https://issues.apache.org/jira/browse/TUSCANY-1842?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ron Gavlin updated TUSCANY-1842:
--------------------------------

    Description: 
In the test method, testComplexTypeWithSimpleContentExtensionChangeSummary() listed below, a DataGraph is created with a dataObject whose property type extends a complexType with simple integer content. After the dataObject is deleted, an attempt is made to save and load the DataGraph. While the DataGraph is being loaded, an unsuccessful attempt is made to convert a zero-length string into a BigInteger. 

Any suggestions on how to best fix this are most welcome.

Thanks,

- Ron

==============================
substitutionWithExtensionValues.xsd
============================== 

<schema xmlns="http://www.w3.org/2001/XMLSchema"
	targetNamespace="http://www.example.com/substitutionEV"
	xmlns:sev="http://www.example.com/substitutionEV">
	<!--
		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.    
	-->
	<element name="results" type="sev:ResultsType" />

	<element name="result" type="sev:ResultType" />
	<element name="myResult" type="sev:MyResultType"
		substitutionGroup="sev:result" />

	<complexType name="ResultsType">
		<sequence>
			<element name="id" type="sev:IdType" />
			<element ref="sev:result" minOccurs="0"
				maxOccurs="unbounded" />
			<element name="comment" type="sev:CommentType" />
		</sequence>
	</complexType>

	<complexType name="ResultType">
		<sequence>
			<element name="id" type="sev:IdType" />
			<element name="name" type="string" />
			<element name="value" type="sev:ValueType" />
		</sequence>
	</complexType>

	<complexType name="MyResultType">
		<complexContent>
			<extension base="sev:ResultType" />
		</complexContent>
	</complexType>

	<simpleType name="IdType">
		<restriction base="sev:AsciiStringType">
			<maxLength value="32" />
			<pattern value="[0-9a-fA-F]*" />
		</restriction>
	</simpleType>

	<simpleType name="AsciiStringType">
		<restriction base="string">
			<pattern value="\p{IsBasicLatin}*" />
		</restriction>
	</simpleType>

	<complexType name="ValueType">
		<simpleContent>
			<extension base="sev:Integer32Bit" />
		</simpleContent>
	</complexType>

	<complexType name="Integer32Bit">
		<simpleContent>
			<restriction base="integer">
				<minInclusive value="0" />
				<maxInclusive value="4290000000" />
			</restriction>
		</simpleContent>
	</complexType>
	
	<complexType name="CommentType">
		<simpleContent>
			<extension base="sev:AsciiStringType">
				<attribute name="language" use="optional">
					<simpleType>
						<restriction base="string">
							<enumeration value="English" />
							<enumeration value="French" />
							<enumeration value="Spanish" />
						</restriction>
					</simpleType>
				</attribute>
			</extension>
		</simpleContent>
	</complexType>

	<complexType name="MyCommentType">
		<simpleContent>
			<restriction base="sev:CommentType">
				<minLength value="0" />
				<maxLength value="40" />
			</restriction>
		</simpleContent>
	</complexType>

	<complexType name="StringBasedCommentType">
		<simpleContent>
			<restriction base="string">
				<minLength value="0" />
				<maxLength value="40" />
			</restriction>
		</simpleContent>
	</complexType>

</schema>

==============================
substitutionWithExtensionValues2.xsd
==============================

<schema xmlns="http://www.w3.org/2001/XMLSchema"
	targetNamespace="http://www.example.com/substitutionEV2"
	xmlns:sev2="http://www.example.com/substitutionEV2"
	xmlns:sev="http://www.example.com/substitutionEV">
	<!--
		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.    
	-->

	<import namespace="http://www.example.com/substitutionEV"
		schemaLocation="substitutionWithExtensionValues.xsd" />

	<element name="allResults" type="sev2:AllResultsType" />

	<complexType name="AllResultsType">
		<sequence>
			<element name="id" type="sev2:Id2Type" />
			<element name="results" minOccurs="0" maxOccurs="unbounded"
				type="sev2:Results2Type" />
			<element name="comment" type="sev2:Comment2Type" />
		</sequence>
	</complexType>

	<complexType name="Results2Type">
		<complexContent>
			<extension base="sev:ResultsType"></extension>
		</complexContent>
	</complexType>

	<simpleType name="Id2Type">
		<restriction base="sev:IdType">
			<maxLength value="10" />
		</restriction>
	</simpleType>

	<complexType name="Comment2Type">
		<simpleContent>
			<restriction base="sev:CommentType">
				<minLength value="0" />
				<maxLength value="20" />
			</restriction>
		</simpleContent>
	</complexType>

</schema>

==============================
substitutionWithExtensionValues1.xml
==============================

<?xml version="1.0" encoding="ASCII"?>
<sev2:allResults xmlns:sev2="http://www.example.com/substitutionEV2">
	<sev2:id>ZZZZZZZZZZZZZZZZZZZZ</sev2:id>
	<sev:results xmlns:sev="http://www.example.com/substitutionEV">
		<sev:id>00000000000000000000</sev:id>
		<sev:result>
			<sev:id>11111111111111111111</sev:id>
			<sev:name>name1</sev:name>
			<sev:value>1</sev:value>
		</sev:result>
		<sev:myResult>
			<sev:id>22222222222222222222</sev:id>
			<sev:name>myName2</sev:name>
			<sev:value>2</sev:value>
		</sev:myResult>
		<sev:comment>comment0</sev:comment>
	</sev:results>
	<sev:results xmlns:sev="http://www.example.com/substitutionEV">
		<sev:id>AAAAAAAAAAAAAAAAAAAA</sev:id>
		<sev:myResult>
			<sev:id>BBBBBBBBBBBBBBBBBBBB</sev:id>
			<sev:name>myNameB</sev:name>
			<sev:value>11</sev:value>
		</sev:myResult>
		<sev:comment>commentA</sev:comment>
	</sev:results>
	<sev2:comment language="English">
		commentZZZZZZZZZZZZZZZZZZ
	</sev2:comment>
</sev2:allResults>

==============================
SubstitutionWithExtensionValuesTestCase.java
============================== 

/**
 *
 *  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.sdo.test;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.List;

import junit.framework.TestCase;

import org.apache.tuscany.sdo.api.SDOUtil;
import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.util.Diagnostician;
import org.eclipse.emf.ecore.util.ExtendedMetaData;

import com.example.substitution.ev.SEVFactory;
import com.example.substitution.ev.impl.SEVFactoryImpl;

import commonj.sdo.DataGraph;
import commonj.sdo.DataObject;
import commonj.sdo.Property;
import commonj.sdo.Type;
import commonj.sdo.helper.HelperContext;
import commonj.sdo.helper.TypeHelper;
import commonj.sdo.impl.HelperProvider;

public final class SubstitutionWithExtensionValuesTestCase extends TestCase 
{
  private static String sev2NamespaceURI;
  private HelperContext hc;
  private DataObject dataObject;
  
  protected void setUp() throws Exception {
    super.setUp();
    hc = HelperProvider.getDefaultContext();
    registerSEV(hc, true);
    
    InputStream inputStream = null;
    URL url = getClass().getResource("/substitutionWithExtensionValues2.xsd");
    inputStream = url.openStream();
    List sev2TypeList = hc.getXSDHelper().define(inputStream, url.toString());
    inputStream.close();
    
    inputStream = getClass().getResourceAsStream("/substitutionWithExtensionValues1.xml");
    dataObject = hc.getXMLHelper().load(inputStream).getRootObject();
    inputStream.close();
    
    if (sev2NamespaceURI == null)
    {
      sev2NamespaceURI = ((Type) sev2TypeList.get(0)).getURI();
    }
  }
  
  private void registerSEV(HelperContext hc, boolean useStaticRegistration) throws IOException
  {
    if (useStaticRegistration)
    {
      SEVFactory.INSTANCE.register(hc);
    }
    else
    {
      InputStream inputStream = null;
      URL url = getClass().getResource("/substitutionWithExtensionValues.xsd");
      inputStream = url.openStream();
      hc.getXSDHelper().define(inputStream, url.toString());
      inputStream.close();
    }
  }

  public void testComplexTypeWithSubstitutionExtension() throws IOException 
  {
    TypeHelper typeHelper = hc.getTypeHelper();
    
    Type resultsType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "ResultsType");
    Type results2Type = typeHelper.getType(sev2NamespaceURI, "Results2Type");
    assertTrue("Results2 type does not report Results as a base type", 
        results2Type.getBaseTypes().contains(resultsType));
    
    assertEquals("results.1/myResult.0/id has unexpected value", 
        "BBBBBBBBBBBBBBBBBBBB", dataObject.getString("results.1/myResult.0/id"));
  }
  
  public void testComplexTypeWithSimpleContentExtensionMetaData() 
  {
    TypeHelper typeHelper = hc.getTypeHelper();
    
    Type stringBasedCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "StringBasedCommentType");
    Type commentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "CommentType");
    Type myCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "MyCommentType");
    Type _myCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "_MyCommentType");
    Type comment2Type = typeHelper.getType(sev2NamespaceURI, "Comment2Type");
    Type _comment2Type = typeHelper.getType(sev2NamespaceURI, "_Comment2Type");
    assertTrue("MyComment type does not report Comment as a base type", 
        myCommentType.getBaseTypes().contains(commentType));
    assertTrue("Comment2 type does not report Comment as a base type", 
        comment2Type.getBaseTypes().contains(commentType));
    
    // Test length facets - resort to EMF APIs until Tuscany SDO exposes these directly
    ExtendedMetaData extendedMetaData = ExtendedMetaData.INSTANCE;

    EStructuralFeature simpleFeature = null;
    EDataType commentSimpleType = null;
    
    simpleFeature = extendedMetaData.getSimpleFeature((EClass) stringBasedCommentType);
    commentSimpleType = (EDataType)simpleFeature.getEType();
    assertEquals(40, extendedMetaData.getMaxLengthFacet(commentSimpleType));
    
    // FIXME Work-around EMF's lack of support for re-definable features - SEE TUSCANY-1832
    commentSimpleType = (EDataType) _myCommentType;
    assertEquals(40, extendedMetaData.getMaxLengthFacet(commentSimpleType));
    
    // FIXME Work-around EMF's lack of support for re-definable features - SEE TUSCANY-1832
    commentSimpleType = (EDataType) _comment2Type;
    assertEquals(20, extendedMetaData.getMaxLengthFacet(commentSimpleType));
  }

  public void testComplexTypeWithSimpleContentExtensionChangeSummary() throws IOException 
  {
    DataGraph dg = SDOUtil.createDataGraph();
    SDOUtil.setRootObject(dg, dataObject);
    dg.getChangeSummary().beginLogging();
    dataObject.getDataObject("results.1/myResult.0").delete();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    SDOUtil.saveDataGraph(dg, baos, null);
    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    SDOUtil.loadDataGraph(bais, null, hc);
  }    
  
  public void testSimpleTypeExtension() 
  {
    TypeHelper typeHelper = hc.getTypeHelper();
    
    Type asciiStringType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "AsciiStringType");
    Type idType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "IdType");
    assertTrue("IdType does not report AsciiStringType as a base type", 
        idType.getBaseTypes().contains(asciiStringType));
    
    Diagnostic diagnostic = Diagnostician.INSTANCE.validate((EObject) dataObject);
    String diagnosticMsg = diagnostic.getChildren().toString();

    Type id2Type = typeHelper.getType(sev2NamespaceURI, "Id2Type");
    assertTrue("Id2Type does not report IdType as a base type", 
        id2Type.getBaseTypes().contains(idType));
    assertTrue("EMF validation should have reported Id pattern match failure", 
        diagnosticMsg.indexOf("Id") > 0);
  }
}

STACKTRACE:

org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Value '' is not legal. (file:///C:/development/working/1/tuscany-sdo/sdo/tools-test/all.datagraph, 27, 48)
	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.handleErrors(XMLLoadImpl.java:83)
	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:193)
	at org.apache.tuscany.sdo.util.DataGraphResourceFactoryImpl$DataGraphResourceImpl$LoadImpl.load(DataGraphResourceFactoryImpl.java:455)
	at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:179)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1094)
	at org.apache.tuscany.sdo.helper.SDOHelperImpl.loadDataGraph(SDOHelperImpl.java:139)
	at org.apache.tuscany.sdo.helper.SDOHelperImpl.loadDataGraph(SDOHelperImpl.java:157)
	at org.apache.tuscany.sdo.api.SDOUtil.loadDataGraph(SDOUtil.java:150)
	at org.apache.tuscany.sdo.test.SubstitutionWithExtensionValuesTestCase.testComplexTypeWithSimpleContentExtensionChangeSummary(SubstitutionWithExtensionValuesTestCase.java:150)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at junit.framework.TestCase.runTest(TestCase.java:154)
	at junit.framework.TestCase.runBare(TestCase.java:127)
	at junit.framework.TestResult$1.protect(TestResult.java:106)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at junit.framework.TestResult.run(TestResult.java:109)
	at junit.framework.TestCase.run(TestCase.java:118)
	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: org.eclipse.emf.ecore.xmi.IllegalValueException: Value '' is not legal. (file:///C:/development/working/1/tuscany-sdo/sdo/tools-test/all.datagraph, 27, 48)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2421)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2406)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.endElement(XMLHandler.java:1347)
	at org.apache.tuscany.sdo.util.DataGraphResourceFactoryImpl$DataGraphResourceImpl$LoadImpl$1.endElement(DataGraphResourceFactoryImpl.java:627)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:633)
	at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:221)
	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:322)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1693)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
	at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:183)
	... 23 more
Caused by: java.lang.NumberFormatException: Zero length BigInteger
	at java.math.BigInteger.<init>(BigInteger.java:275)
	at java.math.BigInteger.<init>(BigInteger.java:447)
	at org.eclipse.emf.ecore.xml.type.impl.XMLTypeFactoryImpl.createInteger(XMLTypeFactoryImpl.java:832)
	at org.apache.tuscany.sdo.model.impl.ModelFactoryImpl.createIntegerFromString(ModelFactoryImpl.java:2086)
	at com.example.substitution.ev.impl.SEVFactoryImpl.create_Integer32BitFromString(SEVFactoryImpl.java:754)
	at com.example.substitution.ev.impl.SEVFactoryImpl.createFromString(SEVFactoryImpl.java:143)
	at org.apache.tuscany.sdo.impl.FactoryBase$SDOEFactoryImpl.createFromString(FactoryBase.java:286)
	at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createFromString(XMLHelperImpl.java:1489)
	at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHelperImpl.java:1053)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2416)
	... 37 more

SAVED PROBLEMATIC DATA GRAPH

<?xml version="1.0" encoding="ASCII"?>
<sdo:datagraph xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sdo="commonj.sdo"
    xmlns:sdo_1="http://www.apache.org/tuscany/2005/SDO" xmlns:sev="http://www.example.com/substitutionEV"
    xmlns:sev2="http://www.example.com/substitutionEV2">
  <changeSummary xmlns=""
      logging="true">
    <objectChanges key="#//@eRootObject/@results.1">
      <value xsi:type="sdo_1:ChangeSummarySetting" featureName="resultGroup">
        <listChanges index="0">
          <featureMapEntryValues featureName="myResult" referenceValue="#//@eChangeSummary/@objectsToAttach.0"/>
        </listChanges>
      </value>
    </objectChanges>
    <objectChanges key="#//@eChangeSummary/@objectsToAttach.0">
      <value xsi:type="sdo_1:ChangeSummarySetting" featureName="value" set="false"
          referenceValue="#//@eChangeSummary/@objectsToAttach.1"/>
      <value xsi:type="sdo_1:ChangeSummarySetting" featureName="id" dataValue="BBBBBBBBBBBBBBBBBBBB"
          set="false"/>
      <value xsi:type="sdo_1:ChangeSummarySetting" featureName="name" dataValue="myNameB"
          set="false"/>
    </objectChanges>
    <objectChanges key="#//@eChangeSummary/@objectsToAttach.1">
      <value xsi:type="sdo_1:ChangeSummarySetting" featureName="value" dataValue="11"
          set="false"/>
    </objectChanges>
    <objectsToAttach xsi:type="sev:MyResultType"/>
    <objectsToAttach xsi:type="sev:ValueType"/>
  </changeSummary>
  <sev2:AllResultsType>
    <id>ZZZZZZZZZZZZZZZZZZZZ</id>
    <results>
      <id>00000000000000000000</id>
      <sev:result>
        <id>11111111111111111111</id>
        <name>name1</name>
        <value>1</value>
      </sev:result>
      <sev:myResult>
        <id>22222222222222222222</id>
        <name>myName2</name>
        <value>2</value>
      </sev:myResult>
      <comment>comment0</comment>
    </results>
    <results>
      <id>AAAAAAAAAAAAAAAAAAAA</id>
      <comment>commentA</comment>
    </results>
    <comment language="English">
		commentZZZZZZZZZZZZZZZZZZ
	</comment>
  </sev2:AllResultsType>
</sdo:datagraph>


  was:
In the test method, testComplexTypeWithSimpleContentExtensionChangeSummary() listed below, a DataGraph is created with a dataObject whose property type extends a complexType with simple integer content. After the dataObject is deleted, an attempt is made to save and load the DataGraph. While the DataGraph is being loaded, an unsuccessful attempt is made to convert a zero-length string into a BigInteger. 

Any suggestions on how to best fix this are most welcome.

Thanks,

- Ron

==============================
substitutionWithExtensionValues.xsd
============================== 

<schema xmlns="http://www.w3.org/2001/XMLSchema"
	targetNamespace="http://www.example.com/substitutionEV"
	xmlns:sev="http://www.example.com/substitutionEV">
	<!--
		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.    
	-->
	<element name="results" type="sev:ResultsType" />

	<element name="result" type="sev:ResultType" />
	<element name="myResult" type="sev:MyResultType"
		substitutionGroup="sev:result" />

	<complexType name="ResultsType">
		<sequence>
			<element name="id" type="sev:IdType" />
			<element ref="sev:result" minOccurs="0"
				maxOccurs="unbounded" />
			<element name="comment" type="sev:CommentType" />
		</sequence>
	</complexType>

	<complexType name="ResultType">
		<sequence>
			<element name="id" type="sev:IdType" />
			<element name="name" type="string" />
			<element name="value" type="sev:ValueType" />
		</sequence>
	</complexType>

	<complexType name="MyResultType">
		<complexContent>
			<extension base="sev:ResultType" />
		</complexContent>
	</complexType>

	<simpleType name="IdType">
		<restriction base="sev:AsciiStringType">
			<maxLength value="32" />
			<pattern value="[0-9a-fA-F]*" />
		</restriction>
	</simpleType>

	<simpleType name="AsciiStringType">
		<restriction base="string">
			<pattern value="\p{IsBasicLatin}*" />
		</restriction>
	</simpleType>

	<complexType name="ValueType">
		<simpleContent>
			<extension base="sev:Integer32Bit" />
		</simpleContent>
	</complexType>

	<complexType name="Integer32Bit">
		<simpleContent>
			<restriction base="integer">
				<minInclusive value="0" />
				<maxInclusive value="4290000000" />
			</restriction>
		</simpleContent>
	</complexType>
	
	<complexType name="CommentType">
		<simpleContent>
			<extension base="sev:AsciiStringType">
				<attribute name="language" use="optional">
					<simpleType>
						<restriction base="string">
							<enumeration value="English" />
							<enumeration value="French" />
							<enumeration value="Spanish" />
						</restriction>
					</simpleType>
				</attribute>
			</extension>
		</simpleContent>
	</complexType>

	<complexType name="MyCommentType">
		<simpleContent>
			<restriction base="sev:CommentType">
				<minLength value="0" />
				<maxLength value="40" />
			</restriction>
		</simpleContent>
	</complexType>

	<complexType name="StringBasedCommentType">
		<simpleContent>
			<restriction base="string">
				<minLength value="0" />
				<maxLength value="40" />
			</restriction>
		</simpleContent>
	</complexType>

</schema>

==============================
substitutionWithExtensionValues2.xsd
==============================

<schema xmlns="http://www.w3.org/2001/XMLSchema"
	targetNamespace="http://www.example.com/substitutionEV2"
	xmlns:sev2="http://www.example.com/substitutionEV2"
	xmlns:sev="http://www.example.com/substitutionEV">
	<!--
		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.    
	-->

	<import namespace="http://www.example.com/substitutionEV"
		schemaLocation="substitutionWithExtensionValues.xsd" />

	<element name="allResults" type="sev2:AllResultsType" />

	<complexType name="AllResultsType">
		<sequence>
			<element name="id" type="sev2:Id2Type" />
			<element name="results" minOccurs="0" maxOccurs="unbounded"
				type="sev2:Results2Type" />
			<element name="comment" type="sev2:Comment2Type" />
		</sequence>
	</complexType>

	<complexType name="Results2Type">
		<complexContent>
			<extension base="sev:ResultsType"></extension>
		</complexContent>
	</complexType>

	<simpleType name="Id2Type">
		<restriction base="sev:IdType">
			<maxLength value="10" />
		</restriction>
	</simpleType>

	<complexType name="Comment2Type">
		<simpleContent>
			<restriction base="sev:CommentType">
				<minLength value="0" />
				<maxLength value="20" />
			</restriction>
		</simpleContent>
	</complexType>

</schema>

==============================
substitutionWithExtensionValues1.xml
==============================

<?xml version="1.0" encoding="ASCII"?>
<sev2:allResults xmlns:sev2="http://www.example.com/substitutionEV2">
	<sev2:id>ZZZZZZZZZZZZZZZZZZZZ</sev2:id>
	<sev:results xmlns:sev="http://www.example.com/substitutionEV">
		<sev:id>00000000000000000000</sev:id>
		<sev:result>
			<sev:id>11111111111111111111</sev:id>
			<sev:name>name1</sev:name>
			<sev:value>1</sev:value>
		</sev:result>
		<sev:myResult>
			<sev:id>22222222222222222222</sev:id>
			<sev:name>myName2</sev:name>
			<sev:value>2</sev:value>
		</sev:myResult>
		<sev:comment>comment0</sev:comment>
	</sev:results>
	<sev:results xmlns:sev="http://www.example.com/substitutionEV">
		<sev:id>AAAAAAAAAAAAAAAAAAAA</sev:id>
		<sev:myResult>
			<sev:id>BBBBBBBBBBBBBBBBBBBB</sev:id>
			<sev:name>myNameB</sev:name>
			<sev:value>11</sev:value>
		</sev:myResult>
		<sev:comment>commentA</sev:comment>
	</sev:results>
	<sev2:comment language="English">
		commentZZZZZZZZZZZZZZZZZZ
	</sev2:comment>
</sev2:allResults>

==============================
SubstitutionWithExtensionValuesTestCase.java
============================== 

/**
 *
 *  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.sdo.test;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.List;

import junit.framework.TestCase;

import org.apache.tuscany.sdo.api.SDOUtil;
import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.util.Diagnostician;
import org.eclipse.emf.ecore.util.ExtendedMetaData;

import com.example.substitution.ev.SEVFactory;
import com.example.substitution.ev.impl.SEVFactoryImpl;

import commonj.sdo.DataGraph;
import commonj.sdo.DataObject;
import commonj.sdo.Property;
import commonj.sdo.Type;
import commonj.sdo.helper.HelperContext;
import commonj.sdo.helper.TypeHelper;
import commonj.sdo.impl.HelperProvider;

public final class SubstitutionWithExtensionValuesTestCase extends TestCase 
{
  private static String sev2NamespaceURI;
  private HelperContext hc;
  private DataObject dataObject;
  
  protected void setUp() throws Exception {
    super.setUp();
    hc = HelperProvider.getDefaultContext();
    registerSEV(hc, true);
    
    InputStream inputStream = null;
    URL url = getClass().getResource("/substitutionWithExtensionValues2.xsd");
    inputStream = url.openStream();
    List sev2TypeList = hc.getXSDHelper().define(inputStream, url.toString());
    inputStream.close();
    
    inputStream = getClass().getResourceAsStream("/substitutionWithExtensionValues1.xml");
    dataObject = hc.getXMLHelper().load(inputStream).getRootObject();
    inputStream.close();
    
    if (sev2NamespaceURI == null)
    {
      sev2NamespaceURI = ((Type) sev2TypeList.get(0)).getURI();
    }
  }
  
  private void registerSEV(HelperContext hc, boolean useStaticRegistration) throws IOException
  {
    if (useStaticRegistration)
    {
      SEVFactory.INSTANCE.register(hc);
    }
    else
    {
      InputStream inputStream = null;
      URL url = getClass().getResource("/substitutionWithExtensionValues.xsd");
      inputStream = url.openStream();
      hc.getXSDHelper().define(inputStream, url.toString());
      inputStream.close();
    }
  }

  public void testComplexTypeWithSubstitutionExtension() throws IOException 
  {
    TypeHelper typeHelper = hc.getTypeHelper();
    
    Type resultsType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "ResultsType");
    Type results2Type = typeHelper.getType(sev2NamespaceURI, "Results2Type");
    assertTrue("Results2 type does not report Results as a base type", 
        results2Type.getBaseTypes().contains(resultsType));
    
    assertEquals("results.1/myResult.0/id has unexpected value", 
        "BBBBBBBBBBBBBBBBBBBB", dataObject.getString("results.1/myResult.0/id"));
  }
  
  public void testComplexTypeWithSimpleContentExtensionMetaData() 
  {
    TypeHelper typeHelper = hc.getTypeHelper();
    
    Type stringBasedCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "StringBasedCommentType");
    Type commentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "CommentType");
    Type myCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "MyCommentType");
    Type _myCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "_MyCommentType");
    Type comment2Type = typeHelper.getType(sev2NamespaceURI, "Comment2Type");
    Type _comment2Type = typeHelper.getType(sev2NamespaceURI, "_Comment2Type");
    assertTrue("MyComment type does not report Comment as a base type", 
        myCommentType.getBaseTypes().contains(commentType));
    assertTrue("Comment2 type does not report Comment as a base type", 
        comment2Type.getBaseTypes().contains(commentType));
    
    // Test length facets - resort to EMF APIs until Tuscany SDO exposes these directly
    ExtendedMetaData extendedMetaData = ExtendedMetaData.INSTANCE;

    EStructuralFeature simpleFeature = null;
    EDataType commentSimpleType = null;
    
    simpleFeature = extendedMetaData.getSimpleFeature((EClass) stringBasedCommentType);
    commentSimpleType = (EDataType)simpleFeature.getEType();
    assertEquals(40, extendedMetaData.getMaxLengthFacet(commentSimpleType));
    
    // FIXME Work-around EMF's lack of support for re-definable features - SEE TUSCANY-1832
    commentSimpleType = (EDataType) _myCommentType;
    assertEquals(40, extendedMetaData.getMaxLengthFacet(commentSimpleType));
    
    // FIXME Work-around EMF's lack of support for re-definable features - SEE TUSCANY-1832
    commentSimpleType = (EDataType) _comment2Type;
    assertEquals(20, extendedMetaData.getMaxLengthFacet(commentSimpleType));
  }

  public void testComplexTypeWithSimpleContentExtensionChangeSummary() throws IOException 
  {
    DataGraph dg = SDOUtil.createDataGraph();
    SDOUtil.setRootObject(dg, dataObject);
    dg.getChangeSummary().beginLogging();
    dataObject.getDataObject("results.1/myResult.0").delete();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    SDOUtil.saveDataGraph(dg, baos, null);
    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    SDOUtil.loadDataGraph(bais, null, hc);
  }    
  
  public void testSimpleTypeExtension() 
  {
    TypeHelper typeHelper = hc.getTypeHelper();
    
    Type asciiStringType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "AsciiStringType");
    Type idType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "IdType");
    assertTrue("IdType does not report AsciiStringType as a base type", 
        idType.getBaseTypes().contains(asciiStringType));
    
    Diagnostic diagnostic = Diagnostician.INSTANCE.validate((EObject) dataObject);
    String diagnosticMsg = diagnostic.getChildren().toString();

    Type id2Type = typeHelper.getType(sev2NamespaceURI, "Id2Type");
    assertTrue("Id2Type does not report IdType as a base type", 
        id2Type.getBaseTypes().contains(idType));
    assertTrue("EMF validation should have reported Id pattern match failure", 
        diagnosticMsg.indexOf("Id") > 0);
  }
}

STACKTRACE:

org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Value '' is not legal. (file:///C:/development/working/1/tuscany-sdo/sdo/tools-test/all.datagraph, 27, 48)
	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.handleErrors(XMLLoadImpl.java:83)
	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:193)
	at org.apache.tuscany.sdo.util.DataGraphResourceFactoryImpl$DataGraphResourceImpl$LoadImpl.load(DataGraphResourceFactoryImpl.java:455)
	at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:179)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1094)
	at org.apache.tuscany.sdo.helper.SDOHelperImpl.loadDataGraph(SDOHelperImpl.java:139)
	at org.apache.tuscany.sdo.helper.SDOHelperImpl.loadDataGraph(SDOHelperImpl.java:157)
	at org.apache.tuscany.sdo.api.SDOUtil.loadDataGraph(SDOUtil.java:150)
	at org.apache.tuscany.sdo.test.SubstitutionWithExtensionValuesTestCase.testComplexTypeWithSimpleContentExtensionChangeSummary(SubstitutionWithExtensionValuesTestCase.java:150)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at junit.framework.TestCase.runTest(TestCase.java:154)
	at junit.framework.TestCase.runBare(TestCase.java:127)
	at junit.framework.TestResult$1.protect(TestResult.java:106)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at junit.framework.TestResult.run(TestResult.java:109)
	at junit.framework.TestCase.run(TestCase.java:118)
	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: org.eclipse.emf.ecore.xmi.IllegalValueException: Value '' is not legal. (file:///C:/development/working/1/tuscany-sdo/sdo/tools-test/all.datagraph, 27, 48)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2421)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2406)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.endElement(XMLHandler.java:1347)
	at org.apache.tuscany.sdo.util.DataGraphResourceFactoryImpl$DataGraphResourceImpl$LoadImpl$1.endElement(DataGraphResourceFactoryImpl.java:627)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:633)
	at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:221)
	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:322)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1693)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
	at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:183)
	... 23 more
Caused by: java.lang.NumberFormatException: Zero length BigInteger
	at java.math.BigInteger.<init>(BigInteger.java:275)
	at java.math.BigInteger.<init>(BigInteger.java:447)
	at org.eclipse.emf.ecore.xml.type.impl.XMLTypeFactoryImpl.createInteger(XMLTypeFactoryImpl.java:832)
	at org.apache.tuscany.sdo.model.impl.ModelFactoryImpl.createIntegerFromString(ModelFactoryImpl.java:2086)
	at com.example.substitution.ev.impl.SEVFactoryImpl.create_Integer32BitFromString(SEVFactoryImpl.java:754)
	at com.example.substitution.ev.impl.SEVFactoryImpl.createFromString(SEVFactoryImpl.java:143)
	at org.apache.tuscany.sdo.impl.FactoryBase$SDOEFactoryImpl.createFromString(FactoryBase.java:286)
	at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createFromString(XMLHelperImpl.java:1489)
	at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHelperImpl.java:1053)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2416)
	... 37 more



Added SAVED PROBLEMATIC DATA GRAPH to description

> IOException loading DataGraph containing a deleted dataObject with a property whose type extends a complexType w/simple integer content
> ---------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: TUSCANY-1842
>                 URL: https://issues.apache.org/jira/browse/TUSCANY-1842
>             Project: Tuscany
>          Issue Type: Bug
>          Components: Java SDO Implementation
>    Affects Versions: Java-SDO-Next
>         Environment: Windows XP, Sun JDK 1.5.0_09
>            Reporter: Ron Gavlin
>            Priority: Critical
>             Fix For: Java-SDO-Next
>
>
> In the test method, testComplexTypeWithSimpleContentExtensionChangeSummary() listed below, a DataGraph is created with a dataObject whose property type extends a complexType with simple integer content. After the dataObject is deleted, an attempt is made to save and load the DataGraph. While the DataGraph is being loaded, an unsuccessful attempt is made to convert a zero-length string into a BigInteger. 
> Any suggestions on how to best fix this are most welcome.
> Thanks,
> - Ron
> ==============================
> substitutionWithExtensionValues.xsd
> ============================== 
> <schema xmlns="http://www.w3.org/2001/XMLSchema"
> 	targetNamespace="http://www.example.com/substitutionEV"
> 	xmlns:sev="http://www.example.com/substitutionEV">
> 	<!--
> 		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.    
> 	-->
> 	<element name="results" type="sev:ResultsType" />
> 	<element name="result" type="sev:ResultType" />
> 	<element name="myResult" type="sev:MyResultType"
> 		substitutionGroup="sev:result" />
> 	<complexType name="ResultsType">
> 		<sequence>
> 			<element name="id" type="sev:IdType" />
> 			<element ref="sev:result" minOccurs="0"
> 				maxOccurs="unbounded" />
> 			<element name="comment" type="sev:CommentType" />
> 		</sequence>
> 	</complexType>
> 	<complexType name="ResultType">
> 		<sequence>
> 			<element name="id" type="sev:IdType" />
> 			<element name="name" type="string" />
> 			<element name="value" type="sev:ValueType" />
> 		</sequence>
> 	</complexType>
> 	<complexType name="MyResultType">
> 		<complexContent>
> 			<extension base="sev:ResultType" />
> 		</complexContent>
> 	</complexType>
> 	<simpleType name="IdType">
> 		<restriction base="sev:AsciiStringType">
> 			<maxLength value="32" />
> 			<pattern value="[0-9a-fA-F]*" />
> 		</restriction>
> 	</simpleType>
> 	<simpleType name="AsciiStringType">
> 		<restriction base="string">
> 			<pattern value="\p{IsBasicLatin}*" />
> 		</restriction>
> 	</simpleType>
> 	<complexType name="ValueType">
> 		<simpleContent>
> 			<extension base="sev:Integer32Bit" />
> 		</simpleContent>
> 	</complexType>
> 	<complexType name="Integer32Bit">
> 		<simpleContent>
> 			<restriction base="integer">
> 				<minInclusive value="0" />
> 				<maxInclusive value="4290000000" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> 	
> 	<complexType name="CommentType">
> 		<simpleContent>
> 			<extension base="sev:AsciiStringType">
> 				<attribute name="language" use="optional">
> 					<simpleType>
> 						<restriction base="string">
> 							<enumeration value="English" />
> 							<enumeration value="French" />
> 							<enumeration value="Spanish" />
> 						</restriction>
> 					</simpleType>
> 				</attribute>
> 			</extension>
> 		</simpleContent>
> 	</complexType>
> 	<complexType name="MyCommentType">
> 		<simpleContent>
> 			<restriction base="sev:CommentType">
> 				<minLength value="0" />
> 				<maxLength value="40" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> 	<complexType name="StringBasedCommentType">
> 		<simpleContent>
> 			<restriction base="string">
> 				<minLength value="0" />
> 				<maxLength value="40" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> </schema>
> ==============================
> substitutionWithExtensionValues2.xsd
> ==============================
> <schema xmlns="http://www.w3.org/2001/XMLSchema"
> 	targetNamespace="http://www.example.com/substitutionEV2"
> 	xmlns:sev2="http://www.example.com/substitutionEV2"
> 	xmlns:sev="http://www.example.com/substitutionEV">
> 	<!--
> 		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.    
> 	-->
> 	<import namespace="http://www.example.com/substitutionEV"
> 		schemaLocation="substitutionWithExtensionValues.xsd" />
> 	<element name="allResults" type="sev2:AllResultsType" />
> 	<complexType name="AllResultsType">
> 		<sequence>
> 			<element name="id" type="sev2:Id2Type" />
> 			<element name="results" minOccurs="0" maxOccurs="unbounded"
> 				type="sev2:Results2Type" />
> 			<element name="comment" type="sev2:Comment2Type" />
> 		</sequence>
> 	</complexType>
> 	<complexType name="Results2Type">
> 		<complexContent>
> 			<extension base="sev:ResultsType"></extension>
> 		</complexContent>
> 	</complexType>
> 	<simpleType name="Id2Type">
> 		<restriction base="sev:IdType">
> 			<maxLength value="10" />
> 		</restriction>
> 	</simpleType>
> 	<complexType name="Comment2Type">
> 		<simpleContent>
> 			<restriction base="sev:CommentType">
> 				<minLength value="0" />
> 				<maxLength value="20" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> </schema>
> ==============================
> substitutionWithExtensionValues1.xml
> ==============================
> <?xml version="1.0" encoding="ASCII"?>
> <sev2:allResults xmlns:sev2="http://www.example.com/substitutionEV2">
> 	<sev2:id>ZZZZZZZZZZZZZZZZZZZZ</sev2:id>
> 	<sev:results xmlns:sev="http://www.example.com/substitutionEV">
> 		<sev:id>00000000000000000000</sev:id>
> 		<sev:result>
> 			<sev:id>11111111111111111111</sev:id>
> 			<sev:name>name1</sev:name>
> 			<sev:value>1</sev:value>
> 		</sev:result>
> 		<sev:myResult>
> 			<sev:id>22222222222222222222</sev:id>
> 			<sev:name>myName2</sev:name>
> 			<sev:value>2</sev:value>
> 		</sev:myResult>
> 		<sev:comment>comment0</sev:comment>
> 	</sev:results>
> 	<sev:results xmlns:sev="http://www.example.com/substitutionEV">
> 		<sev:id>AAAAAAAAAAAAAAAAAAAA</sev:id>
> 		<sev:myResult>
> 			<sev:id>BBBBBBBBBBBBBBBBBBBB</sev:id>
> 			<sev:name>myNameB</sev:name>
> 			<sev:value>11</sev:value>
> 		</sev:myResult>
> 		<sev:comment>commentA</sev:comment>
> 	</sev:results>
> 	<sev2:comment language="English">
> 		commentZZZZZZZZZZZZZZZZZZ
> 	</sev2:comment>
> </sev2:allResults>
> ==============================
> SubstitutionWithExtensionValuesTestCase.java
> ============================== 
> /**
>  *
>  *  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.sdo.test;
> import java.io.ByteArrayInputStream;
> import java.io.ByteArrayOutputStream;
> import java.io.IOException;
> import java.io.InputStream;
> import java.net.URL;
> import java.util.List;
> import junit.framework.TestCase;
> import org.apache.tuscany.sdo.api.SDOUtil;
> import org.eclipse.emf.common.util.Diagnostic;
> import org.eclipse.emf.ecore.EClass;
> import org.eclipse.emf.ecore.EDataType;
> import org.eclipse.emf.ecore.EObject;
> import org.eclipse.emf.ecore.EStructuralFeature;
> import org.eclipse.emf.ecore.util.Diagnostician;
> import org.eclipse.emf.ecore.util.ExtendedMetaData;
> import com.example.substitution.ev.SEVFactory;
> import com.example.substitution.ev.impl.SEVFactoryImpl;
> import commonj.sdo.DataGraph;
> import commonj.sdo.DataObject;
> import commonj.sdo.Property;
> import commonj.sdo.Type;
> import commonj.sdo.helper.HelperContext;
> import commonj.sdo.helper.TypeHelper;
> import commonj.sdo.impl.HelperProvider;
> public final class SubstitutionWithExtensionValuesTestCase extends TestCase 
> {
>   private static String sev2NamespaceURI;
>   private HelperContext hc;
>   private DataObject dataObject;
>   
>   protected void setUp() throws Exception {
>     super.setUp();
>     hc = HelperProvider.getDefaultContext();
>     registerSEV(hc, true);
>     
>     InputStream inputStream = null;
>     URL url = getClass().getResource("/substitutionWithExtensionValues2.xsd");
>     inputStream = url.openStream();
>     List sev2TypeList = hc.getXSDHelper().define(inputStream, url.toString());
>     inputStream.close();
>     
>     inputStream = getClass().getResourceAsStream("/substitutionWithExtensionValues1.xml");
>     dataObject = hc.getXMLHelper().load(inputStream).getRootObject();
>     inputStream.close();
>     
>     if (sev2NamespaceURI == null)
>     {
>       sev2NamespaceURI = ((Type) sev2TypeList.get(0)).getURI();
>     }
>   }
>   
>   private void registerSEV(HelperContext hc, boolean useStaticRegistration) throws IOException
>   {
>     if (useStaticRegistration)
>     {
>       SEVFactory.INSTANCE.register(hc);
>     }
>     else
>     {
>       InputStream inputStream = null;
>       URL url = getClass().getResource("/substitutionWithExtensionValues.xsd");
>       inputStream = url.openStream();
>       hc.getXSDHelper().define(inputStream, url.toString());
>       inputStream.close();
>     }
>   }
>   public void testComplexTypeWithSubstitutionExtension() throws IOException 
>   {
>     TypeHelper typeHelper = hc.getTypeHelper();
>     
>     Type resultsType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "ResultsType");
>     Type results2Type = typeHelper.getType(sev2NamespaceURI, "Results2Type");
>     assertTrue("Results2 type does not report Results as a base type", 
>         results2Type.getBaseTypes().contains(resultsType));
>     
>     assertEquals("results.1/myResult.0/id has unexpected value", 
>         "BBBBBBBBBBBBBBBBBBBB", dataObject.getString("results.1/myResult.0/id"));
>   }
>   
>   public void testComplexTypeWithSimpleContentExtensionMetaData() 
>   {
>     TypeHelper typeHelper = hc.getTypeHelper();
>     
>     Type stringBasedCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "StringBasedCommentType");
>     Type commentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "CommentType");
>     Type myCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "MyCommentType");
>     Type _myCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "_MyCommentType");
>     Type comment2Type = typeHelper.getType(sev2NamespaceURI, "Comment2Type");
>     Type _comment2Type = typeHelper.getType(sev2NamespaceURI, "_Comment2Type");
>     assertTrue("MyComment type does not report Comment as a base type", 
>         myCommentType.getBaseTypes().contains(commentType));
>     assertTrue("Comment2 type does not report Comment as a base type", 
>         comment2Type.getBaseTypes().contains(commentType));
>     
>     // Test length facets - resort to EMF APIs until Tuscany SDO exposes these directly
>     ExtendedMetaData extendedMetaData = ExtendedMetaData.INSTANCE;
>     EStructuralFeature simpleFeature = null;
>     EDataType commentSimpleType = null;
>     
>     simpleFeature = extendedMetaData.getSimpleFeature((EClass) stringBasedCommentType);
>     commentSimpleType = (EDataType)simpleFeature.getEType();
>     assertEquals(40, extendedMetaData.getMaxLengthFacet(commentSimpleType));
>     
>     // FIXME Work-around EMF's lack of support for re-definable features - SEE TUSCANY-1832
>     commentSimpleType = (EDataType) _myCommentType;
>     assertEquals(40, extendedMetaData.getMaxLengthFacet(commentSimpleType));
>     
>     // FIXME Work-around EMF's lack of support for re-definable features - SEE TUSCANY-1832
>     commentSimpleType = (EDataType) _comment2Type;
>     assertEquals(20, extendedMetaData.getMaxLengthFacet(commentSimpleType));
>   }
>   public void testComplexTypeWithSimpleContentExtensionChangeSummary() throws IOException 
>   {
>     DataGraph dg = SDOUtil.createDataGraph();
>     SDOUtil.setRootObject(dg, dataObject);
>     dg.getChangeSummary().beginLogging();
>     dataObject.getDataObject("results.1/myResult.0").delete();
>     ByteArrayOutputStream baos = new ByteArrayOutputStream();
>     SDOUtil.saveDataGraph(dg, baos, null);
>     ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
>     SDOUtil.loadDataGraph(bais, null, hc);
>   }    
>   
>   public void testSimpleTypeExtension() 
>   {
>     TypeHelper typeHelper = hc.getTypeHelper();
>     
>     Type asciiStringType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "AsciiStringType");
>     Type idType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "IdType");
>     assertTrue("IdType does not report AsciiStringType as a base type", 
>         idType.getBaseTypes().contains(asciiStringType));
>     
>     Diagnostic diagnostic = Diagnostician.INSTANCE.validate((EObject) dataObject);
>     String diagnosticMsg = diagnostic.getChildren().toString();
>     Type id2Type = typeHelper.getType(sev2NamespaceURI, "Id2Type");
>     assertTrue("Id2Type does not report IdType as a base type", 
>         id2Type.getBaseTypes().contains(idType));
>     assertTrue("EMF validation should have reported Id pattern match failure", 
>         diagnosticMsg.indexOf("Id") > 0);
>   }
> }
> STACKTRACE:
> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Value '' is not legal. (file:///C:/development/working/1/tuscany-sdo/sdo/tools-test/all.datagraph, 27, 48)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.handleErrors(XMLLoadImpl.java:83)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:193)
> 	at org.apache.tuscany.sdo.util.DataGraphResourceFactoryImpl$DataGraphResourceImpl$LoadImpl.load(DataGraphResourceFactoryImpl.java:455)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:179)
> 	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1094)
> 	at org.apache.tuscany.sdo.helper.SDOHelperImpl.loadDataGraph(SDOHelperImpl.java:139)
> 	at org.apache.tuscany.sdo.helper.SDOHelperImpl.loadDataGraph(SDOHelperImpl.java:157)
> 	at org.apache.tuscany.sdo.api.SDOUtil.loadDataGraph(SDOUtil.java:150)
> 	at org.apache.tuscany.sdo.test.SubstitutionWithExtensionValuesTestCase.testComplexTypeWithSimpleContentExtensionChangeSummary(SubstitutionWithExtensionValuesTestCase.java:150)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:585)
> 	at junit.framework.TestCase.runTest(TestCase.java:154)
> 	at junit.framework.TestCase.runBare(TestCase.java:127)
> 	at junit.framework.TestResult$1.protect(TestResult.java:106)
> 	at junit.framework.TestResult.runProtected(TestResult.java:124)
> 	at junit.framework.TestResult.run(TestResult.java:109)
> 	at junit.framework.TestCase.run(TestCase.java:118)
> 	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
> 	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
> Caused by: org.eclipse.emf.ecore.xmi.IllegalValueException: Value '' is not legal. (file:///C:/development/working/1/tuscany-sdo/sdo/tools-test/all.datagraph, 27, 48)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2421)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2406)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.endElement(XMLHandler.java:1347)
> 	at org.apache.tuscany.sdo.util.DataGraphResourceFactoryImpl$DataGraphResourceImpl$LoadImpl$1.endElement(DataGraphResourceFactoryImpl.java:627)
> 	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:633)
> 	at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:221)
> 	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:322)
> 	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1693)
> 	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
> 	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
> 	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
> 	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
> 	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
> 	at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:183)
> 	... 23 more
> Caused by: java.lang.NumberFormatException: Zero length BigInteger
> 	at java.math.BigInteger.<init>(BigInteger.java:275)
> 	at java.math.BigInteger.<init>(BigInteger.java:447)
> 	at org.eclipse.emf.ecore.xml.type.impl.XMLTypeFactoryImpl.createInteger(XMLTypeFactoryImpl.java:832)
> 	at org.apache.tuscany.sdo.model.impl.ModelFactoryImpl.createIntegerFromString(ModelFactoryImpl.java:2086)
> 	at com.example.substitution.ev.impl.SEVFactoryImpl.create_Integer32BitFromString(SEVFactoryImpl.java:754)
> 	at com.example.substitution.ev.impl.SEVFactoryImpl.createFromString(SEVFactoryImpl.java:143)
> 	at org.apache.tuscany.sdo.impl.FactoryBase$SDOEFactoryImpl.createFromString(FactoryBase.java:286)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createFromString(XMLHelperImpl.java:1489)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHelperImpl.java:1053)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2416)
> 	... 37 more
> SAVED PROBLEMATIC DATA GRAPH
> <?xml version="1.0" encoding="ASCII"?>
> <sdo:datagraph xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sdo="commonj.sdo"
>     xmlns:sdo_1="http://www.apache.org/tuscany/2005/SDO" xmlns:sev="http://www.example.com/substitutionEV"
>     xmlns:sev2="http://www.example.com/substitutionEV2">
>   <changeSummary xmlns=""
>       logging="true">
>     <objectChanges key="#//@eRootObject/@results.1">
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="resultGroup">
>         <listChanges index="0">
>           <featureMapEntryValues featureName="myResult" referenceValue="#//@eChangeSummary/@objectsToAttach.0"/>
>         </listChanges>
>       </value>
>     </objectChanges>
>     <objectChanges key="#//@eChangeSummary/@objectsToAttach.0">
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="value" set="false"
>           referenceValue="#//@eChangeSummary/@objectsToAttach.1"/>
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="id" dataValue="BBBBBBBBBBBBBBBBBBBB"
>           set="false"/>
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="name" dataValue="myNameB"
>           set="false"/>
>     </objectChanges>
>     <objectChanges key="#//@eChangeSummary/@objectsToAttach.1">
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="value" dataValue="11"
>           set="false"/>
>     </objectChanges>
>     <objectsToAttach xsi:type="sev:MyResultType"/>
>     <objectsToAttach xsi:type="sev:ValueType"/>
>   </changeSummary>
>   <sev2:AllResultsType>
>     <id>ZZZZZZZZZZZZZZZZZZZZ</id>
>     <results>
>       <id>00000000000000000000</id>
>       <sev:result>
>         <id>11111111111111111111</id>
>         <name>name1</name>
>         <value>1</value>
>       </sev:result>
>       <sev:myResult>
>         <id>22222222222222222222</id>
>         <name>myName2</name>
>         <value>2</value>
>       </sev:myResult>
>       <comment>comment0</comment>
>     </results>
>     <results>
>       <id>AAAAAAAAAAAAAAAAAAAA</id>
>       <comment>commentA</comment>
>     </results>
>     <comment language="English">
> 		commentZZZZZZZZZZZZZZZZZZ
> 	</comment>
>   </sev2:AllResultsType>
> </sdo:datagraph>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


[jira] Commented: (TUSCANY-1842) IOException loading DataGraph containing a deleted dataObject with a property whose type extends a complexType w/simple integer content

Posted by "Ron Gavlin (JIRA)" <tu...@ws.apache.org>.
    [ https://issues.apache.org/jira/browse/TUSCANY-1842?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12534127 ] 

Ron Gavlin commented on TUSCANY-1842:
-------------------------------------

Greetings,

The following hack seems to work around the problem and satisfy all unit tests. Any comments about the dangers of this patch? Any suggestions for a better way of solving this problem?

Thanks in advance,

- Ron

Index: C:/development/working/1/tuscany-sdo/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataGraphResourceFactoryImpl.java
===================================================================
--- C:/development/working/1/tuscany-sdo/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataGraphResourceFactoryImpl.java	(revision 579682)
+++ C:/development/working/1/tuscany-sdo/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataGraphResourceFactoryImpl.java	(working copy)
@@ -624,6 +624,10 @@
                 }
                 isInModels = false;
               }
+              if ("".equals(uri) && "objectsToAttach".equals(name) && text != null && text.length() == 0)
+              {
+                text = null;
+              }
               super.endElement(uri, localName, name);
             }
 


> IOException loading DataGraph containing a deleted dataObject with a property whose type extends a complexType w/simple integer content
> ---------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: TUSCANY-1842
>                 URL: https://issues.apache.org/jira/browse/TUSCANY-1842
>             Project: Tuscany
>          Issue Type: Bug
>          Components: Java SDO Implementation
>    Affects Versions: Java-SDO-Next
>         Environment: Windows XP, Sun JDK 1.5.0_09
>            Reporter: Ron Gavlin
>            Priority: Critical
>             Fix For: Java-SDO-Next
>
>
> In the test method, testComplexTypeWithSimpleContentExtensionChangeSummary() listed below, a DataGraph is created with a dataObject whose property type extends a complexType with simple integer content. After the dataObject is deleted, an attempt is made to save and load the DataGraph. While the DataGraph is being loaded, an unsuccessful attempt is made to convert a zero-length string into a BigInteger. 
> Any suggestions on how to best fix this are most welcome.
> Thanks,
> - Ron
> ==============================
> substitutionWithExtensionValues.xsd
> ============================== 
> <schema xmlns="http://www.w3.org/2001/XMLSchema"
> 	targetNamespace="http://www.example.com/substitutionEV"
> 	xmlns:sev="http://www.example.com/substitutionEV">
> 	<!--
> 		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.    
> 	-->
> 	<element name="results" type="sev:ResultsType" />
> 	<element name="result" type="sev:ResultType" />
> 	<element name="myResult" type="sev:MyResultType"
> 		substitutionGroup="sev:result" />
> 	<complexType name="ResultsType">
> 		<sequence>
> 			<element name="id" type="sev:IdType" />
> 			<element ref="sev:result" minOccurs="0"
> 				maxOccurs="unbounded" />
> 			<element name="comment" type="sev:CommentType" />
> 		</sequence>
> 	</complexType>
> 	<complexType name="ResultType">
> 		<sequence>
> 			<element name="id" type="sev:IdType" />
> 			<element name="name" type="string" />
> 			<element name="value" type="sev:ValueType" />
> 		</sequence>
> 	</complexType>
> 	<complexType name="MyResultType">
> 		<complexContent>
> 			<extension base="sev:ResultType" />
> 		</complexContent>
> 	</complexType>
> 	<simpleType name="IdType">
> 		<restriction base="sev:AsciiStringType">
> 			<maxLength value="32" />
> 			<pattern value="[0-9a-fA-F]*" />
> 		</restriction>
> 	</simpleType>
> 	<simpleType name="AsciiStringType">
> 		<restriction base="string">
> 			<pattern value="\p{IsBasicLatin}*" />
> 		</restriction>
> 	</simpleType>
> 	<complexType name="ValueType">
> 		<simpleContent>
> 			<extension base="sev:Integer32Bit" />
> 		</simpleContent>
> 	</complexType>
> 	<complexType name="Integer32Bit">
> 		<simpleContent>
> 			<restriction base="integer">
> 				<minInclusive value="0" />
> 				<maxInclusive value="4290000000" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> 	
> 	<complexType name="CommentType">
> 		<simpleContent>
> 			<extension base="sev:AsciiStringType">
> 				<attribute name="language" use="optional">
> 					<simpleType>
> 						<restriction base="string">
> 							<enumeration value="English" />
> 							<enumeration value="French" />
> 							<enumeration value="Spanish" />
> 						</restriction>
> 					</simpleType>
> 				</attribute>
> 			</extension>
> 		</simpleContent>
> 	</complexType>
> 	<complexType name="MyCommentType">
> 		<simpleContent>
> 			<restriction base="sev:CommentType">
> 				<minLength value="0" />
> 				<maxLength value="40" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> 	<complexType name="StringBasedCommentType">
> 		<simpleContent>
> 			<restriction base="string">
> 				<minLength value="0" />
> 				<maxLength value="40" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> </schema>
> ==============================
> substitutionWithExtensionValues2.xsd
> ==============================
> <schema xmlns="http://www.w3.org/2001/XMLSchema"
> 	targetNamespace="http://www.example.com/substitutionEV2"
> 	xmlns:sev2="http://www.example.com/substitutionEV2"
> 	xmlns:sev="http://www.example.com/substitutionEV">
> 	<!--
> 		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.    
> 	-->
> 	<import namespace="http://www.example.com/substitutionEV"
> 		schemaLocation="substitutionWithExtensionValues.xsd" />
> 	<element name="allResults" type="sev2:AllResultsType" />
> 	<complexType name="AllResultsType">
> 		<sequence>
> 			<element name="id" type="sev2:Id2Type" />
> 			<element name="results" minOccurs="0" maxOccurs="unbounded"
> 				type="sev2:Results2Type" />
> 			<element name="comment" type="sev2:Comment2Type" />
> 		</sequence>
> 	</complexType>
> 	<complexType name="Results2Type">
> 		<complexContent>
> 			<extension base="sev:ResultsType"></extension>
> 		</complexContent>
> 	</complexType>
> 	<simpleType name="Id2Type">
> 		<restriction base="sev:IdType">
> 			<maxLength value="10" />
> 		</restriction>
> 	</simpleType>
> 	<complexType name="Comment2Type">
> 		<simpleContent>
> 			<restriction base="sev:CommentType">
> 				<minLength value="0" />
> 				<maxLength value="20" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> </schema>
> ==============================
> substitutionWithExtensionValues1.xml
> ==============================
> <?xml version="1.0" encoding="ASCII"?>
> <sev2:allResults xmlns:sev2="http://www.example.com/substitutionEV2">
> 	<sev2:id>ZZZZZZZZZZZZZZZZZZZZ</sev2:id>
> 	<sev:results xmlns:sev="http://www.example.com/substitutionEV">
> 		<sev:id>00000000000000000000</sev:id>
> 		<sev:result>
> 			<sev:id>11111111111111111111</sev:id>
> 			<sev:name>name1</sev:name>
> 			<sev:value>1</sev:value>
> 		</sev:result>
> 		<sev:myResult>
> 			<sev:id>22222222222222222222</sev:id>
> 			<sev:name>myName2</sev:name>
> 			<sev:value>2</sev:value>
> 		</sev:myResult>
> 		<sev:comment>comment0</sev:comment>
> 	</sev:results>
> 	<sev:results xmlns:sev="http://www.example.com/substitutionEV">
> 		<sev:id>AAAAAAAAAAAAAAAAAAAA</sev:id>
> 		<sev:myResult>
> 			<sev:id>BBBBBBBBBBBBBBBBBBBB</sev:id>
> 			<sev:name>myNameB</sev:name>
> 			<sev:value>11</sev:value>
> 		</sev:myResult>
> 		<sev:comment>commentA</sev:comment>
> 	</sev:results>
> 	<sev2:comment language="English">
> 		commentZZZZZZZZZZZZZZZZZZ
> 	</sev2:comment>
> </sev2:allResults>
> ==============================
> SubstitutionWithExtensionValuesTestCase.java
> ============================== 
> /**
>  *
>  *  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.sdo.test;
> import java.io.ByteArrayInputStream;
> import java.io.ByteArrayOutputStream;
> import java.io.IOException;
> import java.io.InputStream;
> import java.net.URL;
> import java.util.List;
> import junit.framework.TestCase;
> import org.apache.tuscany.sdo.api.SDOUtil;
> import org.eclipse.emf.common.util.Diagnostic;
> import org.eclipse.emf.ecore.EClass;
> import org.eclipse.emf.ecore.EDataType;
> import org.eclipse.emf.ecore.EObject;
> import org.eclipse.emf.ecore.EStructuralFeature;
> import org.eclipse.emf.ecore.util.Diagnostician;
> import org.eclipse.emf.ecore.util.ExtendedMetaData;
> import com.example.substitution.ev.SEVFactory;
> import com.example.substitution.ev.impl.SEVFactoryImpl;
> import commonj.sdo.DataGraph;
> import commonj.sdo.DataObject;
> import commonj.sdo.Property;
> import commonj.sdo.Type;
> import commonj.sdo.helper.HelperContext;
> import commonj.sdo.helper.TypeHelper;
> import commonj.sdo.impl.HelperProvider;
> public final class SubstitutionWithExtensionValuesTestCase extends TestCase 
> {
>   private static String sev2NamespaceURI;
>   private HelperContext hc;
>   private DataObject dataObject;
>   
>   protected void setUp() throws Exception {
>     super.setUp();
>     hc = HelperProvider.getDefaultContext();
>     registerSEV(hc, true);
>     
>     InputStream inputStream = null;
>     URL url = getClass().getResource("/substitutionWithExtensionValues2.xsd");
>     inputStream = url.openStream();
>     List sev2TypeList = hc.getXSDHelper().define(inputStream, url.toString());
>     inputStream.close();
>     
>     inputStream = getClass().getResourceAsStream("/substitutionWithExtensionValues1.xml");
>     dataObject = hc.getXMLHelper().load(inputStream).getRootObject();
>     inputStream.close();
>     
>     if (sev2NamespaceURI == null)
>     {
>       sev2NamespaceURI = ((Type) sev2TypeList.get(0)).getURI();
>     }
>   }
>   
>   private void registerSEV(HelperContext hc, boolean useStaticRegistration) throws IOException
>   {
>     if (useStaticRegistration)
>     {
>       SEVFactory.INSTANCE.register(hc);
>     }
>     else
>     {
>       InputStream inputStream = null;
>       URL url = getClass().getResource("/substitutionWithExtensionValues.xsd");
>       inputStream = url.openStream();
>       hc.getXSDHelper().define(inputStream, url.toString());
>       inputStream.close();
>     }
>   }
>   public void testComplexTypeWithSubstitutionExtension() throws IOException 
>   {
>     TypeHelper typeHelper = hc.getTypeHelper();
>     
>     Type resultsType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "ResultsType");
>     Type results2Type = typeHelper.getType(sev2NamespaceURI, "Results2Type");
>     assertTrue("Results2 type does not report Results as a base type", 
>         results2Type.getBaseTypes().contains(resultsType));
>     
>     assertEquals("results.1/myResult.0/id has unexpected value", 
>         "BBBBBBBBBBBBBBBBBBBB", dataObject.getString("results.1/myResult.0/id"));
>   }
>   
>   public void testComplexTypeWithSimpleContentExtensionMetaData() 
>   {
>     TypeHelper typeHelper = hc.getTypeHelper();
>     
>     Type stringBasedCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "StringBasedCommentType");
>     Type commentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "CommentType");
>     Type myCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "MyCommentType");
>     Type _myCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "_MyCommentType");
>     Type comment2Type = typeHelper.getType(sev2NamespaceURI, "Comment2Type");
>     Type _comment2Type = typeHelper.getType(sev2NamespaceURI, "_Comment2Type");
>     assertTrue("MyComment type does not report Comment as a base type", 
>         myCommentType.getBaseTypes().contains(commentType));
>     assertTrue("Comment2 type does not report Comment as a base type", 
>         comment2Type.getBaseTypes().contains(commentType));
>     
>     // Test length facets - resort to EMF APIs until Tuscany SDO exposes these directly
>     ExtendedMetaData extendedMetaData = ExtendedMetaData.INSTANCE;
>     EStructuralFeature simpleFeature = null;
>     EDataType commentSimpleType = null;
>     
>     simpleFeature = extendedMetaData.getSimpleFeature((EClass) stringBasedCommentType);
>     commentSimpleType = (EDataType)simpleFeature.getEType();
>     assertEquals(40, extendedMetaData.getMaxLengthFacet(commentSimpleType));
>     
>     // FIXME Work-around EMF's lack of support for re-definable features - SEE TUSCANY-1832
>     commentSimpleType = (EDataType) _myCommentType;
>     assertEquals(40, extendedMetaData.getMaxLengthFacet(commentSimpleType));
>     
>     // FIXME Work-around EMF's lack of support for re-definable features - SEE TUSCANY-1832
>     commentSimpleType = (EDataType) _comment2Type;
>     assertEquals(20, extendedMetaData.getMaxLengthFacet(commentSimpleType));
>   }
>   public void testComplexTypeWithSimpleContentExtensionChangeSummary() throws IOException 
>   {
>     DataGraph dg = SDOUtil.createDataGraph();
>     SDOUtil.setRootObject(dg, dataObject);
>     dg.getChangeSummary().beginLogging();
>     dataObject.getDataObject("results.1/myResult.0").delete();
>     ByteArrayOutputStream baos = new ByteArrayOutputStream();
>     SDOUtil.saveDataGraph(dg, baos, null);
>     ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
>     SDOUtil.loadDataGraph(bais, null, hc);
>   }    
>   
>   public void testSimpleTypeExtension() 
>   {
>     TypeHelper typeHelper = hc.getTypeHelper();
>     
>     Type asciiStringType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "AsciiStringType");
>     Type idType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "IdType");
>     assertTrue("IdType does not report AsciiStringType as a base type", 
>         idType.getBaseTypes().contains(asciiStringType));
>     
>     Diagnostic diagnostic = Diagnostician.INSTANCE.validate((EObject) dataObject);
>     String diagnosticMsg = diagnostic.getChildren().toString();
>     Type id2Type = typeHelper.getType(sev2NamespaceURI, "Id2Type");
>     assertTrue("Id2Type does not report IdType as a base type", 
>         id2Type.getBaseTypes().contains(idType));
>     assertTrue("EMF validation should have reported Id pattern match failure", 
>         diagnosticMsg.indexOf("Id") > 0);
>   }
> }
> STACKTRACE:
> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Value '' is not legal. (file:///C:/development/working/1/tuscany-sdo/sdo/tools-test/all.datagraph, 27, 48)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.handleErrors(XMLLoadImpl.java:83)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:193)
> 	at org.apache.tuscany.sdo.util.DataGraphResourceFactoryImpl$DataGraphResourceImpl$LoadImpl.load(DataGraphResourceFactoryImpl.java:455)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:179)
> 	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1094)
> 	at org.apache.tuscany.sdo.helper.SDOHelperImpl.loadDataGraph(SDOHelperImpl.java:139)
> 	at org.apache.tuscany.sdo.helper.SDOHelperImpl.loadDataGraph(SDOHelperImpl.java:157)
> 	at org.apache.tuscany.sdo.api.SDOUtil.loadDataGraph(SDOUtil.java:150)
> 	at org.apache.tuscany.sdo.test.SubstitutionWithExtensionValuesTestCase.testComplexTypeWithSimpleContentExtensionChangeSummary(SubstitutionWithExtensionValuesTestCase.java:150)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:585)
> 	at junit.framework.TestCase.runTest(TestCase.java:154)
> 	at junit.framework.TestCase.runBare(TestCase.java:127)
> 	at junit.framework.TestResult$1.protect(TestResult.java:106)
> 	at junit.framework.TestResult.runProtected(TestResult.java:124)
> 	at junit.framework.TestResult.run(TestResult.java:109)
> 	at junit.framework.TestCase.run(TestCase.java:118)
> 	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
> 	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
> Caused by: org.eclipse.emf.ecore.xmi.IllegalValueException: Value '' is not legal. (file:///C:/development/working/1/tuscany-sdo/sdo/tools-test/all.datagraph, 27, 48)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2421)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2406)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.endElement(XMLHandler.java:1347)
> 	at org.apache.tuscany.sdo.util.DataGraphResourceFactoryImpl$DataGraphResourceImpl$LoadImpl$1.endElement(DataGraphResourceFactoryImpl.java:627)
> 	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:633)
> 	at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:221)
> 	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:322)
> 	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1693)
> 	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
> 	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
> 	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
> 	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
> 	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
> 	at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:183)
> 	... 23 more
> Caused by: java.lang.NumberFormatException: Zero length BigInteger
> 	at java.math.BigInteger.<init>(BigInteger.java:275)
> 	at java.math.BigInteger.<init>(BigInteger.java:447)
> 	at org.eclipse.emf.ecore.xml.type.impl.XMLTypeFactoryImpl.createInteger(XMLTypeFactoryImpl.java:832)
> 	at org.apache.tuscany.sdo.model.impl.ModelFactoryImpl.createIntegerFromString(ModelFactoryImpl.java:2086)
> 	at com.example.substitution.ev.impl.SEVFactoryImpl.create_Integer32BitFromString(SEVFactoryImpl.java:754)
> 	at com.example.substitution.ev.impl.SEVFactoryImpl.createFromString(SEVFactoryImpl.java:143)
> 	at org.apache.tuscany.sdo.impl.FactoryBase$SDOEFactoryImpl.createFromString(FactoryBase.java:286)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createFromString(XMLHelperImpl.java:1489)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHelperImpl.java:1053)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2416)
> 	... 37 more
> SAVED PROBLEMATIC DATA GRAPH
> <?xml version="1.0" encoding="ASCII"?>
> <sdo:datagraph xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sdo="commonj.sdo"
>     xmlns:sdo_1="http://www.apache.org/tuscany/2005/SDO" xmlns:sev="http://www.example.com/substitutionEV"
>     xmlns:sev2="http://www.example.com/substitutionEV2">
>   <changeSummary xmlns=""
>       logging="true">
>     <objectChanges key="#//@eRootObject/@results.1">
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="resultGroup">
>         <listChanges index="0">
>           <featureMapEntryValues featureName="myResult" referenceValue="#//@eChangeSummary/@objectsToAttach.0"/>
>         </listChanges>
>       </value>
>     </objectChanges>
>     <objectChanges key="#//@eChangeSummary/@objectsToAttach.0">
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="value" set="false"
>           referenceValue="#//@eChangeSummary/@objectsToAttach.1"/>
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="id" dataValue="BBBBBBBBBBBBBBBBBBBB"
>           set="false"/>
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="name" dataValue="myNameB"
>           set="false"/>
>     </objectChanges>
>     <objectChanges key="#//@eChangeSummary/@objectsToAttach.1">
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="value" dataValue="11"
>           set="false"/>
>     </objectChanges>
>     <objectsToAttach xsi:type="sev:MyResultType"/>
>     <objectsToAttach xsi:type="sev:ValueType"/>
>   </changeSummary>
>   <sev2:AllResultsType>
>     <id>ZZZZZZZZZZZZZZZZZZZZ</id>
>     <results>
>       <id>00000000000000000000</id>
>       <sev:result>
>         <id>11111111111111111111</id>
>         <name>name1</name>
>         <value>1</value>
>       </sev:result>
>       <sev:myResult>
>         <id>22222222222222222222</id>
>         <name>myName2</name>
>         <value>2</value>
>       </sev:myResult>
>       <comment>comment0</comment>
>     </results>
>     <results>
>       <id>AAAAAAAAAAAAAAAAAAAA</id>
>       <comment>commentA</comment>
>     </results>
>     <comment language="English">
> 		commentZZZZZZZZZZZZZZZZZZ
> 	</comment>
>   </sev2:AllResultsType>
> </sdo:datagraph>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


[jira] Updated: (TUSCANY-1842) IOException loading DataGraph containing a deleted dataObject with a property whose type extends a complexType w/simple integer content

Posted by "Ron Gavlin (JIRA)" <tu...@ws.apache.org>.
     [ https://issues.apache.org/jira/browse/TUSCANY-1842?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ron Gavlin updated TUSCANY-1842:
--------------------------------

    Attachment: tuscany-sdo.TUSCANY-1842.patch

> IOException loading DataGraph containing a deleted dataObject with a property whose type extends a complexType w/simple integer content
> ---------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: TUSCANY-1842
>                 URL: https://issues.apache.org/jira/browse/TUSCANY-1842
>             Project: Tuscany
>          Issue Type: Bug
>          Components: Java SDO Implementation
>    Affects Versions: Java-SDO-Next
>         Environment: Windows XP, Sun JDK 1.5.0_09
>            Reporter: Ron Gavlin
>            Priority: Critical
>             Fix For: Java-SDO-Next
>
>         Attachments: tuscany-sdo.TUSCANY-1842.patch
>
>
> In the test method, testComplexTypeWithSimpleContentExtensionChangeSummary() listed below, a DataGraph is created with a dataObject whose property type extends a complexType with simple integer content. After the dataObject is deleted, an attempt is made to save and load the DataGraph. While the DataGraph is being loaded, an unsuccessful attempt is made to convert a zero-length string into a BigInteger. 
> Any suggestions on how to best fix this are most welcome.
> Thanks,
> - Ron
> ==============================
> substitutionWithExtensionValues.xsd
> ============================== 
> <schema xmlns="http://www.w3.org/2001/XMLSchema"
> 	targetNamespace="http://www.example.com/substitutionEV"
> 	xmlns:sev="http://www.example.com/substitutionEV">
> 	<!--
> 		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.    
> 	-->
> 	<element name="results" type="sev:ResultsType" />
> 	<element name="result" type="sev:ResultType" />
> 	<element name="myResult" type="sev:MyResultType"
> 		substitutionGroup="sev:result" />
> 	<complexType name="ResultsType">
> 		<sequence>
> 			<element name="id" type="sev:IdType" />
> 			<element ref="sev:result" minOccurs="0"
> 				maxOccurs="unbounded" />
> 			<element name="comment" type="sev:CommentType" />
> 		</sequence>
> 	</complexType>
> 	<complexType name="ResultType">
> 		<sequence>
> 			<element name="id" type="sev:IdType" />
> 			<element name="name" type="string" />
> 			<element name="value" type="sev:ValueType" />
> 		</sequence>
> 	</complexType>
> 	<complexType name="MyResultType">
> 		<complexContent>
> 			<extension base="sev:ResultType" />
> 		</complexContent>
> 	</complexType>
> 	<simpleType name="IdType">
> 		<restriction base="sev:AsciiStringType">
> 			<maxLength value="32" />
> 			<pattern value="[0-9a-fA-F]*" />
> 		</restriction>
> 	</simpleType>
> 	<simpleType name="AsciiStringType">
> 		<restriction base="string">
> 			<pattern value="\p{IsBasicLatin}*" />
> 		</restriction>
> 	</simpleType>
> 	<complexType name="ValueType">
> 		<simpleContent>
> 			<extension base="sev:Integer32Bit" />
> 		</simpleContent>
> 	</complexType>
> 	<complexType name="Integer32Bit">
> 		<simpleContent>
> 			<restriction base="integer">
> 				<minInclusive value="0" />
> 				<maxInclusive value="4290000000" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> 	
> 	<complexType name="CommentType">
> 		<simpleContent>
> 			<extension base="sev:AsciiStringType">
> 				<attribute name="language" use="optional">
> 					<simpleType>
> 						<restriction base="string">
> 							<enumeration value="English" />
> 							<enumeration value="French" />
> 							<enumeration value="Spanish" />
> 						</restriction>
> 					</simpleType>
> 				</attribute>
> 			</extension>
> 		</simpleContent>
> 	</complexType>
> 	<complexType name="MyCommentType">
> 		<simpleContent>
> 			<restriction base="sev:CommentType">
> 				<minLength value="0" />
> 				<maxLength value="40" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> 	<complexType name="StringBasedCommentType">
> 		<simpleContent>
> 			<restriction base="string">
> 				<minLength value="0" />
> 				<maxLength value="40" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> </schema>
> ==============================
> substitutionWithExtensionValues2.xsd
> ==============================
> <schema xmlns="http://www.w3.org/2001/XMLSchema"
> 	targetNamespace="http://www.example.com/substitutionEV2"
> 	xmlns:sev2="http://www.example.com/substitutionEV2"
> 	xmlns:sev="http://www.example.com/substitutionEV">
> 	<!--
> 		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.    
> 	-->
> 	<import namespace="http://www.example.com/substitutionEV"
> 		schemaLocation="substitutionWithExtensionValues.xsd" />
> 	<element name="allResults" type="sev2:AllResultsType" />
> 	<complexType name="AllResultsType">
> 		<sequence>
> 			<element name="id" type="sev2:Id2Type" />
> 			<element name="results" minOccurs="0" maxOccurs="unbounded"
> 				type="sev2:Results2Type" />
> 			<element name="comment" type="sev2:Comment2Type" />
> 		</sequence>
> 	</complexType>
> 	<complexType name="Results2Type">
> 		<complexContent>
> 			<extension base="sev:ResultsType"></extension>
> 		</complexContent>
> 	</complexType>
> 	<simpleType name="Id2Type">
> 		<restriction base="sev:IdType">
> 			<maxLength value="10" />
> 		</restriction>
> 	</simpleType>
> 	<complexType name="Comment2Type">
> 		<simpleContent>
> 			<restriction base="sev:CommentType">
> 				<minLength value="0" />
> 				<maxLength value="20" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> </schema>
> ==============================
> substitutionWithExtensionValues1.xml
> ==============================
> <?xml version="1.0" encoding="ASCII"?>
> <sev2:allResults xmlns:sev2="http://www.example.com/substitutionEV2">
> 	<sev2:id>ZZZZZZZZZZZZZZZZZZZZ</sev2:id>
> 	<sev:results xmlns:sev="http://www.example.com/substitutionEV">
> 		<sev:id>00000000000000000000</sev:id>
> 		<sev:result>
> 			<sev:id>11111111111111111111</sev:id>
> 			<sev:name>name1</sev:name>
> 			<sev:value>1</sev:value>
> 		</sev:result>
> 		<sev:myResult>
> 			<sev:id>22222222222222222222</sev:id>
> 			<sev:name>myName2</sev:name>
> 			<sev:value>2</sev:value>
> 		</sev:myResult>
> 		<sev:comment>comment0</sev:comment>
> 	</sev:results>
> 	<sev:results xmlns:sev="http://www.example.com/substitutionEV">
> 		<sev:id>AAAAAAAAAAAAAAAAAAAA</sev:id>
> 		<sev:myResult>
> 			<sev:id>BBBBBBBBBBBBBBBBBBBB</sev:id>
> 			<sev:name>myNameB</sev:name>
> 			<sev:value>11</sev:value>
> 		</sev:myResult>
> 		<sev:comment>commentA</sev:comment>
> 	</sev:results>
> 	<sev2:comment language="English">
> 		commentZZZZZZZZZZZZZZZZZZ
> 	</sev2:comment>
> </sev2:allResults>
> ==============================
> SubstitutionWithExtensionValuesTestCase.java
> ============================== 
> /**
>  *
>  *  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.sdo.test;
> import java.io.ByteArrayInputStream;
> import java.io.ByteArrayOutputStream;
> import java.io.IOException;
> import java.io.InputStream;
> import java.net.URL;
> import java.util.List;
> import junit.framework.TestCase;
> import org.apache.tuscany.sdo.api.SDOUtil;
> import org.eclipse.emf.common.util.Diagnostic;
> import org.eclipse.emf.ecore.EClass;
> import org.eclipse.emf.ecore.EDataType;
> import org.eclipse.emf.ecore.EObject;
> import org.eclipse.emf.ecore.EStructuralFeature;
> import org.eclipse.emf.ecore.util.Diagnostician;
> import org.eclipse.emf.ecore.util.ExtendedMetaData;
> import com.example.substitution.ev.SEVFactory;
> import com.example.substitution.ev.impl.SEVFactoryImpl;
> import commonj.sdo.DataGraph;
> import commonj.sdo.DataObject;
> import commonj.sdo.Property;
> import commonj.sdo.Type;
> import commonj.sdo.helper.HelperContext;
> import commonj.sdo.helper.TypeHelper;
> import commonj.sdo.impl.HelperProvider;
> public final class SubstitutionWithExtensionValuesTestCase extends TestCase 
> {
>   private static String sev2NamespaceURI;
>   private HelperContext hc;
>   private DataObject dataObject;
>   
>   protected void setUp() throws Exception {
>     super.setUp();
>     hc = HelperProvider.getDefaultContext();
>     registerSEV(hc, true);
>     
>     InputStream inputStream = null;
>     URL url = getClass().getResource("/substitutionWithExtensionValues2.xsd");
>     inputStream = url.openStream();
>     List sev2TypeList = hc.getXSDHelper().define(inputStream, url.toString());
>     inputStream.close();
>     
>     inputStream = getClass().getResourceAsStream("/substitutionWithExtensionValues1.xml");
>     dataObject = hc.getXMLHelper().load(inputStream).getRootObject();
>     inputStream.close();
>     
>     if (sev2NamespaceURI == null)
>     {
>       sev2NamespaceURI = ((Type) sev2TypeList.get(0)).getURI();
>     }
>   }
>   
>   private void registerSEV(HelperContext hc, boolean useStaticRegistration) throws IOException
>   {
>     if (useStaticRegistration)
>     {
>       SEVFactory.INSTANCE.register(hc);
>     }
>     else
>     {
>       InputStream inputStream = null;
>       URL url = getClass().getResource("/substitutionWithExtensionValues.xsd");
>       inputStream = url.openStream();
>       hc.getXSDHelper().define(inputStream, url.toString());
>       inputStream.close();
>     }
>   }
>   public void testComplexTypeWithSubstitutionExtension() throws IOException 
>   {
>     TypeHelper typeHelper = hc.getTypeHelper();
>     
>     Type resultsType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "ResultsType");
>     Type results2Type = typeHelper.getType(sev2NamespaceURI, "Results2Type");
>     assertTrue("Results2 type does not report Results as a base type", 
>         results2Type.getBaseTypes().contains(resultsType));
>     
>     assertEquals("results.1/myResult.0/id has unexpected value", 
>         "BBBBBBBBBBBBBBBBBBBB", dataObject.getString("results.1/myResult.0/id"));
>   }
>   
>   public void testComplexTypeWithSimpleContentExtensionMetaData() 
>   {
>     TypeHelper typeHelper = hc.getTypeHelper();
>     
>     Type stringBasedCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "StringBasedCommentType");
>     Type commentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "CommentType");
>     Type myCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "MyCommentType");
>     Type _myCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "_MyCommentType");
>     Type comment2Type = typeHelper.getType(sev2NamespaceURI, "Comment2Type");
>     Type _comment2Type = typeHelper.getType(sev2NamespaceURI, "_Comment2Type");
>     assertTrue("MyComment type does not report Comment as a base type", 
>         myCommentType.getBaseTypes().contains(commentType));
>     assertTrue("Comment2 type does not report Comment as a base type", 
>         comment2Type.getBaseTypes().contains(commentType));
>     
>     // Test length facets - resort to EMF APIs until Tuscany SDO exposes these directly
>     ExtendedMetaData extendedMetaData = ExtendedMetaData.INSTANCE;
>     EStructuralFeature simpleFeature = null;
>     EDataType commentSimpleType = null;
>     
>     simpleFeature = extendedMetaData.getSimpleFeature((EClass) stringBasedCommentType);
>     commentSimpleType = (EDataType)simpleFeature.getEType();
>     assertEquals(40, extendedMetaData.getMaxLengthFacet(commentSimpleType));
>     
>     // FIXME Work-around EMF's lack of support for re-definable features - SEE TUSCANY-1832
>     commentSimpleType = (EDataType) _myCommentType;
>     assertEquals(40, extendedMetaData.getMaxLengthFacet(commentSimpleType));
>     
>     // FIXME Work-around EMF's lack of support for re-definable features - SEE TUSCANY-1832
>     commentSimpleType = (EDataType) _comment2Type;
>     assertEquals(20, extendedMetaData.getMaxLengthFacet(commentSimpleType));
>   }
>   public void testComplexTypeWithSimpleContentExtensionChangeSummary() throws IOException 
>   {
>     DataGraph dg = SDOUtil.createDataGraph();
>     SDOUtil.setRootObject(dg, dataObject);
>     dg.getChangeSummary().beginLogging();
>     dataObject.getDataObject("results.1/myResult.0").delete();
>     ByteArrayOutputStream baos = new ByteArrayOutputStream();
>     SDOUtil.saveDataGraph(dg, baos, null);
>     ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
>     SDOUtil.loadDataGraph(bais, null, hc);
>   }    
>   
>   public void testSimpleTypeExtension() 
>   {
>     TypeHelper typeHelper = hc.getTypeHelper();
>     
>     Type asciiStringType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "AsciiStringType");
>     Type idType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "IdType");
>     assertTrue("IdType does not report AsciiStringType as a base type", 
>         idType.getBaseTypes().contains(asciiStringType));
>     
>     Diagnostic diagnostic = Diagnostician.INSTANCE.validate((EObject) dataObject);
>     String diagnosticMsg = diagnostic.getChildren().toString();
>     Type id2Type = typeHelper.getType(sev2NamespaceURI, "Id2Type");
>     assertTrue("Id2Type does not report IdType as a base type", 
>         id2Type.getBaseTypes().contains(idType));
>     assertTrue("EMF validation should have reported Id pattern match failure", 
>         diagnosticMsg.indexOf("Id") > 0);
>   }
> }
> STACKTRACE:
> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Value '' is not legal. (file:///C:/development/working/1/tuscany-sdo/sdo/tools-test/all.datagraph, 27, 48)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.handleErrors(XMLLoadImpl.java:83)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:193)
> 	at org.apache.tuscany.sdo.util.DataGraphResourceFactoryImpl$DataGraphResourceImpl$LoadImpl.load(DataGraphResourceFactoryImpl.java:455)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:179)
> 	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1094)
> 	at org.apache.tuscany.sdo.helper.SDOHelperImpl.loadDataGraph(SDOHelperImpl.java:139)
> 	at org.apache.tuscany.sdo.helper.SDOHelperImpl.loadDataGraph(SDOHelperImpl.java:157)
> 	at org.apache.tuscany.sdo.api.SDOUtil.loadDataGraph(SDOUtil.java:150)
> 	at org.apache.tuscany.sdo.test.SubstitutionWithExtensionValuesTestCase.testComplexTypeWithSimpleContentExtensionChangeSummary(SubstitutionWithExtensionValuesTestCase.java:150)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:585)
> 	at junit.framework.TestCase.runTest(TestCase.java:154)
> 	at junit.framework.TestCase.runBare(TestCase.java:127)
> 	at junit.framework.TestResult$1.protect(TestResult.java:106)
> 	at junit.framework.TestResult.runProtected(TestResult.java:124)
> 	at junit.framework.TestResult.run(TestResult.java:109)
> 	at junit.framework.TestCase.run(TestCase.java:118)
> 	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
> 	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
> Caused by: org.eclipse.emf.ecore.xmi.IllegalValueException: Value '' is not legal. (file:///C:/development/working/1/tuscany-sdo/sdo/tools-test/all.datagraph, 27, 48)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2421)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2406)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.endElement(XMLHandler.java:1347)
> 	at org.apache.tuscany.sdo.util.DataGraphResourceFactoryImpl$DataGraphResourceImpl$LoadImpl$1.endElement(DataGraphResourceFactoryImpl.java:627)
> 	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:633)
> 	at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:221)
> 	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:322)
> 	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1693)
> 	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
> 	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
> 	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
> 	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
> 	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
> 	at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:183)
> 	... 23 more
> Caused by: java.lang.NumberFormatException: Zero length BigInteger
> 	at java.math.BigInteger.<init>(BigInteger.java:275)
> 	at java.math.BigInteger.<init>(BigInteger.java:447)
> 	at org.eclipse.emf.ecore.xml.type.impl.XMLTypeFactoryImpl.createInteger(XMLTypeFactoryImpl.java:832)
> 	at org.apache.tuscany.sdo.model.impl.ModelFactoryImpl.createIntegerFromString(ModelFactoryImpl.java:2086)
> 	at com.example.substitution.ev.impl.SEVFactoryImpl.create_Integer32BitFromString(SEVFactoryImpl.java:754)
> 	at com.example.substitution.ev.impl.SEVFactoryImpl.createFromString(SEVFactoryImpl.java:143)
> 	at org.apache.tuscany.sdo.impl.FactoryBase$SDOEFactoryImpl.createFromString(FactoryBase.java:286)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createFromString(XMLHelperImpl.java:1489)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHelperImpl.java:1053)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2416)
> 	... 37 more
> SAVED PROBLEMATIC DATA GRAPH
> <?xml version="1.0" encoding="ASCII"?>
> <sdo:datagraph xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sdo="commonj.sdo"
>     xmlns:sdo_1="http://www.apache.org/tuscany/2005/SDO" xmlns:sev="http://www.example.com/substitutionEV"
>     xmlns:sev2="http://www.example.com/substitutionEV2">
>   <changeSummary xmlns=""
>       logging="true">
>     <objectChanges key="#//@eRootObject/@results.1">
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="resultGroup">
>         <listChanges index="0">
>           <featureMapEntryValues featureName="myResult" referenceValue="#//@eChangeSummary/@objectsToAttach.0"/>
>         </listChanges>
>       </value>
>     </objectChanges>
>     <objectChanges key="#//@eChangeSummary/@objectsToAttach.0">
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="value" set="false"
>           referenceValue="#//@eChangeSummary/@objectsToAttach.1"/>
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="id" dataValue="BBBBBBBBBBBBBBBBBBBB"
>           set="false"/>
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="name" dataValue="myNameB"
>           set="false"/>
>     </objectChanges>
>     <objectChanges key="#//@eChangeSummary/@objectsToAttach.1">
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="value" dataValue="11"
>           set="false"/>
>     </objectChanges>
>     <objectsToAttach xsi:type="sev:MyResultType"/>
>     <objectsToAttach xsi:type="sev:ValueType"/>
>   </changeSummary>
>   <sev2:AllResultsType>
>     <id>ZZZZZZZZZZZZZZZZZZZZ</id>
>     <results>
>       <id>00000000000000000000</id>
>       <sev:result>
>         <id>11111111111111111111</id>
>         <name>name1</name>
>         <value>1</value>
>       </sev:result>
>       <sev:myResult>
>         <id>22222222222222222222</id>
>         <name>myName2</name>
>         <value>2</value>
>       </sev:myResult>
>       <comment>comment0</comment>
>     </results>
>     <results>
>       <id>AAAAAAAAAAAAAAAAAAAA</id>
>       <comment>commentA</comment>
>     </results>
>     <comment language="English">
> 		commentZZZZZZZZZZZZZZZZZZ
> 	</comment>
>   </sev2:AllResultsType>
> </sdo:datagraph>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


[jira] Commented: (TUSCANY-1842) IOException loading DataGraph containing a deleted dataObject with a property whose type extends a complexType w/simple integer content

Posted by "Ron Gavlin (JIRA)" <tu...@ws.apache.org>.
    [ https://issues.apache.org/jira/browse/TUSCANY-1842?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12534422 ] 

Ron Gavlin commented on TUSCANY-1842:
-------------------------------------

Hi Frank,

Thanks for making sense of the issue for me. If you don't get to it before then, I'll try to submit patches for issues 1811, 1812, and 1842 late next week.

Thanks again for the excellent support.

- Ron

> IOException loading DataGraph containing a deleted dataObject with a property whose type extends a complexType w/simple integer content
> ---------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: TUSCANY-1842
>                 URL: https://issues.apache.org/jira/browse/TUSCANY-1842
>             Project: Tuscany
>          Issue Type: Bug
>          Components: Java SDO Implementation
>    Affects Versions: Java-SDO-Next
>         Environment: Windows XP, Sun JDK 1.5.0_09
>            Reporter: Ron Gavlin
>            Priority: Critical
>             Fix For: Java-SDO-Next
>
>
> In the test method, testComplexTypeWithSimpleContentExtensionChangeSummary() listed below, a DataGraph is created with a dataObject whose property type extends a complexType with simple integer content. After the dataObject is deleted, an attempt is made to save and load the DataGraph. While the DataGraph is being loaded, an unsuccessful attempt is made to convert a zero-length string into a BigInteger. 
> Any suggestions on how to best fix this are most welcome.
> Thanks,
> - Ron
> ==============================
> substitutionWithExtensionValues.xsd
> ============================== 
> <schema xmlns="http://www.w3.org/2001/XMLSchema"
> 	targetNamespace="http://www.example.com/substitutionEV"
> 	xmlns:sev="http://www.example.com/substitutionEV">
> 	<!--
> 		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.    
> 	-->
> 	<element name="results" type="sev:ResultsType" />
> 	<element name="result" type="sev:ResultType" />
> 	<element name="myResult" type="sev:MyResultType"
> 		substitutionGroup="sev:result" />
> 	<complexType name="ResultsType">
> 		<sequence>
> 			<element name="id" type="sev:IdType" />
> 			<element ref="sev:result" minOccurs="0"
> 				maxOccurs="unbounded" />
> 			<element name="comment" type="sev:CommentType" />
> 		</sequence>
> 	</complexType>
> 	<complexType name="ResultType">
> 		<sequence>
> 			<element name="id" type="sev:IdType" />
> 			<element name="name" type="string" />
> 			<element name="value" type="sev:ValueType" />
> 		</sequence>
> 	</complexType>
> 	<complexType name="MyResultType">
> 		<complexContent>
> 			<extension base="sev:ResultType" />
> 		</complexContent>
> 	</complexType>
> 	<simpleType name="IdType">
> 		<restriction base="sev:AsciiStringType">
> 			<maxLength value="32" />
> 			<pattern value="[0-9a-fA-F]*" />
> 		</restriction>
> 	</simpleType>
> 	<simpleType name="AsciiStringType">
> 		<restriction base="string">
> 			<pattern value="\p{IsBasicLatin}*" />
> 		</restriction>
> 	</simpleType>
> 	<complexType name="ValueType">
> 		<simpleContent>
> 			<extension base="sev:Integer32Bit" />
> 		</simpleContent>
> 	</complexType>
> 	<complexType name="Integer32Bit">
> 		<simpleContent>
> 			<restriction base="integer">
> 				<minInclusive value="0" />
> 				<maxInclusive value="4290000000" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> 	
> 	<complexType name="CommentType">
> 		<simpleContent>
> 			<extension base="sev:AsciiStringType">
> 				<attribute name="language" use="optional">
> 					<simpleType>
> 						<restriction base="string">
> 							<enumeration value="English" />
> 							<enumeration value="French" />
> 							<enumeration value="Spanish" />
> 						</restriction>
> 					</simpleType>
> 				</attribute>
> 			</extension>
> 		</simpleContent>
> 	</complexType>
> 	<complexType name="MyCommentType">
> 		<simpleContent>
> 			<restriction base="sev:CommentType">
> 				<minLength value="0" />
> 				<maxLength value="40" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> 	<complexType name="StringBasedCommentType">
> 		<simpleContent>
> 			<restriction base="string">
> 				<minLength value="0" />
> 				<maxLength value="40" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> </schema>
> ==============================
> substitutionWithExtensionValues2.xsd
> ==============================
> <schema xmlns="http://www.w3.org/2001/XMLSchema"
> 	targetNamespace="http://www.example.com/substitutionEV2"
> 	xmlns:sev2="http://www.example.com/substitutionEV2"
> 	xmlns:sev="http://www.example.com/substitutionEV">
> 	<!--
> 		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.    
> 	-->
> 	<import namespace="http://www.example.com/substitutionEV"
> 		schemaLocation="substitutionWithExtensionValues.xsd" />
> 	<element name="allResults" type="sev2:AllResultsType" />
> 	<complexType name="AllResultsType">
> 		<sequence>
> 			<element name="id" type="sev2:Id2Type" />
> 			<element name="results" minOccurs="0" maxOccurs="unbounded"
> 				type="sev2:Results2Type" />
> 			<element name="comment" type="sev2:Comment2Type" />
> 		</sequence>
> 	</complexType>
> 	<complexType name="Results2Type">
> 		<complexContent>
> 			<extension base="sev:ResultsType"></extension>
> 		</complexContent>
> 	</complexType>
> 	<simpleType name="Id2Type">
> 		<restriction base="sev:IdType">
> 			<maxLength value="10" />
> 		</restriction>
> 	</simpleType>
> 	<complexType name="Comment2Type">
> 		<simpleContent>
> 			<restriction base="sev:CommentType">
> 				<minLength value="0" />
> 				<maxLength value="20" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> </schema>
> ==============================
> substitutionWithExtensionValues1.xml
> ==============================
> <?xml version="1.0" encoding="ASCII"?>
> <sev2:allResults xmlns:sev2="http://www.example.com/substitutionEV2">
> 	<sev2:id>ZZZZZZZZZZZZZZZZZZZZ</sev2:id>
> 	<sev:results xmlns:sev="http://www.example.com/substitutionEV">
> 		<sev:id>00000000000000000000</sev:id>
> 		<sev:result>
> 			<sev:id>11111111111111111111</sev:id>
> 			<sev:name>name1</sev:name>
> 			<sev:value>1</sev:value>
> 		</sev:result>
> 		<sev:myResult>
> 			<sev:id>22222222222222222222</sev:id>
> 			<sev:name>myName2</sev:name>
> 			<sev:value>2</sev:value>
> 		</sev:myResult>
> 		<sev:comment>comment0</sev:comment>
> 	</sev:results>
> 	<sev:results xmlns:sev="http://www.example.com/substitutionEV">
> 		<sev:id>AAAAAAAAAAAAAAAAAAAA</sev:id>
> 		<sev:myResult>
> 			<sev:id>BBBBBBBBBBBBBBBBBBBB</sev:id>
> 			<sev:name>myNameB</sev:name>
> 			<sev:value>11</sev:value>
> 		</sev:myResult>
> 		<sev:comment>commentA</sev:comment>
> 	</sev:results>
> 	<sev2:comment language="English">
> 		commentZZZZZZZZZZZZZZZZZZ
> 	</sev2:comment>
> </sev2:allResults>
> ==============================
> SubstitutionWithExtensionValuesTestCase.java
> ============================== 
> /**
>  *
>  *  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.sdo.test;
> import java.io.ByteArrayInputStream;
> import java.io.ByteArrayOutputStream;
> import java.io.IOException;
> import java.io.InputStream;
> import java.net.URL;
> import java.util.List;
> import junit.framework.TestCase;
> import org.apache.tuscany.sdo.api.SDOUtil;
> import org.eclipse.emf.common.util.Diagnostic;
> import org.eclipse.emf.ecore.EClass;
> import org.eclipse.emf.ecore.EDataType;
> import org.eclipse.emf.ecore.EObject;
> import org.eclipse.emf.ecore.EStructuralFeature;
> import org.eclipse.emf.ecore.util.Diagnostician;
> import org.eclipse.emf.ecore.util.ExtendedMetaData;
> import com.example.substitution.ev.SEVFactory;
> import com.example.substitution.ev.impl.SEVFactoryImpl;
> import commonj.sdo.DataGraph;
> import commonj.sdo.DataObject;
> import commonj.sdo.Property;
> import commonj.sdo.Type;
> import commonj.sdo.helper.HelperContext;
> import commonj.sdo.helper.TypeHelper;
> import commonj.sdo.impl.HelperProvider;
> public final class SubstitutionWithExtensionValuesTestCase extends TestCase 
> {
>   private static String sev2NamespaceURI;
>   private HelperContext hc;
>   private DataObject dataObject;
>   
>   protected void setUp() throws Exception {
>     super.setUp();
>     hc = HelperProvider.getDefaultContext();
>     registerSEV(hc, true);
>     
>     InputStream inputStream = null;
>     URL url = getClass().getResource("/substitutionWithExtensionValues2.xsd");
>     inputStream = url.openStream();
>     List sev2TypeList = hc.getXSDHelper().define(inputStream, url.toString());
>     inputStream.close();
>     
>     inputStream = getClass().getResourceAsStream("/substitutionWithExtensionValues1.xml");
>     dataObject = hc.getXMLHelper().load(inputStream).getRootObject();
>     inputStream.close();
>     
>     if (sev2NamespaceURI == null)
>     {
>       sev2NamespaceURI = ((Type) sev2TypeList.get(0)).getURI();
>     }
>   }
>   
>   private void registerSEV(HelperContext hc, boolean useStaticRegistration) throws IOException
>   {
>     if (useStaticRegistration)
>     {
>       SEVFactory.INSTANCE.register(hc);
>     }
>     else
>     {
>       InputStream inputStream = null;
>       URL url = getClass().getResource("/substitutionWithExtensionValues.xsd");
>       inputStream = url.openStream();
>       hc.getXSDHelper().define(inputStream, url.toString());
>       inputStream.close();
>     }
>   }
>   public void testComplexTypeWithSubstitutionExtension() throws IOException 
>   {
>     TypeHelper typeHelper = hc.getTypeHelper();
>     
>     Type resultsType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "ResultsType");
>     Type results2Type = typeHelper.getType(sev2NamespaceURI, "Results2Type");
>     assertTrue("Results2 type does not report Results as a base type", 
>         results2Type.getBaseTypes().contains(resultsType));
>     
>     assertEquals("results.1/myResult.0/id has unexpected value", 
>         "BBBBBBBBBBBBBBBBBBBB", dataObject.getString("results.1/myResult.0/id"));
>   }
>   
>   public void testComplexTypeWithSimpleContentExtensionMetaData() 
>   {
>     TypeHelper typeHelper = hc.getTypeHelper();
>     
>     Type stringBasedCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "StringBasedCommentType");
>     Type commentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "CommentType");
>     Type myCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "MyCommentType");
>     Type _myCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "_MyCommentType");
>     Type comment2Type = typeHelper.getType(sev2NamespaceURI, "Comment2Type");
>     Type _comment2Type = typeHelper.getType(sev2NamespaceURI, "_Comment2Type");
>     assertTrue("MyComment type does not report Comment as a base type", 
>         myCommentType.getBaseTypes().contains(commentType));
>     assertTrue("Comment2 type does not report Comment as a base type", 
>         comment2Type.getBaseTypes().contains(commentType));
>     
>     // Test length facets - resort to EMF APIs until Tuscany SDO exposes these directly
>     ExtendedMetaData extendedMetaData = ExtendedMetaData.INSTANCE;
>     EStructuralFeature simpleFeature = null;
>     EDataType commentSimpleType = null;
>     
>     simpleFeature = extendedMetaData.getSimpleFeature((EClass) stringBasedCommentType);
>     commentSimpleType = (EDataType)simpleFeature.getEType();
>     assertEquals(40, extendedMetaData.getMaxLengthFacet(commentSimpleType));
>     
>     // FIXME Work-around EMF's lack of support for re-definable features - SEE TUSCANY-1832
>     commentSimpleType = (EDataType) _myCommentType;
>     assertEquals(40, extendedMetaData.getMaxLengthFacet(commentSimpleType));
>     
>     // FIXME Work-around EMF's lack of support for re-definable features - SEE TUSCANY-1832
>     commentSimpleType = (EDataType) _comment2Type;
>     assertEquals(20, extendedMetaData.getMaxLengthFacet(commentSimpleType));
>   }
>   public void testComplexTypeWithSimpleContentExtensionChangeSummary() throws IOException 
>   {
>     DataGraph dg = SDOUtil.createDataGraph();
>     SDOUtil.setRootObject(dg, dataObject);
>     dg.getChangeSummary().beginLogging();
>     dataObject.getDataObject("results.1/myResult.0").delete();
>     ByteArrayOutputStream baos = new ByteArrayOutputStream();
>     SDOUtil.saveDataGraph(dg, baos, null);
>     ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
>     SDOUtil.loadDataGraph(bais, null, hc);
>   }    
>   
>   public void testSimpleTypeExtension() 
>   {
>     TypeHelper typeHelper = hc.getTypeHelper();
>     
>     Type asciiStringType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "AsciiStringType");
>     Type idType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "IdType");
>     assertTrue("IdType does not report AsciiStringType as a base type", 
>         idType.getBaseTypes().contains(asciiStringType));
>     
>     Diagnostic diagnostic = Diagnostician.INSTANCE.validate((EObject) dataObject);
>     String diagnosticMsg = diagnostic.getChildren().toString();
>     Type id2Type = typeHelper.getType(sev2NamespaceURI, "Id2Type");
>     assertTrue("Id2Type does not report IdType as a base type", 
>         id2Type.getBaseTypes().contains(idType));
>     assertTrue("EMF validation should have reported Id pattern match failure", 
>         diagnosticMsg.indexOf("Id") > 0);
>   }
> }
> STACKTRACE:
> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Value '' is not legal. (file:///C:/development/working/1/tuscany-sdo/sdo/tools-test/all.datagraph, 27, 48)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.handleErrors(XMLLoadImpl.java:83)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:193)
> 	at org.apache.tuscany.sdo.util.DataGraphResourceFactoryImpl$DataGraphResourceImpl$LoadImpl.load(DataGraphResourceFactoryImpl.java:455)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:179)
> 	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1094)
> 	at org.apache.tuscany.sdo.helper.SDOHelperImpl.loadDataGraph(SDOHelperImpl.java:139)
> 	at org.apache.tuscany.sdo.helper.SDOHelperImpl.loadDataGraph(SDOHelperImpl.java:157)
> 	at org.apache.tuscany.sdo.api.SDOUtil.loadDataGraph(SDOUtil.java:150)
> 	at org.apache.tuscany.sdo.test.SubstitutionWithExtensionValuesTestCase.testComplexTypeWithSimpleContentExtensionChangeSummary(SubstitutionWithExtensionValuesTestCase.java:150)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:585)
> 	at junit.framework.TestCase.runTest(TestCase.java:154)
> 	at junit.framework.TestCase.runBare(TestCase.java:127)
> 	at junit.framework.TestResult$1.protect(TestResult.java:106)
> 	at junit.framework.TestResult.runProtected(TestResult.java:124)
> 	at junit.framework.TestResult.run(TestResult.java:109)
> 	at junit.framework.TestCase.run(TestCase.java:118)
> 	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
> 	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
> Caused by: org.eclipse.emf.ecore.xmi.IllegalValueException: Value '' is not legal. (file:///C:/development/working/1/tuscany-sdo/sdo/tools-test/all.datagraph, 27, 48)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2421)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2406)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.endElement(XMLHandler.java:1347)
> 	at org.apache.tuscany.sdo.util.DataGraphResourceFactoryImpl$DataGraphResourceImpl$LoadImpl$1.endElement(DataGraphResourceFactoryImpl.java:627)
> 	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:633)
> 	at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:221)
> 	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:322)
> 	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1693)
> 	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
> 	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
> 	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
> 	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
> 	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
> 	at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:183)
> 	... 23 more
> Caused by: java.lang.NumberFormatException: Zero length BigInteger
> 	at java.math.BigInteger.<init>(BigInteger.java:275)
> 	at java.math.BigInteger.<init>(BigInteger.java:447)
> 	at org.eclipse.emf.ecore.xml.type.impl.XMLTypeFactoryImpl.createInteger(XMLTypeFactoryImpl.java:832)
> 	at org.apache.tuscany.sdo.model.impl.ModelFactoryImpl.createIntegerFromString(ModelFactoryImpl.java:2086)
> 	at com.example.substitution.ev.impl.SEVFactoryImpl.create_Integer32BitFromString(SEVFactoryImpl.java:754)
> 	at com.example.substitution.ev.impl.SEVFactoryImpl.createFromString(SEVFactoryImpl.java:143)
> 	at org.apache.tuscany.sdo.impl.FactoryBase$SDOEFactoryImpl.createFromString(FactoryBase.java:286)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createFromString(XMLHelperImpl.java:1489)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHelperImpl.java:1053)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2416)
> 	... 37 more
> SAVED PROBLEMATIC DATA GRAPH
> <?xml version="1.0" encoding="ASCII"?>
> <sdo:datagraph xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sdo="commonj.sdo"
>     xmlns:sdo_1="http://www.apache.org/tuscany/2005/SDO" xmlns:sev="http://www.example.com/substitutionEV"
>     xmlns:sev2="http://www.example.com/substitutionEV2">
>   <changeSummary xmlns=""
>       logging="true">
>     <objectChanges key="#//@eRootObject/@results.1">
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="resultGroup">
>         <listChanges index="0">
>           <featureMapEntryValues featureName="myResult" referenceValue="#//@eChangeSummary/@objectsToAttach.0"/>
>         </listChanges>
>       </value>
>     </objectChanges>
>     <objectChanges key="#//@eChangeSummary/@objectsToAttach.0">
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="value" set="false"
>           referenceValue="#//@eChangeSummary/@objectsToAttach.1"/>
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="id" dataValue="BBBBBBBBBBBBBBBBBBBB"
>           set="false"/>
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="name" dataValue="myNameB"
>           set="false"/>
>     </objectChanges>
>     <objectChanges key="#//@eChangeSummary/@objectsToAttach.1">
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="value" dataValue="11"
>           set="false"/>
>     </objectChanges>
>     <objectsToAttach xsi:type="sev:MyResultType"/>
>     <objectsToAttach xsi:type="sev:ValueType"/>
>   </changeSummary>
>   <sev2:AllResultsType>
>     <id>ZZZZZZZZZZZZZZZZZZZZ</id>
>     <results>
>       <id>00000000000000000000</id>
>       <sev:result>
>         <id>11111111111111111111</id>
>         <name>name1</name>
>         <value>1</value>
>       </sev:result>
>       <sev:myResult>
>         <id>22222222222222222222</id>
>         <name>myName2</name>
>         <value>2</value>
>       </sev:myResult>
>       <comment>comment0</comment>
>     </results>
>     <results>
>       <id>AAAAAAAAAAAAAAAAAAAA</id>
>       <comment>commentA</comment>
>     </results>
>     <comment language="English">
> 		commentZZZZZZZZZZZZZZZZZZ
> 	</comment>
>   </sev2:AllResultsType>
> </sdo:datagraph>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


[jira] Updated: (TUSCANY-1842) IOException loading DataGraph containing a deleted dataObject with a property whose type extends a complexType w/simple integer content

Posted by "Kelvin Goodson (JIRA)" <tu...@ws.apache.org>.
     [ https://issues.apache.org/jira/browse/TUSCANY-1842?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kelvin Goodson updated TUSCANY-1842:
------------------------------------

    Patch Info: [Patch Available]

Setting PAtach Available: Ron's suggestion gives us a quick workaround to be committed under this JIRA.  TUSCANY-1862 will provide the proper fix.

> IOException loading DataGraph containing a deleted dataObject with a property whose type extends a complexType w/simple integer content
> ---------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: TUSCANY-1842
>                 URL: https://issues.apache.org/jira/browse/TUSCANY-1842
>             Project: Tuscany
>          Issue Type: Bug
>          Components: Java SDO Implementation
>    Affects Versions: Java-SDO-Next
>         Environment: Windows XP, Sun JDK 1.5.0_09
>            Reporter: Ron Gavlin
>            Priority: Critical
>             Fix For: Java-SDO-Next
>
>
> In the test method, testComplexTypeWithSimpleContentExtensionChangeSummary() listed below, a DataGraph is created with a dataObject whose property type extends a complexType with simple integer content. After the dataObject is deleted, an attempt is made to save and load the DataGraph. While the DataGraph is being loaded, an unsuccessful attempt is made to convert a zero-length string into a BigInteger. 
> Any suggestions on how to best fix this are most welcome.
> Thanks,
> - Ron
> ==============================
> substitutionWithExtensionValues.xsd
> ============================== 
> <schema xmlns="http://www.w3.org/2001/XMLSchema"
> 	targetNamespace="http://www.example.com/substitutionEV"
> 	xmlns:sev="http://www.example.com/substitutionEV">
> 	<!--
> 		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.    
> 	-->
> 	<element name="results" type="sev:ResultsType" />
> 	<element name="result" type="sev:ResultType" />
> 	<element name="myResult" type="sev:MyResultType"
> 		substitutionGroup="sev:result" />
> 	<complexType name="ResultsType">
> 		<sequence>
> 			<element name="id" type="sev:IdType" />
> 			<element ref="sev:result" minOccurs="0"
> 				maxOccurs="unbounded" />
> 			<element name="comment" type="sev:CommentType" />
> 		</sequence>
> 	</complexType>
> 	<complexType name="ResultType">
> 		<sequence>
> 			<element name="id" type="sev:IdType" />
> 			<element name="name" type="string" />
> 			<element name="value" type="sev:ValueType" />
> 		</sequence>
> 	</complexType>
> 	<complexType name="MyResultType">
> 		<complexContent>
> 			<extension base="sev:ResultType" />
> 		</complexContent>
> 	</complexType>
> 	<simpleType name="IdType">
> 		<restriction base="sev:AsciiStringType">
> 			<maxLength value="32" />
> 			<pattern value="[0-9a-fA-F]*" />
> 		</restriction>
> 	</simpleType>
> 	<simpleType name="AsciiStringType">
> 		<restriction base="string">
> 			<pattern value="\p{IsBasicLatin}*" />
> 		</restriction>
> 	</simpleType>
> 	<complexType name="ValueType">
> 		<simpleContent>
> 			<extension base="sev:Integer32Bit" />
> 		</simpleContent>
> 	</complexType>
> 	<complexType name="Integer32Bit">
> 		<simpleContent>
> 			<restriction base="integer">
> 				<minInclusive value="0" />
> 				<maxInclusive value="4290000000" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> 	
> 	<complexType name="CommentType">
> 		<simpleContent>
> 			<extension base="sev:AsciiStringType">
> 				<attribute name="language" use="optional">
> 					<simpleType>
> 						<restriction base="string">
> 							<enumeration value="English" />
> 							<enumeration value="French" />
> 							<enumeration value="Spanish" />
> 						</restriction>
> 					</simpleType>
> 				</attribute>
> 			</extension>
> 		</simpleContent>
> 	</complexType>
> 	<complexType name="MyCommentType">
> 		<simpleContent>
> 			<restriction base="sev:CommentType">
> 				<minLength value="0" />
> 				<maxLength value="40" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> 	<complexType name="StringBasedCommentType">
> 		<simpleContent>
> 			<restriction base="string">
> 				<minLength value="0" />
> 				<maxLength value="40" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> </schema>
> ==============================
> substitutionWithExtensionValues2.xsd
> ==============================
> <schema xmlns="http://www.w3.org/2001/XMLSchema"
> 	targetNamespace="http://www.example.com/substitutionEV2"
> 	xmlns:sev2="http://www.example.com/substitutionEV2"
> 	xmlns:sev="http://www.example.com/substitutionEV">
> 	<!--
> 		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.    
> 	-->
> 	<import namespace="http://www.example.com/substitutionEV"
> 		schemaLocation="substitutionWithExtensionValues.xsd" />
> 	<element name="allResults" type="sev2:AllResultsType" />
> 	<complexType name="AllResultsType">
> 		<sequence>
> 			<element name="id" type="sev2:Id2Type" />
> 			<element name="results" minOccurs="0" maxOccurs="unbounded"
> 				type="sev2:Results2Type" />
> 			<element name="comment" type="sev2:Comment2Type" />
> 		</sequence>
> 	</complexType>
> 	<complexType name="Results2Type">
> 		<complexContent>
> 			<extension base="sev:ResultsType"></extension>
> 		</complexContent>
> 	</complexType>
> 	<simpleType name="Id2Type">
> 		<restriction base="sev:IdType">
> 			<maxLength value="10" />
> 		</restriction>
> 	</simpleType>
> 	<complexType name="Comment2Type">
> 		<simpleContent>
> 			<restriction base="sev:CommentType">
> 				<minLength value="0" />
> 				<maxLength value="20" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> </schema>
> ==============================
> substitutionWithExtensionValues1.xml
> ==============================
> <?xml version="1.0" encoding="ASCII"?>
> <sev2:allResults xmlns:sev2="http://www.example.com/substitutionEV2">
> 	<sev2:id>ZZZZZZZZZZZZZZZZZZZZ</sev2:id>
> 	<sev:results xmlns:sev="http://www.example.com/substitutionEV">
> 		<sev:id>00000000000000000000</sev:id>
> 		<sev:result>
> 			<sev:id>11111111111111111111</sev:id>
> 			<sev:name>name1</sev:name>
> 			<sev:value>1</sev:value>
> 		</sev:result>
> 		<sev:myResult>
> 			<sev:id>22222222222222222222</sev:id>
> 			<sev:name>myName2</sev:name>
> 			<sev:value>2</sev:value>
> 		</sev:myResult>
> 		<sev:comment>comment0</sev:comment>
> 	</sev:results>
> 	<sev:results xmlns:sev="http://www.example.com/substitutionEV">
> 		<sev:id>AAAAAAAAAAAAAAAAAAAA</sev:id>
> 		<sev:myResult>
> 			<sev:id>BBBBBBBBBBBBBBBBBBBB</sev:id>
> 			<sev:name>myNameB</sev:name>
> 			<sev:value>11</sev:value>
> 		</sev:myResult>
> 		<sev:comment>commentA</sev:comment>
> 	</sev:results>
> 	<sev2:comment language="English">
> 		commentZZZZZZZZZZZZZZZZZZ
> 	</sev2:comment>
> </sev2:allResults>
> ==============================
> SubstitutionWithExtensionValuesTestCase.java
> ============================== 
> /**
>  *
>  *  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.sdo.test;
> import java.io.ByteArrayInputStream;
> import java.io.ByteArrayOutputStream;
> import java.io.IOException;
> import java.io.InputStream;
> import java.net.URL;
> import java.util.List;
> import junit.framework.TestCase;
> import org.apache.tuscany.sdo.api.SDOUtil;
> import org.eclipse.emf.common.util.Diagnostic;
> import org.eclipse.emf.ecore.EClass;
> import org.eclipse.emf.ecore.EDataType;
> import org.eclipse.emf.ecore.EObject;
> import org.eclipse.emf.ecore.EStructuralFeature;
> import org.eclipse.emf.ecore.util.Diagnostician;
> import org.eclipse.emf.ecore.util.ExtendedMetaData;
> import com.example.substitution.ev.SEVFactory;
> import com.example.substitution.ev.impl.SEVFactoryImpl;
> import commonj.sdo.DataGraph;
> import commonj.sdo.DataObject;
> import commonj.sdo.Property;
> import commonj.sdo.Type;
> import commonj.sdo.helper.HelperContext;
> import commonj.sdo.helper.TypeHelper;
> import commonj.sdo.impl.HelperProvider;
> public final class SubstitutionWithExtensionValuesTestCase extends TestCase 
> {
>   private static String sev2NamespaceURI;
>   private HelperContext hc;
>   private DataObject dataObject;
>   
>   protected void setUp() throws Exception {
>     super.setUp();
>     hc = HelperProvider.getDefaultContext();
>     registerSEV(hc, true);
>     
>     InputStream inputStream = null;
>     URL url = getClass().getResource("/substitutionWithExtensionValues2.xsd");
>     inputStream = url.openStream();
>     List sev2TypeList = hc.getXSDHelper().define(inputStream, url.toString());
>     inputStream.close();
>     
>     inputStream = getClass().getResourceAsStream("/substitutionWithExtensionValues1.xml");
>     dataObject = hc.getXMLHelper().load(inputStream).getRootObject();
>     inputStream.close();
>     
>     if (sev2NamespaceURI == null)
>     {
>       sev2NamespaceURI = ((Type) sev2TypeList.get(0)).getURI();
>     }
>   }
>   
>   private void registerSEV(HelperContext hc, boolean useStaticRegistration) throws IOException
>   {
>     if (useStaticRegistration)
>     {
>       SEVFactory.INSTANCE.register(hc);
>     }
>     else
>     {
>       InputStream inputStream = null;
>       URL url = getClass().getResource("/substitutionWithExtensionValues.xsd");
>       inputStream = url.openStream();
>       hc.getXSDHelper().define(inputStream, url.toString());
>       inputStream.close();
>     }
>   }
>   public void testComplexTypeWithSubstitutionExtension() throws IOException 
>   {
>     TypeHelper typeHelper = hc.getTypeHelper();
>     
>     Type resultsType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "ResultsType");
>     Type results2Type = typeHelper.getType(sev2NamespaceURI, "Results2Type");
>     assertTrue("Results2 type does not report Results as a base type", 
>         results2Type.getBaseTypes().contains(resultsType));
>     
>     assertEquals("results.1/myResult.0/id has unexpected value", 
>         "BBBBBBBBBBBBBBBBBBBB", dataObject.getString("results.1/myResult.0/id"));
>   }
>   
>   public void testComplexTypeWithSimpleContentExtensionMetaData() 
>   {
>     TypeHelper typeHelper = hc.getTypeHelper();
>     
>     Type stringBasedCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "StringBasedCommentType");
>     Type commentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "CommentType");
>     Type myCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "MyCommentType");
>     Type _myCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "_MyCommentType");
>     Type comment2Type = typeHelper.getType(sev2NamespaceURI, "Comment2Type");
>     Type _comment2Type = typeHelper.getType(sev2NamespaceURI, "_Comment2Type");
>     assertTrue("MyComment type does not report Comment as a base type", 
>         myCommentType.getBaseTypes().contains(commentType));
>     assertTrue("Comment2 type does not report Comment as a base type", 
>         comment2Type.getBaseTypes().contains(commentType));
>     
>     // Test length facets - resort to EMF APIs until Tuscany SDO exposes these directly
>     ExtendedMetaData extendedMetaData = ExtendedMetaData.INSTANCE;
>     EStructuralFeature simpleFeature = null;
>     EDataType commentSimpleType = null;
>     
>     simpleFeature = extendedMetaData.getSimpleFeature((EClass) stringBasedCommentType);
>     commentSimpleType = (EDataType)simpleFeature.getEType();
>     assertEquals(40, extendedMetaData.getMaxLengthFacet(commentSimpleType));
>     
>     // FIXME Work-around EMF's lack of support for re-definable features - SEE TUSCANY-1832
>     commentSimpleType = (EDataType) _myCommentType;
>     assertEquals(40, extendedMetaData.getMaxLengthFacet(commentSimpleType));
>     
>     // FIXME Work-around EMF's lack of support for re-definable features - SEE TUSCANY-1832
>     commentSimpleType = (EDataType) _comment2Type;
>     assertEquals(20, extendedMetaData.getMaxLengthFacet(commentSimpleType));
>   }
>   public void testComplexTypeWithSimpleContentExtensionChangeSummary() throws IOException 
>   {
>     DataGraph dg = SDOUtil.createDataGraph();
>     SDOUtil.setRootObject(dg, dataObject);
>     dg.getChangeSummary().beginLogging();
>     dataObject.getDataObject("results.1/myResult.0").delete();
>     ByteArrayOutputStream baos = new ByteArrayOutputStream();
>     SDOUtil.saveDataGraph(dg, baos, null);
>     ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
>     SDOUtil.loadDataGraph(bais, null, hc);
>   }    
>   
>   public void testSimpleTypeExtension() 
>   {
>     TypeHelper typeHelper = hc.getTypeHelper();
>     
>     Type asciiStringType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "AsciiStringType");
>     Type idType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "IdType");
>     assertTrue("IdType does not report AsciiStringType as a base type", 
>         idType.getBaseTypes().contains(asciiStringType));
>     
>     Diagnostic diagnostic = Diagnostician.INSTANCE.validate((EObject) dataObject);
>     String diagnosticMsg = diagnostic.getChildren().toString();
>     Type id2Type = typeHelper.getType(sev2NamespaceURI, "Id2Type");
>     assertTrue("Id2Type does not report IdType as a base type", 
>         id2Type.getBaseTypes().contains(idType));
>     assertTrue("EMF validation should have reported Id pattern match failure", 
>         diagnosticMsg.indexOf("Id") > 0);
>   }
> }
> STACKTRACE:
> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Value '' is not legal. (file:///C:/development/working/1/tuscany-sdo/sdo/tools-test/all.datagraph, 27, 48)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.handleErrors(XMLLoadImpl.java:83)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:193)
> 	at org.apache.tuscany.sdo.util.DataGraphResourceFactoryImpl$DataGraphResourceImpl$LoadImpl.load(DataGraphResourceFactoryImpl.java:455)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:179)
> 	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1094)
> 	at org.apache.tuscany.sdo.helper.SDOHelperImpl.loadDataGraph(SDOHelperImpl.java:139)
> 	at org.apache.tuscany.sdo.helper.SDOHelperImpl.loadDataGraph(SDOHelperImpl.java:157)
> 	at org.apache.tuscany.sdo.api.SDOUtil.loadDataGraph(SDOUtil.java:150)
> 	at org.apache.tuscany.sdo.test.SubstitutionWithExtensionValuesTestCase.testComplexTypeWithSimpleContentExtensionChangeSummary(SubstitutionWithExtensionValuesTestCase.java:150)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:585)
> 	at junit.framework.TestCase.runTest(TestCase.java:154)
> 	at junit.framework.TestCase.runBare(TestCase.java:127)
> 	at junit.framework.TestResult$1.protect(TestResult.java:106)
> 	at junit.framework.TestResult.runProtected(TestResult.java:124)
> 	at junit.framework.TestResult.run(TestResult.java:109)
> 	at junit.framework.TestCase.run(TestCase.java:118)
> 	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
> 	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
> Caused by: org.eclipse.emf.ecore.xmi.IllegalValueException: Value '' is not legal. (file:///C:/development/working/1/tuscany-sdo/sdo/tools-test/all.datagraph, 27, 48)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2421)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2406)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.endElement(XMLHandler.java:1347)
> 	at org.apache.tuscany.sdo.util.DataGraphResourceFactoryImpl$DataGraphResourceImpl$LoadImpl$1.endElement(DataGraphResourceFactoryImpl.java:627)
> 	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:633)
> 	at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:221)
> 	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:322)
> 	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1693)
> 	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
> 	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
> 	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
> 	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
> 	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
> 	at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:183)
> 	... 23 more
> Caused by: java.lang.NumberFormatException: Zero length BigInteger
> 	at java.math.BigInteger.<init>(BigInteger.java:275)
> 	at java.math.BigInteger.<init>(BigInteger.java:447)
> 	at org.eclipse.emf.ecore.xml.type.impl.XMLTypeFactoryImpl.createInteger(XMLTypeFactoryImpl.java:832)
> 	at org.apache.tuscany.sdo.model.impl.ModelFactoryImpl.createIntegerFromString(ModelFactoryImpl.java:2086)
> 	at com.example.substitution.ev.impl.SEVFactoryImpl.create_Integer32BitFromString(SEVFactoryImpl.java:754)
> 	at com.example.substitution.ev.impl.SEVFactoryImpl.createFromString(SEVFactoryImpl.java:143)
> 	at org.apache.tuscany.sdo.impl.FactoryBase$SDOEFactoryImpl.createFromString(FactoryBase.java:286)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createFromString(XMLHelperImpl.java:1489)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHelperImpl.java:1053)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2416)
> 	... 37 more
> SAVED PROBLEMATIC DATA GRAPH
> <?xml version="1.0" encoding="ASCII"?>
> <sdo:datagraph xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sdo="commonj.sdo"
>     xmlns:sdo_1="http://www.apache.org/tuscany/2005/SDO" xmlns:sev="http://www.example.com/substitutionEV"
>     xmlns:sev2="http://www.example.com/substitutionEV2">
>   <changeSummary xmlns=""
>       logging="true">
>     <objectChanges key="#//@eRootObject/@results.1">
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="resultGroup">
>         <listChanges index="0">
>           <featureMapEntryValues featureName="myResult" referenceValue="#//@eChangeSummary/@objectsToAttach.0"/>
>         </listChanges>
>       </value>
>     </objectChanges>
>     <objectChanges key="#//@eChangeSummary/@objectsToAttach.0">
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="value" set="false"
>           referenceValue="#//@eChangeSummary/@objectsToAttach.1"/>
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="id" dataValue="BBBBBBBBBBBBBBBBBBBB"
>           set="false"/>
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="name" dataValue="myNameB"
>           set="false"/>
>     </objectChanges>
>     <objectChanges key="#//@eChangeSummary/@objectsToAttach.1">
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="value" dataValue="11"
>           set="false"/>
>     </objectChanges>
>     <objectsToAttach xsi:type="sev:MyResultType"/>
>     <objectsToAttach xsi:type="sev:ValueType"/>
>   </changeSummary>
>   <sev2:AllResultsType>
>     <id>ZZZZZZZZZZZZZZZZZZZZ</id>
>     <results>
>       <id>00000000000000000000</id>
>       <sev:result>
>         <id>11111111111111111111</id>
>         <name>name1</name>
>         <value>1</value>
>       </sev:result>
>       <sev:myResult>
>         <id>22222222222222222222</id>
>         <name>myName2</name>
>         <value>2</value>
>       </sev:myResult>
>       <comment>comment0</comment>
>     </results>
>     <results>
>       <id>AAAAAAAAAAAAAAAAAAAA</id>
>       <comment>commentA</comment>
>     </results>
>     <comment language="English">
> 		commentZZZZZZZZZZZZZZZZZZ
> 	</comment>
>   </sev2:AllResultsType>
> </sdo:datagraph>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


[jira] Updated: (TUSCANY-1842) IOException loading DataGraph containing a deleted dataObject with a property whose type extends a complexType w/simple integer content

Posted by "Kelvin Goodson (JIRA)" <tu...@ws.apache.org>.
     [ https://issues.apache.org/jira/browse/TUSCANY-1842?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kelvin Goodson updated TUSCANY-1842:
------------------------------------

    Attachment: 1842data.zip

Hi Ron,
   I'm having trouble getting the data files to validate before I run the test cases.  I have made some updates,  but need some assistance in fixing the final errors without changing the meaning of the test case.  I have attached my updates to the files in 1842data.zip.  In these files I have fixed up some of the validation errors by ...

adding elementFormDefault="qualified" to both schema files
changing the sev:results to sev2:results elements
changing the values of the sev2:id and sev2:comment elements to match the appropriate facets

but I am left with the errors below,  and no matter how I try to vary the method of type derivation I cant seem to create a valid schema that conveys the meaning I think you want.  Can you take a look please?

src-ct.2.1: Complex Type Definition Representation Error for type 'Integer32Bit'.  When <simpleContent> is used, the base type must be a complexType whose content type is simple, or, only if restriction is specified, a complex type with mixed content and emptiable particle, or, only if extension is specified, a simple type. 'integer' satisfies none of these conditions.	tuscany-sdo-tools-test/src/main/resources	substitutionWithExtensionValues.xsd	line 69

src-ct.2.1: Complex Type Definition Representation Error for type 'StringBasedCommentType'.  When <simpleContent> is used, the base type must be a complexType whose content type is simple, or, only if restriction is specified, a complex type with mixed content and emptiable particle, or, only if extension is specified, a simple type. 'string' satisfies none of these conditions.	tuscany-sdo-tools-test/src/main/resources	substitutionWithExtensionValues.xsd	line 103	

src-ct.2.1: Complex Type Definition Representation Error for type 'ValueType'.  When <simpleContent> is used, the base type must be a complexType whose content type is simple, or, only if restriction is specified, a complex type with mixed content and emptiable particle, or, only if extension is specified, a simple type. 'Integer32Bit' satisfies none of these conditions.	tuscany-sdo-tools-test/src/main/resources	substitutionWithExtensionValues.xsd	line 63	




> IOException loading DataGraph containing a deleted dataObject with a property whose type extends a complexType w/simple integer content
> ---------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: TUSCANY-1842
>                 URL: https://issues.apache.org/jira/browse/TUSCANY-1842
>             Project: Tuscany
>          Issue Type: Bug
>          Components: Java SDO Implementation
>    Affects Versions: Java-SDO-Next
>         Environment: Windows XP, Sun JDK 1.5.0_09
>            Reporter: Ron Gavlin
>            Priority: Critical
>             Fix For: Java-SDO-Next
>
>         Attachments: 1842data.zip, tuscany-sdo.TUSCANY-1842.patch
>
>
> In the test method, testComplexTypeWithSimpleContentExtensionChangeSummary() listed below, a DataGraph is created with a dataObject whose property type extends a complexType with simple integer content. After the dataObject is deleted, an attempt is made to save and load the DataGraph. While the DataGraph is being loaded, an unsuccessful attempt is made to convert a zero-length string into a BigInteger. 
> Any suggestions on how to best fix this are most welcome.
> Thanks,
> - Ron
> ==============================
> substitutionWithExtensionValues.xsd
> ============================== 
> <schema xmlns="http://www.w3.org/2001/XMLSchema"
> 	targetNamespace="http://www.example.com/substitutionEV"
> 	xmlns:sev="http://www.example.com/substitutionEV">
> 	<!--
> 		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.    
> 	-->
> 	<element name="results" type="sev:ResultsType" />
> 	<element name="result" type="sev:ResultType" />
> 	<element name="myResult" type="sev:MyResultType"
> 		substitutionGroup="sev:result" />
> 	<complexType name="ResultsType">
> 		<sequence>
> 			<element name="id" type="sev:IdType" />
> 			<element ref="sev:result" minOccurs="0"
> 				maxOccurs="unbounded" />
> 			<element name="comment" type="sev:CommentType" />
> 		</sequence>
> 	</complexType>
> 	<complexType name="ResultType">
> 		<sequence>
> 			<element name="id" type="sev:IdType" />
> 			<element name="name" type="string" />
> 			<element name="value" type="sev:ValueType" />
> 		</sequence>
> 	</complexType>
> 	<complexType name="MyResultType">
> 		<complexContent>
> 			<extension base="sev:ResultType" />
> 		</complexContent>
> 	</complexType>
> 	<simpleType name="IdType">
> 		<restriction base="sev:AsciiStringType">
> 			<maxLength value="32" />
> 			<pattern value="[0-9a-fA-F]*" />
> 		</restriction>
> 	</simpleType>
> 	<simpleType name="AsciiStringType">
> 		<restriction base="string">
> 			<pattern value="\p{IsBasicLatin}*" />
> 		</restriction>
> 	</simpleType>
> 	<complexType name="ValueType">
> 		<simpleContent>
> 			<extension base="sev:Integer32Bit" />
> 		</simpleContent>
> 	</complexType>
> 	<complexType name="Integer32Bit">
> 		<simpleContent>
> 			<restriction base="integer">
> 				<minInclusive value="0" />
> 				<maxInclusive value="4290000000" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> 	
> 	<complexType name="CommentType">
> 		<simpleContent>
> 			<extension base="sev:AsciiStringType">
> 				<attribute name="language" use="optional">
> 					<simpleType>
> 						<restriction base="string">
> 							<enumeration value="English" />
> 							<enumeration value="French" />
> 							<enumeration value="Spanish" />
> 						</restriction>
> 					</simpleType>
> 				</attribute>
> 			</extension>
> 		</simpleContent>
> 	</complexType>
> 	<complexType name="MyCommentType">
> 		<simpleContent>
> 			<restriction base="sev:CommentType">
> 				<minLength value="0" />
> 				<maxLength value="40" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> 	<complexType name="StringBasedCommentType">
> 		<simpleContent>
> 			<restriction base="string">
> 				<minLength value="0" />
> 				<maxLength value="40" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> </schema>
> ==============================
> substitutionWithExtensionValues2.xsd
> ==============================
> <schema xmlns="http://www.w3.org/2001/XMLSchema"
> 	targetNamespace="http://www.example.com/substitutionEV2"
> 	xmlns:sev2="http://www.example.com/substitutionEV2"
> 	xmlns:sev="http://www.example.com/substitutionEV">
> 	<!--
> 		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.    
> 	-->
> 	<import namespace="http://www.example.com/substitutionEV"
> 		schemaLocation="substitutionWithExtensionValues.xsd" />
> 	<element name="allResults" type="sev2:AllResultsType" />
> 	<complexType name="AllResultsType">
> 		<sequence>
> 			<element name="id" type="sev2:Id2Type" />
> 			<element name="results" minOccurs="0" maxOccurs="unbounded"
> 				type="sev2:Results2Type" />
> 			<element name="comment" type="sev2:Comment2Type" />
> 		</sequence>
> 	</complexType>
> 	<complexType name="Results2Type">
> 		<complexContent>
> 			<extension base="sev:ResultsType"></extension>
> 		</complexContent>
> 	</complexType>
> 	<simpleType name="Id2Type">
> 		<restriction base="sev:IdType">
> 			<maxLength value="10" />
> 		</restriction>
> 	</simpleType>
> 	<complexType name="Comment2Type">
> 		<simpleContent>
> 			<restriction base="sev:CommentType">
> 				<minLength value="0" />
> 				<maxLength value="20" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> </schema>
> ==============================
> substitutionWithExtensionValues1.xml
> ==============================
> <?xml version="1.0" encoding="ASCII"?>
> <sev2:allResults xmlns:sev2="http://www.example.com/substitutionEV2">
> 	<sev2:id>ZZZZZZZZZZZZZZZZZZZZ</sev2:id>
> 	<sev:results xmlns:sev="http://www.example.com/substitutionEV">
> 		<sev:id>00000000000000000000</sev:id>
> 		<sev:result>
> 			<sev:id>11111111111111111111</sev:id>
> 			<sev:name>name1</sev:name>
> 			<sev:value>1</sev:value>
> 		</sev:result>
> 		<sev:myResult>
> 			<sev:id>22222222222222222222</sev:id>
> 			<sev:name>myName2</sev:name>
> 			<sev:value>2</sev:value>
> 		</sev:myResult>
> 		<sev:comment>comment0</sev:comment>
> 	</sev:results>
> 	<sev:results xmlns:sev="http://www.example.com/substitutionEV">
> 		<sev:id>AAAAAAAAAAAAAAAAAAAA</sev:id>
> 		<sev:myResult>
> 			<sev:id>BBBBBBBBBBBBBBBBBBBB</sev:id>
> 			<sev:name>myNameB</sev:name>
> 			<sev:value>11</sev:value>
> 		</sev:myResult>
> 		<sev:comment>commentA</sev:comment>
> 	</sev:results>
> 	<sev2:comment language="English">
> 		commentZZZZZZZZZZZZZZZZZZ
> 	</sev2:comment>
> </sev2:allResults>
> ==============================
> SubstitutionWithExtensionValuesTestCase.java
> ============================== 
> /**
>  *
>  *  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.sdo.test;
> import java.io.ByteArrayInputStream;
> import java.io.ByteArrayOutputStream;
> import java.io.IOException;
> import java.io.InputStream;
> import java.net.URL;
> import java.util.List;
> import junit.framework.TestCase;
> import org.apache.tuscany.sdo.api.SDOUtil;
> import org.eclipse.emf.common.util.Diagnostic;
> import org.eclipse.emf.ecore.EClass;
> import org.eclipse.emf.ecore.EDataType;
> import org.eclipse.emf.ecore.EObject;
> import org.eclipse.emf.ecore.EStructuralFeature;
> import org.eclipse.emf.ecore.util.Diagnostician;
> import org.eclipse.emf.ecore.util.ExtendedMetaData;
> import com.example.substitution.ev.SEVFactory;
> import com.example.substitution.ev.impl.SEVFactoryImpl;
> import commonj.sdo.DataGraph;
> import commonj.sdo.DataObject;
> import commonj.sdo.Property;
> import commonj.sdo.Type;
> import commonj.sdo.helper.HelperContext;
> import commonj.sdo.helper.TypeHelper;
> import commonj.sdo.impl.HelperProvider;
> public final class SubstitutionWithExtensionValuesTestCase extends TestCase 
> {
>   private static String sev2NamespaceURI;
>   private HelperContext hc;
>   private DataObject dataObject;
>   
>   protected void setUp() throws Exception {
>     super.setUp();
>     hc = HelperProvider.getDefaultContext();
>     registerSEV(hc, true);
>     
>     InputStream inputStream = null;
>     URL url = getClass().getResource("/substitutionWithExtensionValues2.xsd");
>     inputStream = url.openStream();
>     List sev2TypeList = hc.getXSDHelper().define(inputStream, url.toString());
>     inputStream.close();
>     
>     inputStream = getClass().getResourceAsStream("/substitutionWithExtensionValues1.xml");
>     dataObject = hc.getXMLHelper().load(inputStream).getRootObject();
>     inputStream.close();
>     
>     if (sev2NamespaceURI == null)
>     {
>       sev2NamespaceURI = ((Type) sev2TypeList.get(0)).getURI();
>     }
>   }
>   
>   private void registerSEV(HelperContext hc, boolean useStaticRegistration) throws IOException
>   {
>     if (useStaticRegistration)
>     {
>       SEVFactory.INSTANCE.register(hc);
>     }
>     else
>     {
>       InputStream inputStream = null;
>       URL url = getClass().getResource("/substitutionWithExtensionValues.xsd");
>       inputStream = url.openStream();
>       hc.getXSDHelper().define(inputStream, url.toString());
>       inputStream.close();
>     }
>   }
>   public void testComplexTypeWithSubstitutionExtension() throws IOException 
>   {
>     TypeHelper typeHelper = hc.getTypeHelper();
>     
>     Type resultsType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "ResultsType");
>     Type results2Type = typeHelper.getType(sev2NamespaceURI, "Results2Type");
>     assertTrue("Results2 type does not report Results as a base type", 
>         results2Type.getBaseTypes().contains(resultsType));
>     
>     assertEquals("results.1/myResult.0/id has unexpected value", 
>         "BBBBBBBBBBBBBBBBBBBB", dataObject.getString("results.1/myResult.0/id"));
>   }
>   
>   public void testComplexTypeWithSimpleContentExtensionMetaData() 
>   {
>     TypeHelper typeHelper = hc.getTypeHelper();
>     
>     Type stringBasedCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "StringBasedCommentType");
>     Type commentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "CommentType");
>     Type myCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "MyCommentType");
>     Type _myCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "_MyCommentType");
>     Type comment2Type = typeHelper.getType(sev2NamespaceURI, "Comment2Type");
>     Type _comment2Type = typeHelper.getType(sev2NamespaceURI, "_Comment2Type");
>     assertTrue("MyComment type does not report Comment as a base type", 
>         myCommentType.getBaseTypes().contains(commentType));
>     assertTrue("Comment2 type does not report Comment as a base type", 
>         comment2Type.getBaseTypes().contains(commentType));
>     
>     // Test length facets - resort to EMF APIs until Tuscany SDO exposes these directly
>     ExtendedMetaData extendedMetaData = ExtendedMetaData.INSTANCE;
>     EStructuralFeature simpleFeature = null;
>     EDataType commentSimpleType = null;
>     
>     simpleFeature = extendedMetaData.getSimpleFeature((EClass) stringBasedCommentType);
>     commentSimpleType = (EDataType)simpleFeature.getEType();
>     assertEquals(40, extendedMetaData.getMaxLengthFacet(commentSimpleType));
>     
>     // FIXME Work-around EMF's lack of support for re-definable features - SEE TUSCANY-1832
>     commentSimpleType = (EDataType) _myCommentType;
>     assertEquals(40, extendedMetaData.getMaxLengthFacet(commentSimpleType));
>     
>     // FIXME Work-around EMF's lack of support for re-definable features - SEE TUSCANY-1832
>     commentSimpleType = (EDataType) _comment2Type;
>     assertEquals(20, extendedMetaData.getMaxLengthFacet(commentSimpleType));
>   }
>   public void testComplexTypeWithSimpleContentExtensionChangeSummary() throws IOException 
>   {
>     DataGraph dg = SDOUtil.createDataGraph();
>     SDOUtil.setRootObject(dg, dataObject);
>     dg.getChangeSummary().beginLogging();
>     dataObject.getDataObject("results.1/myResult.0").delete();
>     ByteArrayOutputStream baos = new ByteArrayOutputStream();
>     SDOUtil.saveDataGraph(dg, baos, null);
>     ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
>     SDOUtil.loadDataGraph(bais, null, hc);
>   }    
>   
>   public void testSimpleTypeExtension() 
>   {
>     TypeHelper typeHelper = hc.getTypeHelper();
>     
>     Type asciiStringType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "AsciiStringType");
>     Type idType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "IdType");
>     assertTrue("IdType does not report AsciiStringType as a base type", 
>         idType.getBaseTypes().contains(asciiStringType));
>     
>     Diagnostic diagnostic = Diagnostician.INSTANCE.validate((EObject) dataObject);
>     String diagnosticMsg = diagnostic.getChildren().toString();
>     Type id2Type = typeHelper.getType(sev2NamespaceURI, "Id2Type");
>     assertTrue("Id2Type does not report IdType as a base type", 
>         id2Type.getBaseTypes().contains(idType));
>     assertTrue("EMF validation should have reported Id pattern match failure", 
>         diagnosticMsg.indexOf("Id") > 0);
>   }
> }
> STACKTRACE:
> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Value '' is not legal. (file:///C:/development/working/1/tuscany-sdo/sdo/tools-test/all.datagraph, 27, 48)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.handleErrors(XMLLoadImpl.java:83)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:193)
> 	at org.apache.tuscany.sdo.util.DataGraphResourceFactoryImpl$DataGraphResourceImpl$LoadImpl.load(DataGraphResourceFactoryImpl.java:455)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:179)
> 	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1094)
> 	at org.apache.tuscany.sdo.helper.SDOHelperImpl.loadDataGraph(SDOHelperImpl.java:139)
> 	at org.apache.tuscany.sdo.helper.SDOHelperImpl.loadDataGraph(SDOHelperImpl.java:157)
> 	at org.apache.tuscany.sdo.api.SDOUtil.loadDataGraph(SDOUtil.java:150)
> 	at org.apache.tuscany.sdo.test.SubstitutionWithExtensionValuesTestCase.testComplexTypeWithSimpleContentExtensionChangeSummary(SubstitutionWithExtensionValuesTestCase.java:150)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:585)
> 	at junit.framework.TestCase.runTest(TestCase.java:154)
> 	at junit.framework.TestCase.runBare(TestCase.java:127)
> 	at junit.framework.TestResult$1.protect(TestResult.java:106)
> 	at junit.framework.TestResult.runProtected(TestResult.java:124)
> 	at junit.framework.TestResult.run(TestResult.java:109)
> 	at junit.framework.TestCase.run(TestCase.java:118)
> 	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
> 	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
> Caused by: org.eclipse.emf.ecore.xmi.IllegalValueException: Value '' is not legal. (file:///C:/development/working/1/tuscany-sdo/sdo/tools-test/all.datagraph, 27, 48)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2421)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2406)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.endElement(XMLHandler.java:1347)
> 	at org.apache.tuscany.sdo.util.DataGraphResourceFactoryImpl$DataGraphResourceImpl$LoadImpl$1.endElement(DataGraphResourceFactoryImpl.java:627)
> 	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:633)
> 	at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:221)
> 	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:322)
> 	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1693)
> 	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
> 	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
> 	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
> 	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
> 	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
> 	at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:183)
> 	... 23 more
> Caused by: java.lang.NumberFormatException: Zero length BigInteger
> 	at java.math.BigInteger.<init>(BigInteger.java:275)
> 	at java.math.BigInteger.<init>(BigInteger.java:447)
> 	at org.eclipse.emf.ecore.xml.type.impl.XMLTypeFactoryImpl.createInteger(XMLTypeFactoryImpl.java:832)
> 	at org.apache.tuscany.sdo.model.impl.ModelFactoryImpl.createIntegerFromString(ModelFactoryImpl.java:2086)
> 	at com.example.substitution.ev.impl.SEVFactoryImpl.create_Integer32BitFromString(SEVFactoryImpl.java:754)
> 	at com.example.substitution.ev.impl.SEVFactoryImpl.createFromString(SEVFactoryImpl.java:143)
> 	at org.apache.tuscany.sdo.impl.FactoryBase$SDOEFactoryImpl.createFromString(FactoryBase.java:286)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createFromString(XMLHelperImpl.java:1489)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHelperImpl.java:1053)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2416)
> 	... 37 more
> SAVED PROBLEMATIC DATA GRAPH
> <?xml version="1.0" encoding="ASCII"?>
> <sdo:datagraph xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sdo="commonj.sdo"
>     xmlns:sdo_1="http://www.apache.org/tuscany/2005/SDO" xmlns:sev="http://www.example.com/substitutionEV"
>     xmlns:sev2="http://www.example.com/substitutionEV2">
>   <changeSummary xmlns=""
>       logging="true">
>     <objectChanges key="#//@eRootObject/@results.1">
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="resultGroup">
>         <listChanges index="0">
>           <featureMapEntryValues featureName="myResult" referenceValue="#//@eChangeSummary/@objectsToAttach.0"/>
>         </listChanges>
>       </value>
>     </objectChanges>
>     <objectChanges key="#//@eChangeSummary/@objectsToAttach.0">
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="value" set="false"
>           referenceValue="#//@eChangeSummary/@objectsToAttach.1"/>
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="id" dataValue="BBBBBBBBBBBBBBBBBBBB"
>           set="false"/>
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="name" dataValue="myNameB"
>           set="false"/>
>     </objectChanges>
>     <objectChanges key="#//@eChangeSummary/@objectsToAttach.1">
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="value" dataValue="11"
>           set="false"/>
>     </objectChanges>
>     <objectsToAttach xsi:type="sev:MyResultType"/>
>     <objectsToAttach xsi:type="sev:ValueType"/>
>   </changeSummary>
>   <sev2:AllResultsType>
>     <id>ZZZZZZZZZZZZZZZZZZZZ</id>
>     <results>
>       <id>00000000000000000000</id>
>       <sev:result>
>         <id>11111111111111111111</id>
>         <name>name1</name>
>         <value>1</value>
>       </sev:result>
>       <sev:myResult>
>         <id>22222222222222222222</id>
>         <name>myName2</name>
>         <value>2</value>
>       </sev:myResult>
>       <comment>comment0</comment>
>     </results>
>     <results>
>       <id>AAAAAAAAAAAAAAAAAAAA</id>
>       <comment>commentA</comment>
>     </results>
>     <comment language="English">
> 		commentZZZZZZZZZZZZZZZZZZ
> 	</comment>
>   </sev2:AllResultsType>
> </sdo:datagraph>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


[jira] Commented: (TUSCANY-1842) IOException loading DataGraph containing a deleted dataObject with a property whose type extends a complexType w/simple integer content

Posted by "Frank Budinsky (JIRA)" <tu...@ws.apache.org>.
    [ https://issues.apache.org/jira/browse/TUSCANY-1842?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12534410 ] 

Frank Budinsky commented on TUSCANY-1842:
-----------------------------------------

Hi Ron,

It looks like the problem is caused because DataObject.delete() calls unset() on the special "value" property of a wrapper type which causes an invalid instance to be serialized:

   <objectsToAttach xsi:type="sev:ValueType"/>

Your hack works around the issue by forcing the loader to accept the invalid instance.

A better fix would be to prevent DataObject.delete() from calling unset() on "value" properties, but there is currently no way to detect that a property is one of these special wrapper value properties. So, I guess your hack is as good as any for now, but we need to document the fact that this is a temporary fix. In the future we need to ensure that unset() is not called - or it has special behavior - for the value properties.

Frank.
 

> IOException loading DataGraph containing a deleted dataObject with a property whose type extends a complexType w/simple integer content
> ---------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: TUSCANY-1842
>                 URL: https://issues.apache.org/jira/browse/TUSCANY-1842
>             Project: Tuscany
>          Issue Type: Bug
>          Components: Java SDO Implementation
>    Affects Versions: Java-SDO-Next
>         Environment: Windows XP, Sun JDK 1.5.0_09
>            Reporter: Ron Gavlin
>            Priority: Critical
>             Fix For: Java-SDO-Next
>
>
> In the test method, testComplexTypeWithSimpleContentExtensionChangeSummary() listed below, a DataGraph is created with a dataObject whose property type extends a complexType with simple integer content. After the dataObject is deleted, an attempt is made to save and load the DataGraph. While the DataGraph is being loaded, an unsuccessful attempt is made to convert a zero-length string into a BigInteger. 
> Any suggestions on how to best fix this are most welcome.
> Thanks,
> - Ron
> ==============================
> substitutionWithExtensionValues.xsd
> ============================== 
> <schema xmlns="http://www.w3.org/2001/XMLSchema"
> 	targetNamespace="http://www.example.com/substitutionEV"
> 	xmlns:sev="http://www.example.com/substitutionEV">
> 	<!--
> 		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.    
> 	-->
> 	<element name="results" type="sev:ResultsType" />
> 	<element name="result" type="sev:ResultType" />
> 	<element name="myResult" type="sev:MyResultType"
> 		substitutionGroup="sev:result" />
> 	<complexType name="ResultsType">
> 		<sequence>
> 			<element name="id" type="sev:IdType" />
> 			<element ref="sev:result" minOccurs="0"
> 				maxOccurs="unbounded" />
> 			<element name="comment" type="sev:CommentType" />
> 		</sequence>
> 	</complexType>
> 	<complexType name="ResultType">
> 		<sequence>
> 			<element name="id" type="sev:IdType" />
> 			<element name="name" type="string" />
> 			<element name="value" type="sev:ValueType" />
> 		</sequence>
> 	</complexType>
> 	<complexType name="MyResultType">
> 		<complexContent>
> 			<extension base="sev:ResultType" />
> 		</complexContent>
> 	</complexType>
> 	<simpleType name="IdType">
> 		<restriction base="sev:AsciiStringType">
> 			<maxLength value="32" />
> 			<pattern value="[0-9a-fA-F]*" />
> 		</restriction>
> 	</simpleType>
> 	<simpleType name="AsciiStringType">
> 		<restriction base="string">
> 			<pattern value="\p{IsBasicLatin}*" />
> 		</restriction>
> 	</simpleType>
> 	<complexType name="ValueType">
> 		<simpleContent>
> 			<extension base="sev:Integer32Bit" />
> 		</simpleContent>
> 	</complexType>
> 	<complexType name="Integer32Bit">
> 		<simpleContent>
> 			<restriction base="integer">
> 				<minInclusive value="0" />
> 				<maxInclusive value="4290000000" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> 	
> 	<complexType name="CommentType">
> 		<simpleContent>
> 			<extension base="sev:AsciiStringType">
> 				<attribute name="language" use="optional">
> 					<simpleType>
> 						<restriction base="string">
> 							<enumeration value="English" />
> 							<enumeration value="French" />
> 							<enumeration value="Spanish" />
> 						</restriction>
> 					</simpleType>
> 				</attribute>
> 			</extension>
> 		</simpleContent>
> 	</complexType>
> 	<complexType name="MyCommentType">
> 		<simpleContent>
> 			<restriction base="sev:CommentType">
> 				<minLength value="0" />
> 				<maxLength value="40" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> 	<complexType name="StringBasedCommentType">
> 		<simpleContent>
> 			<restriction base="string">
> 				<minLength value="0" />
> 				<maxLength value="40" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> </schema>
> ==============================
> substitutionWithExtensionValues2.xsd
> ==============================
> <schema xmlns="http://www.w3.org/2001/XMLSchema"
> 	targetNamespace="http://www.example.com/substitutionEV2"
> 	xmlns:sev2="http://www.example.com/substitutionEV2"
> 	xmlns:sev="http://www.example.com/substitutionEV">
> 	<!--
> 		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.    
> 	-->
> 	<import namespace="http://www.example.com/substitutionEV"
> 		schemaLocation="substitutionWithExtensionValues.xsd" />
> 	<element name="allResults" type="sev2:AllResultsType" />
> 	<complexType name="AllResultsType">
> 		<sequence>
> 			<element name="id" type="sev2:Id2Type" />
> 			<element name="results" minOccurs="0" maxOccurs="unbounded"
> 				type="sev2:Results2Type" />
> 			<element name="comment" type="sev2:Comment2Type" />
> 		</sequence>
> 	</complexType>
> 	<complexType name="Results2Type">
> 		<complexContent>
> 			<extension base="sev:ResultsType"></extension>
> 		</complexContent>
> 	</complexType>
> 	<simpleType name="Id2Type">
> 		<restriction base="sev:IdType">
> 			<maxLength value="10" />
> 		</restriction>
> 	</simpleType>
> 	<complexType name="Comment2Type">
> 		<simpleContent>
> 			<restriction base="sev:CommentType">
> 				<minLength value="0" />
> 				<maxLength value="20" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> </schema>
> ==============================
> substitutionWithExtensionValues1.xml
> ==============================
> <?xml version="1.0" encoding="ASCII"?>
> <sev2:allResults xmlns:sev2="http://www.example.com/substitutionEV2">
> 	<sev2:id>ZZZZZZZZZZZZZZZZZZZZ</sev2:id>
> 	<sev:results xmlns:sev="http://www.example.com/substitutionEV">
> 		<sev:id>00000000000000000000</sev:id>
> 		<sev:result>
> 			<sev:id>11111111111111111111</sev:id>
> 			<sev:name>name1</sev:name>
> 			<sev:value>1</sev:value>
> 		</sev:result>
> 		<sev:myResult>
> 			<sev:id>22222222222222222222</sev:id>
> 			<sev:name>myName2</sev:name>
> 			<sev:value>2</sev:value>
> 		</sev:myResult>
> 		<sev:comment>comment0</sev:comment>
> 	</sev:results>
> 	<sev:results xmlns:sev="http://www.example.com/substitutionEV">
> 		<sev:id>AAAAAAAAAAAAAAAAAAAA</sev:id>
> 		<sev:myResult>
> 			<sev:id>BBBBBBBBBBBBBBBBBBBB</sev:id>
> 			<sev:name>myNameB</sev:name>
> 			<sev:value>11</sev:value>
> 		</sev:myResult>
> 		<sev:comment>commentA</sev:comment>
> 	</sev:results>
> 	<sev2:comment language="English">
> 		commentZZZZZZZZZZZZZZZZZZ
> 	</sev2:comment>
> </sev2:allResults>
> ==============================
> SubstitutionWithExtensionValuesTestCase.java
> ============================== 
> /**
>  *
>  *  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.sdo.test;
> import java.io.ByteArrayInputStream;
> import java.io.ByteArrayOutputStream;
> import java.io.IOException;
> import java.io.InputStream;
> import java.net.URL;
> import java.util.List;
> import junit.framework.TestCase;
> import org.apache.tuscany.sdo.api.SDOUtil;
> import org.eclipse.emf.common.util.Diagnostic;
> import org.eclipse.emf.ecore.EClass;
> import org.eclipse.emf.ecore.EDataType;
> import org.eclipse.emf.ecore.EObject;
> import org.eclipse.emf.ecore.EStructuralFeature;
> import org.eclipse.emf.ecore.util.Diagnostician;
> import org.eclipse.emf.ecore.util.ExtendedMetaData;
> import com.example.substitution.ev.SEVFactory;
> import com.example.substitution.ev.impl.SEVFactoryImpl;
> import commonj.sdo.DataGraph;
> import commonj.sdo.DataObject;
> import commonj.sdo.Property;
> import commonj.sdo.Type;
> import commonj.sdo.helper.HelperContext;
> import commonj.sdo.helper.TypeHelper;
> import commonj.sdo.impl.HelperProvider;
> public final class SubstitutionWithExtensionValuesTestCase extends TestCase 
> {
>   private static String sev2NamespaceURI;
>   private HelperContext hc;
>   private DataObject dataObject;
>   
>   protected void setUp() throws Exception {
>     super.setUp();
>     hc = HelperProvider.getDefaultContext();
>     registerSEV(hc, true);
>     
>     InputStream inputStream = null;
>     URL url = getClass().getResource("/substitutionWithExtensionValues2.xsd");
>     inputStream = url.openStream();
>     List sev2TypeList = hc.getXSDHelper().define(inputStream, url.toString());
>     inputStream.close();
>     
>     inputStream = getClass().getResourceAsStream("/substitutionWithExtensionValues1.xml");
>     dataObject = hc.getXMLHelper().load(inputStream).getRootObject();
>     inputStream.close();
>     
>     if (sev2NamespaceURI == null)
>     {
>       sev2NamespaceURI = ((Type) sev2TypeList.get(0)).getURI();
>     }
>   }
>   
>   private void registerSEV(HelperContext hc, boolean useStaticRegistration) throws IOException
>   {
>     if (useStaticRegistration)
>     {
>       SEVFactory.INSTANCE.register(hc);
>     }
>     else
>     {
>       InputStream inputStream = null;
>       URL url = getClass().getResource("/substitutionWithExtensionValues.xsd");
>       inputStream = url.openStream();
>       hc.getXSDHelper().define(inputStream, url.toString());
>       inputStream.close();
>     }
>   }
>   public void testComplexTypeWithSubstitutionExtension() throws IOException 
>   {
>     TypeHelper typeHelper = hc.getTypeHelper();
>     
>     Type resultsType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "ResultsType");
>     Type results2Type = typeHelper.getType(sev2NamespaceURI, "Results2Type");
>     assertTrue("Results2 type does not report Results as a base type", 
>         results2Type.getBaseTypes().contains(resultsType));
>     
>     assertEquals("results.1/myResult.0/id has unexpected value", 
>         "BBBBBBBBBBBBBBBBBBBB", dataObject.getString("results.1/myResult.0/id"));
>   }
>   
>   public void testComplexTypeWithSimpleContentExtensionMetaData() 
>   {
>     TypeHelper typeHelper = hc.getTypeHelper();
>     
>     Type stringBasedCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "StringBasedCommentType");
>     Type commentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "CommentType");
>     Type myCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "MyCommentType");
>     Type _myCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "_MyCommentType");
>     Type comment2Type = typeHelper.getType(sev2NamespaceURI, "Comment2Type");
>     Type _comment2Type = typeHelper.getType(sev2NamespaceURI, "_Comment2Type");
>     assertTrue("MyComment type does not report Comment as a base type", 
>         myCommentType.getBaseTypes().contains(commentType));
>     assertTrue("Comment2 type does not report Comment as a base type", 
>         comment2Type.getBaseTypes().contains(commentType));
>     
>     // Test length facets - resort to EMF APIs until Tuscany SDO exposes these directly
>     ExtendedMetaData extendedMetaData = ExtendedMetaData.INSTANCE;
>     EStructuralFeature simpleFeature = null;
>     EDataType commentSimpleType = null;
>     
>     simpleFeature = extendedMetaData.getSimpleFeature((EClass) stringBasedCommentType);
>     commentSimpleType = (EDataType)simpleFeature.getEType();
>     assertEquals(40, extendedMetaData.getMaxLengthFacet(commentSimpleType));
>     
>     // FIXME Work-around EMF's lack of support for re-definable features - SEE TUSCANY-1832
>     commentSimpleType = (EDataType) _myCommentType;
>     assertEquals(40, extendedMetaData.getMaxLengthFacet(commentSimpleType));
>     
>     // FIXME Work-around EMF's lack of support for re-definable features - SEE TUSCANY-1832
>     commentSimpleType = (EDataType) _comment2Type;
>     assertEquals(20, extendedMetaData.getMaxLengthFacet(commentSimpleType));
>   }
>   public void testComplexTypeWithSimpleContentExtensionChangeSummary() throws IOException 
>   {
>     DataGraph dg = SDOUtil.createDataGraph();
>     SDOUtil.setRootObject(dg, dataObject);
>     dg.getChangeSummary().beginLogging();
>     dataObject.getDataObject("results.1/myResult.0").delete();
>     ByteArrayOutputStream baos = new ByteArrayOutputStream();
>     SDOUtil.saveDataGraph(dg, baos, null);
>     ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
>     SDOUtil.loadDataGraph(bais, null, hc);
>   }    
>   
>   public void testSimpleTypeExtension() 
>   {
>     TypeHelper typeHelper = hc.getTypeHelper();
>     
>     Type asciiStringType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "AsciiStringType");
>     Type idType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "IdType");
>     assertTrue("IdType does not report AsciiStringType as a base type", 
>         idType.getBaseTypes().contains(asciiStringType));
>     
>     Diagnostic diagnostic = Diagnostician.INSTANCE.validate((EObject) dataObject);
>     String diagnosticMsg = diagnostic.getChildren().toString();
>     Type id2Type = typeHelper.getType(sev2NamespaceURI, "Id2Type");
>     assertTrue("Id2Type does not report IdType as a base type", 
>         id2Type.getBaseTypes().contains(idType));
>     assertTrue("EMF validation should have reported Id pattern match failure", 
>         diagnosticMsg.indexOf("Id") > 0);
>   }
> }
> STACKTRACE:
> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Value '' is not legal. (file:///C:/development/working/1/tuscany-sdo/sdo/tools-test/all.datagraph, 27, 48)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.handleErrors(XMLLoadImpl.java:83)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:193)
> 	at org.apache.tuscany.sdo.util.DataGraphResourceFactoryImpl$DataGraphResourceImpl$LoadImpl.load(DataGraphResourceFactoryImpl.java:455)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:179)
> 	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1094)
> 	at org.apache.tuscany.sdo.helper.SDOHelperImpl.loadDataGraph(SDOHelperImpl.java:139)
> 	at org.apache.tuscany.sdo.helper.SDOHelperImpl.loadDataGraph(SDOHelperImpl.java:157)
> 	at org.apache.tuscany.sdo.api.SDOUtil.loadDataGraph(SDOUtil.java:150)
> 	at org.apache.tuscany.sdo.test.SubstitutionWithExtensionValuesTestCase.testComplexTypeWithSimpleContentExtensionChangeSummary(SubstitutionWithExtensionValuesTestCase.java:150)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:585)
> 	at junit.framework.TestCase.runTest(TestCase.java:154)
> 	at junit.framework.TestCase.runBare(TestCase.java:127)
> 	at junit.framework.TestResult$1.protect(TestResult.java:106)
> 	at junit.framework.TestResult.runProtected(TestResult.java:124)
> 	at junit.framework.TestResult.run(TestResult.java:109)
> 	at junit.framework.TestCase.run(TestCase.java:118)
> 	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
> 	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
> Caused by: org.eclipse.emf.ecore.xmi.IllegalValueException: Value '' is not legal. (file:///C:/development/working/1/tuscany-sdo/sdo/tools-test/all.datagraph, 27, 48)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2421)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2406)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.endElement(XMLHandler.java:1347)
> 	at org.apache.tuscany.sdo.util.DataGraphResourceFactoryImpl$DataGraphResourceImpl$LoadImpl$1.endElement(DataGraphResourceFactoryImpl.java:627)
> 	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:633)
> 	at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:221)
> 	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:322)
> 	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1693)
> 	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
> 	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
> 	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
> 	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
> 	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
> 	at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:183)
> 	... 23 more
> Caused by: java.lang.NumberFormatException: Zero length BigInteger
> 	at java.math.BigInteger.<init>(BigInteger.java:275)
> 	at java.math.BigInteger.<init>(BigInteger.java:447)
> 	at org.eclipse.emf.ecore.xml.type.impl.XMLTypeFactoryImpl.createInteger(XMLTypeFactoryImpl.java:832)
> 	at org.apache.tuscany.sdo.model.impl.ModelFactoryImpl.createIntegerFromString(ModelFactoryImpl.java:2086)
> 	at com.example.substitution.ev.impl.SEVFactoryImpl.create_Integer32BitFromString(SEVFactoryImpl.java:754)
> 	at com.example.substitution.ev.impl.SEVFactoryImpl.createFromString(SEVFactoryImpl.java:143)
> 	at org.apache.tuscany.sdo.impl.FactoryBase$SDOEFactoryImpl.createFromString(FactoryBase.java:286)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createFromString(XMLHelperImpl.java:1489)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHelperImpl.java:1053)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2416)
> 	... 37 more
> SAVED PROBLEMATIC DATA GRAPH
> <?xml version="1.0" encoding="ASCII"?>
> <sdo:datagraph xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sdo="commonj.sdo"
>     xmlns:sdo_1="http://www.apache.org/tuscany/2005/SDO" xmlns:sev="http://www.example.com/substitutionEV"
>     xmlns:sev2="http://www.example.com/substitutionEV2">
>   <changeSummary xmlns=""
>       logging="true">
>     <objectChanges key="#//@eRootObject/@results.1">
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="resultGroup">
>         <listChanges index="0">
>           <featureMapEntryValues featureName="myResult" referenceValue="#//@eChangeSummary/@objectsToAttach.0"/>
>         </listChanges>
>       </value>
>     </objectChanges>
>     <objectChanges key="#//@eChangeSummary/@objectsToAttach.0">
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="value" set="false"
>           referenceValue="#//@eChangeSummary/@objectsToAttach.1"/>
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="id" dataValue="BBBBBBBBBBBBBBBBBBBB"
>           set="false"/>
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="name" dataValue="myNameB"
>           set="false"/>
>     </objectChanges>
>     <objectChanges key="#//@eChangeSummary/@objectsToAttach.1">
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="value" dataValue="11"
>           set="false"/>
>     </objectChanges>
>     <objectsToAttach xsi:type="sev:MyResultType"/>
>     <objectsToAttach xsi:type="sev:ValueType"/>
>   </changeSummary>
>   <sev2:AllResultsType>
>     <id>ZZZZZZZZZZZZZZZZZZZZ</id>
>     <results>
>       <id>00000000000000000000</id>
>       <sev:result>
>         <id>11111111111111111111</id>
>         <name>name1</name>
>         <value>1</value>
>       </sev:result>
>       <sev:myResult>
>         <id>22222222222222222222</id>
>         <name>myName2</name>
>         <value>2</value>
>       </sev:myResult>
>       <comment>comment0</comment>
>     </results>
>     <results>
>       <id>AAAAAAAAAAAAAAAAAAAA</id>
>       <comment>commentA</comment>
>     </results>
>     <comment language="English">
> 		commentZZZZZZZZZZZZZZZZZZ
> 	</comment>
>   </sev2:AllResultsType>
> </sdo:datagraph>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


[jira] Commented: (TUSCANY-1842) IOException loading DataGraph containing a deleted dataObject with a property whose type extends a complexType w/simple integer content

Posted by "Ron Gavlin (JIRA)" <tu...@ws.apache.org>.
    [ https://issues.apache.org/jira/browse/TUSCANY-1842?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12542235 ] 

Ron Gavlin commented on TUSCANY-1842:
-------------------------------------

Hi Kelvin,

Please ignore the in-line code/text included in this issue and only consider the content of the attached patch file. However, before applying the patch attached to this issue, please apply the patch for TUSCANY-1812. The patch for that issue includes updated versions of the in-line code appearing in this issue.

Let me know if you have questions.

- Ron

> IOException loading DataGraph containing a deleted dataObject with a property whose type extends a complexType w/simple integer content
> ---------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: TUSCANY-1842
>                 URL: https://issues.apache.org/jira/browse/TUSCANY-1842
>             Project: Tuscany
>          Issue Type: Bug
>          Components: Java SDO Implementation
>    Affects Versions: Java-SDO-Next
>         Environment: Windows XP, Sun JDK 1.5.0_09
>            Reporter: Ron Gavlin
>            Priority: Critical
>             Fix For: Java-SDO-Next
>
>         Attachments: 1842data.zip, tuscany-sdo.TUSCANY-1842.patch
>
>
> In the test method, testComplexTypeWithSimpleContentExtensionChangeSummary() listed below, a DataGraph is created with a dataObject whose property type extends a complexType with simple integer content. After the dataObject is deleted, an attempt is made to save and load the DataGraph. While the DataGraph is being loaded, an unsuccessful attempt is made to convert a zero-length string into a BigInteger. 
> Any suggestions on how to best fix this are most welcome.
> Thanks,
> - Ron
> ==============================
> substitutionWithExtensionValues.xsd
> ============================== 
> <schema xmlns="http://www.w3.org/2001/XMLSchema"
> 	targetNamespace="http://www.example.com/substitutionEV"
> 	xmlns:sev="http://www.example.com/substitutionEV">
> 	<!--
> 		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.    
> 	-->
> 	<element name="results" type="sev:ResultsType" />
> 	<element name="result" type="sev:ResultType" />
> 	<element name="myResult" type="sev:MyResultType"
> 		substitutionGroup="sev:result" />
> 	<complexType name="ResultsType">
> 		<sequence>
> 			<element name="id" type="sev:IdType" />
> 			<element ref="sev:result" minOccurs="0"
> 				maxOccurs="unbounded" />
> 			<element name="comment" type="sev:CommentType" />
> 		</sequence>
> 	</complexType>
> 	<complexType name="ResultType">
> 		<sequence>
> 			<element name="id" type="sev:IdType" />
> 			<element name="name" type="string" />
> 			<element name="value" type="sev:ValueType" />
> 		</sequence>
> 	</complexType>
> 	<complexType name="MyResultType">
> 		<complexContent>
> 			<extension base="sev:ResultType" />
> 		</complexContent>
> 	</complexType>
> 	<simpleType name="IdType">
> 		<restriction base="sev:AsciiStringType">
> 			<maxLength value="32" />
> 			<pattern value="[0-9a-fA-F]*" />
> 		</restriction>
> 	</simpleType>
> 	<simpleType name="AsciiStringType">
> 		<restriction base="string">
> 			<pattern value="\p{IsBasicLatin}*" />
> 		</restriction>
> 	</simpleType>
> 	<complexType name="ValueType">
> 		<simpleContent>
> 			<extension base="sev:Integer32Bit" />
> 		</simpleContent>
> 	</complexType>
> 	<complexType name="Integer32Bit">
> 		<simpleContent>
> 			<restriction base="integer">
> 				<minInclusive value="0" />
> 				<maxInclusive value="4290000000" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> 	
> 	<complexType name="CommentType">
> 		<simpleContent>
> 			<extension base="sev:AsciiStringType">
> 				<attribute name="language" use="optional">
> 					<simpleType>
> 						<restriction base="string">
> 							<enumeration value="English" />
> 							<enumeration value="French" />
> 							<enumeration value="Spanish" />
> 						</restriction>
> 					</simpleType>
> 				</attribute>
> 			</extension>
> 		</simpleContent>
> 	</complexType>
> 	<complexType name="MyCommentType">
> 		<simpleContent>
> 			<restriction base="sev:CommentType">
> 				<minLength value="0" />
> 				<maxLength value="40" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> 	<complexType name="StringBasedCommentType">
> 		<simpleContent>
> 			<restriction base="string">
> 				<minLength value="0" />
> 				<maxLength value="40" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> </schema>
> ==============================
> substitutionWithExtensionValues2.xsd
> ==============================
> <schema xmlns="http://www.w3.org/2001/XMLSchema"
> 	targetNamespace="http://www.example.com/substitutionEV2"
> 	xmlns:sev2="http://www.example.com/substitutionEV2"
> 	xmlns:sev="http://www.example.com/substitutionEV">
> 	<!--
> 		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.    
> 	-->
> 	<import namespace="http://www.example.com/substitutionEV"
> 		schemaLocation="substitutionWithExtensionValues.xsd" />
> 	<element name="allResults" type="sev2:AllResultsType" />
> 	<complexType name="AllResultsType">
> 		<sequence>
> 			<element name="id" type="sev2:Id2Type" />
> 			<element name="results" minOccurs="0" maxOccurs="unbounded"
> 				type="sev2:Results2Type" />
> 			<element name="comment" type="sev2:Comment2Type" />
> 		</sequence>
> 	</complexType>
> 	<complexType name="Results2Type">
> 		<complexContent>
> 			<extension base="sev:ResultsType"></extension>
> 		</complexContent>
> 	</complexType>
> 	<simpleType name="Id2Type">
> 		<restriction base="sev:IdType">
> 			<maxLength value="10" />
> 		</restriction>
> 	</simpleType>
> 	<complexType name="Comment2Type">
> 		<simpleContent>
> 			<restriction base="sev:CommentType">
> 				<minLength value="0" />
> 				<maxLength value="20" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> </schema>
> ==============================
> substitutionWithExtensionValues1.xml
> ==============================
> <?xml version="1.0" encoding="ASCII"?>
> <sev2:allResults xmlns:sev2="http://www.example.com/substitutionEV2">
> 	<sev2:id>ZZZZZZZZZZZZZZZZZZZZ</sev2:id>
> 	<sev:results xmlns:sev="http://www.example.com/substitutionEV">
> 		<sev:id>00000000000000000000</sev:id>
> 		<sev:result>
> 			<sev:id>11111111111111111111</sev:id>
> 			<sev:name>name1</sev:name>
> 			<sev:value>1</sev:value>
> 		</sev:result>
> 		<sev:myResult>
> 			<sev:id>22222222222222222222</sev:id>
> 			<sev:name>myName2</sev:name>
> 			<sev:value>2</sev:value>
> 		</sev:myResult>
> 		<sev:comment>comment0</sev:comment>
> 	</sev:results>
> 	<sev:results xmlns:sev="http://www.example.com/substitutionEV">
> 		<sev:id>AAAAAAAAAAAAAAAAAAAA</sev:id>
> 		<sev:myResult>
> 			<sev:id>BBBBBBBBBBBBBBBBBBBB</sev:id>
> 			<sev:name>myNameB</sev:name>
> 			<sev:value>11</sev:value>
> 		</sev:myResult>
> 		<sev:comment>commentA</sev:comment>
> 	</sev:results>
> 	<sev2:comment language="English">
> 		commentZZZZZZZZZZZZZZZZZZ
> 	</sev2:comment>
> </sev2:allResults>
> ==============================
> SubstitutionWithExtensionValuesTestCase.java
> ============================== 
> /**
>  *
>  *  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.sdo.test;
> import java.io.ByteArrayInputStream;
> import java.io.ByteArrayOutputStream;
> import java.io.IOException;
> import java.io.InputStream;
> import java.net.URL;
> import java.util.List;
> import junit.framework.TestCase;
> import org.apache.tuscany.sdo.api.SDOUtil;
> import org.eclipse.emf.common.util.Diagnostic;
> import org.eclipse.emf.ecore.EClass;
> import org.eclipse.emf.ecore.EDataType;
> import org.eclipse.emf.ecore.EObject;
> import org.eclipse.emf.ecore.EStructuralFeature;
> import org.eclipse.emf.ecore.util.Diagnostician;
> import org.eclipse.emf.ecore.util.ExtendedMetaData;
> import com.example.substitution.ev.SEVFactory;
> import com.example.substitution.ev.impl.SEVFactoryImpl;
> import commonj.sdo.DataGraph;
> import commonj.sdo.DataObject;
> import commonj.sdo.Property;
> import commonj.sdo.Type;
> import commonj.sdo.helper.HelperContext;
> import commonj.sdo.helper.TypeHelper;
> import commonj.sdo.impl.HelperProvider;
> public final class SubstitutionWithExtensionValuesTestCase extends TestCase 
> {
>   private static String sev2NamespaceURI;
>   private HelperContext hc;
>   private DataObject dataObject;
>   
>   protected void setUp() throws Exception {
>     super.setUp();
>     hc = HelperProvider.getDefaultContext();
>     registerSEV(hc, true);
>     
>     InputStream inputStream = null;
>     URL url = getClass().getResource("/substitutionWithExtensionValues2.xsd");
>     inputStream = url.openStream();
>     List sev2TypeList = hc.getXSDHelper().define(inputStream, url.toString());
>     inputStream.close();
>     
>     inputStream = getClass().getResourceAsStream("/substitutionWithExtensionValues1.xml");
>     dataObject = hc.getXMLHelper().load(inputStream).getRootObject();
>     inputStream.close();
>     
>     if (sev2NamespaceURI == null)
>     {
>       sev2NamespaceURI = ((Type) sev2TypeList.get(0)).getURI();
>     }
>   }
>   
>   private void registerSEV(HelperContext hc, boolean useStaticRegistration) throws IOException
>   {
>     if (useStaticRegistration)
>     {
>       SEVFactory.INSTANCE.register(hc);
>     }
>     else
>     {
>       InputStream inputStream = null;
>       URL url = getClass().getResource("/substitutionWithExtensionValues.xsd");
>       inputStream = url.openStream();
>       hc.getXSDHelper().define(inputStream, url.toString());
>       inputStream.close();
>     }
>   }
>   public void testComplexTypeWithSubstitutionExtension() throws IOException 
>   {
>     TypeHelper typeHelper = hc.getTypeHelper();
>     
>     Type resultsType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "ResultsType");
>     Type results2Type = typeHelper.getType(sev2NamespaceURI, "Results2Type");
>     assertTrue("Results2 type does not report Results as a base type", 
>         results2Type.getBaseTypes().contains(resultsType));
>     
>     assertEquals("results.1/myResult.0/id has unexpected value", 
>         "BBBBBBBBBBBBBBBBBBBB", dataObject.getString("results.1/myResult.0/id"));
>   }
>   
>   public void testComplexTypeWithSimpleContentExtensionMetaData() 
>   {
>     TypeHelper typeHelper = hc.getTypeHelper();
>     
>     Type stringBasedCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "StringBasedCommentType");
>     Type commentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "CommentType");
>     Type myCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "MyCommentType");
>     Type _myCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "_MyCommentType");
>     Type comment2Type = typeHelper.getType(sev2NamespaceURI, "Comment2Type");
>     Type _comment2Type = typeHelper.getType(sev2NamespaceURI, "_Comment2Type");
>     assertTrue("MyComment type does not report Comment as a base type", 
>         myCommentType.getBaseTypes().contains(commentType));
>     assertTrue("Comment2 type does not report Comment as a base type", 
>         comment2Type.getBaseTypes().contains(commentType));
>     
>     // Test length facets - resort to EMF APIs until Tuscany SDO exposes these directly
>     ExtendedMetaData extendedMetaData = ExtendedMetaData.INSTANCE;
>     EStructuralFeature simpleFeature = null;
>     EDataType commentSimpleType = null;
>     
>     simpleFeature = extendedMetaData.getSimpleFeature((EClass) stringBasedCommentType);
>     commentSimpleType = (EDataType)simpleFeature.getEType();
>     assertEquals(40, extendedMetaData.getMaxLengthFacet(commentSimpleType));
>     
>     // FIXME Work-around EMF's lack of support for re-definable features - SEE TUSCANY-1832
>     commentSimpleType = (EDataType) _myCommentType;
>     assertEquals(40, extendedMetaData.getMaxLengthFacet(commentSimpleType));
>     
>     // FIXME Work-around EMF's lack of support for re-definable features - SEE TUSCANY-1832
>     commentSimpleType = (EDataType) _comment2Type;
>     assertEquals(20, extendedMetaData.getMaxLengthFacet(commentSimpleType));
>   }
>   public void testComplexTypeWithSimpleContentExtensionChangeSummary() throws IOException 
>   {
>     DataGraph dg = SDOUtil.createDataGraph();
>     SDOUtil.setRootObject(dg, dataObject);
>     dg.getChangeSummary().beginLogging();
>     dataObject.getDataObject("results.1/myResult.0").delete();
>     ByteArrayOutputStream baos = new ByteArrayOutputStream();
>     SDOUtil.saveDataGraph(dg, baos, null);
>     ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
>     SDOUtil.loadDataGraph(bais, null, hc);
>   }    
>   
>   public void testSimpleTypeExtension() 
>   {
>     TypeHelper typeHelper = hc.getTypeHelper();
>     
>     Type asciiStringType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "AsciiStringType");
>     Type idType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "IdType");
>     assertTrue("IdType does not report AsciiStringType as a base type", 
>         idType.getBaseTypes().contains(asciiStringType));
>     
>     Diagnostic diagnostic = Diagnostician.INSTANCE.validate((EObject) dataObject);
>     String diagnosticMsg = diagnostic.getChildren().toString();
>     Type id2Type = typeHelper.getType(sev2NamespaceURI, "Id2Type");
>     assertTrue("Id2Type does not report IdType as a base type", 
>         id2Type.getBaseTypes().contains(idType));
>     assertTrue("EMF validation should have reported Id pattern match failure", 
>         diagnosticMsg.indexOf("Id") > 0);
>   }
> }
> STACKTRACE:
> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Value '' is not legal. (file:///C:/development/working/1/tuscany-sdo/sdo/tools-test/all.datagraph, 27, 48)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.handleErrors(XMLLoadImpl.java:83)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:193)
> 	at org.apache.tuscany.sdo.util.DataGraphResourceFactoryImpl$DataGraphResourceImpl$LoadImpl.load(DataGraphResourceFactoryImpl.java:455)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:179)
> 	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1094)
> 	at org.apache.tuscany.sdo.helper.SDOHelperImpl.loadDataGraph(SDOHelperImpl.java:139)
> 	at org.apache.tuscany.sdo.helper.SDOHelperImpl.loadDataGraph(SDOHelperImpl.java:157)
> 	at org.apache.tuscany.sdo.api.SDOUtil.loadDataGraph(SDOUtil.java:150)
> 	at org.apache.tuscany.sdo.test.SubstitutionWithExtensionValuesTestCase.testComplexTypeWithSimpleContentExtensionChangeSummary(SubstitutionWithExtensionValuesTestCase.java:150)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:585)
> 	at junit.framework.TestCase.runTest(TestCase.java:154)
> 	at junit.framework.TestCase.runBare(TestCase.java:127)
> 	at junit.framework.TestResult$1.protect(TestResult.java:106)
> 	at junit.framework.TestResult.runProtected(TestResult.java:124)
> 	at junit.framework.TestResult.run(TestResult.java:109)
> 	at junit.framework.TestCase.run(TestCase.java:118)
> 	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
> 	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
> Caused by: org.eclipse.emf.ecore.xmi.IllegalValueException: Value '' is not legal. (file:///C:/development/working/1/tuscany-sdo/sdo/tools-test/all.datagraph, 27, 48)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2421)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2406)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.endElement(XMLHandler.java:1347)
> 	at org.apache.tuscany.sdo.util.DataGraphResourceFactoryImpl$DataGraphResourceImpl$LoadImpl$1.endElement(DataGraphResourceFactoryImpl.java:627)
> 	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:633)
> 	at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:221)
> 	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:322)
> 	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1693)
> 	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
> 	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
> 	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
> 	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
> 	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
> 	at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:183)
> 	... 23 more
> Caused by: java.lang.NumberFormatException: Zero length BigInteger
> 	at java.math.BigInteger.<init>(BigInteger.java:275)
> 	at java.math.BigInteger.<init>(BigInteger.java:447)
> 	at org.eclipse.emf.ecore.xml.type.impl.XMLTypeFactoryImpl.createInteger(XMLTypeFactoryImpl.java:832)
> 	at org.apache.tuscany.sdo.model.impl.ModelFactoryImpl.createIntegerFromString(ModelFactoryImpl.java:2086)
> 	at com.example.substitution.ev.impl.SEVFactoryImpl.create_Integer32BitFromString(SEVFactoryImpl.java:754)
> 	at com.example.substitution.ev.impl.SEVFactoryImpl.createFromString(SEVFactoryImpl.java:143)
> 	at org.apache.tuscany.sdo.impl.FactoryBase$SDOEFactoryImpl.createFromString(FactoryBase.java:286)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createFromString(XMLHelperImpl.java:1489)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHelperImpl.java:1053)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2416)
> 	... 37 more
> SAVED PROBLEMATIC DATA GRAPH
> <?xml version="1.0" encoding="ASCII"?>
> <sdo:datagraph xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sdo="commonj.sdo"
>     xmlns:sdo_1="http://www.apache.org/tuscany/2005/SDO" xmlns:sev="http://www.example.com/substitutionEV"
>     xmlns:sev2="http://www.example.com/substitutionEV2">
>   <changeSummary xmlns=""
>       logging="true">
>     <objectChanges key="#//@eRootObject/@results.1">
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="resultGroup">
>         <listChanges index="0">
>           <featureMapEntryValues featureName="myResult" referenceValue="#//@eChangeSummary/@objectsToAttach.0"/>
>         </listChanges>
>       </value>
>     </objectChanges>
>     <objectChanges key="#//@eChangeSummary/@objectsToAttach.0">
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="value" set="false"
>           referenceValue="#//@eChangeSummary/@objectsToAttach.1"/>
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="id" dataValue="BBBBBBBBBBBBBBBBBBBB"
>           set="false"/>
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="name" dataValue="myNameB"
>           set="false"/>
>     </objectChanges>
>     <objectChanges key="#//@eChangeSummary/@objectsToAttach.1">
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="value" dataValue="11"
>           set="false"/>
>     </objectChanges>
>     <objectsToAttach xsi:type="sev:MyResultType"/>
>     <objectsToAttach xsi:type="sev:ValueType"/>
>   </changeSummary>
>   <sev2:AllResultsType>
>     <id>ZZZZZZZZZZZZZZZZZZZZ</id>
>     <results>
>       <id>00000000000000000000</id>
>       <sev:result>
>         <id>11111111111111111111</id>
>         <name>name1</name>
>         <value>1</value>
>       </sev:result>
>       <sev:myResult>
>         <id>22222222222222222222</id>
>         <name>myName2</name>
>         <value>2</value>
>       </sev:myResult>
>       <comment>comment0</comment>
>     </results>
>     <results>
>       <id>AAAAAAAAAAAAAAAAAAAA</id>
>       <comment>commentA</comment>
>     </results>
>     <comment language="English">
> 		commentZZZZZZZZZZZZZZZZZZ
> 	</comment>
>   </sev2:AllResultsType>
> </sdo:datagraph>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


[jira] Updated: (TUSCANY-1842) IOException loading DataGraph containing a deleted dataObject with a property whose type extends a complexType w/simple integer content

Posted by "Ron Gavlin (JIRA)" <tu...@ws.apache.org>.
     [ https://issues.apache.org/jira/browse/TUSCANY-1842?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ron Gavlin updated TUSCANY-1842:
--------------------------------

    Summary: IOException loading DataGraph containing a deleted dataObject with a property whose type extends a complexType w/simple integer content  (was: IOException loading DataGraph containing a deleted dataObject whose property type extends a complexType w/simple integer content)

Fix typo in Issue Summary

> IOException loading DataGraph containing a deleted dataObject with a property whose type extends a complexType w/simple integer content
> ---------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: TUSCANY-1842
>                 URL: https://issues.apache.org/jira/browse/TUSCANY-1842
>             Project: Tuscany
>          Issue Type: Bug
>          Components: Java SDO Implementation
>    Affects Versions: Java-SDO-Next
>         Environment: Windows XP, Sun JDK 1.5.0_09
>            Reporter: Ron Gavlin
>            Priority: Critical
>             Fix For: Java-SDO-Next
>
>
> In the test method, testComplexTypeWithSimpleContentExtensionChangeSummary() listed below, a DataGraph is created with a dataObject whose property type extends a complexType with simple integer content. After the dataObject is deleted, an attempt is made to save and load the DataGraph. While the DataGraph is being loaded, an unsuccessful attempt is made to convert a zero-length string into a BigInteger. 
> Any suggestions on how to best fix this are most welcome.
> Thanks,
> - Ron
> ==============================
> substitutionWithExtensionValues.xsd
> ============================== 
> <schema xmlns="http://www.w3.org/2001/XMLSchema"
> 	targetNamespace="http://www.example.com/substitutionEV"
> 	xmlns:sev="http://www.example.com/substitutionEV">
> 	<!--
> 		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.    
> 	-->
> 	<element name="results" type="sev:ResultsType" />
> 	<element name="result" type="sev:ResultType" />
> 	<element name="myResult" type="sev:MyResultType"
> 		substitutionGroup="sev:result" />
> 	<complexType name="ResultsType">
> 		<sequence>
> 			<element name="id" type="sev:IdType" />
> 			<element ref="sev:result" minOccurs="0"
> 				maxOccurs="unbounded" />
> 			<element name="comment" type="sev:CommentType" />
> 		</sequence>
> 	</complexType>
> 	<complexType name="ResultType">
> 		<sequence>
> 			<element name="id" type="sev:IdType" />
> 			<element name="name" type="string" />
> 			<element name="value" type="sev:ValueType" />
> 		</sequence>
> 	</complexType>
> 	<complexType name="MyResultType">
> 		<complexContent>
> 			<extension base="sev:ResultType" />
> 		</complexContent>
> 	</complexType>
> 	<simpleType name="IdType">
> 		<restriction base="sev:AsciiStringType">
> 			<maxLength value="32" />
> 			<pattern value="[0-9a-fA-F]*" />
> 		</restriction>
> 	</simpleType>
> 	<simpleType name="AsciiStringType">
> 		<restriction base="string">
> 			<pattern value="\p{IsBasicLatin}*" />
> 		</restriction>
> 	</simpleType>
> 	<complexType name="ValueType">
> 		<simpleContent>
> 			<extension base="sev:Integer32Bit" />
> 		</simpleContent>
> 	</complexType>
> 	<complexType name="Integer32Bit">
> 		<simpleContent>
> 			<restriction base="integer">
> 				<minInclusive value="0" />
> 				<maxInclusive value="4290000000" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> 	
> 	<complexType name="CommentType">
> 		<simpleContent>
> 			<extension base="sev:AsciiStringType">
> 				<attribute name="language" use="optional">
> 					<simpleType>
> 						<restriction base="string">
> 							<enumeration value="English" />
> 							<enumeration value="French" />
> 							<enumeration value="Spanish" />
> 						</restriction>
> 					</simpleType>
> 				</attribute>
> 			</extension>
> 		</simpleContent>
> 	</complexType>
> 	<complexType name="MyCommentType">
> 		<simpleContent>
> 			<restriction base="sev:CommentType">
> 				<minLength value="0" />
> 				<maxLength value="40" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> 	<complexType name="StringBasedCommentType">
> 		<simpleContent>
> 			<restriction base="string">
> 				<minLength value="0" />
> 				<maxLength value="40" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> </schema>
> ==============================
> substitutionWithExtensionValues2.xsd
> ==============================
> <schema xmlns="http://www.w3.org/2001/XMLSchema"
> 	targetNamespace="http://www.example.com/substitutionEV2"
> 	xmlns:sev2="http://www.example.com/substitutionEV2"
> 	xmlns:sev="http://www.example.com/substitutionEV">
> 	<!--
> 		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.    
> 	-->
> 	<import namespace="http://www.example.com/substitutionEV"
> 		schemaLocation="substitutionWithExtensionValues.xsd" />
> 	<element name="allResults" type="sev2:AllResultsType" />
> 	<complexType name="AllResultsType">
> 		<sequence>
> 			<element name="id" type="sev2:Id2Type" />
> 			<element name="results" minOccurs="0" maxOccurs="unbounded"
> 				type="sev2:Results2Type" />
> 			<element name="comment" type="sev2:Comment2Type" />
> 		</sequence>
> 	</complexType>
> 	<complexType name="Results2Type">
> 		<complexContent>
> 			<extension base="sev:ResultsType"></extension>
> 		</complexContent>
> 	</complexType>
> 	<simpleType name="Id2Type">
> 		<restriction base="sev:IdType">
> 			<maxLength value="10" />
> 		</restriction>
> 	</simpleType>
> 	<complexType name="Comment2Type">
> 		<simpleContent>
> 			<restriction base="sev:CommentType">
> 				<minLength value="0" />
> 				<maxLength value="20" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> </schema>
> ==============================
> substitutionWithExtensionValues1.xml
> ==============================
> <?xml version="1.0" encoding="ASCII"?>
> <sev2:allResults xmlns:sev2="http://www.example.com/substitutionEV2">
> 	<sev2:id>ZZZZZZZZZZZZZZZZZZZZ</sev2:id>
> 	<sev:results xmlns:sev="http://www.example.com/substitutionEV">
> 		<sev:id>00000000000000000000</sev:id>
> 		<sev:result>
> 			<sev:id>11111111111111111111</sev:id>
> 			<sev:name>name1</sev:name>
> 			<sev:value>1</sev:value>
> 		</sev:result>
> 		<sev:myResult>
> 			<sev:id>22222222222222222222</sev:id>
> 			<sev:name>myName2</sev:name>
> 			<sev:value>2</sev:value>
> 		</sev:myResult>
> 		<sev:comment>comment0</sev:comment>
> 	</sev:results>
> 	<sev:results xmlns:sev="http://www.example.com/substitutionEV">
> 		<sev:id>AAAAAAAAAAAAAAAAAAAA</sev:id>
> 		<sev:myResult>
> 			<sev:id>BBBBBBBBBBBBBBBBBBBB</sev:id>
> 			<sev:name>myNameB</sev:name>
> 			<sev:value>11</sev:value>
> 		</sev:myResult>
> 		<sev:comment>commentA</sev:comment>
> 	</sev:results>
> 	<sev2:comment language="English">
> 		commentZZZZZZZZZZZZZZZZZZ
> 	</sev2:comment>
> </sev2:allResults>
> ==============================
> SubstitutionWithExtensionValuesTestCase.java
> ============================== 
> /**
>  *
>  *  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.sdo.test;
> import java.io.ByteArrayInputStream;
> import java.io.ByteArrayOutputStream;
> import java.io.IOException;
> import java.io.InputStream;
> import java.net.URL;
> import java.util.List;
> import junit.framework.TestCase;
> import org.apache.tuscany.sdo.api.SDOUtil;
> import org.eclipse.emf.common.util.Diagnostic;
> import org.eclipse.emf.ecore.EClass;
> import org.eclipse.emf.ecore.EDataType;
> import org.eclipse.emf.ecore.EObject;
> import org.eclipse.emf.ecore.EStructuralFeature;
> import org.eclipse.emf.ecore.util.Diagnostician;
> import org.eclipse.emf.ecore.util.ExtendedMetaData;
> import com.example.substitution.ev.SEVFactory;
> import com.example.substitution.ev.impl.SEVFactoryImpl;
> import commonj.sdo.DataGraph;
> import commonj.sdo.DataObject;
> import commonj.sdo.Property;
> import commonj.sdo.Type;
> import commonj.sdo.helper.HelperContext;
> import commonj.sdo.helper.TypeHelper;
> import commonj.sdo.impl.HelperProvider;
> public final class SubstitutionWithExtensionValuesTestCase extends TestCase 
> {
>   private static String sev2NamespaceURI;
>   private HelperContext hc;
>   private DataObject dataObject;
>   
>   protected void setUp() throws Exception {
>     super.setUp();
>     hc = HelperProvider.getDefaultContext();
>     registerSEV(hc, true);
>     
>     InputStream inputStream = null;
>     URL url = getClass().getResource("/substitutionWithExtensionValues2.xsd");
>     inputStream = url.openStream();
>     List sev2TypeList = hc.getXSDHelper().define(inputStream, url.toString());
>     inputStream.close();
>     
>     inputStream = getClass().getResourceAsStream("/substitutionWithExtensionValues1.xml");
>     dataObject = hc.getXMLHelper().load(inputStream).getRootObject();
>     inputStream.close();
>     
>     if (sev2NamespaceURI == null)
>     {
>       sev2NamespaceURI = ((Type) sev2TypeList.get(0)).getURI();
>     }
>   }
>   
>   private void registerSEV(HelperContext hc, boolean useStaticRegistration) throws IOException
>   {
>     if (useStaticRegistration)
>     {
>       SEVFactory.INSTANCE.register(hc);
>     }
>     else
>     {
>       InputStream inputStream = null;
>       URL url = getClass().getResource("/substitutionWithExtensionValues.xsd");
>       inputStream = url.openStream();
>       hc.getXSDHelper().define(inputStream, url.toString());
>       inputStream.close();
>     }
>   }
>   public void testComplexTypeWithSubstitutionExtension() throws IOException 
>   {
>     TypeHelper typeHelper = hc.getTypeHelper();
>     
>     Type resultsType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "ResultsType");
>     Type results2Type = typeHelper.getType(sev2NamespaceURI, "Results2Type");
>     assertTrue("Results2 type does not report Results as a base type", 
>         results2Type.getBaseTypes().contains(resultsType));
>     
>     assertEquals("results.1/myResult.0/id has unexpected value", 
>         "BBBBBBBBBBBBBBBBBBBB", dataObject.getString("results.1/myResult.0/id"));
>   }
>   
>   public void testComplexTypeWithSimpleContentExtensionMetaData() 
>   {
>     TypeHelper typeHelper = hc.getTypeHelper();
>     
>     Type stringBasedCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "StringBasedCommentType");
>     Type commentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "CommentType");
>     Type myCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "MyCommentType");
>     Type _myCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "_MyCommentType");
>     Type comment2Type = typeHelper.getType(sev2NamespaceURI, "Comment2Type");
>     Type _comment2Type = typeHelper.getType(sev2NamespaceURI, "_Comment2Type");
>     assertTrue("MyComment type does not report Comment as a base type", 
>         myCommentType.getBaseTypes().contains(commentType));
>     assertTrue("Comment2 type does not report Comment as a base type", 
>         comment2Type.getBaseTypes().contains(commentType));
>     
>     // Test length facets - resort to EMF APIs until Tuscany SDO exposes these directly
>     ExtendedMetaData extendedMetaData = ExtendedMetaData.INSTANCE;
>     EStructuralFeature simpleFeature = null;
>     EDataType commentSimpleType = null;
>     
>     simpleFeature = extendedMetaData.getSimpleFeature((EClass) stringBasedCommentType);
>     commentSimpleType = (EDataType)simpleFeature.getEType();
>     assertEquals(40, extendedMetaData.getMaxLengthFacet(commentSimpleType));
>     
>     // FIXME Work-around EMF's lack of support for re-definable features - SEE TUSCANY-1832
>     commentSimpleType = (EDataType) _myCommentType;
>     assertEquals(40, extendedMetaData.getMaxLengthFacet(commentSimpleType));
>     
>     // FIXME Work-around EMF's lack of support for re-definable features - SEE TUSCANY-1832
>     commentSimpleType = (EDataType) _comment2Type;
>     assertEquals(20, extendedMetaData.getMaxLengthFacet(commentSimpleType));
>   }
>   public void testComplexTypeWithSimpleContentExtensionChangeSummary() throws IOException 
>   {
>     DataGraph dg = SDOUtil.createDataGraph();
>     SDOUtil.setRootObject(dg, dataObject);
>     dg.getChangeSummary().beginLogging();
>     dataObject.getDataObject("results.1/myResult.0").delete();
>     ByteArrayOutputStream baos = new ByteArrayOutputStream();
>     SDOUtil.saveDataGraph(dg, baos, null);
>     ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
>     SDOUtil.loadDataGraph(bais, null, hc);
>   }    
>   
>   public void testSimpleTypeExtension() 
>   {
>     TypeHelper typeHelper = hc.getTypeHelper();
>     
>     Type asciiStringType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "AsciiStringType");
>     Type idType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "IdType");
>     assertTrue("IdType does not report AsciiStringType as a base type", 
>         idType.getBaseTypes().contains(asciiStringType));
>     
>     Diagnostic diagnostic = Diagnostician.INSTANCE.validate((EObject) dataObject);
>     String diagnosticMsg = diagnostic.getChildren().toString();
>     Type id2Type = typeHelper.getType(sev2NamespaceURI, "Id2Type");
>     assertTrue("Id2Type does not report IdType as a base type", 
>         id2Type.getBaseTypes().contains(idType));
>     assertTrue("EMF validation should have reported Id pattern match failure", 
>         diagnosticMsg.indexOf("Id") > 0);
>   }
> }
> STACKTRACE:
> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Value '' is not legal. (file:///C:/development/working/1/tuscany-sdo/sdo/tools-test/all.datagraph, 27, 48)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.handleErrors(XMLLoadImpl.java:83)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:193)
> 	at org.apache.tuscany.sdo.util.DataGraphResourceFactoryImpl$DataGraphResourceImpl$LoadImpl.load(DataGraphResourceFactoryImpl.java:455)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:179)
> 	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1094)
> 	at org.apache.tuscany.sdo.helper.SDOHelperImpl.loadDataGraph(SDOHelperImpl.java:139)
> 	at org.apache.tuscany.sdo.helper.SDOHelperImpl.loadDataGraph(SDOHelperImpl.java:157)
> 	at org.apache.tuscany.sdo.api.SDOUtil.loadDataGraph(SDOUtil.java:150)
> 	at org.apache.tuscany.sdo.test.SubstitutionWithExtensionValuesTestCase.testComplexTypeWithSimpleContentExtensionChangeSummary(SubstitutionWithExtensionValuesTestCase.java:150)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:585)
> 	at junit.framework.TestCase.runTest(TestCase.java:154)
> 	at junit.framework.TestCase.runBare(TestCase.java:127)
> 	at junit.framework.TestResult$1.protect(TestResult.java:106)
> 	at junit.framework.TestResult.runProtected(TestResult.java:124)
> 	at junit.framework.TestResult.run(TestResult.java:109)
> 	at junit.framework.TestCase.run(TestCase.java:118)
> 	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
> 	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
> Caused by: org.eclipse.emf.ecore.xmi.IllegalValueException: Value '' is not legal. (file:///C:/development/working/1/tuscany-sdo/sdo/tools-test/all.datagraph, 27, 48)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2421)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2406)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.endElement(XMLHandler.java:1347)
> 	at org.apache.tuscany.sdo.util.DataGraphResourceFactoryImpl$DataGraphResourceImpl$LoadImpl$1.endElement(DataGraphResourceFactoryImpl.java:627)
> 	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:633)
> 	at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:221)
> 	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:322)
> 	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1693)
> 	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
> 	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
> 	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
> 	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
> 	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
> 	at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:183)
> 	... 23 more
> Caused by: java.lang.NumberFormatException: Zero length BigInteger
> 	at java.math.BigInteger.<init>(BigInteger.java:275)
> 	at java.math.BigInteger.<init>(BigInteger.java:447)
> 	at org.eclipse.emf.ecore.xml.type.impl.XMLTypeFactoryImpl.createInteger(XMLTypeFactoryImpl.java:832)
> 	at org.apache.tuscany.sdo.model.impl.ModelFactoryImpl.createIntegerFromString(ModelFactoryImpl.java:2086)
> 	at com.example.substitution.ev.impl.SEVFactoryImpl.create_Integer32BitFromString(SEVFactoryImpl.java:754)
> 	at com.example.substitution.ev.impl.SEVFactoryImpl.createFromString(SEVFactoryImpl.java:143)
> 	at org.apache.tuscany.sdo.impl.FactoryBase$SDOEFactoryImpl.createFromString(FactoryBase.java:286)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createFromString(XMLHelperImpl.java:1489)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHelperImpl.java:1053)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2416)
> 	... 37 more

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


[jira] Updated: (TUSCANY-1842) IOException loading DataGraph containing a deleted dataObject with a property whose type extends a complexType w/simple integer content

Posted by "Amita Vadhavkar (JIRA)" <tu...@ws.apache.org>.
     [ https://issues.apache.org/jira/browse/TUSCANY-1842?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Amita Vadhavkar updated TUSCANY-1842:
-------------------------------------

    Fix Version/s:     (was: Java-SDO-Next)
                   Java-SDO-1.1

> IOException loading DataGraph containing a deleted dataObject with a property whose type extends a complexType w/simple integer content
> ---------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: TUSCANY-1842
>                 URL: https://issues.apache.org/jira/browse/TUSCANY-1842
>             Project: Tuscany
>          Issue Type: Bug
>          Components: Java SDO Implementation
>    Affects Versions: Java-SDO-Next
>         Environment: Windows XP, Sun JDK 1.5.0_09
>            Reporter: Ron Gavlin
>            Priority: Critical
>             Fix For: Java-SDO-1.1
>
>         Attachments: 1842data.zip, tuscany-sdo.TUSCANY-1842.patch
>
>
> In the test method, testComplexTypeWithSimpleContentExtensionChangeSummary() listed below, a DataGraph is created with a dataObject whose property type extends a complexType with simple integer content. After the dataObject is deleted, an attempt is made to save and load the DataGraph. While the DataGraph is being loaded, an unsuccessful attempt is made to convert a zero-length string into a BigInteger. 
> Any suggestions on how to best fix this are most welcome.
> Thanks,
> - Ron
> ==============================
> substitutionWithExtensionValues.xsd
> ============================== 
> <schema xmlns="http://www.w3.org/2001/XMLSchema"
> 	targetNamespace="http://www.example.com/substitutionEV"
> 	xmlns:sev="http://www.example.com/substitutionEV">
> 	<!--
> 		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.    
> 	-->
> 	<element name="results" type="sev:ResultsType" />
> 	<element name="result" type="sev:ResultType" />
> 	<element name="myResult" type="sev:MyResultType"
> 		substitutionGroup="sev:result" />
> 	<complexType name="ResultsType">
> 		<sequence>
> 			<element name="id" type="sev:IdType" />
> 			<element ref="sev:result" minOccurs="0"
> 				maxOccurs="unbounded" />
> 			<element name="comment" type="sev:CommentType" />
> 		</sequence>
> 	</complexType>
> 	<complexType name="ResultType">
> 		<sequence>
> 			<element name="id" type="sev:IdType" />
> 			<element name="name" type="string" />
> 			<element name="value" type="sev:ValueType" />
> 		</sequence>
> 	</complexType>
> 	<complexType name="MyResultType">
> 		<complexContent>
> 			<extension base="sev:ResultType" />
> 		</complexContent>
> 	</complexType>
> 	<simpleType name="IdType">
> 		<restriction base="sev:AsciiStringType">
> 			<maxLength value="32" />
> 			<pattern value="[0-9a-fA-F]*" />
> 		</restriction>
> 	</simpleType>
> 	<simpleType name="AsciiStringType">
> 		<restriction base="string">
> 			<pattern value="\p{IsBasicLatin}*" />
> 		</restriction>
> 	</simpleType>
> 	<complexType name="ValueType">
> 		<simpleContent>
> 			<extension base="sev:Integer32Bit" />
> 		</simpleContent>
> 	</complexType>
> 	<complexType name="Integer32Bit">
> 		<simpleContent>
> 			<restriction base="integer">
> 				<minInclusive value="0" />
> 				<maxInclusive value="4290000000" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> 	
> 	<complexType name="CommentType">
> 		<simpleContent>
> 			<extension base="sev:AsciiStringType">
> 				<attribute name="language" use="optional">
> 					<simpleType>
> 						<restriction base="string">
> 							<enumeration value="English" />
> 							<enumeration value="French" />
> 							<enumeration value="Spanish" />
> 						</restriction>
> 					</simpleType>
> 				</attribute>
> 			</extension>
> 		</simpleContent>
> 	</complexType>
> 	<complexType name="MyCommentType">
> 		<simpleContent>
> 			<restriction base="sev:CommentType">
> 				<minLength value="0" />
> 				<maxLength value="40" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> 	<complexType name="StringBasedCommentType">
> 		<simpleContent>
> 			<restriction base="string">
> 				<minLength value="0" />
> 				<maxLength value="40" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> </schema>
> ==============================
> substitutionWithExtensionValues2.xsd
> ==============================
> <schema xmlns="http://www.w3.org/2001/XMLSchema"
> 	targetNamespace="http://www.example.com/substitutionEV2"
> 	xmlns:sev2="http://www.example.com/substitutionEV2"
> 	xmlns:sev="http://www.example.com/substitutionEV">
> 	<!--
> 		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.    
> 	-->
> 	<import namespace="http://www.example.com/substitutionEV"
> 		schemaLocation="substitutionWithExtensionValues.xsd" />
> 	<element name="allResults" type="sev2:AllResultsType" />
> 	<complexType name="AllResultsType">
> 		<sequence>
> 			<element name="id" type="sev2:Id2Type" />
> 			<element name="results" minOccurs="0" maxOccurs="unbounded"
> 				type="sev2:Results2Type" />
> 			<element name="comment" type="sev2:Comment2Type" />
> 		</sequence>
> 	</complexType>
> 	<complexType name="Results2Type">
> 		<complexContent>
> 			<extension base="sev:ResultsType"></extension>
> 		</complexContent>
> 	</complexType>
> 	<simpleType name="Id2Type">
> 		<restriction base="sev:IdType">
> 			<maxLength value="10" />
> 		</restriction>
> 	</simpleType>
> 	<complexType name="Comment2Type">
> 		<simpleContent>
> 			<restriction base="sev:CommentType">
> 				<minLength value="0" />
> 				<maxLength value="20" />
> 			</restriction>
> 		</simpleContent>
> 	</complexType>
> </schema>
> ==============================
> substitutionWithExtensionValues1.xml
> ==============================
> <?xml version="1.0" encoding="ASCII"?>
> <sev2:allResults xmlns:sev2="http://www.example.com/substitutionEV2">
> 	<sev2:id>ZZZZZZZZZZZZZZZZZZZZ</sev2:id>
> 	<sev:results xmlns:sev="http://www.example.com/substitutionEV">
> 		<sev:id>00000000000000000000</sev:id>
> 		<sev:result>
> 			<sev:id>11111111111111111111</sev:id>
> 			<sev:name>name1</sev:name>
> 			<sev:value>1</sev:value>
> 		</sev:result>
> 		<sev:myResult>
> 			<sev:id>22222222222222222222</sev:id>
> 			<sev:name>myName2</sev:name>
> 			<sev:value>2</sev:value>
> 		</sev:myResult>
> 		<sev:comment>comment0</sev:comment>
> 	</sev:results>
> 	<sev:results xmlns:sev="http://www.example.com/substitutionEV">
> 		<sev:id>AAAAAAAAAAAAAAAAAAAA</sev:id>
> 		<sev:myResult>
> 			<sev:id>BBBBBBBBBBBBBBBBBBBB</sev:id>
> 			<sev:name>myNameB</sev:name>
> 			<sev:value>11</sev:value>
> 		</sev:myResult>
> 		<sev:comment>commentA</sev:comment>
> 	</sev:results>
> 	<sev2:comment language="English">
> 		commentZZZZZZZZZZZZZZZZZZ
> 	</sev2:comment>
> </sev2:allResults>
> ==============================
> SubstitutionWithExtensionValuesTestCase.java
> ============================== 
> /**
>  *
>  *  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.sdo.test;
> import java.io.ByteArrayInputStream;
> import java.io.ByteArrayOutputStream;
> import java.io.IOException;
> import java.io.InputStream;
> import java.net.URL;
> import java.util.List;
> import junit.framework.TestCase;
> import org.apache.tuscany.sdo.api.SDOUtil;
> import org.eclipse.emf.common.util.Diagnostic;
> import org.eclipse.emf.ecore.EClass;
> import org.eclipse.emf.ecore.EDataType;
> import org.eclipse.emf.ecore.EObject;
> import org.eclipse.emf.ecore.EStructuralFeature;
> import org.eclipse.emf.ecore.util.Diagnostician;
> import org.eclipse.emf.ecore.util.ExtendedMetaData;
> import com.example.substitution.ev.SEVFactory;
> import com.example.substitution.ev.impl.SEVFactoryImpl;
> import commonj.sdo.DataGraph;
> import commonj.sdo.DataObject;
> import commonj.sdo.Property;
> import commonj.sdo.Type;
> import commonj.sdo.helper.HelperContext;
> import commonj.sdo.helper.TypeHelper;
> import commonj.sdo.impl.HelperProvider;
> public final class SubstitutionWithExtensionValuesTestCase extends TestCase 
> {
>   private static String sev2NamespaceURI;
>   private HelperContext hc;
>   private DataObject dataObject;
>   
>   protected void setUp() throws Exception {
>     super.setUp();
>     hc = HelperProvider.getDefaultContext();
>     registerSEV(hc, true);
>     
>     InputStream inputStream = null;
>     URL url = getClass().getResource("/substitutionWithExtensionValues2.xsd");
>     inputStream = url.openStream();
>     List sev2TypeList = hc.getXSDHelper().define(inputStream, url.toString());
>     inputStream.close();
>     
>     inputStream = getClass().getResourceAsStream("/substitutionWithExtensionValues1.xml");
>     dataObject = hc.getXMLHelper().load(inputStream).getRootObject();
>     inputStream.close();
>     
>     if (sev2NamespaceURI == null)
>     {
>       sev2NamespaceURI = ((Type) sev2TypeList.get(0)).getURI();
>     }
>   }
>   
>   private void registerSEV(HelperContext hc, boolean useStaticRegistration) throws IOException
>   {
>     if (useStaticRegistration)
>     {
>       SEVFactory.INSTANCE.register(hc);
>     }
>     else
>     {
>       InputStream inputStream = null;
>       URL url = getClass().getResource("/substitutionWithExtensionValues.xsd");
>       inputStream = url.openStream();
>       hc.getXSDHelper().define(inputStream, url.toString());
>       inputStream.close();
>     }
>   }
>   public void testComplexTypeWithSubstitutionExtension() throws IOException 
>   {
>     TypeHelper typeHelper = hc.getTypeHelper();
>     
>     Type resultsType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "ResultsType");
>     Type results2Type = typeHelper.getType(sev2NamespaceURI, "Results2Type");
>     assertTrue("Results2 type does not report Results as a base type", 
>         results2Type.getBaseTypes().contains(resultsType));
>     
>     assertEquals("results.1/myResult.0/id has unexpected value", 
>         "BBBBBBBBBBBBBBBBBBBB", dataObject.getString("results.1/myResult.0/id"));
>   }
>   
>   public void testComplexTypeWithSimpleContentExtensionMetaData() 
>   {
>     TypeHelper typeHelper = hc.getTypeHelper();
>     
>     Type stringBasedCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "StringBasedCommentType");
>     Type commentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "CommentType");
>     Type myCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "MyCommentType");
>     Type _myCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "_MyCommentType");
>     Type comment2Type = typeHelper.getType(sev2NamespaceURI, "Comment2Type");
>     Type _comment2Type = typeHelper.getType(sev2NamespaceURI, "_Comment2Type");
>     assertTrue("MyComment type does not report Comment as a base type", 
>         myCommentType.getBaseTypes().contains(commentType));
>     assertTrue("Comment2 type does not report Comment as a base type", 
>         comment2Type.getBaseTypes().contains(commentType));
>     
>     // Test length facets - resort to EMF APIs until Tuscany SDO exposes these directly
>     ExtendedMetaData extendedMetaData = ExtendedMetaData.INSTANCE;
>     EStructuralFeature simpleFeature = null;
>     EDataType commentSimpleType = null;
>     
>     simpleFeature = extendedMetaData.getSimpleFeature((EClass) stringBasedCommentType);
>     commentSimpleType = (EDataType)simpleFeature.getEType();
>     assertEquals(40, extendedMetaData.getMaxLengthFacet(commentSimpleType));
>     
>     // FIXME Work-around EMF's lack of support for re-definable features - SEE TUSCANY-1832
>     commentSimpleType = (EDataType) _myCommentType;
>     assertEquals(40, extendedMetaData.getMaxLengthFacet(commentSimpleType));
>     
>     // FIXME Work-around EMF's lack of support for re-definable features - SEE TUSCANY-1832
>     commentSimpleType = (EDataType) _comment2Type;
>     assertEquals(20, extendedMetaData.getMaxLengthFacet(commentSimpleType));
>   }
>   public void testComplexTypeWithSimpleContentExtensionChangeSummary() throws IOException 
>   {
>     DataGraph dg = SDOUtil.createDataGraph();
>     SDOUtil.setRootObject(dg, dataObject);
>     dg.getChangeSummary().beginLogging();
>     dataObject.getDataObject("results.1/myResult.0").delete();
>     ByteArrayOutputStream baos = new ByteArrayOutputStream();
>     SDOUtil.saveDataGraph(dg, baos, null);
>     ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
>     SDOUtil.loadDataGraph(bais, null, hc);
>   }    
>   
>   public void testSimpleTypeExtension() 
>   {
>     TypeHelper typeHelper = hc.getTypeHelper();
>     
>     Type asciiStringType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "AsciiStringType");
>     Type idType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "IdType");
>     assertTrue("IdType does not report AsciiStringType as a base type", 
>         idType.getBaseTypes().contains(asciiStringType));
>     
>     Diagnostic diagnostic = Diagnostician.INSTANCE.validate((EObject) dataObject);
>     String diagnosticMsg = diagnostic.getChildren().toString();
>     Type id2Type = typeHelper.getType(sev2NamespaceURI, "Id2Type");
>     assertTrue("Id2Type does not report IdType as a base type", 
>         id2Type.getBaseTypes().contains(idType));
>     assertTrue("EMF validation should have reported Id pattern match failure", 
>         diagnosticMsg.indexOf("Id") > 0);
>   }
> }
> STACKTRACE:
> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Value '' is not legal. (file:///C:/development/working/1/tuscany-sdo/sdo/tools-test/all.datagraph, 27, 48)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.handleErrors(XMLLoadImpl.java:83)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:193)
> 	at org.apache.tuscany.sdo.util.DataGraphResourceFactoryImpl$DataGraphResourceImpl$LoadImpl.load(DataGraphResourceFactoryImpl.java:455)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:179)
> 	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1094)
> 	at org.apache.tuscany.sdo.helper.SDOHelperImpl.loadDataGraph(SDOHelperImpl.java:139)
> 	at org.apache.tuscany.sdo.helper.SDOHelperImpl.loadDataGraph(SDOHelperImpl.java:157)
> 	at org.apache.tuscany.sdo.api.SDOUtil.loadDataGraph(SDOUtil.java:150)
> 	at org.apache.tuscany.sdo.test.SubstitutionWithExtensionValuesTestCase.testComplexTypeWithSimpleContentExtensionChangeSummary(SubstitutionWithExtensionValuesTestCase.java:150)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:585)
> 	at junit.framework.TestCase.runTest(TestCase.java:154)
> 	at junit.framework.TestCase.runBare(TestCase.java:127)
> 	at junit.framework.TestResult$1.protect(TestResult.java:106)
> 	at junit.framework.TestResult.runProtected(TestResult.java:124)
> 	at junit.framework.TestResult.run(TestResult.java:109)
> 	at junit.framework.TestCase.run(TestCase.java:118)
> 	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
> 	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
> Caused by: org.eclipse.emf.ecore.xmi.IllegalValueException: Value '' is not legal. (file:///C:/development/working/1/tuscany-sdo/sdo/tools-test/all.datagraph, 27, 48)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2421)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2406)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.endElement(XMLHandler.java:1347)
> 	at org.apache.tuscany.sdo.util.DataGraphResourceFactoryImpl$DataGraphResourceImpl$LoadImpl$1.endElement(DataGraphResourceFactoryImpl.java:627)
> 	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:633)
> 	at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:221)
> 	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:322)
> 	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1693)
> 	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
> 	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
> 	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
> 	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
> 	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
> 	at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:183)
> 	... 23 more
> Caused by: java.lang.NumberFormatException: Zero length BigInteger
> 	at java.math.BigInteger.<init>(BigInteger.java:275)
> 	at java.math.BigInteger.<init>(BigInteger.java:447)
> 	at org.eclipse.emf.ecore.xml.type.impl.XMLTypeFactoryImpl.createInteger(XMLTypeFactoryImpl.java:832)
> 	at org.apache.tuscany.sdo.model.impl.ModelFactoryImpl.createIntegerFromString(ModelFactoryImpl.java:2086)
> 	at com.example.substitution.ev.impl.SEVFactoryImpl.create_Integer32BitFromString(SEVFactoryImpl.java:754)
> 	at com.example.substitution.ev.impl.SEVFactoryImpl.createFromString(SEVFactoryImpl.java:143)
> 	at org.apache.tuscany.sdo.impl.FactoryBase$SDOEFactoryImpl.createFromString(FactoryBase.java:286)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createFromString(XMLHelperImpl.java:1489)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHelperImpl.java:1053)
> 	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2416)
> 	... 37 more
> SAVED PROBLEMATIC DATA GRAPH
> <?xml version="1.0" encoding="ASCII"?>
> <sdo:datagraph xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sdo="commonj.sdo"
>     xmlns:sdo_1="http://www.apache.org/tuscany/2005/SDO" xmlns:sev="http://www.example.com/substitutionEV"
>     xmlns:sev2="http://www.example.com/substitutionEV2">
>   <changeSummary xmlns=""
>       logging="true">
>     <objectChanges key="#//@eRootObject/@results.1">
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="resultGroup">
>         <listChanges index="0">
>           <featureMapEntryValues featureName="myResult" referenceValue="#//@eChangeSummary/@objectsToAttach.0"/>
>         </listChanges>
>       </value>
>     </objectChanges>
>     <objectChanges key="#//@eChangeSummary/@objectsToAttach.0">
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="value" set="false"
>           referenceValue="#//@eChangeSummary/@objectsToAttach.1"/>
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="id" dataValue="BBBBBBBBBBBBBBBBBBBB"
>           set="false"/>
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="name" dataValue="myNameB"
>           set="false"/>
>     </objectChanges>
>     <objectChanges key="#//@eChangeSummary/@objectsToAttach.1">
>       <value xsi:type="sdo_1:ChangeSummarySetting" featureName="value" dataValue="11"
>           set="false"/>
>     </objectChanges>
>     <objectsToAttach xsi:type="sev:MyResultType"/>
>     <objectsToAttach xsi:type="sev:ValueType"/>
>   </changeSummary>
>   <sev2:AllResultsType>
>     <id>ZZZZZZZZZZZZZZZZZZZZ</id>
>     <results>
>       <id>00000000000000000000</id>
>       <sev:result>
>         <id>11111111111111111111</id>
>         <name>name1</name>
>         <value>1</value>
>       </sev:result>
>       <sev:myResult>
>         <id>22222222222222222222</id>
>         <name>myName2</name>
>         <value>2</value>
>       </sev:myResult>
>       <comment>comment0</comment>
>     </results>
>     <results>
>       <id>AAAAAAAAAAAAAAAAAAAA</id>
>       <comment>commentA</comment>
>     </results>
>     <comment language="English">
> 		commentZZZZZZZZZZZZZZZZZZ
> 	</comment>
>   </sev2:AllResultsType>
> </sdo:datagraph>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org