Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This will install the contribution in the Tuscany runtime, start the composite it contains, and then wait. At this point you can use
other clients to send messages to services that the running SCA applcation exposes, for example, try learning-more/sca-client/calculator-scaclient.

maven-junit

Maven will run JUnit tests found in a module's src/test/java directory automatically. If you use embedded-jse style code in the JUnit test to install a contribution and start any composites it contains they you can unit test your contributions. This directory contains a contribution and a unit test which installs the contribution using very similar code to that found in embedded-jse.

To run the contributions unit test do the following:

Code Block

cd maven-junit/calculator-contribution
mvn

maven-junit-osgi

You can use a special Tuscany Maven plugin (maven-osgi-junit-plugin) to unit test contributions in a JUnit environment. This relies on adding some configuration to the Maven pom.xml. For example, if you look in maven-junit-osgi/calculator-osgi you'll see:

Code Block

            <plugin>
                <groupId>org.apache.tuscany.maven.plugins</groupId>
                <artifactId>maven-osgi-junit-plugin</artifactId>
                <version>1.0</version>
                <dependencies>
                   <dependency>
                      <groupId>org.apache.tuscany.sca</groupId>
                      <artifactId>tuscany-node-launcher-equinox</artifactId>
                      <version>${pom.version}</version>
                   </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <id>osgi-test</id>
                        <phase>test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <systemProperties>
                                <property>
                                    <name>osgi.configuration.area</name>
                                    <value>${project.build.directory}/equinox</value>
                                </property>
                            </systemProperties>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

This configures the maven-osgi-junit-plugin to use the tuscany-node-launcher-equinox to install the contribution represented by the calculator-osgi directory. As an alternative to this configuration you could use the contents of tuscany-node-launcher-equinox directly in your JUnit test to launch the Tuscany runtime using OSGi.

To run the contributions unit test do the following:

Code Block

cd maven-junit/calculator-contribution
mvn

osgi

The Tuscany runtime can be run in a vanilla OSGi container such as Equinox. To do this you have to:

...