невозможно установить значения свойств в верблюжьем XML-маршруте во время модульного тестирования - PullRequest
0 голосов
/ 29 июня 2018

Я новичок в Apache Camel Dev (3 месяца). Я использую основанный на XML (не Java DSL) и пытаюсь разработать модульный тест. Но я не могу выполнить две вещи

  1. Невозможно установить значение для ключа свойства в узле xml InOut
  2. Я не могу использовать weavbyToString для макета URI InOut, так как он показывает, что выходные данные не соответствуют шаблону. Поэтому я вынужден использовать weaveById, предоставляя идентификатор для узла InOut. Но мое требование - выполнять переплетение только по шаблону.

Маршрутный XML-код

<route id="testID">
      <from uri="direct:getCustDetails" />
       <to uri="velocity:META-INF/templates/manage/input.vm" />
        <inOut uri="{{url}}/custinquiry?httpClient.soTimeout={{timeout}}&amp;bridgeEndpoint=true&amp;throwExceptionOnFailure=false" id="cardEnquiryService"/>
         <to uri = "bean:responseProcessor">

</route>

Java часть

ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext("classpath:META-INF/routes/route.xml");
        PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();
        Properties prop = new Properties();
        prop.setProperty("url", "http://127.0.0.1:xxxx/server2");
        prop.setProperty("timeout", "50000000");
        configurer.setProperties(prop);
        appContext.addBeanFactoryPostProcessor(configurer);
        CamelContext camelContext =        SpringCamelContext.springCamelContext(appContext,false);

        try 
                {
                    ProducerTemplate template = camelContext.createProducerTemplate();
                    //camelContext.start();
                    Exchange ex = new DefaultExchange(camelContext);
                    final InputStream in = ResponseTest.class
                            .getResourceAsStream("/Cust_Inquiry_Res.json");
                    camelContext.getRouteDefinition("testID").adviceWith(camelContext, new AdviceWithRouteBuilder() {
                        @Override
                        public void configure() throws Exception {
                            System.out.println("Inside configure method");
                            weaveById("cardEnquiryService").replace()

/*   //Not working
    weaveByToString(".*httpClient.*").replace() */
                            .process(new Processor() {
                                public void process(Exchange exchange) throws Exception {
                                    exchange.getIn().setBody(in);
                                }
                            });
                          }
                    }); 
                    camelContext.start();

Когда я запускаю код контекста верблюда, используя приведенный выше код, я получаю следующую ошибку

Причина:

 java.lang.IllegalArgumentException: PropertiesComponent with name properties must be defined in CamelContext to support property placeholders. Property with key [url] not found in properties from text: {{url}}/custinquiry?httpClient.soTimeout={{timeout}}&bridgeEndpoint=true&throwExceptionOnFailure=false
    at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.getPropertyValue(DefaultPropertiesParser.java:269)
    at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.readProperty(DefaultPropertiesParser.java:155)
    at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.doParse(DefaultPropertiesParser.java:114)
    at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.parse(DefaultPropertiesParser.java:98)
    at org.apache.camel.component.properties.DefaultPropertiesParser.parseUri(DefaultPropertiesParser.java:63)
    at org.apache.camel.component.properties.PropertiesComponent.parseUri(PropertiesComponent.java:177)
    at org.apache.camel.component.properties.PropertiesComponent.parseUri(PropertiesComponent.java:128)
    at org.apache.camel.impl.DefaultCamelContext.resolvePropertyPlaceholders(DefaultCamelContext.java:1267)
    at org.apache.camel.model.ProcessorDefinitionHelper.resolvePropertyPlaceholders(ProcessorDefinitionHelper.java:633)
    at org.apache.camel.model.ProcessorDefinition.createOutputsProcessor(ProcessorDefinition.java:410)
    at org.apache.camel.model.ProcessorDefinition.createOutputsProcessor(ProcessorDefinition.java:159)
    at org.apache.camel.model.ProcessorDefinition.createChildProcessor(ProcessorDefinition.java:178)
    at org.apache.camel.model.OtherwiseDefinition.createProcessor(OtherwiseDefinition.java:47)
    at org.apache.camel.model.ProcessorDefinition.createProcessor(ProcessorDefinition.java:460)
    at org.apache.camel.model.ChoiceDefinition.createProcessor(ChoiceDefinition.java:139)
    at org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:500)
    at org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:213)
    at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:942)
    ... 51 more
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...