yhknight / odata4j

Automatically exported from code.google.com/p/odata4j
0 stars 0 forks source link

OData4j unit tests failing on IBM jvm due to StAX library #236

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
Run the odata4j-core with an IBM jvm. (webpshere one for example)

What is the expected output? What do you see instead?
Successful unit tests, but instead, I get multiple:
java.lang.RuntimeException: javax.xml.stream.XMLStreamException: The namespace 
URI "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" has not 
been bound to a prefix.
    at org.odata4j.core.Throwables.propagate(Throwables.java:11)
    at org.odata4j.stax2.staximpl.StaxXMLWriter2.writeAttribute(StaxXMLWriter2.java:100)
    at org.odata4j.format.xml.EdmxFormatWriter.write(EdmxFormatWriter.java:46)
    at org.odata4j.test.unit.format.xml.EdmxFormatWriterTest.testReferentialConstraint(EdmxFormatWriterTest.java:110)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:611)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: javax.xml.stream.XMLStreamException: The namespace URI 
"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" has not been 
bound to a prefix.
    at com.ibm.xml.xlxp.api.stax.msg.StAXMessageProvider.throwXMLStreamException(StAXMessageProvider.java:59)
    at com.ibm.xml.xlxp.api.stax.XMLStreamWriterBase.writeAttribute(XMLStreamWriterBase.java:468)
    at com.ibm.xml.xlxp.api.stax.XMLEventWriterImpl.writeAttribute(XMLEventWriterImpl.java:279)
    at com.ibm.xml.xlxp.api.stax.XMLEventWriterImpl.add(XMLEventWriterImpl.java:118)
    at org.odata4j.stax2.staximpl.StaxXMLWriter2.writeAttribute(StaxXMLWriter2.java:97)
    ... 26 more

Please note, that the problem also affects runtime usage of OData4j not only 
unit tests.

What version of the product are you using? On what operating system?
Latest trunk rev bc266b0751bb on win7.

Please provide any additional information below.

The problem is due to the sensitivity of the IBM StAX library.
It does not accept the usage of a namespace prefix before namespace defintion.
For example:
<edmx:DataServices m:DataServiceVersion="2.0" 
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
will fail, but
<edmx:DataServices 
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" 
m:DataServiceVersion="2.0">
will success.

The fix is simply to put namespace definition before the prefix usage in class 
'EdmxFormatWriter'.

Th patch containing fix and test-case is attached to this issue.

Original issue reported on code.google.com by samuel.v...@gmail.com on 19 Dec 2012 at 2:07

Attachments: