You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by Raymond Feng <en...@gmail.com> on 2006/07/12 08:18:16 UTC

[PATCH] Re: JAXB databinding - problem with test code leaking into output jar

Hi,

Here's the patch to fix this problem. I'll adjust for other projects later 
on.

Thanks,
Raymond

----- Original Message ----- 
From: "Jeremy Boynes" <jb...@apache.org>
To: <tu...@ws.apache.org>
Sent: Tuesday, July 11, 2006 7:32 PM
Subject: JAXB databinding - problem with test code leaking into output jar


> The JAXB databinding attaches the jaxb plugin to the generate sources 
> phase and this results in the test code ending up in the output jar:
> $ jar tf target/databinding-jaxb-1.0-chianti-SNAPSHOT.jar
> META-INF/
> META-INF/MANIFEST.MF
> com/
> com/example/
> com/example/ipo/
> com/example/ipo/jaxb/
> org/
> org/apache/
> org/apache/tuscany/
> org/apache/tuscany/databinding/
> org/apache/tuscany/databinding/jaxb/
> com/example/ipo/jaxb/Address.class
> com/example/ipo/jaxb/Items$Item.class
> com/example/ipo/jaxb/Items.class
> com/example/ipo/jaxb/ObjectFactory.class
> com/example/ipo/jaxb/package-info.class
> com/example/ipo/jaxb/PurchaseOrderType.class
> com/example/ipo/jaxb/UKAddress.class
> com/example/ipo/jaxb/USAddress.class
> com/example/ipo/jaxb/USState.class
> org/apache/tuscany/databinding/jaxb/JAXB2Node.class
> org/apache/tuscany/databinding/jaxb/Node2JAXB.class
> org/apache/tuscany/databinding/jaxb/XMLStreamReader2JAXB.class
> META-INF/maven/
> META-INF/maven/org.apache.tuscany.databinding/
> META-INF/maven/org.apache.tuscany.databinding/databinding-jaxb/
> META-INF/maven/org.apache.tuscany.databinding/databinding-jaxb/pom.xml
> META-INF/maven/org.apache.tuscany.databinding/databinding-jaxb/ 
> pom.properties
>
> If I change the pom to attach this to the generate-test-sources phase:
> $ svn diff pom.xml
> Index: pom.xml
> ===================================================================
> --- pom.xml     (revision 421082)
> +++ pom.xml     (working copy)
> @@ -100,7 +100,7 @@
>                  <executions>
>                      <execution>
>                          <id>generate-jaxb</id>
> -                        <phase>generate-sources</phase>
> +                        <phase>generate-test-sources</phase>
>                          <goals>
>                              <goal>generate</goal>
>                          </goals>
>
> then I get an error running the tests:
> $ mvn -o clean test
> [INFO]
> NOTE: Maven is executing in offline mode. Any artifacts not already  in 
> your local
> repository will be inaccessible.
>
> [INFO] Scanning for projects...
> 
> INFO]  ------------------------------------------------------------------------
> ----
> [INFO] Building Tuscany JAXB Data Binding
> [INFO]    task-segment: [clean, test]
> 
> INFO]  ------------------------------------------------------------------------
> ----
> [INFO] [clean:clean]
> [INFO] Deleting directory /Users/jboynes/tuscany/sandbox/chianti/sca/ 
> databinding/databinding-jaxb/target
> [INFO] Deleting directory /Users/jboynes/tuscany/sandbox/chianti/sca/ 
> databinding/databinding-jaxb/target/classes
> [INFO] Deleting directory /Users/jboynes/tuscany/sandbox/chianti/sca/ 
> databinding/databinding-jaxb/target/test-classes
> [INFO] [resources:resources]
> [INFO] Using default encoding to copy filtered resources.
> [INFO] [compiler:compile]
> Compiling 3 source files to /Users/jboynes/tuscany/sandbox/chianti/ 
> sca/databinding/databinding-jaxb/target/classes
> [INFO] [jaxb:generate {execution: generate-jaxb}]
> [INFO] /Users/jboynes/tuscany/sandbox/chianti/sca/databinding/ 
> databinding-jaxb/target/jaxb-source/com/example/ipo/jaxb is not found  and 
> thus excluded from the dependency check
> [INFO] Compiling file:/Users/jboynes/tuscany/sandbox/chianti/sca/ 
> databinding/databinding-jaxb/src/test/resources/ipo.xsd
> [INFO] Writing output to /Users/jboynes/tuscany/sandbox/chianti/sca/ 
> databinding/databinding-jaxb/target/jaxb-source
> [INFO] [resources:testResources]
> [INFO] Using default encoding to copy filtered resources.
> [INFO] [compiler:testCompile]
> Compiling 1 source file to /Users/jboynes/tuscany/sandbox/chianti/sca/ 
> databinding/databinding-jaxb/target/test-classes
> [INFO] [surefire:test]
> [INFO] Surefire report directory: /Users/jboynes/tuscany/sandbox/ 
> chianti/sca/databinding/databinding-jaxb/target/surefire-reports
>
> -------------------------------------------------------
> T E S T S
> -------------------------------------------------------
> Running org.apache.tuscany.databinding.jaxb.JAXBTestCase
> Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.083  sec 
> <<< FAILURE!
> testTransform(org.apache.tuscany.databinding.jaxb.JAXBTestCase)  Time 
> elapsed: 0.041 sec  <<< ERROR!
> javax.xml.bind.JAXBException: "com.example.ipo.jaxb" doesnt contain 
> ObjectFactory.class or jaxb.index
>         at com.sun.xml.bind.v2.ContextFactory.createContext 
> (ContextFactory.java:119)
>         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 javax.xml.bind.ContextFinder.newInstance 
> (ContextFinder.java:132)
>         at javax.xml.bind.ContextFinder.find(ContextFinder.java:286)
>         at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:372)
>         at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:337)
>         at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:244)
>         at  org.apache.tuscany.databinding.jaxb.JAXBTestCase.testTransform 
> (JAXBTestCase.java:48)
>
>
> Results :
> Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
>
> 
> INFO]  ------------------------------------------------------------------------
> [ERROR] BUILD FAILURE
> 
> INFO]  ------------------------------------------------------------------------
> [INFO] There are test failures.
> 
> INFO]  ------------------------------------------------------------------------
> [INFO] For more information, run Maven with the -e switch
> 
> INFO]  ------------------------------------------------------------------------
> [INFO] Total time: 5 seconds
> [INFO] Finished at: Tue Jul 11 19:29:45 PDT 2006
> [INFO] Final Memory: 6M/15M
> 
> INFO]  ------------------------------------------------------------------------
>
> Could someone more familiar with this plugin tell me what is going  wrong 
> and how we can avoid have the test code in the output jar?
> Thanks
> --
> Jeremy
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-dev-help@ws.apache.org
> 

Re: [PATCH] Re: JAXB databinding - problem with test code leaking into output jar

Posted by Jeremy Boynes <jb...@apache.org>.
On Jul 12, 2006, at 12:38 PM, Raymond Feng wrote:

> Hi,
>
> After more investigation, I found the patch doesn't fix the problem  
> completely. Now the testSourceDirectory is switched and test cases  
> in the test/src/java folder cannot be detected by Surefire plugin  
> any more. The key question is that if maven 2 supports more than  
> one test source folders. The result from google search is not very  
> promising.
>
> One work around to this issue is to have generated code placed in  
> src/test/java. But it's not very nice.

m2 does support multiple (main) source folders as this is used by  
other code generators to generate main-line code. The generator mojo  
is responsible for adding the root of its generated code to the set  
of source folders.

I think the same function is there in m2 for test source folders.  
However, it may be that the plugin is not able to do that. I would  
suggest asking on the plugin's dev list (or use the source) if this  
is something it supports.

--
Jeremy

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


Re: [PATCH] Re: JAXB databinding - problem with test code leaking into output jar

Posted by Raymond Feng <en...@gmail.com>.
Hi,

After more investigation, I found the patch doesn't fix the problem 
completely. Now the testSourceDirectory is switched and test cases in the 
test/src/java folder cannot be detected by Surefire plugin any more. The key 
question is that if maven 2 supports more than one test source folders. The 
result from google search is not very promising.

One work around to this issue is to have generated code placed in 
src/test/java. But it's not very nice.

Thanks,
Raymond

----- Original Message ----- 
From: "Jeremy Boynes" <jb...@apache.org>
To: <tu...@ws.apache.org>
Sent: Wednesday, July 12, 2006 6:26 AM
Subject: Re: [PATCH] Re: JAXB databinding - problem with test code leaking 
into output jar


> On Jul 11, 2006, at 11:18 PM, Raymond Feng wrote:
>
>> Hi,
>>
>> Here's the patch to fix this problem. I'll adjust for other  projects 
>> later on.
>>
>
> Thanks Raymond, worked like a charm.
> --
> Jeremy
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-dev-help@ws.apache.org
> 


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


Re: [PATCH] Re: JAXB databinding - problem with test code leaking into output jar

Posted by Jeremy Boynes <jb...@apache.org>.
On Jul 11, 2006, at 11:18 PM, Raymond Feng wrote:

> Hi,
>
> Here's the patch to fix this problem. I'll adjust for other  
> projects later on.
>

Thanks Raymond, worked like a charm.
--
Jeremy

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