camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Willem Jiang (JIRA)" <j...@apache.org>
Subject [jira] [Assigned] (CAMEL-8475) CamelSpringDelegatingTestContextLoader and TestNG
Date Thu, 12 Mar 2015 03:31:38 GMT

     [ https://issues.apache.org/jira/browse/CAMEL-8475?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Willem Jiang reassigned CAMEL-8475:
-----------------------------------

    Assignee: Willem Jiang

> CamelSpringDelegatingTestContextLoader and TestNG
> -------------------------------------------------
>
>                 Key: CAMEL-8475
>                 URL: https://issues.apache.org/jira/browse/CAMEL-8475
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-spring-javaconfig, camel-test
>    Affects Versions: 2.14.1
>            Reporter: Jani
>            Assignee: Willem Jiang
>
> I'm trying to use {{CamelSpringDelegatingTestContextLoader}} with TestNG. Here's my test
class:
> {code:title=MyTest.java|}
> @ContextConfiguration(classes = SpringTestConfiguration.class, loader = CamelSpringDelegatingTestContextLoader.class)
> public class MyTest extends AbstractCamelTestNGSpringContextTests {
>     @Autowired
>     private CamelContext camelContext;
>     @Test
>     public void test() {
>         Assert.notNull(camelContext);
>     }
> }
> {code}
> Configuration class:
> {code:title=SpringTestConfiguration.java}
> @Configuration
> @ComponentScan(basePackageClasses = {SpringTestRoot.class})
> public class SpringTestConfiguration extends CamelConfiguration {
> }
> {code}
> Here's the exception I'm getting:
> {code}
> org.testng.TestNGException: 
> Cannot instantiate class com.mycompany.demo.MyTest
> 	at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:38)
> 	at org.testng.internal.ClassHelper.createInstance1(ClassHelper.java:380)
> 	at org.testng.internal.ClassHelper.createInstance(ClassHelper.java:293)
> 	at org.testng.internal.ClassImpl.getDefaultInstance(ClassImpl.java:115)
> 	at org.testng.internal.ClassImpl.getInstances(ClassImpl.java:200)
> 	at org.testng.internal.TestNGClassFinder.<init>(TestNGClassFinder.java:120)
> 	at org.testng.TestRunner.initMethods(TestRunner.java:409)
> 	at org.testng.TestRunner.init(TestRunner.java:235)
> 	at org.testng.TestRunner.init(TestRunner.java:205)
> 	at org.testng.TestRunner.<init>(TestRunner.java:160)
> 	at org.testng.remote.RemoteTestNG$1.newTestRunner(RemoteTestNG.java:141)
> 	at org.testng.remote.RemoteTestNG$DelegatingTestRunnerFactory.newTestRunner(RemoteTestNG.java:271)
> 	at org.testng.SuiteRunner$ProxyTestRunnerFactory.newTestRunner(SuiteRunner.java:575)
> 	at org.testng.SuiteRunner.init(SuiteRunner.java:159)
> 	at org.testng.SuiteRunner.<init>(SuiteRunner.java:113)
> 	at org.testng.TestNG.createSuiteRunner(TestNG.java:1299)
> 	at org.testng.TestNG.createSuiteRunners(TestNG.java:1286)
> 	at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
> 	at org.testng.TestNG.run(TestNG.java:1057)
> 	at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
> 	at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
> 	at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
> 	at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:125)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:483)
> 	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
> Caused by: java.lang.reflect.InvocationTargetException
> 	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
> 	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
> 	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
> 	at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
> 	at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:29)
> 	... 27 more
> Caused by: java.lang.IllegalStateException: Neither GenericXmlContextLoader nor AnnotationConfigContextLoader
was able to detect defaults, and no ApplicationContextInitializers were declared for context
configuration [ContextConfigurationAttributes@327b636c declaringClass = 'org.apache.camel.testng.AbstractCamelTestNGSpringContextTests',
classes = '{}', locations = '{}', inheritLocations = true, initializers = '{}', inheritInitializers
= true, name = [null], contextLoaderClass = 'org.apache.camel.testng.AbstractCamelTestNGSpringContextTests$TestNGCamelSpringTestContextLoader']
> 	at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.processContextConfiguration(AbstractDelegatingSmartContextLoader.java:201)
> 	at org.springframework.test.context.ContextLoaderUtils.buildMergedContextConfiguration(ContextLoaderUtils.java:607)
> 	at org.springframework.test.context.ContextLoaderUtils.buildMergedContextConfiguration(ContextLoaderUtils.java:560)
> 	at org.springframework.test.context.TestContext.<init>(TestContext.java:99)
> 	at org.springframework.test.context.TestContextManager.<init>(TestContextManager.java:121)
> 	at org.springframework.test.context.TestContextManager.<init>(TestContextManager.java:107)
> 	at org.springframework.test.context.testng.AbstractTestNGSpringContextTests.<init>(AbstractTestNGSpringContextTests.java:108)
> 	at org.apache.camel.testng.AbstractCamelTestNGSpringContextTests.<init>(AbstractCamelTestNGSpringContextTests.java:49)
> 	at com.mycompany.demo.MyTest.<init>(MyTest.java:12)
> 	... 32 more
> {code}
> If I drop {{AbstractCamelTestNGSpringContextTests}} and use {{AbstractTestNGSpringContextTests}}
and copy the listeners I'm able to execute the test.
> Will there be TestNG support for {{CamelSpringDelegatingTestContextLoader}}?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message