summaryrefslogtreecommitdiffstats
path: root/site/trunk/site-publish/plugins/tuscany-itest-plugin/usage.html
diff options
context:
space:
mode:
Diffstat (limited to 'site/trunk/site-publish/plugins/tuscany-itest-plugin/usage.html')
-rw-r--r--site/trunk/site-publish/plugins/tuscany-itest-plugin/usage.html190
1 files changed, 190 insertions, 0 deletions
diff --git a/site/trunk/site-publish/plugins/tuscany-itest-plugin/usage.html b/site/trunk/site-publish/plugins/tuscany-itest-plugin/usage.html
new file mode 100644
index 0000000000..32f475446f
--- /dev/null
+++ b/site/trunk/site-publish/plugins/tuscany-itest-plugin/usage.html
@@ -0,0 +1,190 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+
+
+
+
+
+
+
+
+
+<html>
+ <head>
+ <title>Apache Tuscany Integration Test Plugin - </title>
+ <style type="text/css" media="all">
+ @import url("./css/maven-base.css");
+ @import url("./css/maven-theme.css");
+ @import url("./css/site.css");
+ </style>
+ <link rel="stylesheet" href="./css/print.css" type="text/css" media="print" />
+ <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
+ </head>
+ <body class="composite">
+ <div id="banner">
+ <span id="bannerLeft">
+
+ Apache Tuscany Integration Test Plugin
+
+ </span>
+ <div class="clear">
+ <hr/>
+ </div>
+ </div>
+ <div id="breadcrumbs">
+
+
+
+
+
+
+
+
+ <div class="xleft">
+ Last Published: 02/15/2007
+ </div>
+ <div class="xright">
+
+
+
+
+
+
+
+ </div>
+ <div class="clear">
+ <hr/>
+ </div>
+ </div>
+ <div id="leftColumn">
+ <div id="navcolumn">
+
+
+
+
+
+
+
+
+ <h5>Overview</h5>
+ <ul>
+
+ <li class="none">
+ <a href="index.html">Introduction</a>
+ </li>
+
+ <li class="none">
+ <a href="plugin-info.html">Goals</a>
+ </li>
+
+ <li class="none">
+ <strong>Usage</strong>
+ </li>
+
+ <li class="none">
+ <a href="faq.html">FAQ</a>
+ </li>
+ </ul>
+ <h5>Examples</h5>
+ <ul>
+ </ul>
+ <a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy">
+ <img alt="Built by Maven" src="./images/logos/maven-feather.png"></img>
+ </a>
+
+
+
+
+
+
+
+
+ </div>
+ </div>
+ <div id="bodyColumn">
+ <div id="contentBox">
+ <div class="section"><h2>Usage</h2><p>The <tt>tuscany-itest-plugin</tt> is associated with the <tt>integration-test</tt> phase of the build lifecycle.</p><p>The plugin can be invoked directly from the command line:</p><div class="source"><pre>mvn org.apache.tuscany.sca:tuscany-itest-plugin:test</pre></div><p>or can be included in the build definition for your project:</p><div class="source"><pre> &lt;build&gt;
+ &lt;plugins&gt;
+ &lt;plugin&gt;
+ &lt;groupId&gt;org.apache.tuscany.sca&lt;/groupId&gt;
+ &lt;artifactId&gt;tuscany-itest-plugin&lt;/artifactId&gt;
+ &lt;executions&gt;
+ &lt;execution&gt;
+ &lt;goals&gt;
+ &lt;goal&gt;test&lt;/goal&gt;
+ &lt;/goals&gt;
+ &lt;/execution&gt;
+ &lt;/executions&gt;
+ &lt;/plugin&gt;
+ &lt;/plugins&gt;
+ &lt;/build&gt;</pre></div><div class="section"><h3>Writing Integration Tests</h3><p>Integration tests are written as JUnit TestCases (currently only JUnit 3.8.1 is supported but other frameworks may be added later) that use SCA references to access services provided by the components under test. The references are injected into your testcase before its setUp method is called (using constructor, setter or field injection).</p><p>For example, to test a component that implemented the <tt>MyService</tt> interface you could write:</p><div class="source"><pre>public class ServiceTestComponent extends TestCase {
+
+ @Reference
+ public MyService service;
+
+ public void testSomething() {
+ assertEquals(result, service.doSomething);
+ }
+}</pre></div><p>This TestCase is used as a component within a SCA composite that defines the test suite as described in the next section. This separates TestCase's for normal unit tests from those that are integration tests.</p><p>If any methods have an SCA <tt>@Init</tt> or <tt>@Destroy</tt> annotation they will be called before and after executing tests; if no methods are annotated in this way the normal JUnit <tt>setUp</tt> and <tt>tearDown</tt> methods will be called.</p><p>If the component's scope is <tt>STATELESS</tt> (the default), then a new instance of the test component will used to run each test; if the component's scope is <tt>COMPOSITE</tt> then a single instance will be used to run all tests. The scope can be set with the standard SCA <tt>@Scope</tt> annotation.</p></div><div class="section"><h3>Defining an SCA Test Suite</h3><p>The Test Suite for your integration tests is defined by an SCA composite file that contains the test components written above wired to the production components for the application. The test components must use an implementation type of <tt> &lt;tuscany:junit&gt; </tt>.</p><p>A simple way to achieve this is to use a SCDL <i>include</i> element to include the content of production composite in the test harness; this gives the test components access to all of the components and references in the production composite.</p><p>For example, the following SCDL configures the <tt>ServiceTestComponent</tt> above to test the <tt>MyServiceComponent</tt> in the production composite <tt>ProductionComposite</tt>:</p><div class="source"><pre>&lt;composite xmlns=&quot;http://www.osoa.org/xmlns/sca/1.0&quot;
+ xmlns:tuscany=&quot;http://tuscany.apache.org/xmlns/sca/1.0&quot;
+ name=&quot;PropertyTestHarnessComposite&quot;&gt;
+
+ &lt;include name=&quot;ProductionComposite&quot; scdlResource=&quot;META-INF/sca/default.scdl&quot;/&gt;
+
+ &lt;component name=&quot;testMyService&quot;&gt;
+ &lt;tuscany:junit class=&quot;ServiceTestComponent&quot;/&gt;
+ &lt;reference name=&quot;service&quot;&gt;MyServiceImpl&lt;/reference&gt;
+ &lt;/component&gt;
+&lt;/composite&gt;</pre></div><p>Alternatively, the production composite can be tested as a black box by using it to implement a component and wiring test components to it. This allows the externally visible services to be tested without knowledge of the internals of the composite.</p><p>For example, the following SCDL tests the <tt>ProductionComposite</tt> in this way:</p><div class="source"><pre>&lt;composite xmlns=&quot;http://www.osoa.org/xmlns/sca/1.0&quot;
+ xmlns:tuscany=&quot;http://tuscany.apache.org/xmlns/sca/1.0&quot;
+ name=&quot;PropertyTestHarnessComposite&quot;&gt;
+
+ &lt;component name=&quot;ProductionComponent&quot;&gt;
+ &lt;implementation.composite name=&quot;ProductionComposite&quot;
+ scdlResource=&quot;META-INF/sca/default.scdl&quot;/&gt;
+ &lt;/component&gt;
+
+ &lt;component name=&quot;testMyService&quot;&gt;
+ &lt;tuscany:junit class=&quot;ServiceTestComponent&quot;/&gt;
+ &lt;reference name=&quot;service&quot;&gt;ProductionComponent&lt;/reference&gt;
+ &lt;/component&gt;
+&lt;/composite&gt;</pre></div><p>The location of this test composite definition can be specified using the <tt>testScdl</tt> plugin configuration property; the default location is <tt>$<a name="project.build.testoutputdirectory">project.build.testOutputDirectory</a>/itest.scdl</tt> which allows the <tt>itest.scdl</tt> source file to be placed in the test resources (<tt>src/test/resources</tt>).</p></div><div class="section"><h3>Test Result Output</h3><p>The test results are output using Surefire's reporting framework for integration with other test reports. XML and test results are stored in the normal test output directory (<tt>target/surefire-reports</tt>) with a summary displayed on the console:</p><div class="source"><pre>[INFO] [tuscany-itest:test {execution: default}]
+[INFO] Starting Tuscany...
+[INFO] Deploying test SCDL from .../target/test-classes/itest.scdl
+[INFO] Executing tests...
+
+-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running testMyService
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.002 sec
+
+Results :
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
+[INFO] Stopping Tuscany...</pre></div></div></div>
+ </div>
+ </div>
+ <div class="clear">
+ <hr/>
+ </div>
+ <div id="footer">
+ <div class="xright">&#169;
+ 2007
+
+ Apache Software Foundation
+
+
+
+
+
+
+
+
+ </div>
+ <div class="clear">
+ <hr/>
+ </div>
+ </div>
+ </body>
+</html>