> I see. But in what scenario is suppression of the constructor needed then?
> ****
> ** **
> *From:* powermock@googlegroups.com [mailto:powermock@googlegroups.com] *On
> Behalf Of *Johan Haleby
> *Sent:* Donnerstag, 21. Juni 2012 23:30
> *To:* powermock@googlegroups.com
> *Subject:* Re: [powermock] PowerMock not working with JAXB****
> ** **
> Glad you got it working and thanks for your patience.****
> ** **
> Actually in the example you give "suppress(constructor(X.class));" is not
> needed. Whitebox.newInstance(..) creates a new instance of a class without
> invoking any constructor at all and it doesn't even require byte-code
> manipulation (so no need for @PrepareForTest). ****
> ** **
> Regards,****
> /Johan****
> On Thu, Jun 21, Glad 2012 at 8:18 PM, Markus KARG <mar...@headcrashing.eu>
> wrote:****
> Yes! Got it! IT WORKS! IT WORKS! HAPPY! :-)****
> ****
> suppress(constructor(X.class));****
> final X x = Whitebox.newInstance(X.class);****
> JAXB.marshal(new Y(x), System.out);****
> ****
> Thank you so much for your tip. This indeed is a great solution! I love
> PowerMock!****
> ****
> Regards****
> Markus****
> ****
> *From:* Markus KARG [mailto:mar...@headcrashing.eu]
> *Sent:* Donnerstag, 21. Juni 2012 20:02
> *To:* 'powermock@googlegroups.com'
> *Subject:* RE: [powermock] PowerMock not working with JAXB****
> ****
> I am not familiar to "suppres". But how does this help me? I need an
> instance of X.class, how to get it if the constructor is suppressed?****
> ****
> *From:* powermock@googlegroups.com [mailto:powermock@googlegroups.com<powermock@googlegroups.com>]
> *On Behalf Of *Johan Haleby****
> *Sent:* Donnerstag, 21. Juni 2012 07:53****
> *To:* powermock@googlegroups.com
> *Subject:* Re: [powermock] PowerMock not working with JAXB****
> ****
> Hmm if the problem is the constructor you could suppress the constructor:
> ****
> ****
> suppress(constructor(X.class));****
> ****
> Regards,****
> /Johan****
> ****
> On Wed, Jun 20, 2012 at 11:03 PM, Markus KARG <mar...@headcrashing.eu>
> wrote:****
> Yes, I need to mock the class, as the purpose is to provide an instance of
> the mock to the class under test as a parameter. If I cannot mock the
> class, I have to create an instance, which is a problem as ist constructor
> want more (non-mockable) DTOs then and so on. The target is to cut
> dependencies between classes, which is no possible by simply stubbing
> methods.****
> ****
> *From:* powermock@googlegroups.com [mailto:powermock@googlegroups.com] *On
> Behalf Of *Johan Haleby
> *Sent:* Mittwoch, 20. Juni 2012 07:43****
> *To:* powermock@googlegroups.com
> *Subject:* Re: [powermock] PowerMock not working with JAXB****
> ****
> Alright I see. Do you really need to mock the class? Perhaps it would be
> alright to just stub the method to always return the same value using the
> stubbing API:****
> ****
> stub(method(PowerMockTest.class, "myMethodName")).toReturn(..);****
> ****
> If I remember it correctly this approach will not create a CgLib proxy but
> rather modify the byte-code of "PowerMockTest" directly.****
> ****
> Regards,****
> /Johan****
> On Tue, Jun 19, 2012 at 10:25 PM, Markus KARG <mar...@headcrashing.eu>
> wrote:****
> Indeed I mock the DTOs, but the problem in the link you provided is
> different -- that guy actually did not mock anything but simply forgot add
> a constructor. I do have a constructor, but the mock provided by Powermock
> does not. THAT is my problem. See, my original DTO works well with JAXB.
> Just the mock does not.****
> ****
> *From:* powermock@googlegroups.com [mailto:powermock@googlegroups.com] *On
> Behalf Of *Johan Haleby
> *Sent:* Montag, 18. Juni 2012 08:17
> *To:* powermock@googlegroups.com
> *Subject:* Re: [powermock] PowerMock not working with JAXB****
> ****
> Sorry to hear that but perhaps there's something else that's wrong. A
> quick search on google got me here for example:
> http://jersey.576304.n2.nabble.com/Error-marshalling-out-JAXB-object-....
> Are you trying to mock the DTO objects?****
> ****
> Regards,****
> /Johan****
> On Thu, Jun 14, 2012 at 8:03 PM, Markus Karg <mar...@headcrashing.eu>
> wrote:****
> Eager loading solved the Java 7 issues, but brought me back to my original
> problem (I'm starting to drive nuts)...:****
> ****
> javax.xml.bind.DataBindingException:
> com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 3 counts
> of IllegalAnnotationExceptions
> net.java.dev.webdav.jaxrs.xml.properties.PowermockTest$X$EnhancerByCGLIB$95 116475
> does not have a no-arg default constructor.****
> this problem is related to the following location:****
> at
> net.java.dev.webdav.jaxrs.xml.properties.PowermockTest$X$EnhancerByCGLIB$95 116475
> ****
> *net.sf.cglib.proxy.Callback is an interface, and JAXB can't handle
> interfaces.**
> *this problem is related to the following location:
> at net.sf.cglib.proxy.Callback****
> at public net.sf.cglib.proxy.Callback[]
> net.java.dev.webdav.jaxrs.xml.properties.PowermockTest$X$EnhancerByCGLIB$95 116475.getCallbacks()
> at
> net.java.dev.webdav.jaxrs.xml.properties.PowermockTest$X$EnhancerByCGLIB$95 116475
> ****
> *net.sf.cglib.proxy.Callback does not have a no-arg default constructor.**
> *this problem is related to the following location:
> at net.sf.cglib.proxy.Callback****
> at public net.sf.cglib.proxy.Callback[]
> net.java.dev.webdav.jaxrs.xml.properties.PowermockTest$X$EnhancerByCGLIB$95 116475.getCallbacks()
> at
> net.java.dev.webdav.jaxrs.xml.properties.PowermockTest$X$EnhancerByCGLIB$95 116475
> ****
> at javax.xml.bind.JAXB._marshal(Unknown Source)
> at javax.xml.bind.JAXB.marshal(Unknown Source)****
> at
> net.java.dev.webdav.jaxrs.xml.properties.PowermockTest.x(PowermockTest.java :33)
> ****
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod .java:45)
> at
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable. java:15)
> at
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.j ava:42)
> at
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.ja va:20)
> ****
> at
> org.powermock.modules.junit4.rule.PowerMockStatement.evaluate(PowerMockRule .java:49)
> at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
> at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.ja va:68)
> at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.ja va:47)
> at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
> at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)****
> at org.junit.runners.ParentRunner.access0(ParentRunner.java:50)****
> at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
> at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
> at
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestRe ference.java:50)
> at
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java: 38)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestR unner.java:467)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestR unner.java:683)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner .java:390)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunne r.java:197)
> ****
> Caused by:
> com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 3 counts
> of IllegalAnnotationExceptions
> net.java.dev.webdav.jaxrs.xml.properties.PowermockTest$X$EnhancerByCGLIB$95 116475
> does not have a no-arg default constructor.****
> this problem is related to the following location:****
> at
> net.java.dev.webdav.jaxrs.xml.properties.PowermockTest$X$EnhancerByCGLIB$95 116475
> ****
> net.sf.cglib.proxy.Callback is an interface, and JAXB can't handle
> interfaces.
> this problem is related to the following location:
> at net.sf.cglib.proxy.Callback****
> at public net.sf.cglib.proxy.Callback[]
> net.java.dev.webdav.jaxrs.xml.properties.PowermockTest$X$EnhancerByCGLIB$95 116475.getCallbacks()
> at
> net.java.dev.webdav.jaxrs.xml.properties.PowermockTest$X$EnhancerByCGLIB$95 116475
> ****
> net.sf.cglib.proxy.Callback does not have a no-arg default constructor.
> this problem is related to the following location:
> at net.sf.cglib.proxy.Callback****
> at public net.sf.cglib.proxy.Callback[]
> net.java.dev.webdav.jaxrs.xml.properties.PowermockTest$X$EnhancerByCGLIB$95 116475.getCallbacks()
> at
> net.java.dev.webdav.jaxrs.xml.properties.PowermockTest$X$EnhancerByCGLIB$95 116475
> ****
> at
> com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.ch eck(Unknown
> Source)
> at
> com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(Unknown
> Source)
> at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(Unknown
> Source)
> at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(Unknown
> Source)
> at
> com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.bui ld(Unknown
> Source)
> at com.sun.xml.internal.bind.v2.ContextFactory.createContext(Unknown
> Source)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)****
> at javax.xml.bind.ContextFinder.newInstance(Unknown Source)
> at javax.xml.bind.ContextFinder.newInstance(Unknown Source)
> at javax.xml.bind.ContextFinder.find(Unknown Source)
> at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
> at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
> at javax.xml.bind.JAXB$Cache.<init>(Unknown Source)
> at javax.xml.bind.JAXB.getContext(Unknown Source)****
> ... 27 more****
> Am Donnerstag, 14. Juni 2012 06:52:04 UTC+2 schrieb Johan Haleby:****
> Hmm you may be right. You could try eager loading<http://code.google.com/p/powermock/wiki/PowerMockAgent#Eager_loading_...>the agent instead.
> /Johan****
> ****
> On Wed, Jun 13, 2012 at 10:37 PM, Markus Karg <mar...@headcrashing.eu>
> wrote:****
> ****
> --
> You received this message because you are subscribed to the Google Groups
> "PowerMock" group.****
> To view this discussion on the web visit
> https://groups.google.com/d/msg/powermock/-/ePogiSbm4-oJ.****
> To post to this group, send email to powermock@googlegroups.com.
> To unsubscribe from this group, send email to
> powermock+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/powermock?hl=en.****
> ****
> --
> You received this message because you are subscribed to the Google Groups
> "PowerMock" group.
> To post to this group, send email to powermock@googlegroups.com.
> To unsubscribe from this group, send email to
> powermock+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/powermock?hl=en.****
> --
> You received this message because you are subscribed to the Google Groups
> "PowerMock" group.
> To post to this group, send email to powermock@googlegroups.com.
> To unsubscribe from this group, send email to
> powermock+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/powermock?hl=en.****
> ****
> --
> You received this message because you are subscribed to the Google Groups
> "PowerMock" group.
> To post to this group, send email to powermock@googlegroups.com.
> To unsubscribe from this group, send email to
> powermock+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/powermock?hl=en.****
> --
> You received this message because you are subscribed to the Google Groups
> "PowerMock" group.
> To post to this group, send email to powermock@googlegroups.com.
> To unsubscribe from this group, send email to
> powermock+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/powermock?hl=en.****
> ****
> --
> You received this message because you are subscribed to the Google Groups
> "PowerMock" group.
> To post to this group, send email to powermock@googlegroups.com.
> To unsubscribe from this group, send email to
> powermock+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/powermock?hl=en.****
> --
> You received this message because you are subscribed to the Google Groups
> "PowerMock" group.
> To post to this group, send email to powermock@googlegroups.com.
> To unsubscribe from this group, send email to
> powermock+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/powermock?hl=en.****
> ** **
> --
> You received this message because you are subscribed to the Google Groups
> "PowerMock" group.
> To post to this group, send email to powermock@googlegroups.com.
> To unsubscribe from this group, send email to
> powermock+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/powermock?hl=en.****
> --
> You received this message because you are subscribed to the Google Groups
> "PowerMock" group.
> To post to this group, send email to powermock@googlegroups.com.
> To unsubscribe from this group, send email to
> powermock+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/powermock?hl=en.