Creating a Maven project for unit test - 8.0

Data Service and Routing Examples

Version
8.0
Language
English
Product
Talend Data Fabric
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for ESB
Talend Real-Time Big Data Platform
Module
Talend Studio
Content
Design and Development > Designing Routes
Design and Development > Designing Services
Last publication date
2023-12-08

Unit tests will be put in a separate project.

You need to switch to the Java perspective and create a simple maven-based project.

Procedure

  1. Right-click the blank area in the Package Explorer and select New > Project... in the context menu.
  2. The New Project wizard opens. Select Maven Project under the Maven node and click Next.
    New Project wizard.
  3. In the Select project name and location view, the Use default Workspace location option is selected. Keep it and click Next.
    New Maven Project wizard.
  4. In the Select an Archetype view, the GroupId org.apache.maven.archetypes and ArtifactId maven-archetype-quickstart is selected. Keep the default settings and click Next.
    New Maven Project wizard.
  5. In the Specify Archetype parameters view, enter org.talend in the Group Id field and route-unit-test in the Artifact Id field. Click Finish. The project appears in the Package Explorer.
    New Maven Project wizard.
  6. Double-click the pom.xml file under the newly created project node to open it in the design workspace and edit it as shown below.
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>org.talend</groupId>
        <artifactId>route-unit-test</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <dependencies>
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.8.1</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.camel</groupId>
                <artifactId>camel-test</artifactId>
                <version>2.9.1</version>
            </dependency>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-jdk14</artifactId>
                <version>1.6.1</version>
            </dependency>
            <dependency>
                <groupId>org.talend.camel</groupId>
                <artifactId>systemRoutines</artifactId>
                <version>1.0.0</version>
            </dependency>
            <dependency>
                <groupId>org.talend.camel</groupId>
                <artifactId>userRoutines</artifactId>
                <version>1.0.0</version>
            </dependency>
            <dependency>
                <groupId>org.example</groupId>
                <artifactId>SimpleRoute</artifactId>
                <version>0.2.0-SNAPSHOT</version>
                <type>jar</type>
            </dependency>
        </dependencies>
        <repositories>
            <repository>
                <id>repo-snapshot</id>
                <name>Snapshots bundles</name>
                <url>http://tadmin:tadmin@localhost:8082/archiva/repository/repo-snapshot/</url>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
            </repository>
        </repositories>
    </project>

    As is shown above, the Maven dependencies are Junit and Camel unit testing framework, Utility JAR files required for Talend ESB Route, and Route JAR files published from Talend Studio.

    In this use case we will use the Route in Talend Artifact Repository directly, so it needs to be added into the pom.xml file as a repository. The username and password is put in the repository URL for simplicity. You can also specify it in your ${Maven_HOME}/conf/settings.xml.

  7. Save your pom.xml file.