Jux | 3 Jan 12:09 2008
Picon

Re: JMock 2.2.0, Maven 2.0.7 and JUnit 4.4


mraible wrote:
> 
> When trying to use JMock 2.2.0 with JUnit 4.4, I'm getting the following
> error. This happens when I run the test in IDEA 6.0.5 as well, so I don't
> think it's a Maven problem.
> 
> Thanks,
> 
> Matt
> 
> org.apache.maven.surefire.booter.SurefireExecutionException:
> org/junit/internal/runners/TestClassMethodsRunner; nested exception is
> java.lang.NoClassDefFoundError:
> org/junit/internal/runners/TestClassMethodsRunner
> java.lang.NoClassDefFoundError:
> org/junit/internal/runners/TestClassMethodsRunner
>         at java.lang.ClassLoader.defineClass2(Native Method)
>         at java.lang.ClassLoader.defineClass(ClassLoader.java:719)
>         at
> java.security.SecureClassLoader.defineClass(SecureClassLoader.java:160)
>         at java.net.URLClassLoader.defineClass(URLClassLoader.java:254)
>         at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
>         at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
>         at java.security.AccessController.doPrivileged(Native Method)
>         at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>         at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
>         at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
>         at
> org.apache.maven.surefire.booter.IsolatedClassLoader.loadClass(IsolatedClassLoader.java:103)
(Continue reading)

Nat Pryce | 3 Jan 13:47 2008
Picon

Re: JMock 2.2.0, Maven 2.0.7 and JUnit 4.4

That seems to have nothing to do with jMock.  You'd be better off
asking on a mailing list dedicated to JUnit or Unitils (probably the
latter).

--Nat

On 03/01/2008, Jux <jux@...> wrote:
>
>
>
> mraible wrote:
> >
> > When trying to use JMock 2.2.0 with JUnit 4.4, I'm getting the following
> > error. This happens when I run the test in IDEA 6.0.5 as well, so I don't
> > think it's a Maven problem.
> >
> > Thanks,
> >
> > Matt
> >
> > org.apache.maven.surefire.booter.SurefireExecutionException:
> > org/junit/internal/runners/TestClassMethodsRunner; nested exception is
> > java.lang.NoClassDefFoundError:
> > org/junit/internal/runners/TestClassMethodsRunner
> > java.lang.NoClassDefFoundError:
> > org/junit/internal/runners/TestClassMethodsRunner
> >         at java.lang.ClassLoader.defineClass2(Native Method)
> >         at java.lang.ClassLoader.defineClass(ClassLoader.java:719)
> >         at
> > java.security.SecureClassLoader.defineClass(SecureClassLoader.java:160)
(Continue reading)

Thomas Becker | 4 Jan 14:40 2008
Picon

Re: JMock 2.2.0, Maven 2.0.7 and JUnit 4.4

Nat, hope it's ok to answer here anyhow.

Do you guys have the junit-dep artifact loaded as well as the junit
artifact for 4.4?

> That seems to have nothing to do with jMock.  You'd be better off
> asking on a mailing list dedicated to JUnit or Unitils (probably the
> latter).
>
> --Nat
>
> On 03/01/2008, Jux <jux@...> wrote:
>>
>>
>>
>> mraible wrote:
>> >
>> > When trying to use JMock 2.2.0 with JUnit 4.4, I'm getting the
>> following
>> > error. This happens when I run the test in IDEA 6.0.5 as well, so I
>> don't
>> > think it's a Maven problem.
>> >
>> > Thanks,
>> >
>> > Matt
>> >
>> > org.apache.maven.surefire.booter.SurefireExecutionException:
>> > org/junit/internal/runners/TestClassMethodsRunner; nested exception is
>> > java.lang.NoClassDefFoundError:
(Continue reading)

Mauro Talevi | 4 Jan 19:25 2008

Re: JMock 2.2.0, Maven 2.0.7 and JUnit 4.4

Thomas Becker wrote:

> Do you guys have the junit-dep artifact loaded as well as the junit
> artifact for 4.4?
> 

Yes - both junit and junit-dep are available for version 4.4 on Maven 
Central Repo.

http://mvnrepository.com/search.html?query=junit-dep

Cheers

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

    http://xircles.codehaus.org/manage_email

vr.sundar | 9 Jan 02:54 2008
Picon

instanceOf generics problem

Hi,

I have

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

    http://xircles.codehaus.org/manage_email

vr.sundar | 9 Jan 03:07 2008
Picon

Re: instanceOf generics problem

Sorry, sent the earlier mail by mistake. Here is the problem

I am trying to do this:
			allowing(obj).someMethod(with(instanceOf(subType.class)));
where someMethod takes parameters of type superType. I want to allow
all instances of subTypes though I don't believe this has anything to
do with the problem.

With the line above, I get a compile error: Method
someMethod(superType) in type xyz is not applicable for the arguments
(object). Basically what is being passed in to someMethod is of type
Object instead of superType. I checked the 2.4.0 source and I see
this:

  public static org.hamcrest.Matcher<java.lang.Object>
instanceOf(java.lang.Class<?> type) {
    return org.hamcrest.core.IsInstanceOf.instanceOf(type);
  }

The return type of instanceOf is defined as Matcher<Object> instead of
Matcher<T>. Well, there is no T here: the input parameter is defined
as Class<?> and IsInstanceOf is defined as BaseMatcher<Object>

Is there an instanceOf method somewhere else (or some other method)
that I can use that returns the right type?

thanks
sundar

On Jan 8, 2008 5:54 PM, vr. sundar <vr.sundar@...> wrote:
(Continue reading)

Nat Pryce | 9 Jan 12:00 2008
Picon

Re: Re: instanceOf generics problem

You can use nonNull(Class<T>) if you want the parameter to be any T
that is not null.  Or you can use any(Class<T>) if you want the
parameter to be any T, possibly null.

--Nat

On 09/01/2008, vr. sundar <vr.sundar@...> wrote:
> Sorry, sent the earlier mail by mistake. Here is the problem
>
> I am trying to do this:
>                         allowing(obj).someMethod(with(instanceOf(subType.class)));
> where someMethod takes parameters of type superType. I want to allow
> all instances of subTypes though I don't believe this has anything to
> do with the problem.
>
> With the line above, I get a compile error: Method
> someMethod(superType) in type xyz is not applicable for the arguments
> (object). Basically what is being passed in to someMethod is of type
> Object instead of superType. I checked the 2.4.0 source and I see
> this:
>
>   public static org.hamcrest.Matcher<java.lang.Object>
> instanceOf(java.lang.Class<?> type) {
>     return org.hamcrest.core.IsInstanceOf.instanceOf(type);
>   }
>
> The return type of instanceOf is defined as Matcher<Object> instead of
> Matcher<T>. Well, there is no T here: the input parameter is defined
> as Class<?> and IsInstanceOf is defined as BaseMatcher<Object>
>
(Continue reading)

vr.sundar | 9 Jan 19:32 2008
Picon

Re: Re: instanceOf generics problem

Nat,

Thanks for the response. I didn't find a nonNull but I found a
aNonNull and notNullValue. But any, aNonNull and notNullValue all
don't actually check the type of the actual argument. The type seems
to be used mainly for compile time type-checking not to test the type
of the argument that is passed in during the test. In my case, I want
to ignore all calls with instances of a specific type. When I use
"any", basically all calls to that method are ignored as any
internally uses hamcrests's IsAnything which just returns true. With
notNullValue and aNonNull, the type of the passed in arg is not
checked.

Maybe I'm missing something but it looks like any use of the
instanceOf with a method that takes a sub-class of object would result
in a compile time error. So I'm wondering how are ppl using
instanceOf?

Any help is greatly appreciated

thanks
sundar

On Jan 9, 2008 3:00 AM, Nat Pryce <nat.pryce@...> wrote:
> You can use nonNull(Class<T>) if you want the parameter to be any T
> that is not null.  Or you can use any(Class<T>) if you want the
> parameter to be any T, possibly null.
>
> --Nat
>
(Continue reading)

Nat Pryce | 10 Jan 11:59 2008
Picon

Re: Re: instanceOf generics problem

Yes.  Instanceof is a left-over from jMock 1 days and the type
signature is not very useful.

Perhaps it should be

  Matcher<T> instanceOf(Class<? extends T> subtype)

That would cover the current case and your case.

If you could raise a JIRA issue that would help remind us to implement
it in the next release.

--Nat

On 09/01/2008, vr. sundar <vr.sundar@...> wrote:
> Nat,
>
> Thanks for the response. I didn't find a nonNull but I found a
> aNonNull and notNullValue. But any, aNonNull and notNullValue all
> don't actually check the type of the actual argument. The type seems
> to be used mainly for compile time type-checking not to test the type
> of the argument that is passed in during the test. In my case, I want
> to ignore all calls with instances of a specific type. When I use
> "any", basically all calls to that method are ignored as any
> internally uses hamcrests's IsAnything which just returns true. With
> notNullValue and aNonNull, the type of the passed in arg is not
> checked.
>
> Maybe I'm missing something but it looks like any use of the
> instanceOf with a method that takes a sub-class of object would result
(Continue reading)

Steve Freeman | 10 Jan 12:16 2008
Picon

Re: Re: instanceOf generics problem

In the meantime, it wouldn't take much to make your own version  
locally. It'll be a single class and maybe a static import to make it  
look nice.

S.

On 10 Jan 2008, at 10:59, Nat Pryce wrote:
> Yes.  Instanceof is a left-over from jMock 1 days and the type
> signature is not very useful.
>
> Perhaps it should be
>
>   Matcher<T> instanceOf(Class<? extends T> subtype)
>
> That would cover the current case and your case.
>
> If you could raise a JIRA issue that would help remind us to implement
> it in the next release.
>
> --Nat

Steve Freeman
Winner of the Agile Alliance Gordon Pask award 2006

http://www.m3p.co.uk

M3P Limited.
Registered office. 2 Church Street, Burnham, Bucks, SL1 7HZ.
Company registered in England & Wales. Number 03689627

(Continue reading)


Gmane