testingcitrus-framework

Citrus flightbooking sample execution?


I am new to Citrus so I tried to execute

flight booking sample but I face some problems. First of all, I think that something

is wrong with the readme file (readme.md on https://github.com/christophd/citrus-samples/tree/master/sample-flightbooking) . "Got to the folder and start the BookStore WebService application in a Web Container. The easiest way for you to do this is to execute" it seems to be part of another sample readme file.

When I execute mvn jetty:run , jetty server starts but I got these messages :

  • retrying using FixedBackOff{interval=5000, currentAttempts=4, maxAttempts=unlimited}. Cause: Could not connect to broker URL: tcp://localhost:61616. Reason: java.net.ConnectException: Connection refused: connect 11:18:22,197 ERROR ageListenerContainer| Could not refresh JMS Connection for destination 'Travel.Agency.Request.Queue'

Also, when I try mvn integration-test (while jetty server runs) , tests fails and got these messages :

[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 4.575 s <<< FAILURE! - in com.consol.citrus.samples.flightbooking.FlightBookingIT [ERROR] FlightBookingIT(com.consol.citrus.samples.flightbooking.FlightBookingIT) Time elapsed: 1.514 s <<< FAILURE! com.consol.citrus.exceptions.TestCaseFailedException: Test case failed Caused by: org.springframework.jms.UncategorizedJmsException: Uncategorized exception occurred during JMS processing; nested exception is javax.jms.JMSException: Could not connect to broker URL: tcp://localhost:61616. Reason: java.net.ConnectException: Connection refused: connect Caused by: javax.jms.JMSException: Could not connect to broker URL: tcp://localhost:61616. Reason: java.net.ConnectException: Connection refused: connect Caused by: java.net.ConnectException: Connection refused: connect

It seems like something is missing (JMS broker, I suppose?) on localhost:61616 .

Could you please guide me how to execute successfully the sample?

(I am running Windows 10)


Solution

  • Short Answer

    I am sorry for your bad first impression with Citrus. You are right about the README file, this seems to be a copy-paste error. If will fix it in the repo.

    The correct maven command to execute is:

    mvn clean verify -Dembedded
    

    Long Answer

    The embedded parameter will activate two profiles in the POM, activemq-embedded and jetty-embedded. As their names suggest this will start an in-memory ActiveMQ broker, and a Jetty server with the system under test deployed before the integration tests run.

    Note that in other samples, e.g. sample-databind, the README suggests running mvn clean install -Dembedded=true. This will do almost the same, but I prefer the verify lifecycle since it doesn't copy the artefacts to the local maven repository. Moreover, the =true part for profile activation is not necessary, since the corresponding profiles are activated as soon as the property exists (irrelevant of its actual value), see

    <activation>
      <property>
        <name>embedded</name>
      </property>
    </activation>