Skip to content

Need solution for resolving the build issues for Camel spring boot application #62

@suresh-devaki

Description

@suresh-devaki

Error and test case and POM flle details are as below. Please suggest solution for resolving this error.

Error details:

[ERROR] symbol: method camel()
[ERROR] location: class com.consol.citrus.HelloGreetingIT
[ERROR] /C:/suresh Devaki/D Drive/Suresh/Devaki/Telia/Misc/Tasks/Citus and Apache camel support/Source code-Citrus/citrus-sample-camel-context1/citrus-sample-camel-context1/src/test/java/com/consol/citrus/HelloGreetingIT.java:[25,39] cannot find symbol
[ERROR] symbol: method direct(java.lang.String)
[ERROR] location: class com.consol.citrus.HelloGreetingIT
[ERROR] /C:/suresh Devaki/D Drive/Suresh/Devaki/Telia/Misc/Tasks/Citus and Apache camel support/Source code-Citrus/citrus-sample-camel-con


EndpointConfig.java

/*

  • Copyright 2006-2017 the original author or authors.
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at
  • http://www.apache.org/licenses/LICENSE-2.0
    
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.
    */

package com.consol.citrus;

import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

@configuration
@propertysource("citrus.properties")
public class EndpointConfig {

@Bean
public CamelContext camelContext() throws Exception {
    CamelContext context = new DefaultCamelContext();

    context.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:hello")
                .routeId("helloRoute")
                .to("log:com.consol.citrus.camel?level=INFO")
                .to("seda:greetings");
        }
    });

    return context;
}

}

HelloGreetingIT.java
package com.consol.citrus;

import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
//import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.annotations.Test;

import com.consol.citrus.annotations.CitrusTest;
import com.consol.citrus.camel.message.CamelMessageProcessor;
import com.consol.citrus.camel.message.CamelRouteProcessor;
import com.consol.citrus.message.MessageType;
import com.consol.citrus.testng.spring.TestNGCitrusSpringSupport;

@SuppressWarnings("deprecation")
public class HelloGreetingIT extends TestNGCitrusSpringSupport {

//Endpoint DSL support
@CitrusTest(name = "HelloGreeting_Ok_IT")
public void helloGreeting_Ok_1_Test() {
   
	send(camel().endpoint(direct("hello")::getUri))
    .message()
    .body("Hello from Citrus!");

	receive(camel().endpoint(seda("greetings")::getUri))
    .message()
    .type(MessageType.PLAINTEXT)
    .body("Hello from Citrus!");
	
}


@Autowired
private CamelContext camelContext;


//Camel processor support
@Test
@CitrusTest
public void shouldProcessMessages() {
    CamelMessageProcessor.Builder toUppercase = camel(camelContext)
            .process(exchange -> exchange
                    .getMessage()
                    .setBody(exchange.getMessage().getBody(String.class).toUpperCase()));

    $(send(camel().endpoint(seda("test")::getUri))
            .message()
            .body("Citrus rocks!")
            .process(toUppercase)
    );
    
    $(receive(camel().endpoint(seda("test")::getUri))
            .process(toUppercase)
            .message()
            .type(MessageType.PLAINTEXT)
            .body("CITRUS ROCKS!"));
}


//support to apply transformations
@Test
@CitrusTest
public void shouldTransformMessageReceived() {
    $(send(camel().endpoint(seda("hello")::getUri))
            .message()
            .body("{\"message\": \"Citrus rocks!\"}")
    );

    $(receive(camel().endpoint(seda("hello")::getUri))
            .transform(
                camel()
                    .camelContext(camelContext)
                    .transform()
                    .jsonpath("$.message"))
            .message()
            .type(MessageType.PLAINTEXT)
            .body("Citrus rocks!"));
}

//message processor  - able to apply a complete route logic as part of the test action.
@Test
@CitrusTest
public void shouldProcessRoute() {
    CamelRouteProcessor.Builder beforeReceive = camel(camelContext).route(route ->
            route.choice()
                .when(jsonpath("$.greeting[?(@.language == 'EN')]"))
                    .setBody(constant("Hello!"))
                .when(jsonpath("$.greeting[?(@.language == 'DE')]"))
                    .setBody(constant("Hallo!"))
                .otherwise()
                    .setBody(constant("Hi!")));

    $(send(camel().endpoint(seda("greetings")::getUri))
            .message()
            .body("{" +
                    "\"greeting\": {" +
                        "\"language\": \"EN\"" +
                    "}" +
                  "}")
    );

    $(receive("camel:" + camel().endpoints().seda("greetings").getUri())
            .process(beforeReceive)
            .message()
            .type(MessageType.PLAINTEXT)
            .body("Hello!"));
}


//Camel data format support
@org.testng.annotations.Test
@CitrusTest
public void shouldApplyDataFormat() {
    when(send(camel().endpoint(seda("data")::getUri))
            .message()
            .body("Citrus rocks!")
            .transform(camel(camelContext)
                    .marshal()
                    .base64())
    );

    then(receive("camel:" + camel().endpoints().seda("data").getUri())
            .transform(camel(camelContext)
                    .unmarshal()
                    .base64())
            .transform(camel(camelContext)
                    .convertBodyTo(String.class))
            .message()
            .type(MessageType.PLAINTEXT)
            .body("Citrus rocks!"));
}


@Test
@CitrusTest
public void createCamelRoute() {
    $(camel().camelContext(camelContext)
        .route()
        .create(new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                from("direct:messages")
                    .routeId("message-tokenizer")
                    .split().tokenize(" ")
                    .to("seda:words");
            }
        }));
}

}

pom.xml

4.0.0

com.consol.citrus.samples
citrus-sample-camel-context1
3.0.0
Citrus Samples:: Apache Camel Context

UTF-8 UTF-8 5.3.6 3.0.10.RELEASE 2.4.8.RELEASE 3.9.0 5.16.2 1.7.30 3.1.0 embedded 7.4.0 org.apache.maven.plugins maven-compiler-plugin 3.8.1 ${project.build.sourceEncoding} 11 11
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>3.0.2</version>
  </plugin>

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.22.2</version>
    <configuration>
      <failIfNoTests>false</failIfNoTests>
      <workingDirectory>${project.build.directory}</workingDirectory>
    </configuration>
  </plugin>

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>2.22.2</version>
    <executions>
      <execution>
        <id>integration-tests</id>
        <goals>
          <goal>integration-test</goal>
          <goal>verify</goal>
        </goals>
      </execution>
    </executions>
  </plugin>

  <plugin>
    <groupId>org.apache.activemq.tooling</groupId>
    <artifactId>activemq-maven-plugin</artifactId>
    <version>${activemq.version}</version>
    <configuration>
      <fork>false</fork>
      <systemProperties>
        <property>
          <name>log4j.configuration</name>
          <value>log4j.properties</value>
        </property>
      </systemProperties>
    </configuration>
  </plugin>
</plugins>
org.springframework.ws spring-ws-core ${spring.ws.version} org.springframework.webflow spring-js ${spring.webflow.js.version} org.springframework spring-core ${spring.version} org.springframework spring-beans ${spring.version} org.springframework spring-context ${spring.version} org.springframework spring-aop ${spring.version} org.springframework spring-webmvc ${spring.version} org.springframework spring-web ${spring.version} org.springframework spring-orm ${spring.version} org.springframework spring-oxm ${spring.version}
<!-- ActiveMQ broker-->
<dependency>
  <groupId>org.apache.activemq</groupId>
  <artifactId>activemq-broker</artifactId>
  <version>${activemq.version}</version>
</dependency>
<dependency>
  <groupId>org.apache.activemq</groupId>
  <artifactId>activemq-spring</artifactId>
  <version>${activemq.version}</version>
</dependency>
<dependency>
  <groupId>org.apache.xbean</groupId>
  <artifactId>xbean-spring</artifactId>
  <version>4.5</version>
</dependency>

<!-- Apache Camel -->
<dependency>
  <groupId>org.apache.camel</groupId>
  <artifactId>camel-spring-ws</artifactId>
  <version>${apache.camel.version}</version>
</dependency>
<dependency>
  <groupId>org.apache.camel</groupId>
  <artifactId>camel-jms</artifactId>
  <version>${apache.camel.version}</version>
  <exclusions>
    <exclusion>
      <groupId>org.springframework</groupId>
      <artifactId>spring-beans</artifactId>
    </exclusion>
  </exclusions>
</dependency>

<!-- Logging -->
<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>jcl-over-slf4j</artifactId>
  <version>${slf4j.version}</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>slf4j-log4j12</artifactId>
  <version>${slf4j.version}</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>commons-logging</groupId>
  <artifactId>commons-logging</artifactId>
  <version>1.2</version>
  <scope>provided</scope>
</dependency>

<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-test</artifactId>
  <version>${spring.version}</version>
  <scope>provided</scope>
</dependency>

<!-- Citrus -->
<dependency>
  <groupId>com.consol.citrus</groupId>
  <artifactId>citrus-api</artifactId>
  <version>${citrus.version}</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>com.consol.citrus</groupId>
  <artifactId>citrus-base</artifactId>
  <version>${citrus.version}</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>com.consol.citrus</groupId>
  <artifactId>citrus-spring</artifactId>
  <version>${citrus.version}</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>com.consol.citrus</groupId>
  <artifactId>citrus-endpoint-catalog</artifactId>
  <version>${citrus.version}</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>com.consol.citrus</groupId>
  <artifactId>citrus-testng</artifactId>
  <version>${citrus.version}</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>com.consol.citrus</groupId>
  <artifactId>citrus-jms</artifactId>
  <version>${citrus.version}</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>com.consol.citrus</groupId>
  <artifactId>citrus-http</artifactId>
  <version>${citrus.version}</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>com.consol.citrus</groupId>
  <artifactId>citrus-ws</artifactId>
  <version>${citrus.version}</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>com.consol.citrus</groupId>
  <artifactId>citrus-camel</artifactId>
  <version>${citrus.version}</version>
  <scope>test</scope>
</dependency>
<dependency>
    <groupId>com.consol.citrus</groupId>
    <artifactId>citrus-junit</artifactId>
    <version>3.0.0-M3</version>
</dependency>
<dependency>
  <groupId>com.consol.citrus</groupId>
  <artifactId>citrus-validation-xml</artifactId>
  <version>${citrus.version}</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>com.consol.citrus</groupId>
  <artifactId>citrus-core</artifactId>
  <version>${citrus.version}</version>
</dependency><dependency>
  <groupId>com.consol.citrus</groupId>
  <artifactId>citrus-java-dsl</artifactId>
  <version>${citrus.version}</version>
</dependency>
 <dependency>
  <groupId>com.consol.citrus</groupId>
  <artifactId>citrus-http</artifactId>
  <version>${citrus.version}</version>
</dependency>
<dependency>
  <groupId>org.apache.camel</groupId>
  <artifactId>camel-endpointdsl</artifactId>
  <scope>provided</scope>
  <version>${apache.camel.version}</version>
</dependency>
<dependency>
  <groupId>org.apache.camel</groupId>
  <artifactId>camel-jms</artifactId>
  <version>${apache.camel.version}</version>
  <exclusions>
    <exclusion>
      <groupId>org.springframework</groupId>
      <artifactId>spring-beans</artifactId>
    </exclusion>
  </exclusions>
</dependency>
<dependency>
  <groupId>org.testng</groupId>
  <artifactId>testng</artifactId>
  <version>${testng.version}</version>
  <scope>test</scope>
</dependency>
consol-labs-snapshots http://labs.consol.de/maven/snapshots-repository/ true interval:10080 activemq-embedded system.under.test.mode embedded com.consol.citrus.mvn citrus-maven-plugin ${citrus.version} org.apache.activemq.tooling activemq-maven-plugin start-activemq pre-integration-test run true stop-activemq post-integration-test stop ---------------------------------------- citrus-application.properties citrus.spring.java.config=com.consol.citrus.EndpointConfig ----------------------------------------

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions