Details

    • Type: Improvement Improvement
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.3.3rc1
    • Fix Version/s: 1.3.3rc1
    • Component/s: JAXB
    • Labels:
      None
    • Number of attachments :
      7

      Description

      The idea of this task is to improve the current implementation of jaxb by implementing missing functionality.

      1. CastorMarshallerTest.patch
        19 kB
        Jakub Narloch
      2. CastorUnmarshallerTest.patch
        20 kB
        Jakub Narloch
      3. Code_refactoring_and_documentation_.patch
        42 kB
        Jakub Narloch
      4. Renamed_the_fascade_classes.patch
        69 kB
        Jakub Narloch
      5. Revised_the_implementation.patch
        20 kB
        Jakub Narloch
      6. UPDATE_TO_CASTOR_1_3_2.patch
        1 kB
        Jakub Narloch
      7. Updated_Tests_to_JUnit_4_x.patch
        63 kB
        Jakub Narloch

        Activity

        Hide
        Jakub Narloch added a comment -

        First observation, it would be wise to switch the dependant version of the Castor XML from 1.3.2 to 1.3.3,
        that would provide the support for the STaX and (javax.xml.transform) Source/Result.

        Show
        Jakub Narloch added a comment - First observation, it would be wise to switch the dependant version of the Castor XML from 1.3.2 to 1.3.3, that would provide the support for the STaX and (javax.xml.transform) Source/Result.
        Hide
        Ralf Joachim added a comment -

        I don't think this is a good idea because, after a new release other users won't be able to build until the new snapshot has been deployed in maven repository. Therefore we should only depend on the last public relase which is 1.3.2 at this time.

        Show
        Ralf Joachim added a comment - I don't think this is a good idea because, after a new release other users won't be able to build until the new snapshot has been deployed in maven repository. Therefore we should only depend on the last public relase which is 1.3.2 at this time.
        Hide
        Jakub Narloch added a comment - - edited

        List of methods from (Un-)Marshaller that require implementation:

        Marshaller:

        • public < A extends XmlAdapter > A getAdapter(final Class < A > xmlAdapter)
        • public AttachmentMarshaller getAttachmentMarshaller()
        • public Node getNode(final Object node)
        • public void marshal(final Object object, final XMLStreamWriter xmlStreamWriter)
        • public void marshal(final Object object, final XMLEventWriter xmlEventWriter)
        • public void setAdapter(final XmlAdapter arg0)
        • public < A extends XmlAdapter > void setAdapter(final Class < A > arg0, final A arg1)
        • public void setAttachmentMarshaller(final AttachmentMarshaller arg0)

        Unmarshaller:

        • public < A extends XmlAdapter > A getAdapter(final Class < A > arg0)
        • public AttachmentUnmarshaller getAttachmentUnmarshaller()
        • public ValidationEventHandler getEventHandler()
        • public Schema getSchema()
        • public UnmarshallerHandler getUnmarshallerHandler()
        • public void setAdapter(final XmlAdapter xmlAdapter)
        • public < A extends XmlAdapter > void setAdapter(final Class < A > type, final A xmlAdapter)
        • public void setAttachmentUnmarshaller(final AttachmentUnmarshaller attachmentUnmarshaller)
        • public void setEventHandler(final ValidationEventHandler validationEventHandler)
        • public void setSchema(final Schema schema)
        • public Object unmarshal(final XMLStreamReader xmlStreamReader)
        • public Object unmarshal(final XMLEventReader xmlEventReader)
        • public < T > JAXBElement < T > unmarshal(final Node node, final Class < T > type)
        • public < T > JAXBElement < T > unmarshal(final Source node, final Class < T > type)
        • public < T > JAXBElement < T > unmarshal(final XMLStreamReader xmlStreamReader, final Class < T > type)
        • public < T > JAXBElement < T > unmarshal(final XMLEventReader xmlEventReader, final Class < T > type)

        JAXBContext:

        • public Validator createValidator() throws JAXBException
        • public <T> Binder<T> createBinder(final Class<T> domType)
        • public Binder<org.w3c.dom.Node> createBinder()
        • public void generateSchema(final SchemaOutputResolver schemaOutputResolver)
        Show
        Jakub Narloch added a comment - - edited List of methods from (Un-)Marshaller that require implementation: Marshaller: public < A extends XmlAdapter > A getAdapter(final Class < A > xmlAdapter) public AttachmentMarshaller getAttachmentMarshaller() public Node getNode(final Object node) public void marshal(final Object object, final XMLStreamWriter xmlStreamWriter) public void marshal(final Object object, final XMLEventWriter xmlEventWriter) public void setAdapter(final XmlAdapter arg0) public < A extends XmlAdapter > void setAdapter(final Class < A > arg0, final A arg1) public void setAttachmentMarshaller(final AttachmentMarshaller arg0) Unmarshaller: public < A extends XmlAdapter > A getAdapter(final Class < A > arg0) public AttachmentUnmarshaller getAttachmentUnmarshaller() public ValidationEventHandler getEventHandler() public Schema getSchema() public UnmarshallerHandler getUnmarshallerHandler() public void setAdapter(final XmlAdapter xmlAdapter) public < A extends XmlAdapter > void setAdapter(final Class < A > type, final A xmlAdapter) public void setAttachmentUnmarshaller(final AttachmentUnmarshaller attachmentUnmarshaller) public void setEventHandler(final ValidationEventHandler validationEventHandler) public void setSchema(final Schema schema) public Object unmarshal(final XMLStreamReader xmlStreamReader) public Object unmarshal(final XMLEventReader xmlEventReader) public < T > JAXBElement < T > unmarshal(final Node node, final Class < T > type) public < T > JAXBElement < T > unmarshal(final Source node, final Class < T > type) public < T > JAXBElement < T > unmarshal(final XMLStreamReader xmlStreamReader, final Class < T > type) public < T > JAXBElement < T > unmarshal(final XMLEventReader xmlEventReader, final Class < T > type) JAXBContext: public Validator createValidator() throws JAXBException public <T> Binder<T> createBinder(final Class<T> domType) public Binder<org.w3c.dom.Node> createBinder() public void generateSchema(final SchemaOutputResolver schemaOutputResolver)
        Hide
        Jakub Narloch added a comment -

        Ok, Ralf good point.

        Show
        Jakub Narloch added a comment - Ok, Ralf good point.
        Hide
        Jakub Narloch added a comment -

        I revised the current implementation of the (Un-)Marshaller class, doing some refactoring and implementating couple of methods from Unmarshaller:

        Precisely:

        • public Object unmarshal(final XMLStreamReader xmlStreamReader)
        • public Object unmarshal(final XMLEventReader xmlEventReader)
        • public < T > JAXBElement < T > unmarshal(final Node node, final Class < T > type)
        • public < T > JAXBElement < T > unmarshal(final Source node, final Class < T > type)
        • public < T > JAXBElement < T > unmarshal(final XMLStreamReader xmlStreamReader, final Class < T > type)
        • public < T > JAXBElement < T > unmarshal(final XMLEventReader xmlEventReader, final Class < T > type)
        Show
        Jakub Narloch added a comment - I revised the current implementation of the (Un-)Marshaller class, doing some refactoring and implementating couple of methods from Unmarshaller: Precisely: public Object unmarshal(final XMLStreamReader xmlStreamReader) public Object unmarshal(final XMLEventReader xmlEventReader) public < T > JAXBElement < T > unmarshal(final Node node, final Class < T > type) public < T > JAXBElement < T > unmarshal(final Source node, final Class < T > type) public < T > JAXBElement < T > unmarshal(final XMLStreamReader xmlStreamReader, final Class < T > type) public < T > JAXBElement < T > unmarshal(final XMLEventReader xmlEventReader, final Class < T > type)
        Hide
        Jakub Narloch added a comment -

        I made changes in documentation.

        Show
        Jakub Narloch added a comment - I made changes in documentation.
        Hide
        Jakub Narloch added a comment -

        Couple additional thoughts:

        • I think if this is going to work as real provider then those JAXBContext#newInstance methods are useless, the user is not suppose to use the org.castor.jaxb classes directly. Instead I would introduce a CastorJAXBContextFactory which would be responsible for creating the JAXBContext. According to the api docs(http://jaxb.java.net/nonav/jaxb20-fcs/docs/api/index.html) a jaxb.properties file is required in each package that contains annotated classes.
        • How about renaiming the classes into CastorMarshaller, CastorUnmarshaller, CastorJAXBContext, CastorJAXBIntrospector.
        Show
        Jakub Narloch added a comment - Couple additional thoughts: I think if this is going to work as real provider then those JAXBContext#newInstance methods are useless, the user is not suppose to use the org.castor.jaxb classes directly. Instead I would introduce a CastorJAXBContextFactory which would be responsible for creating the JAXBContext. According to the api docs( http://jaxb.java.net/nonav/jaxb20-fcs/docs/api/index.html ) a jaxb.properties file is required in each package that contains annotated classes. How about renaiming the classes into CastorMarshaller, CastorUnmarshaller, CastorJAXBContext, CastorJAXBIntrospector.
        Hide
        Jakub Narloch added a comment -

        I wish to upgrade the test framework to JUnit 4.x, there for I already modified the existing test cases.

        Show
        Jakub Narloch added a comment - I wish to upgrade the test framework to JUnit 4.x, there for I already modified the existing test cases.
        Hide
        Werner Guttmann added a comment -

        I will try to get those changes in one after one ... let's see how far I get.

        Show
        Werner Guttmann added a comment - I will try to get those changes in one after one ... let's see how far I get.
        Hide
        Werner Guttmann added a comment -

        JUnit and Castor dependencies upgraded.

        Show
        Werner Guttmann added a comment - JUnit and Castor dependencies upgraded.
        Hide
        Werner Guttmann added a comment -

        Rest committed as well.

        Show
        Werner Guttmann added a comment - Rest committed as well.
        Hide
        Werner Guttmann added a comment -

        I revised the current implementation of the (Un-)Marshaller class, doing some refactoring and implementating couple of methods from Unmarshaller:

        Great stuff. But rather than maintaining all your work progress in Jira pages, can I please ask you to create yet another Wiki page (similar to the page for the OXM stuff), and add all relevant information there, e.g. what still needs to be implemented and what has been done/finalized already.

        Show
        Werner Guttmann added a comment - I revised the current implementation of the (Un-)Marshaller class, doing some refactoring and implementating couple of methods from Unmarshaller: Great stuff. But rather than maintaining all your work progress in Jira pages, can I please ask you to create yet another Wiki page (similar to the page for the OXM stuff), and add all relevant information there, e.g. what still needs to be implemented and what has been done/finalized already.
        Hide
        Werner Guttmann added a comment -

        How about renaiming the classes into CastorMarshaller, CastorUnmarshaller, CastorJAXBContext, CastorJAXBIntrospector

        Yes, pretty please. Should make the JAXB code much more readable.

        Show
        Werner Guttmann added a comment - How about renaiming the classes into CastorMarshaller, CastorUnmarshaller, CastorJAXBContext, CastorJAXBIntrospector Yes, pretty please. Should make the JAXB code much more readable.
        Hide
        Werner Guttmann added a comment -

        Instead I would introduce a CastorJAXBContextFactory which would be responsible for creating the JAXBContext

        Feel free. I honestly have to admit that I need to start looking at the JAXB specs again .. .

        Show
        Werner Guttmann added a comment - Instead I would introduce a CastorJAXBContextFactory which would be responsible for creating the JAXBContext Feel free. I honestly have to admit that I need to start looking at the JAXB specs again .. .
        Hide
        Jakub Narloch added a comment -

        Draft of the wiki page created -> http://docs.codehaus.org/display/CASTOR/Castor+JAXB

        Show
        Jakub Narloch added a comment - Draft of the wiki page created -> http://docs.codehaus.org/display/CASTOR/Castor+JAXB
        Hide
        Werner Guttmann added a comment -

        I think what really is required is a suite of functional tests that tests the individual features of the JAXB spec/API and its working (with respect of e.g. various annotation settings). E.g. verify that the use of @XmlElementWrapper together with @XmlElement works as designed.

        Show
        Werner Guttmann added a comment - I think what really is required is a suite of functional tests that tests the individual features of the JAXB spec/API and its working (with respect of e.g. various annotation settings). E.g. verify that the use of @XmlElementWrapper together with @XmlElement works as designed.
        Hide
        Jakub Narloch added a comment - - edited

        I agree here and this is what I am trying to achieve.

        Show
        Jakub Narloch added a comment - - edited I agree here and this is what I am trying to achieve.
        Hide
        Jakub Narloch added a comment - - edited

        I prepared next patch in which I have done the fallowing:

        • modified the Castor version to 1.3.3-SNAPSHOT
        • introduced CastorJAXBContextFactory for createing the JAXBContext
        • renamed the Marshaller, Unmarshaller, JAXBContext and JAXBIntrospector
        • introduced CastorUnmarshallerHandler
        Show
        Jakub Narloch added a comment - - edited I prepared next patch in which I have done the fallowing: modified the Castor version to 1.3.3-SNAPSHOT introduced CastorJAXBContextFactory for createing the JAXBContext renamed the Marshaller, Unmarshaller, JAXBContext and JAXBIntrospector introduced CastorUnmarshallerHandler
        Hide
        Jakub Narloch added a comment - - edited

        Tests for various marshall methods attached.

        Show
        Jakub Narloch added a comment - - edited Tests for various marshall methods attached.
        Hide
        Werner Guttmann added a comment -

        Jakub, hwne trying to apply your patch from Ausgust 2nd, I am getting the following problems in CastorMarshallerTest:

        -------------------------------------------------------------------------------
        Test set: org.castor.jaxb.CastorMarshallerTest
        -------------------------------------------------------------------------------
        Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 0.037 sec <<< FAILURE!
        testMarshallWriter(org.castor.jaxb.CastorMarshallerTest)  Time elapsed: 0.035 sec  <<< ERROR!
        com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
        Class has two properties of the same name "name"
        	this problem is related to the following location:
        		at public java.lang.String org.castor.entities.Entity.getName()
        		at org.castor.entities.Entity
        	this problem is related to the following location:
        		at private java.lang.String org.castor.entities.Entity.name
        		at org.castor.entities.Entity
        
        	at com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:91)
        	at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:436)
        	at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:277)
        	at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1100)
        	at com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:143)
        	at com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:110)
        	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:597)
        	at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:202)
        	at javax.xml.bind.ContextFinder.find(ContextFinder.java:376)
        	at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)
        	at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:522)
        	at org.castor.jaxb.CastorMarshallerTest.setUp(CastorMarshallerTest.java:49)
        	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:597)
        	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.RunBefores.evaluate(RunBefores.java:27)
        	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.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53)
        	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:123)
        	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104)
        	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:597)
        	at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
        	at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
        	at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:172)
        	at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:104)
        	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:70)
        testMarshallWriterJAXBElement(org.castor.jaxb.CastorMarshallerTest)  Time elapsed: 0.001 sec  <<< ERROR!
        com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
        Class has two properties of the same name "name"
        	this problem is related to the following location:
        		at public java.lang.String org.castor.entities.Entity.getName()
        		at org.castor.entities.Entity
        	this problem is related to the following location:
        		at private java.lang.String org.castor.entities.Entity.name
        		at org.castor.entities.Entity
        
        	at com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:91)
        	at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:436)
        	at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:277)
        	at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1100)
        	at com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:143)
        	at com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:110)
        	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:597)
        	at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:202)
        	at javax.xml.bind.ContextFinder.find(ContextFinder.java:376)
        	at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)
        	at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:522)
        	at org.castor.jaxb.CastorMarshallerTest.setUp(CastorMarshallerTest.java:49)
        	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:597)
        	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.RunBefores.evaluate(RunBefores.java:27)
        	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.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53)
        	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:123)
        	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104)
        	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:597)
        	at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
        	at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
        	at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:172)
        	at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:104)
        	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:70)
        
        Show
        Werner Guttmann added a comment - Jakub, hwne trying to apply your patch from Ausgust 2nd, I am getting the following problems in CastorMarshallerTest : ------------------------------------------------------------------------------- Test set: org.castor.jaxb.CastorMarshallerTest ------------------------------------------------------------------------------- Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 0.037 sec <<< FAILURE! testMarshallWriter(org.castor.jaxb.CastorMarshallerTest) Time elapsed: 0.035 sec <<< ERROR! com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions Class has two properties of the same name "name" this problem is related to the following location: at public java.lang. String org.castor.entities.Entity.getName() at org.castor.entities.Entity this problem is related to the following location: at private java.lang. String org.castor.entities.Entity.name at org.castor.entities.Entity at com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:91) at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:436) at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:277) at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1100) at com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:143) at com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:110) 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:597) at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:202) at javax.xml.bind.ContextFinder.find(ContextFinder.java:376) at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574) at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:522) at org.castor.jaxb.CastorMarshallerTest.setUp(CastorMarshallerTest.java:49) 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:597) 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.RunBefores.evaluate(RunBefores.java:27) 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.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53) at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:123) at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104) 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:597) at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164) at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110) at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:172) at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:104) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:70) testMarshallWriterJAXBElement(org.castor.jaxb.CastorMarshallerTest) Time elapsed: 0.001 sec <<< ERROR! com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions Class has two properties of the same name "name" this problem is related to the following location: at public java.lang. String org.castor.entities.Entity.getName() at org.castor.entities.Entity this problem is related to the following location: at private java.lang. String org.castor.entities.Entity.name at org.castor.entities.Entity at com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:91) at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:436) at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:277) at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1100) at com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:143) at com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:110) 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:597) at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:202) at javax.xml.bind.ContextFinder.find(ContextFinder.java:376) at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574) at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:522) at org.castor.jaxb.CastorMarshallerTest.setUp(CastorMarshallerTest.java:49) 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:597) 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.RunBefores.evaluate(RunBefores.java:27) 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.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53) at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:123) at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104) 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:597) at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164) at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110) at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:172) at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:104) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:70)
        Hide
        Werner Guttmann added a comment -

        Had to change the setUp() method as follows to get things working (and comment out testMarshallWriterJAXBElement):

            @Before
            public void setUp() throws JAXBException {
        
                javax.xml.bind.JAXBContext context = org.castor.jaxb.JAXBContext.newInstance(Entity.class);
                marshaller = context.createMarshaller();
            }
        

        Any idea why that seems to be working with you and not with me ?

        Show
        Werner Guttmann added a comment - Had to change the setUp() method as follows to get things working (and comment out testMarshallWriterJAXBElement): @Before public void setUp() throws JAXBException { javax.xml.bind.JAXBContext context = org.castor.jaxb.JAXBContext.newInstance(Entity.class); marshaller = context.createMarshaller(); } Any idea why that seems to be working with you and not with me ?
        Hide
        Jakub Narloch added a comment -

        The proper class should be loaded from jaxb.properties file.
        I placed such file in src/test/java/org/castor/entities directory, it has a single entry, which is:
        javax.xml.bind.context.factory=org.castor.jaxb.CastorJAXBContextFactory

        Show
        Jakub Narloch added a comment - The proper class should be loaded from jaxb.properties file. I placed such file in src/test/java/org/castor/entities directory, it has a single entry, which is: javax.xml.bind.context.factory=org.castor.jaxb.CastorJAXBContextFactory
        Hide
        Jakub Narloch added a comment -

        But I tested that (on Win7 with Java 6) and I don't know how come the file is skipped.

        Show
        Jakub Narloch added a comment - But I tested that (on Win7 with Java 6) and I don't know how come the file is skipped.
        Hide
        Werner Guttmann added a comment -

        Can I please ask you to re-attach the patch for CastorMarshallerTest after you have SVN UPed my commit ?

        Show
        Werner Guttmann added a comment - Can I please ask you to re-attach the patch for CastorMarshallerTest after you have SVN UPed my commit ?
        Hide
        Jakub Narloch added a comment -

        No problem, I will add the tests for CastorUnmarshaller by the way.

        Show
        Jakub Narloch added a comment - No problem, I will add the tests for CastorUnmarshaller by the way.
        Hide
        Werner Guttmann added a comment -

        Great. Can I ask you a favour, pretty please. Can you please create sub-tasks for some of the packages you are working on, and attach patches there ? This task is getting rather long-ish ....

        Show
        Werner Guttmann added a comment - Great. Can I ask you a favour, pretty please. Can you please create sub-tasks for some of the packages you are working on, and attach patches there ? This task is getting rather long-ish ....
        Hide
        Werner Guttmann added a comment - - edited

        I was asking myself yesterday how to ago about testing (functionally) all the fatures of the JAXB specification. Take, for example, the @XmlAttribute annotation. Just focusing on the annotation itself (and its use) and the available 'name' property, there's at least a few variants here that need to be tested.

        @XmlAttribute
        private String name;
        
        @XmlAttribute
        private String complexName;
        
        @XmlAttribute (name = "name2") 
        private String name;
        

        It is definitely possible to create (in this case) three POJOs, all configured accordingly, but this might get a bit tedious when we expand the scope. Any idea on this ?

        Show
        Werner Guttmann added a comment - - edited I was asking myself yesterday how to ago about testing (functionally) all the fatures of the JAXB specification. Take, for example, the @XmlAttribute annotation. Just focusing on the annotation itself (and its use) and the available 'name' property, there's at least a few variants here that need to be tested. @XmlAttribute private String name; @XmlAttribute private String complexName; @XmlAttribute (name = "name2" ) private String name; It is definitely possible to create (in this case) three POJOs, all configured accordingly, but this might get a bit tedious when we expand the scope. Any idea on this ?
        Hide
        Werner Guttmann added a comment -

        The proper class should be loaded from jaxb.properties file.
        I placed such file in src/test/java/org/castor/entities directory, it has a single entry, which is:
        javax.xml.bind.context.factory=org.castor.jaxb.CastorJAXBContextFactory

        Yes, I have seen that file, but for some reason that does not work for me. And I am on Win7 and Java 6 as well, in case that does make a difference.

        Show
        Werner Guttmann added a comment - The proper class should be loaded from jaxb.properties file. I placed such file in src/test/java/org/castor/entities directory, it has a single entry, which is: javax.xml.bind.context.factory=org.castor.jaxb.CastorJAXBContextFactory Yes, I have seen that file, but for some reason that does not work for me. And I am on Win7 and Java 6 as well, in case that does make a difference.
        Hide
        Werner Guttmann added a comment -

        In addition, can I ask you to create bugs/sub-tasks for all your findings from the Confluence page(s). E.g. the issue with the 'incorrect' XML naming definitely should be a traceable item.

        Show
        Werner Guttmann added a comment - In addition, can I ask you to create bugs/sub-tasks for all your findings from the Confluence page(s). E.g. the issue with the 'incorrect' XML naming definitely should be a traceable item.
        Hide
        Jakub Narloch added a comment -

        Reason, why the tests failed, found. The solution was quite simple. I had to move the mentinoned file into the resources directory, then the tests seams to work. Patch attached.

        Show
        Jakub Narloch added a comment - Reason, why the tests failed, found. The solution was quite simple. I had to move the mentinoned file into the resources directory, then the tests seams to work. Patch attached.
        Hide
        Jakub Narloch added a comment -

        Testsing will be a a non trivial issue in this case, but I don't see a simple solution that would give some posibility to tests that automaticily.

        My idea for testsing was to do two things tests the interface of the classes, which I try to do in this moment - prepare a test for each method and see if dose at least work with simple cases and after that it would be the best thing to prepare seperate unit cases that tests concreate functionality, for example the annotation handling.

        I had an idea to prepare a schema file (xsd) and add the xjc pluging which would generete the mapped classes in other to found out what actually works.

        Show
        Jakub Narloch added a comment - Testsing will be a a non trivial issue in this case, but I don't see a simple solution that would give some posibility to tests that automaticily. My idea for testsing was to do two things tests the interface of the classes, which I try to do in this moment - prepare a test for each method and see if dose at least work with simple cases and after that it would be the best thing to prepare seperate unit cases that tests concreate functionality, for example the annotation handling. I had an idea to prepare a schema file (xsd) and add the xjc pluging which would generete the mapped classes in other to found out what actually works.
        Hide
        Jakub Narloch added a comment -

        Patch for CastorUnmarshaller has been prepared.

        Show
        Jakub Narloch added a comment - Patch for CastorUnmarshaller has been prepared.
        Hide
        Jakub Narloch added a comment -

        How I see this farther:

        • I want to remove the Marshaller, Unmarshaller, JAXBContext and JAXBIntrospector, but first I would have to deal with the tests.
        • Add extra tests that shows how much of the JAXB annotations is supported.
        • Implement the Marshaller properties support.
        • Implement validation agains the schema in both marshaller and unmarshaller.
        • Implement package registreation in JAXBContext.

        There two things that currently I am not sure how to deal with: XmlAdapter class and AttachmentMarshaller/Unmarshaller the second thing won't be trivial without 'native' support from Castor.

        Show
        Jakub Narloch added a comment - How I see this farther: I want to remove the Marshaller, Unmarshaller, JAXBContext and JAXBIntrospector, but first I would have to deal with the tests. Add extra tests that shows how much of the JAXB annotations is supported. Implement the Marshaller properties support. Implement validation agains the schema in both marshaller and unmarshaller. Implement package registreation in JAXBContext. There two things that currently I am not sure how to deal with: XmlAdapter class and AttachmentMarshaller/Unmarshaller the second thing won't be trivial without 'native' support from Castor.
        Hide
        Werner Guttmann added a comment -

        I want to remove the Marshaller, Unmarshaller, JAXBContext and JAXBIntrospector, but first I would have to deal with the tests.

        I guess that refers to to the classes for which you have already added their corresponding Castor- equivalents ?

        Show
        Werner Guttmann added a comment - I want to remove the Marshaller, Unmarshaller, JAXBContext and JAXBIntrospector, but first I would have to deal with the tests. I guess that refers to to the classes for which you have already added their corresponding Castor- equivalents ?
        Hide
        Werner Guttmann added a comment -

        Personally, I'd not look into Attachement* functionality for the time being, as I'd consider it to be the least important. Yes, we can have a go at this once everything else is in place.

        Show
        Werner Guttmann added a comment - Personally, I'd not look into Attachement* functionality for the time being, as I'd consider it to be the least important. Yes, we can have a go at this once everything else is in place.
        Hide
        Jakub Narloch added a comment -

        Thanks Werner

        I guess that refers to to the classes for which you have already added their corresponding Castor- equivalents ?

        Yes, that is correct, but I had to first modify the existing tests.

        Show
        Jakub Narloch added a comment - Thanks Werner I guess that refers to to the classes for which you have already added their corresponding Castor- equivalents ? Yes, that is correct, but I had to first modify the existing tests.

          People

          • Assignee:
            Jakub Narloch
            Reporter:
            Jakub Narloch
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 2 days, 35 minutes
              2d 35m
              Remaining:
              Remaining Estimate - 2 days, 15 minutes
              2d 15m
              Logged:
              Remaining Estimate - 2 days, 15 minutes
              20m