|
#1
|
|||
|
|||
|
Hi,
I'm using Spring 2.5-rc1 test context framework. When I do this: Code:
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.TestExecutionListeners;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({})
public class TestContext {
@Test
public void testTrue() {
assertTrue(true);
}
}
Code:
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.TestExecutionListeners;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:src/test/resources/context.xml" })
public class TestContext {
@Test
public void testTrue() {
assertTrue(true);
}
}
Code:
java.lang.NoSuchMethodError: org.springframework.core.annotation.AnnotationUtils.findAnnotationDeclaringClass(Ljava/lang/Class;Ljava/lang/Class;)Ljava/lang/Class;
at org.springframework.test.context.TestContext.retrieveContextLocations(TestContext.java:159)
at org.springframework.test.context.TestContext.<init>(TestContext.java:115)
at org.springframework.test.context.TestContextManager.<init>(TestContextManager.java:106)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTestContextManager(SpringJUnit4ClassRunner.java:114)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.<init>(SpringJUnit4ClassRunner.java:80)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.junit.internal.requests.ClassRequest.buildRunner(ClassRequest.java:33)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:28)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:26)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:24)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:40)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:30)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:445)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Code:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd"
default-lazy-init="true">
<bean class="org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor" lazy-init="false" />
<import resource="classpath:com/foo/bar/wc/dl/context/*.xml" />
<util:properties id="bar.wc.HibernateProperties" location="classpath:bar.wc.hibernate.properties" />
</beans>
Code:
@RunWith(SpringJUnit4ClassRunner.class) Any help much appreciated. |
|
#2
|
|||
|
|||
|
Try the JUnit shipped with Spring instead of the one shipped with Eclipse. Also make sure you don't have duplicate classes/jars on your classpath.
__________________
Marten Deinum
Blog Use the [ code ] tags, young padawan |
|
#3
|
|||
|
|||
|
Hi Narada,
Quote:
So basically, just make sure you are using spring.jar and spring-test.jar from 2.5 RC1, and that should do the trick. ![]() Cheers, Sam
__________________
Sam Brannen, Software Consultant Spring Framework Core Developer Follow me on Twitter
|
|
#4
|
|||
|
|||
|
Hi. Thanks all. This issue is now resolved. I was using maven and had Spring 2.0.7 stable as compile time dependency and Spring-Test 2.5-rc1 as test time dependency so that I could use the test context framework. However I switched to the latter for both now by altering version in pom file. Now it works fine. Thanks. (Now to decide whether to use 2.5-rc1 in production ;)
|
|
#5
|
|||
|
|||
|
Narada, you say you found a repository where Spring 2.5-rc1 is publicly avalaible? I'd love to know where to get it from with maven..
|
|
#6
|
|||
|
|||
|
Quote:
http://forum.springframework.org/sho...79&postcount=3 Note: Ben mentions two different URLs. The one at s3browse.com is solely for browsing the repository within a web browser; whereas, the one at s3.amazonaws.com is the actual URL to use with Maven. Regards, Sam
__________________
Sam Brannen, Software Consultant Spring Framework Core Developer Follow me on Twitter
|
|
#7
|
|||
|
|||
|
This blog post explains where to get Spring Portfolio maven artifacts and how the releases are managed/published.
__________________
Marten Deinum
Blog Use the [ code ] tags, young padawan |
![]() |
| Thread Tools | |
| Display Modes | |
|
|