0
私のテストでは、envirementでapplication.properiesを使用することはできませんが、メインではうまく動作します。そのような諺を見つけることができないと書いてください。 @TestPropertySource(locations = "classpath:application.properties")を使用しようとしましたが、助けにはなりませんでした。また、テストフォルダのリソースにapplication.properiesを追加しました。Camelテストにapplication.propを追加できません
私のテストクラス:
@RunWith(SpringRunner.class)
@SpringBootTest
//@TestPropertySource(locations="classpath:application.properties")
public class Excercise5to7ApplicationTests extends CamelTestSupport {
@Override
protected RouteBuilder createRouteBuilder() {
return new MyRoute();
}
@Before
public void mockEndpoints() throws Exception {
AdviceWithRouteBuilder mockKafka = new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
// mock the for testing
interceptSendToEndpoint("kafka:*")
.skipSendToOriginalEndpoint()
.to("mock:kafka");
}
};
RouteDefinition myRoute = context.getRouteDefinition("myRoute");
myRoute.adviceWith(context, mockKafka);
}
@Test
public void testWithRealFile() throws Exception {
context.start();
MockEndpoint kafka = getMockEndpoint("mock:kafka");
kafka.expectedMessageCount(10);
kafka.assertIsSatisfied();
context.stop();
}
@Override
protected Context createJndiContext() throws Exception {
JndiContext context = new JndiContext();
context.bind("myBean", new MyBean());
return context;
}
@Override
public boolean isUseAdviceWith() {
return true;
}
}
例外自体:
org.apache.camel.RuntimeCamelException: java.lang.IllegalArgumentException: Property with key [route.from.path] not found in properties from text: file:{{route.from.path}}?noop=true
at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1774)
at org.apache.camel.model.RouteDefinitionHelper.initRouteInputs(RouteDefinitionHelper.java:380)
at org.apache.camel.model.RouteDefinitionHelper.prepareRouteImp(RouteDefinitionHelper.java:298)
at org.apache.camel.model.RouteDefinitionHelper.prepareRoute(RouteDefinitionHelper.java:270)
at org.apache.camel.model.RoutesDefinition.route(RoutesDefinition.java:205)
at org.apache.camel.model.RoutesDefinition.from(RoutesDefinition.java:158)
at org.apache.camel.builder.RouteBuilder.from(RouteBuilder.java:169)
at com.bisnode.excercise5to7.Routes.MyRoute.configure(MyRoute.java:16)
at org.apache.camel.builder.RouteBuilder.checkInitialized(RouteBuilder.java:462)
at org.apache.camel.builder.RouteBuilder.configureRoutes(RouteBuilder.java:402)
at org.apache.camel.builder.RouteBuilder.addRoutesToCamelContext(RouteBuilder.java:383)
at org.apache.camel.impl.DefaultCamelContext$1.call(DefaultCamelContext.java:971)
at org.apache.camel.impl.DefaultCamelContext$1.call(DefaultCamelContext.java:968)
at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:3108)
at org.apache.camel.impl.DefaultCamelContext.addRoutes(DefaultCamelContext.java:968)
at org.apache.camel.test.junit4.CamelTestSupport.doSetUp(CamelTestSupport.java:352)
at org.apache.camel.test.junit4.CamelTestSupport.setUp(CamelTestSupport.java:262)
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:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.lang.IllegalArgumentException: Property with key [route.from.path] not found in properties from text: file:{{route.from.path}}?noop=true
at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.getPropertyValue(DefaultPropertiesParser.java:271)
at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.readProperty(DefaultPropertiesParser.java:157)
at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.doParse(DefaultPropertiesParser.java:116)
at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.parse(DefaultPropertiesParser.java:100)
at org.apache.camel.component.properties.DefaultPropertiesParser.parseUri(DefaultPropertiesParser.java:63)
at org.apache.camel.component.properties.PropertiesComponent.parseUri(PropertiesComponent.java:230)
at org.apache.camel.component.properties.PropertiesComponent.parseUri(PropertiesComponent.java:173)
at org.apache.camel.impl.DefaultCamelContext.resolvePropertyPlaceholders(DefaultCamelContext.java:2411)
at org.apache.camel.model.ProcessorDefinitionHelper.resolvePropertyPlaceholders(ProcessorDefinitionHelper.java:735)
at org.apache.camel.model.RouteDefinitionHelper.initRouteInputs(RouteDefinitionHelper.java:378)
... 48 more
:あなたがここでより多くの情報を見つけることができます
}?注釈ベースの設定またはXMLベースの設定を使用していますか? – notionquest
@notionquest私は春のブートを使用していて、設定に触れないでください – Eugene
CamelTestSupportクラスを表示できますか? – notionquest