Error attempting to mock concrete class

View: New views
5 Messages — Rating Filter:   Alert me  

Error attempting to mock concrete class

by Sam-186 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I'm receiving the error below while attempting to mock java.util.Logger. I've
run across this error before and wasn't able to find an answer to the problem
but somehow, during the course of adding/removing jar's to my IDE's classpath,
the problem went away. However the problem has appeared again and this time I'm
unable to replicate the solution using the previous 'method'.

Any thoughts would be greatly appreciated.

Cheers,
Sam

java.lang.NullPointerException
at net.sf.cglib.proxy.EnhancerEmitter$4.getMethods
(EnhancerEmitter.java:407)
at net.sf.cglib.proxy.NoOpGenerator.generate
(NoOpGenerator.java:69)
at net.sf.cglib.proxy.EnhancerEmitter.emitMethods
(EnhancerEmitter.java:431)
at net.sf.cglib.proxy.EnhancerEmitter.<init>
(EnhancerEmitter.java:172)
atnet.sf.cglib.proxy.Enhancer.generateClass
(Enhancer.java:344)
atnet.sf.cglib.core.DefaultGeneratorStrategy.generate
(DefaultGeneratorStrategy.java:63)
atnet.sf.cglib.core.AbstractClassGenerator.create
(AbstractClassGenerator.java:190)
at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:330)
at net.sf.cglib.proxy.Enhancer.createClass(Enhancer.java:278)
at
org.jmock.lib.legacy.ClassImposteriser.createProxyClass
(ClassImposteriser.java:122)
at org.jmock.lib.legacy.ClassImposteriser.imposterise
(ClassImposteriser.java:65)
at org.jmock.Mockery.mock(Mockery.java:139)
at org.jmock.Mockery.mock(Mockery.java:120)
                at
org.jmock.integration.junit3.MockObjectTestCase.mock
(MockObjectTestCase.java:107)



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: Error attempting to mock concrete class

by Sam-186 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Sam <mail@...> writes:


> I'm receiving the error below while attempting to mock java.util.Logger :
 
> java.lang.NullPointerException
> at net.sf.cglib.proxy.EnhancerEmitter$4.getMethods
> (EnhancerEmitter.java:407)
> at net.sf.cglib.proxy.NoOpGenerator.generate
> (NoOpGenerator.java:69)
> at net.sf.cglib.proxy.EnhancerEmitter.emitMethods



Error received while attempting to mock concrete classes.

Specifically, adding the following lines to my test class generates the error
detailed in my previous post:

{
  setImposteriser(ClassImposteriser.INSTANCE);  
}

Surely I can't be the only person to have run into this issue?

Any input (I mean it, any!) would be appreciated.
-Sam





---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: Re: Error attempting to mock concrete class

by Ignat Zapolsky :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Could you please include full text of test fixture ?


Sam wrote:

> Sam<mail@...>  writes:
>
>
>    
>> I'm receiving the error below while attempting to mock java.util.Logger :
>>      
>
>    
>> java.lang.NullPointerException
>> at net.sf.cglib.proxy.EnhancerEmitter$4.getMethods
>> (EnhancerEmitter.java:407)
>> at net.sf.cglib.proxy.NoOpGenerator.generate
>> (NoOpGenerator.java:69)
>> at net.sf.cglib.proxy.EnhancerEmitter.emitMethods
>>      
>
>
> Error received while attempting to mock concrete classes.
>
> Specifically, adding the following lines to my test class generates the error
> detailed in my previous post:
>
> {
>    setImposteriser(ClassImposteriser.INSTANCE);
> }
>
> Surely I can't be the only person to have run into this issue?
>
> Any input (I mean it, any!) would be appreciated.
> -Sam
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>      http://xircles.codehaus.org/manage_email
>
>
>    


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: Error attempting to mock concrete class

by Sam-186 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ignat Zapolsky <izapolsky@...> writes:

>
> Could you please include full text of test fixture ?
>

Hi Ignat,

Thanks for your reply. A class as simple as the following generates the error.

Regards,
Sam


package biz.pgood.air;

import org.jmock.integration.junit3.MockObjectTestCase;
import org.jmock.lib.legacy.ClassImposteriser;

import java.util.logging.Logger;

import j2ee.ClientServices;
import biz.domain.fn.Money;

/**
 */
public class AirCommissionCalculatorTest extends MockObjectTestCase {
    {
        setImposteriser(ClassImposteriser.INSTANCE);    
    }



    public void testSomething() {
        Logger log = mock(Logger.class);
       
        AirComissionAndCM_Calculator.doSomething(log);
    }
}



> Sam wrote:
> > Sam<mail@...>  writes:
> >
> >
> >    
> >> I'm receiving the error below while attempting to mock java.util.Logger :
> >>      
> >
> >    
> >> java.lang.NullPointerException
> >> at net.sf.cglib.proxy.EnhancerEmitter$4.getMethods
> >> (EnhancerEmitter.java:407)
> >> at net.sf.cglib.proxy.NoOpGenerator.generate
> >> (NoOpGenerator.java:69)
> >> at net.sf.cglib.proxy.EnhancerEmitter.emitMethods
> >>      
> >
> >
> > Error received while attempting to mock concrete classes.
> >
> > Specifically, adding the following lines to my test class generates the error
> > detailed in my previous post:
> >
> > {
> >    setImposteriser(ClassImposteriser.INSTANCE);
> > }
> >
> > Surely I can't be the only person to have run into this issue?
> >
> > Any input (I mean it, any!) would be appreciated.
> > -Sam
> >
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe from this list, please visit:
> >
> >      http://xircles.codehaus.org/manage_email
> >
> >
> >    
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>





---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: Error attempting to mock concrete class

by Sam-186 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Issue resolved after much class path tweeking.
Thanks.







---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email