deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From johndam...@apache.org
Subject svn commit: r1756698 [18/18] - /deltaspike/site/trunk/content/documentation/
Date Thu, 18 Aug 2016 00:36:56 GMT
Modified: deltaspike/site/trunk/content/documentation/test-control.html
URL: http://svn.apache.org/viewvc/deltaspike/site/trunk/content/documentation/test-control.html?rev=1756698&r1=1756697&r2=1756698&view=diff
==============================================================================
--- deltaspike/site/trunk/content/documentation/test-control.html (original)
+++ deltaspike/site/trunk/content/documentation/test-control.html Thu Aug 18 00:36:56 2016
@@ -1,1074 +1,1078 @@
-<!DOCTYPE html>
-<head>
-    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-    <meta charset="utf-8">
-    <meta name="viewport" content="width=device-width, initial-scale=1.0">
-    <meta name="description" content="deltaspike-generate-pages">
-    <meta name="author" content="chm">
-    <!-- No caching headers -->
-    <meta http-equiv="cache-control" content="no-cache"/>
-    <meta http-equiv="pragma" content="no-cache"/>
-    <meta http-equiv="expires" content="-1"/>
-
-    <title>Test-Control Module</title>
-
-    <!--
-        Licensed to the Apache Software Foundation (ASF) under one
-        or more contributor license agreements.  See the NOTICE file
-        distributed with this work for additional information
-        regarding copyright ownership.  The ASF licenses this file
-        to you 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.
-    -->
-
-    <!-- Styles -->
-    <link href="https://deltaspike.apache.org/resources/css/bootstrap.css" rel="stylesheet">
-    <link href="https://deltaspike.apache.org/resources/css/bootstrap-responsive.css" rel="stylesheet">
-    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.1.0/css/font-awesome.min.css" rel="stylesheet">
-
-    
-
-    
-        <!-- Tocify - nice dynamic autoscrolling TOC -->
-        <link href="https://cdnjs.cloudflare.com/ajax/libs/jquery.tocify/1.9.0/stylesheets/jquery.tocify.min.css" rel="stylesheet">
-        <script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
-        <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
-        <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.tocify/1.9.0/javascripts/jquery.tocify.min.js"></script>
-
-
-        <script type="text/javascript">
-            $(function () {
-                $("#toc").tocify({
-                    scrollTo: 50,
-                    extendPage: true,
-                    context: "#doc-content",
-                    selectors: "h2,h3,h4,h5"
-                });
-                $(".fallback-toc").hide();
-            });
-        </script>
-    
-
-    <style type="text/css">
-        /* Stylesheet for CodeRay to match GitHub theme | MIT License | http://foundation.zurb.com */
-/*pre.CodeRay {background-color:#f7f7f8;}*/
-.CodeRay .line-numbers{border-right:1px solid #d8d8d8;padding:0 0.5em 0 .25em}
-.CodeRay span.line-numbers{display:inline-block;margin-right:.5em;color:rgba(0,0,0,.3)}
-.CodeRay .line-numbers strong{font-weight: normal}
-table.CodeRay{border-collapse:separate;border-spacing:0;margin-bottom:0;border:0;background:none}
-table.CodeRay td{vertical-align: top}
-table.CodeRay td.line-numbers{text-align:right}
-table.CodeRay td.line-numbers>pre{padding:0;color:rgba(0,0,0,.3)}
-table.CodeRay td.code{padding:0 0 0 .5em}
-table.CodeRay td.code>pre{padding:0}
-.CodeRay .debug{color:#fff !important;background:#000080 !important}
-.CodeRay .annotation{color:#007}
-.CodeRay .attribute-name{color:#000080}
-.CodeRay .attribute-value{color:#700}
-.CodeRay .binary{color:#509}
-.CodeRay .comment{color:#998;font-style:italic}
-.CodeRay .char{color:#04d}
-.CodeRay .char .content{color:#04d}
-.CodeRay .char .delimiter{color:#039}
-.CodeRay .class{color:#458;font-weight:bold}
-.CodeRay .complex{color:#a08}
-.CodeRay .constant,.CodeRay .predefined-constant{color:#008080}
-.CodeRay .color{color:#099}
-.CodeRay .class-variable{color:#369}
-.CodeRay .decorator{color:#b0b}
-.CodeRay .definition{color:#099}
-.CodeRay .delimiter{color:#000}
-.CodeRay .doc{color:#970}
-.CodeRay .doctype{color:#34b}
-.CodeRay .doc-string{color:#d42}
-.CodeRay .escape{color:#666}
-.CodeRay .entity{color:#800}
-.CodeRay .error{color:#808}
-.CodeRay .exception{color:inherit}
-.CodeRay .filename{color:#099}
-.CodeRay .function{color:#900;font-weight:bold}
-.CodeRay .global-variable{color:#008080}
-.CodeRay .hex{color:#058}
-.CodeRay .integer,.CodeRay .float{color:#099}
-.CodeRay .include{color:#555}
-.CodeRay .inline{color:#00}
-.CodeRay .inline .inline{background:#ccc}
-.CodeRay .inline .inline .inline{background:#bbb}
-.CodeRay .inline .inline-delimiter{color:#d14}
-.CodeRay .inline-delimiter{color:#d14}
-.CodeRay .important{color:#555;font-weight:bold}
-.CodeRay .interpreted{color:#b2b}
-.CodeRay .instance-variable{color:#008080}
-.CodeRay .label{color:#970}
-.CodeRay .local-variable{color:#963}
-.CodeRay .octal{color:#40e}
-.CodeRay .predefined{color:#369}
-.CodeRay .preprocessor{color:#579}
-.CodeRay .pseudo-class{color:#555}
-.CodeRay .directive{font-weight:bold}
-.CodeRay .type{font-weight:bold}
-.CodeRay .predefined-type{color:inherit}
-.CodeRay .reserved,.CodeRay .keyword {color:#000;font-weight:bold}
-.CodeRay .key{color:#808}
-.CodeRay .key .delimiter{color:#606}
-.CodeRay .key .char{color:#80f}
-.CodeRay .value{color:#088}
-.CodeRay .regexp .delimiter{color:#808}
-.CodeRay .regexp .content{color:#808}
-.CodeRay .regexp .modifier{color:#808}
-.CodeRay .regexp .char{color:#d14}
-.CodeRay .regexp .function{color:#404;font-weight:bold}
-.CodeRay .string{color:#d20}
-.CodeRay .string .string .string{background:#ffd0d0}
-.CodeRay .string .content{color:#d14}
-.CodeRay .string .char{color:#d14}
-.CodeRay .string .delimiter{color:#d14}
-.CodeRay .shell{color:#d14}
-.CodeRay .shell .delimiter{color:#d14}
-.CodeRay .symbol{color:#990073}
-.CodeRay .symbol .content{color:#a60}
-.CodeRay .symbol .delimiter{color:#630}
-.CodeRay .tag{color:#008080}
-.CodeRay .tag-special{color:#d70}
-.CodeRay .variable{color:#036}
-.CodeRay .insert{background:#afa}
-.CodeRay .delete{background:#faa}
-.CodeRay .change{color:#aaf;background:#007}
-.CodeRay .head{color:#f8f;background:#505}
-.CodeRay .insert .insert{color:#080}
-.CodeRay .delete .delete{color:#800}
-.CodeRay .change .change{color:#66f}
-.CodeRay .head .head{color:#f4f}
-
-        body {
-            padding-top: 60px;
-            padding-bottom: 40px;
-        }
-
-        .toc-like {
-            border-radius: 6px;
-            border: 1px solid #ccc;
-        }
-
-        .toc-like li {
-            line-height: 30px;
-            text-indent: 10px;
-        }
-
-        .toc-like li.custom-toc-header {
-            font-weight: bold;
-            background: #666;
-            color: white;
-            cursor: initial !important;
-            padding: 5px;
-        }
-
-        .toc-like li.custom-toc-header a {
-            color: white;
-            font-style: normal;
-            text-shadow: none;
-            padding: 0;
-        }
-
-        .toc-like li.custom-toc-header:hover a {
-            background: #666;
-        }
-
-        .page-title {
-            text-align: left;
-        }
-
-        #doc-content h2,
-        #doc-content h3,
-        #doc-content h4,
-        #doc-content h5,
-        #doc-content h6 {
-            padding-top: 0;
-            margin-top: 25px;
-            margin-bottom: 10px;
-            line-height: 1.4em;
-        }
-
-        #doc-content h2 {
-            border-bottom: 1px solid lightgrey;
-        }
-
-
-    </style>
-
-    <script type="text/javascript">
-
-        var _gaq = _gaq || [];
-        _gaq.push(['_setAccount', 'UA-36103647-1']);
-        _gaq.push(['_trackPageview']);
-
-        (function () {
-            var ga = document.createElement('script');
-            ga.type = 'text/javascript';
-            ga.async = true;
-            ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
-            var s = document.getElementsByTagName('script')[0];
-            s.parentNode.insertBefore(ga, s);
-        })();
-
-    </script>
-</head>
-
-<body>
-
-<div class="navbar navbar-fixed-top">
-    <div class="navbar-inner">
-        <div class="container">
-            <a class="btn btn-navbar" data-toggle="collapse"
-               data-target=".nav-collapse"> <span class="icon-bar"></span> <span
-            class="icon-bar"></span> <span class="icon-bar"></span>
-            </a>
-            <a class="brand logocolor" href="../index.html">Apache DeltaSpike</a>
-
-            <div class="nav-collapse">
-
-                
-                <ul class="nav">
-                    <li><a href="../index.html">Home</a></li>
-                    <li class="active"><a href="../documentation">Documentation</a></li>
-                    <li  ><a href="../javadoc.html">Javadoc</a></li>
-                    <li ><a href="../source.html">Source</a></li>
-                    <li ><a href="../download.html">Download</a></li>
-                    <li ><a href="../community.html">Community</a></li>
-                    <!-- <li><a href="./support.html">Support</a></li>  -->
-                    <li ><a href="../news.html">News</a></li>
-                </ul>
-            </div>
-            <!--/.nav-collapse -->
-            <form id="search-form" action="https://www.google.com/search"
-                  method="get" class="navbar-search pull-right">
-                <input value="deltaspike.apache.org" name="sitesearch"
-                       type="hidden"> <input class="search-query" name="q"
-                                             id="query" type="text">
-            </form>
-        </div>
-    </div>
-</div>
-
-<div class="container">
-    <div class="row-fluid">
-
-        
-
-        <div class="span8">
-            <div class="page-title">
-                <h1>Test-Control Module</h1>
-            </div>
-
-            <div id="doc-content">
-                <div class="sect1">
-<h2 id="_overview">Overview</h2>
-<div class="sectionbody">
-<div class="paragraph">
-<p>The Test-Control module enables you to write CDI-based tests easily. Calls to stop and start the CDI container are built into the Test-Control API, with simplified commands for customizing the management of contexts and other aspects during testing.</p>
-</div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_project_setup">Project Setup</h2>
-<div class="sectionbody">
-<div class="paragraph">
-<p>The configuration information provided here is for Maven-based projects and it assumes that you have already declared the DeltaSpike version and DeltaSpike Core module for your projects, as detailed in <a href="configure.html">Configure DeltaSpike in Your Projects</a>. For Maven-independent projects, see <a href="configure.html#config-maven-indep">Configure DeltaSpike in Maven-independent Projects</a>.</p>
-</div>
-<div class="sect2">
-<h3 id="_1_declare_test_control_module_dependencies">1. Declare Test-Control Module Dependencies</h3>
-<div class="paragraph">
-<p>Add the Test-Control module to the list of dependencies in the project <code>pom.xml</code> file using this code snippet:</p>
-</div>
-<div class="listingblock">
-<div class="content">
-<pre class="CodeRay highlight"><code data-lang="xml"><span class="tag">&lt;dependency&gt;</span>
-    <span class="tag">&lt;groupId&gt;</span>org.apache.deltaspike.modules<span class="tag">&lt;/groupId&gt;</span>
-    <span class="tag">&lt;artifactId&gt;</span>deltaspike-test-control-module-api<span class="tag">&lt;/artifactId&gt;</span>
-    <span class="tag">&lt;version&gt;</span>${deltaspike.version}<span class="tag">&lt;/version&gt;</span>
-    <span class="tag">&lt;scope&gt;</span>test<span class="tag">&lt;/scope&gt;</span>
-<span class="tag">&lt;/dependency&gt;</span>
-
-<span class="tag">&lt;dependency&gt;</span>
-    <span class="tag">&lt;groupId&gt;</span>org.apache.deltaspike.modules<span class="tag">&lt;/groupId&gt;</span>
-    <span class="tag">&lt;artifactId&gt;</span>deltaspike-test-control-module-impl<span class="tag">&lt;/artifactId&gt;</span>
-    <span class="tag">&lt;version&gt;</span>${deltaspike.version}<span class="tag">&lt;/version&gt;</span>
-    <span class="tag">&lt;scope&gt;</span>test<span class="tag">&lt;/scope&gt;</span>
-<span class="tag">&lt;/dependency&gt;</span></code></pre>
-</div>
-</div>
-<div class="paragraph">
-<p>Or if you&#8217;re using Gradle, add these dependencies to your <code>build.gradle</code>:</p>
-</div>
-<div class="listingblock">
-<div class="content">
-<pre class="CodeRay highlight"><code>     testCompile 'org.apache.deltaspike.modules:deltaspike-test-control-module-impl'
-     testRuntime 'org.apache.deltaspike.modules:deltaspike-test-control-module-api'</code></pre>
-</div>
-</div>
-</div>
-<div class="sect2">
-<h3 id="_2_declare_cdi_implementation_specific_dependencies">2. Declare CDI-implementation-specific dependencies</h3>
-<div class="paragraph">
-<p>The Test-Control module depends on the Container-Control module, which provides adapters for several major CDI implementations. Therefore, to use Test-Control, declare dependency on a CDI implementation and a corresponding Container Control implementation in the <code>pom.xml</code>.</p>
-</div>
-<div class="sect3">
-<h4 id="_openwebbeans">OpenWebBeans</h4>
-<div class="paragraph">
-<p>If you are using OpenWebBeans, add an OpenWebBeans implementation and the OpenWebBeans-specific Container Control module to the list of dependencies:</p>
-</div>
-<div class="listingblock">
-<div class="content">
-<pre class="CodeRay highlight"><code data-lang="xml"> <span class="tag">&lt;dependency&gt;</span>
-     <span class="tag">&lt;groupId&gt;</span>org.apache.deltaspike.cdictrl<span class="tag">&lt;/groupId&gt;</span>
-     <span class="tag">&lt;artifactId&gt;</span>deltaspike-cdictrl-owb<span class="tag">&lt;/artifactId&gt;</span>
-     <span class="tag">&lt;version&gt;</span>${deltaspike.version}<span class="tag">&lt;/version&gt;</span>
-     <span class="tag">&lt;scope&gt;</span>test<span class="tag">&lt;/scope&gt;</span>
- <span class="tag">&lt;/dependency&gt;</span>
-
-<span class="tag">&lt;dependency&gt;</span>
-    <span class="tag">&lt;groupId&gt;</span>org.apache.openwebbeans<span class="tag">&lt;/groupId&gt;</span>
-    <span class="tag">&lt;artifactId&gt;</span>openwebbeans-impl<span class="tag">&lt;/artifactId&gt;</span>
-    <span class="tag">&lt;version&gt;</span>${owb.version}<span class="tag">&lt;/version&gt;</span>
-    <span class="tag">&lt;scope&gt;</span>test<span class="tag">&lt;/scope&gt;</span>
-<span class="tag">&lt;/dependency&gt;</span></code></pre>
-</div>
-</div>
-</div>
-<div class="sect3">
-<h4 id="_weld">Weld</h4>
-<div class="paragraph">
-<p>If you are using Weld, add a Weld implementation and the Weld-specific Container Control module to the list of dependencies:</p>
-</div>
-<div class="listingblock">
-<div class="content">
-<pre class="CodeRay highlight"><code data-lang="xml"><span class="tag">&lt;dependency&gt;</span>
-    <span class="tag">&lt;groupId&gt;</span>org.apache.deltaspike.cdictrl<span class="tag">&lt;/groupId&gt;</span>
-    <span class="tag">&lt;artifactId&gt;</span>deltaspike-cdictrl-weld<span class="tag">&lt;/artifactId&gt;</span>
-    <span class="tag">&lt;version&gt;</span>${deltaspike.version}<span class="tag">&lt;/version&gt;</span>
-    <span class="tag">&lt;scope&gt;</span>test<span class="tag">&lt;/scope&gt;</span>
-<span class="tag">&lt;/dependency&gt;</span>
-
-<span class="tag">&lt;dependency&gt;</span>
-    <span class="tag">&lt;groupId&gt;</span>org.jboss.weld.se<span class="tag">&lt;/groupId&gt;</span>
-    <span class="tag">&lt;artifactId&gt;</span>weld-se-core<span class="tag">&lt;/artifactId&gt;</span>
-    <span class="tag">&lt;version&gt;</span>${weld.version}<span class="tag">&lt;/version&gt;</span>
-    <span class="tag">&lt;scope&gt;</span>test<span class="tag">&lt;/scope&gt;</span>
-<span class="tag">&lt;/dependency&gt;</span></code></pre>
-</div>
-</div>
-</div>
-<div class="sect3">
-<h4 id="_openejb">OpenEJB</h4>
-<div class="paragraph">
-<p>If you are using OpenWebBeans as the CDI implementation and you need to test
-EJBs as well, add the OpenEJB-specific Container Control module to the list
-of dependencies instead of the OpenWebBeans-specific Container Control module:</p>
-</div>
-<div class="listingblock">
-<div class="content">
-<pre class="CodeRay highlight"><code data-lang="xml"><span class="tag">&lt;dependency&gt;</span>
-    <span class="tag">&lt;groupId&gt;</span>org.apache.deltaspike.cdictrl<span class="tag">&lt;/groupId&gt;</span>
-    <span class="tag">&lt;artifactId&gt;</span>deltaspike-cdictrl-openejb<span class="tag">&lt;/artifactId&gt;</span>
-    <span class="tag">&lt;version&gt;</span>${deltaspike.version}<span class="tag">&lt;/version&gt;</span>
-    <span class="tag">&lt;scope&gt;</span>test<span class="tag">&lt;/scope&gt;</span>
-<span class="tag">&lt;/dependency&gt;</span>
-
-<span class="tag">&lt;dependency&gt;</span>
-    <span class="tag">&lt;groupId&gt;</span>org.apache.openejb<span class="tag">&lt;/groupId&gt;</span>
-    <span class="tag">&lt;artifactId&gt;</span>openejb-core<span class="tag">&lt;/artifactId&gt;</span>
-    <span class="tag">&lt;version&gt;</span>${openejb.version}<span class="tag">&lt;/version&gt;</span>
-    <span class="tag">&lt;scope&gt;</span>test<span class="tag">&lt;/scope&gt;</span>
-<span class="tag">&lt;/dependency&gt;</span></code></pre>
-</div>
-</div>
-</div>
-</div>
-<div class="sect2">
-<h3 id="_3_complete_additional_project_configuration">3. Complete Additional Project Configuration</h3>
-<div class="paragraph">
-<p>Add a <code>beans.xml</code> file in the project test module (e.g. src/test/resources/META-INF/beans.xml).</p>
-</div>
-</div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_automated_container_booting_and_shutdown">Automated Container Booting and Shutdown</h2>
-<div class="sectionbody">
-<div class="sect2">
-<h3 id="_cditestrunner">CdiTestRunner</h3>
-<div class="paragraph">
-<p>Start and stop the CDI container automatically per test class with CdiTestRunner, a JUnit Test-Runner.
-This also starts and stops one request and session per test-method.</p>
-</div>
-<div class="listingblock">
-<div class="title">Example of CdiTestRunner Usage</div>
-<div class="content">
-<pre class="CodeRay highlight"><code data-lang="java"><span class="annotation">@RunWith</span>(CdiTestRunner.class)
-<span class="directive">public</span> <span class="type">class</span> <span class="class">ContainerAndInjectionControl</span>
-{
-    <span class="annotation">@Inject</span>
-    <span class="directive">private</span> ApplicationScopedBean applicationScopedBean;
-
-    <span class="annotation">@Inject</span>
-    <span class="directive">private</span> SessionScopedBean sessionScopedBean;
-
-    <span class="annotation">@Inject</span>
-    <span class="directive">private</span> RequestScopedBean requestScopedBean;
-
-    <span class="comment">//test the injected beans</span>
-}</code></pre>
-</div>
-</div>
-</div>
-<div class="sect2">
-<h3 id="_cditestsuiterunner">CdiTestSuiteRunner</h3>
-<div class="paragraph">
-<p>Extend automated CDI container start and stop actions to whole test suites with CdiTestSuiteRunner, a JUnit Test-Suite-Runner.</p>
-</div>
-<div class="listingblock">
-<div class="title">Example of CdiTestSuiteRunner Usage</div>
-<div class="content">
-<pre class="CodeRay highlight"><code data-lang="java"><span class="annotation">@RunWith</span>(CdiTestSuiteRunner.class)
-<span class="annotation">@Suite</span>.SuiteClasses({
-    TestX.class,
-    TestY.class
-})
-<span class="directive">public</span> <span class="type">class</span> <span class="class">SuiteLevelContainerControl</span>
-{
-}</code></pre>
-</div>
-</div>
-</div>
-<div class="sect2">
-<h3 id="_optional_shutdown_configuration">Optional Shutdown Configuration</h3>
-<div class="paragraph">
-<p>You can set <code>deltaspike.testcontrol.stop_container</code> to <code>false</code> (via the standard DeltaSpike config), resulting in the CDI Container being started just once for all tests.</p>
-</div>
-</div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_test_customization">Test Customization</h2>
-<div class="sectionbody">
-<div class="sect2">
-<h3 id="__testcontrol">@TestControl</h3>
-<div class="paragraph">
-<p>Customize the default behavior of CdiTestRunner with @TestControl. In the following
-case only one session for all test-methods (of the test-class) will be
-created.</p>
-</div>
-<div class="listingblock">
-<div class="title">Example of @TestControl Usage</div>
-<div class="content">
-<pre class="CodeRay highlight"><code data-lang="java"><span class="annotation">@RunWith</span>(CdiTestRunner.class)
-<span class="annotation">@TestControl</span>(startScopes = SessionScoped.class)
-<span class="directive">public</span> <span class="type">class</span> <span class="class">CustomizedScopeHandling</span>
-{
-    <span class="comment">//inject beans and test them</span>
-}</code></pre>
-</div>
-</div>
-</div>
-<div class="sect2">
-<h3 id="_projectstage_control">ProjectStage Control</h3>
-<div class="paragraph">
-<p>Override the default ProjectStage for unit tests with <code>ProjectStage.UnitTest.class</code>.</p>
-</div>
-<div class="listingblock">
-<div class="title">Example of projectStage Usage</div>
-<div class="content">
-<pre class="CodeRay highlight"><code data-lang="java"><span class="annotation">@RunWith</span>(CdiTestRunner.class)
-<span class="annotation">@TestControl</span>(projectStage = CustomTestStage.class)
-<span class="directive">public</span> <span class="type">class</span> <span class="class">TestStageControl</span>
-{
-    <span class="comment">//tests here will see ProjectStage CustomTestStage.class</span>
-
-    <span class="annotation">@Test</span>
-    <span class="annotation">@TestControl</span>(projectStage = ProjectStage.Development.class)
-    <span class="directive">public</span> <span class="type">void</span> checkDevEnv()
-    {
-    }
-
-    <span class="comment">//tests here will see ProjectStage CustomTestStage.class</span>
-}</code></pre>
-</div>
-</div>
-</div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_optional_configuration">Optional Configuration</h2>
-<div class="sectionbody">
-<div class="paragraph">
-<p>From DeltaSpike 1.2, it is possible to provide a configuration for the underlying test-container.
-However, currently only the adapter for OpenEJB embedded (available in CDI-Control) supports it out-of-the-box.
-To pass properties to the underlying test-container,
-you have to add <code>/META-INF/apache-deltaspike_test-container.properties</code>
-to the resources-directory of your test-classpath.
-The content of the file are key/value pairs which get passed to the container.
-Therefore, it is a configuration which is not used by DeltaSpike itself
-(it is just forwarded (as it is) to the underlying test-container).</p>
-</div>
-<div class="sect2">
-<h3 id="_reconfigure_the_config_file_name_or_location">Reconfigure the config-file Name or Location</h3>
-<div class="paragraph">
-<p>If you would like to point to an existing config-file, you have to add for example:</p>
-</div>
-<div class="listingblock">
-<div class="content">
-<pre class="CodeRay highlight"><code data-lang="Properties">deltaspike.testcontrol.test-container.config-file=META-INF/existingConfig.properties</code></pre>
-</div>
-</div>
-<div class="paragraph">
-<p>to <code>/META-INF/apache-deltaspike.properties</code>.</p>
-</div>
-<div class="paragraph">
-<p>If you would like to do it per ProjectStage, you can use for example:</p>
-</div>
-<div class="listingblock">
-<div class="content">
-<pre class="CodeRay highlight"><code data-lang="Properties">deltaspike.testcontrol.test-container.config-file.UnitTest=META-INF/unit-test/existingConfig.properties</code></pre>
-</div>
-</div>
-</div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_optional_integrations">Optional Integrations</h2>
-<div class="sectionbody">
-<div class="sect2">
-<h3 id="_mock_frameworks">Mock Frameworks</h3>
-<div class="paragraph">
-<p>From DeltaSpike 1.0, it is possible to mock CDI-Beans. Usually @Exclude (+
-ProjectStage) is enough, however, for some cases mocked beans might be
-easier. Therefore it is possible to create (mock-)instances manually or
-via a mocking framework and add them, for example, via <code>DynamicMockManager</code>.</p>
-</div>
-<div class="paragraph">
-<p><strong>Attention:</strong> Mocking CDI beans is not supported for every feature of CDI and/or
-every implementation version. For example, we can not mock intercepted CDI beans and
-with some implementations mocking specialized beans fails.
-Usually all features are active by default, however,
-due to those reasons we deactivated this feature by default.
-You can enable it by adding</p>
-</div>
-<div class="paragraph">
-<p><code>deltaspike.testcontrol.mock-support.allow_mocked_beans=true</code>
-and/or
-<code>deltaspike.testcontrol.mock-support.allow_mocked_producers=true</code></p>
-</div>
-<div class="paragraph">
-<p>to <code>/META-INF/apache-deltaspike.properties</code> in your test-folder.</p>
-</div>
-<div class="paragraph">
-<p>If you need dependency-injection in the mocked instances, you can use
-<code>BeanProvider.injectFields(myMockedBean);</code>.</p>
-</div>
-<div class="listingblock">
-<div class="content">
-<pre class="CodeRay highlight"><code data-lang="java"><span class="annotation">@RunWith</span>(CdiTestRunner.class)
-<span class="directive">public</span> <span class="type">class</span> <span class="class">MockedRequestScopedBeanTest</span>
-{
-    <span class="annotation">@Inject</span>
-    <span class="directive">private</span> RequestScopedBean requestScopedBean;
-
-    <span class="annotation">@Inject</span>
-    <span class="directive">private</span> DynamicMockManager mockManager;
-
-    <span class="annotation">@Test</span>
-    <span class="directive">public</span> <span class="type">void</span> manualMock()
-    {
-        mockManager.addMock(<span class="keyword">new</span> RequestScopedBean() {
-            <span class="annotation">@Override</span>
-            <span class="directive">public</span> <span class="type">int</span> getCount()
-            {
-                <span class="keyword">return</span> <span class="integer">7</span>;
-            }
-        });
-
-        Assert.assertEquals(<span class="integer">7</span>, requestScopedBean.getCount());
-        requestScopedBean.increaseCount();
-        Assert.assertEquals(<span class="integer">7</span>, requestScopedBean.getCount());
-    }
-}
-
-<span class="annotation">@RequestScoped</span>
-<span class="directive">public</span> <span class="type">class</span> <span class="class">RequestScopedBean</span>
-{
-    <span class="directive">private</span> <span class="type">int</span> count = <span class="integer">0</span>;
-
-    <span class="directive">public</span> <span class="type">int</span> getCount()
-    {
-        <span class="keyword">return</span> count;
-    }
-
-    <span class="directive">public</span> <span class="type">void</span> increaseCount()
-    {
-        <span class="local-variable">this</span>.count++;
-    }
-}</code></pre>
-</div>
-</div>
-<div class="paragraph">
-<p>Using a mocking framework makes no difference for adding the mock.</p>
-</div>
-<div class="listingblock">
-<div class="title">Example via Mockito</div>
-<div class="content">
-<pre class="CodeRay highlight"><code data-lang="java"><span class="annotation">@RunWith</span>(CdiTestRunner.class)
-<span class="directive">public</span> <span class="type">class</span> <span class="class">MockitoMockedRequestScopedBeanTest</span>
-{
-    <span class="annotation">@Inject</span>
-    <span class="directive">private</span> RequestScopedBean requestScopedBean;
-
-    <span class="annotation">@Inject</span>
-    <span class="directive">private</span> DynamicMockManager mockManager;
-
-    <span class="annotation">@Test</span>
-    <span class="directive">public</span> <span class="type">void</span> mockitoMockAsCdiBean()
-    {
-        RequestScopedBean mockedRequestScopedBean = mock(RequestScopedBean.class);
-        when(mockedRequestScopedBean.getCount()).thenReturn(<span class="integer">7</span>);
-        mockManager.addMock(mockedRequestScopedBean);
-
-        Assert.assertEquals(<span class="integer">7</span>, requestScopedBean.getCount());
-        requestScopedBean.increaseCount();
-        Assert.assertEquals(<span class="integer">7</span>, requestScopedBean.getCount());
-    }
-}</code></pre>
-</div>
-</div>
-<div class="paragraph">
-<p>Since CDI implementations like OpenWebBeans use a lot of optimizations,
-it is required to handle mocks for application-scoped beans differently, for example:</p>
-</div>
-<div class="listingblock">
-<div class="content">
-<pre class="CodeRay highlight"><code data-lang="java"><span class="annotation">@RunWith</span>(CdiTestRunner.class)
-<span class="directive">public</span> <span class="type">class</span> <span class="class">MockedApplicationScopedBeanTest</span>
-{
-    <span class="annotation">@Inject</span>
-    <span class="directive">private</span> ApplicationScopedBean applicationScopedBean;
-
-    <span class="annotation">@BeforeClass</span>
-    <span class="directive">public</span> <span class="directive">static</span> <span class="type">void</span> init()
-    {
-        ApplicationMockManager applicationMockManager = BeanProvider.getContextualReference(ApplicationMockManager.class);
-        applicationMockManager.addMock(<span class="keyword">new</span> MockedApplicationScopedBean());
-    }
-
-    <span class="annotation">@Test</span>
-    <span class="directive">public</span> <span class="type">void</span> manualMock()
-    {
-        Assert.assertEquals(<span class="integer">14</span>, applicationScopedBean.getCount());
-        applicationScopedBean.increaseCount();
-        Assert.assertEquals(<span class="integer">14</span>, applicationScopedBean.getCount());
-    }
-}
-
-<span class="annotation">@ApplicationScoped</span>
-<span class="directive">public</span> <span class="type">class</span> <span class="class">ApplicationScopedBean</span>
-{
-    <span class="directive">private</span> <span class="type">int</span> count = <span class="integer">0</span>;
-
-    <span class="directive">public</span> <span class="type">int</span> getCount()
-    {
-        <span class="keyword">return</span> count;
-    }
-
-    <span class="directive">public</span> <span class="type">void</span> increaseCount()
-    {
-        <span class="local-variable">this</span>.count++;
-    }
-}
-
-<span class="annotation">@Typed</span>() <span class="comment">//exclude it for the cdi type-check</span>
-<span class="directive">public</span> <span class="type">class</span> <span class="class">MockedApplicationScopedBean</span> <span class="directive">extends</span> ApplicationScopedBean
-{
-    <span class="annotation">@Override</span>
-    <span class="directive">public</span> <span class="type">int</span> getCount()
-    {
-        <span class="keyword">return</span> <span class="integer">14</span>;
-    }
-}</code></pre>
-</div>
-</div>
-<div class="paragraph">
-<p>However, <code>ApplicationMockManager</code> can be used for adding all mocks, if
-they should be active for the lifetime of the CDI-container.</p>
-</div>
-<div class="paragraph">
-<p>It is also possible to mock qualified beans. Just add the
-literal-instance(s) as additional parameter(s), for example:</p>
-</div>
-<div class="listingblock">
-<div class="content">
-<pre class="CodeRay highlight"><code data-lang="java"><span class="annotation">@RunWith</span>(CdiTestRunner.class)
-<span class="directive">public</span> <span class="type">class</span> <span class="class">MockedQualifiedBeanTest</span>
-{
-    <span class="annotation">@Inject</span>
-    <span class="annotation">@MyQualifier</span>
-    <span class="directive">private</span> QualifiedBean qualifiedBean;
-
-    <span class="annotation">@Inject</span>
-    <span class="directive">private</span> DynamicMockManager mockManager;
-
-    <span class="annotation">@Test</span>
-    <span class="directive">public</span> <span class="type">void</span> manualMockWithQualifier()
-    {
-        mockManager.addMock(<span class="keyword">new</span> QualifiedBean() {
-            <span class="annotation">@Override</span>
-            <span class="directive">public</span> <span class="type">int</span> getCount()
-            {
-                <span class="keyword">return</span> <span class="integer">21</span>;
-            }
-        }, AnnotationInstanceProvider.of(MyQualifier.class));
-
-        Assert.assertEquals(<span class="integer">21</span>, qualifiedBean.getCount());
-        qualifiedBean.increaseCount();
-        Assert.assertEquals(<span class="integer">21</span>, qualifiedBean.getCount());
-    }
-}</code></pre>
-</div>
-</div>
-<div class="paragraph">
-<p>In some cases it is necessary to use <code>@javax.enterprise.inject.Typed</code>.
-Mocking such typed beans can result in an
-<code>AmbiguousResolutionException</code>. Therefore it is necessary to exclude the
-mocked implementation via <code>@Exclude</code> or <code>@Typed()</code> (or a parametrized
-constructor) and specify the target-type via <code>@TypedMock</code>.</p>
-</div>
-</div>
-<div class="sect2">
-<h3 id="_jsf_via_myfaces_test">JSF (via MyFaces-Test)</h3>
-<div class="paragraph">
-<p>add on of</p>
-</div>
-<div class="ulist">
-<ul>
-<li>
-<p>org.apache.deltaspike.testcontrol.impl.jsf.MockedJsf2TestContainer</p>
-</li>
-<li>
-<p>org.apache.deltaspike.testcontrol.impl.jsf.MockedJsfTestContainerAdapter</p>
-</li>
-<li>
-<p>org.apache.deltaspike.testcontrol.impl.jsf.MyFacesContainerAdapter</p>
-</li>
-<li>
-<p>org.apache.deltaspike.testcontrol.impl.jsf.MyFacesContainerPerTestMethodAdapter</p>
-</li>
-</ul>
-</div>
-<div class="paragraph">
-<p>as content to</p>
-</div>
-<div class="paragraph">
-<p>/META-INF/services/org.apache.deltaspike.testcontrol.spi.ExternalContainer</p>
-</div>
-<div class="paragraph">
-<p>(in your config-folder for tests, e.g. test/resources)</p>
-</div>
-</div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_using_jersey_test_with_test_control">Using jersey-test with test-control</h2>
-<div class="sectionbody">
-<div class="paragraph">
-<p>Jersey-test starts jetty which answers requests in a separated thread. Since ds test-control just handles the thread of the test itself, it&#8217;s needed to integrate jetty and jersey with the cdi-container. Usually that&#8217;s done via a ServletRequestListener - the following part describes an alternative approach for jersey-test:</p>
-</div>
-<div class="listingblock">
-<div class="content">
-<pre class="CodeRay highlight"><code data-lang="java"><span class="comment">//use: -Djersey.config.test.container.factory=custom.CdiAwareJettyTestContainerFactory</span>
-
-<span class="annotation">@RunWith</span>(CdiTestRunner.class)
-<span class="directive">public</span> <span class="type">class</span> <span class="class">SimpleCdiAndJaxRsTest</span> <span class="directive">extends</span> JerseyTest
-{
-  <span class="comment">//...</span>
-}</code></pre>
-</div>
-</div>
-<div class="paragraph">
-<p>or</p>
-</div>
-<div class="listingblock">
-<div class="content">
-<pre class="CodeRay highlight"><code data-lang="java"><span class="directive">public</span> <span class="type">class</span> <span class="class">CdiAwareJerseyTest</span> <span class="directive">extends</span> JerseyTest
-{
-    <span class="directive">static</span>
-    {
-        <span class="predefined-type">System</span>.setProperty(<span class="string"><span class="delimiter">&quot;</span><span class="content">jersey.config.test.container.factory</span><span class="delimiter">&quot;</span></span>, CdiAwareJettyTestContainerFactory.class.getName());
-    }
-}
-
-<span class="annotation">@RunWith</span>(CdiTestRunner.class)
-<span class="directive">public</span> <span class="type">class</span> <span class="class">SimpleCdiAndJaxRsTest</span> <span class="directive">extends</span> CdiAwareJerseyTest
-{
-    <span class="comment">//...</span>
-}</code></pre>
-</div>
-</div>
-<div class="listingblock">
-<div class="content">
-<pre class="CodeRay highlight"><code data-lang="java"><span class="directive">public</span> <span class="type">class</span> <span class="class">CdiAwareJettyTestContainerFactory</span> <span class="directive">implements</span> TestContainerFactory
-{
-    <span class="annotation">@Override</span>
-    <span class="directive">public</span> TestContainer create(<span class="directive">final</span> <span class="predefined-type">URI</span> baseUri, <span class="directive">final</span> DeploymentContext context) <span class="directive">throws</span> <span class="exception">IllegalArgumentException</span>
-    {
-        <span class="keyword">return</span> <span class="keyword">new</span> CdiAwareJettyTestContainer(baseUri, context);
-    }
-}</code></pre>
-</div>
-</div>
-<div class="paragraph">
-<p>CdiAwareJettyTestContainer is a copy of JettyTestContainerFactory.JettyTestContainer but with</p>
-</div>
-<div class="listingblock">
-<div class="content">
-<pre class="CodeRay highlight"><code data-lang="java">HandlerWrapper cdiHandlerWrapper = <span class="keyword">new</span> CdiAwareHandlerWrapper();
-cdiHandlerWrapper.setHandler(<span class="local-variable">this</span>.server.getHandler());
-<span class="local-variable">this</span>.server.setHandler(cdiHandlerWrapper);</code></pre>
-</div>
-</div>
-<div class="paragraph">
-<p>after the line with JettyHttpContainerFactory#createServer</p>
-</div>
-<div class="listingblock">
-<div class="content">
-<pre class="CodeRay highlight"><code data-lang="java"><span class="comment">//activate the request-context e.g. via:</span>
-<span class="directive">public</span> <span class="type">class</span> <span class="class">CdiAwareHandlerWrapper</span> <span class="directive">extends</span> HandlerWrapper
-{
-    <span class="annotation">@Override</span>
-    <span class="directive">public</span> <span class="type">void</span> handle(<span class="predefined-type">String</span> target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) <span class="directive">throws</span> <span class="exception">IOException</span>, ServletException
-    {
-        CdiContainer cdiContainer = CdiContainerLoader.getCdiContainer();
-
-        <span class="keyword">try</span>
-        {
-            cdiContainer.getContextControl().startContext(RequestScoped.class);
-            <span class="local-variable">super</span>.handle(target, baseRequest, request, response);
-        }
-        <span class="keyword">finally</span>
-        {
-            cdiContainer.getContextControl().stopContext(RequestScoped.class);
-        }
-    }
-}</code></pre>
-</div>
-</div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_mixed_tests">Mixed Tests</h2>
-<div class="sectionbody">
-<div class="paragraph">
-<p>Usually you should have one kind of tests per test-module. However, if
-you need to add, for example, a test without an external-container to your
-test-module which uses external-containers, you can annotate your test
-with:</p>
-</div>
-<div class="listingblock">
-<div class="content">
-<pre class="CodeRay highlight"><code data-lang="java"><span class="annotation">@RunWith</span>(CdiTestRunner.class)
-<span class="annotation">@TestControl</span>(startExternalContainers = <span class="predefined-constant">false</span>)
-<span class="directive">public</span> <span class="type">class</span> <span class="class">JsfContainerTest</span>
-{
-    <span class="comment">//...</span>
-}</code></pre>
-</div>
-</div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_known_restrictions">Known Restrictions</h2>
-<div class="sectionbody">
-<div class="sect2">
-<h3 id="_liquibase">Liquibase</h3>
-<div class="paragraph">
-<p>Liquibase invokes <code>#toString</code> in a <code>AfterDeploymentValidation</code> observer.
-<strong>that is not portable</strong> and therefore you have to deactivate the
-mocking-support via:</p>
-</div>
-<div class="listingblock">
-<div class="content">
-<pre class="CodeRay highlight"><code data-lang="java"><span class="directive">public</span> <span class="type">class</span> <span class="class">LiquibaseAwareClassDeactivator</span> <span class="directive">implements</span> ClassDeactivator {
-    <span class="annotation">@Override</span>
-    <span class="directive">public</span> <span class="predefined-type">Boolean</span> isActivated(<span class="predefined-type">Class</span>&lt;? <span class="directive">extends</span> Deactivatable&gt; targetClass) {
-        <span class="keyword">return</span> !<span class="string"><span class="delimiter">&quot;</span><span class="content">org.apache.deltaspike.testcontrol.impl.mock.MockExtension</span><span class="delimiter">&quot;</span></span>.equals(targetClass.getName());
-    }
-}</code></pre>
-</div>
-</div>
-<div class="paragraph">
-<p>and add <code>LiquibaseAwareClassDeactivator</code> to <code>/META-INF/apache-deltaspike.properties</code>, for example:</p>
-</div>
-<div class="listingblock">
-<div class="content">
-<pre>org.apache.deltaspike.core.spi.activation.ClassDeactivator=myPackage.LiquibaseAwareClassDeactivator</pre>
-</div>
-</div>
-<div class="paragraph">
-<p>Further details are available at deactivatable.</p>
-</div>
-</div>
-<div class="sect2">
-<h3 id="_gradle">Gradle</h3>
-<div class="paragraph">
-<p>Gradle by default does not put resources and compiled sources in to the same directory.
-When running a test using Gradle, this means your classes will not be in bean archives as
-defined by the CDI spec.  To work around this, you need to set your main and test directories
-for resources to point to where the compiled code lives.  This is an example of how to do that:</p>
-</div>
-<div class="listingblock">
-<div class="content">
-<pre class="CodeRay highlight"><code data-lang="groovy">sourceSets {
-    main {
-        output.resourcesDir = <span class="string"><span class="delimiter">'</span><span class="content">build/classes/main</span><span class="delimiter">'</span></span>
-        output.classesDir   = <span class="string"><span class="delimiter">'</span><span class="content">build/classes/main</span><span class="delimiter">'</span></span>
-    }
-    test {
-        output.resourcesDir = <span class="string"><span class="delimiter">'</span><span class="content">build/classes/test</span><span class="delimiter">'</span></span>
-        output.classesDir   = <span class="string"><span class="delimiter">'</span><span class="content">build/classes/test</span><span class="delimiter">'</span></span>
-    }
-}</code></pre>
-</div>
-</div>
-</div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_spi">SPI</h2>
-<div class="sectionbody">
-<div class="sect2">
-<h3 id="_externalcontainer">ExternalContainer</h3>
-<div class="paragraph">
-<p>org.apache.deltaspike.testcontrol.spi.ExternalContainer allows to
-integrate containers which get started after the CDI container.
-Currently DeltaSpike provides:</p>
-</div>
-<div class="ulist">
-<ul>
-<li>
-<p>MockedJsf2TestContainer (integration with MyFaces-Test)</p>
-</li>
-</ul>
-</div>
-</div>
-</div>
-</div>
-            </div>
-        </div>
-
-        
-            <div class="span4">
-                <div id="toc">
-                    <div class="moduledeps">
-                        <ul class="toc-like nav nav-list">
-                            
-                                <li class="custom-toc-header">Depends on</li>
-                                
-                                    <li><a href="core.html">Core</a></li>
-                                
-                                    <li><a href="container-control.html">Container control</a></li>
-                                
-                            
-                            
-                                <li class="custom-toc-header"><a href="core.html#_internal_configuration">Configuration</a></li>
-                                
-                                    <li><a href="https://github.com/apache/deltaspike/blob/master/deltaspike/modules/test-control/api/src/main/java/org/apache/deltaspike/testcontrol/api/junit/TestBaseConfig.java">TestBaseConfig</a></li>
-                                
-                                    <li><a href="https://github.com/apache/deltaspike/blob/master/deltaspike/modules/test-control/impl/src/main/java/org/apache/deltaspike/testcontrol/impl/jsf/MyFacesTestBaseConfig.java">MyFacesTestBaseConfig</a></li>
-                                
-                            
-                            
-                                <li class="custom-toc-header">Table of Contents</li>
-                            
-                        </ul>
-                    </div>
-                </div>
-                
-                    <div class="fallback-toc">
-                        <ul class="sectlevel1">
-<li><a href="#_overview">Overview</a></li>
-<li><a href="#_project_setup">Project Setup</a>
-<ul class="sectlevel2">
-<li><a href="#_1_declare_test_control_module_dependencies">1. Declare Test-Control Module Dependencies</a></li>
-<li><a href="#_2_declare_cdi_implementation_specific_dependencies">2. Declare CDI-implementation-specific dependencies</a>
-<ul class="sectlevel3">
-<li><a href="#_openwebbeans">OpenWebBeans</a></li>
-<li><a href="#_weld">Weld</a></li>
-<li><a href="#_openejb">OpenEJB</a></li>
-</ul>
-</li>
-<li><a href="#_3_complete_additional_project_configuration">3. Complete Additional Project Configuration</a></li>
-</ul>
-</li>
-<li><a href="#_automated_container_booting_and_shutdown">Automated Container Booting and Shutdown</a>
-<ul class="sectlevel2">
-<li><a href="#_cditestrunner">CdiTestRunner</a></li>
-<li><a href="#_cditestsuiterunner">CdiTestSuiteRunner</a></li>
-<li><a href="#_optional_shutdown_configuration">Optional Shutdown Configuration</a></li>
-</ul>
-</li>
-<li><a href="#_test_customization">Test Customization</a>
-<ul class="sectlevel2">
-<li><a href="#__testcontrol">@TestControl</a></li>
-<li><a href="#_projectstage_control">ProjectStage Control</a></li>
-</ul>
-</li>
-<li><a href="#_optional_configuration">Optional Configuration</a>
-<ul class="sectlevel2">
-<li><a href="#_reconfigure_the_config_file_name_or_location">Reconfigure the config-file Name or Location</a></li>
-</ul>
-</li>
-<li><a href="#_optional_integrations">Optional Integrations</a>
-<ul class="sectlevel2">
-<li><a href="#_mock_frameworks">Mock Frameworks</a></li>
-<li><a href="#_jsf_via_myfaces_test">JSF (via MyFaces-Test)</a></li>
-</ul>
-</li>
-<li><a href="#_using_jersey_test_with_test_control">Using jersey-test with test-control</a></li>
-<li><a href="#_mixed_tests">Mixed Tests</a></li>
-<li><a href="#_known_restrictions">Known Restrictions</a>
-<ul class="sectlevel2">
-<li><a href="#_liquibase">Liquibase</a></li>
-<li><a href="#_gradle">Gradle</a></li>
-</ul>
-</li>
-<li><a href="#_spi">SPI</a>
-<ul class="sectlevel2">
-<li><a href="#_externalcontainer">ExternalContainer</a></li>
-</ul>
-</li>
-</ul>
-                    </div>
-                
-            </div>
-        
-
-    </div>
-    <div class="row">
-        <hr>
-        <footer>
-            <p>Copyright &copy; 2011-2016 The Apache Software Foundation,
-                Licensed under the Apache License, Version 2.0.</p>
-
-            <p>Apache and the Apache feather logo are trademarks of The Apache Software Foundation.</p>
-        </footer>
-    </div>
-</div>
-
-</body>
+<!DOCTYPE html>
+<head>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <meta name="description" content="deltaspike-generate-pages">
+    <meta name="author" content="chm">
+    <!-- No caching headers -->
+    <meta http-equiv="cache-control" content="no-cache"/>
+    <meta http-equiv="pragma" content="no-cache"/>
+    <meta http-equiv="expires" content="-1"/>
+
+    <title>Test-Control Module</title>
+
+    <!--
+        Licensed to the Apache Software Foundation (ASF) under one
+        or more contributor license agreements.  See the NOTICE file
+        distributed with this work for additional information
+        regarding copyright ownership.  The ASF licenses this file
+        to you 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.
+    -->
+
+    <!-- Styles -->
+    <link href="https://deltaspike.apache.org/resources/css/bootstrap.css" rel="stylesheet">
+    <link href="https://deltaspike.apache.org/resources/css/bootstrap-responsive.css" rel="stylesheet">
+    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.1.0/css/font-awesome.min.css" rel="stylesheet">
+
+    
+
+    
+        <!-- Tocify - nice dynamic autoscrolling TOC -->
+        <link href="https://cdnjs.cloudflare.com/ajax/libs/jquery.tocify/1.9.0/stylesheets/jquery.tocify.min.css" rel="stylesheet">
+        <script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
+        <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
+        <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.tocify/1.9.0/javascripts/jquery.tocify.min.js"></script>
+
+
+        <script type="text/javascript">
+            $(function () {
+                $("#toc").tocify({
+                    scrollTo: 50,
+                    extendPage: true,
+                    context: "#doc-content",
+                    selectors: "h2,h3,h4,h5"
+                });
+                $(".fallback-toc").hide();
+            });
+        </script>
+    
+
+    <style type="text/css">
+        /* Stylesheet for CodeRay to match GitHub theme | MIT License | http://foundation.zurb.com */
+/*pre.CodeRay {background-color:#f7f7f8;}*/
+.CodeRay .line-numbers{border-right:1px solid #d8d8d8;padding:0 0.5em 0 .25em}
+.CodeRay span.line-numbers{display:inline-block;margin-right:.5em;color:rgba(0,0,0,.3)}
+.CodeRay .line-numbers strong{font-weight: normal}
+table.CodeRay{border-collapse:separate;border-spacing:0;margin-bottom:0;border:0;background:none}
+table.CodeRay td{vertical-align: top}
+table.CodeRay td.line-numbers{text-align:right}
+table.CodeRay td.line-numbers>pre{padding:0;color:rgba(0,0,0,.3)}
+table.CodeRay td.code{padding:0 0 0 .5em}
+table.CodeRay td.code>pre{padding:0}
+.CodeRay .debug{color:#fff !important;background:#000080 !important}
+.CodeRay .annotation{color:#007}
+.CodeRay .attribute-name{color:#000080}
+.CodeRay .attribute-value{color:#700}
+.CodeRay .binary{color:#509}
+.CodeRay .comment{color:#998;font-style:italic}
+.CodeRay .char{color:#04d}
+.CodeRay .char .content{color:#04d}
+.CodeRay .char .delimiter{color:#039}
+.CodeRay .class{color:#458;font-weight:bold}
+.CodeRay .complex{color:#a08}
+.CodeRay .constant,.CodeRay .predefined-constant{color:#008080}
+.CodeRay .color{color:#099}
+.CodeRay .class-variable{color:#369}
+.CodeRay .decorator{color:#b0b}
+.CodeRay .definition{color:#099}
+.CodeRay .delimiter{color:#000}
+.CodeRay .doc{color:#970}
+.CodeRay .doctype{color:#34b}
+.CodeRay .doc-string{color:#d42}
+.CodeRay .escape{color:#666}
+.CodeRay .entity{color:#800}
+.CodeRay .error{color:#808}
+.CodeRay .exception{color:inherit}
+.CodeRay .filename{color:#099}
+.CodeRay .function{color:#900;font-weight:bold}
+.CodeRay .global-variable{color:#008080}
+.CodeRay .hex{color:#058}
+.CodeRay .integer,.CodeRay .float{color:#099}
+.CodeRay .include{color:#555}
+.CodeRay .inline{color:#00}
+.CodeRay .inline .inline{background:#ccc}
+.CodeRay .inline .inline .inline{background:#bbb}
+.CodeRay .inline .inline-delimiter{color:#d14}
+.CodeRay .inline-delimiter{color:#d14}
+.CodeRay .important{color:#555;font-weight:bold}
+.CodeRay .interpreted{color:#b2b}
+.CodeRay .instance-variable{color:#008080}
+.CodeRay .label{color:#970}
+.CodeRay .local-variable{color:#963}
+.CodeRay .octal{color:#40e}
+.CodeRay .predefined{color:#369}
+.CodeRay .preprocessor{color:#579}
+.CodeRay .pseudo-class{color:#555}
+.CodeRay .directive{font-weight:bold}
+.CodeRay .type{font-weight:bold}
+.CodeRay .predefined-type{color:inherit}
+.CodeRay .reserved,.CodeRay .keyword {color:#000;font-weight:bold}
+.CodeRay .key{color:#808}
+.CodeRay .key .delimiter{color:#606}
+.CodeRay .key .char{color:#80f}
+.CodeRay .value{color:#088}
+.CodeRay .regexp .delimiter{color:#808}
+.CodeRay .regexp .content{color:#808}
+.CodeRay .regexp .modifier{color:#808}
+.CodeRay .regexp .char{color:#d14}
+.CodeRay .regexp .function{color:#404;font-weight:bold}
+.CodeRay .string{color:#d20}
+.CodeRay .string .string .string{background:#ffd0d0}
+.CodeRay .string .content{color:#d14}
+.CodeRay .string .char{color:#d14}
+.CodeRay .string .delimiter{color:#d14}
+.CodeRay .shell{color:#d14}
+.CodeRay .shell .delimiter{color:#d14}
+.CodeRay .symbol{color:#990073}
+.CodeRay .symbol .content{color:#a60}
+.CodeRay .symbol .delimiter{color:#630}
+.CodeRay .tag{color:#008080}
+.CodeRay .tag-special{color:#d70}
+.CodeRay .variable{color:#036}
+.CodeRay .insert{background:#afa}
+.CodeRay .delete{background:#faa}
+.CodeRay .change{color:#aaf;background:#007}
+.CodeRay .head{color:#f8f;background:#505}
+.CodeRay .insert .insert{color:#080}
+.CodeRay .delete .delete{color:#800}
+.CodeRay .change .change{color:#66f}
+.CodeRay .head .head{color:#f4f}
+
+        body {
+            padding-top: 60px;
+            padding-bottom: 40px;
+        }
+
+        .toc-like {
+            border-radius: 6px;
+            border: 1px solid #ccc;
+        }
+
+        .toc-like li {
+            line-height: 30px;
+            text-indent: 10px;
+        }
+
+        .toc-like li.custom-toc-header {
+            font-weight: bold;
+            background: #666;
+            color: white;
+            cursor: initial !important;
+            padding: 5px;
+        }
+
+        .toc-like li.custom-toc-header a {
+            color: white;
+            font-style: normal;
+            text-shadow: none;
+            padding: 0;
+        }
+
+        .toc-like li.custom-toc-header:hover a {
+            background: #666;
+        }
+
+        .page-title {
+            text-align: left;
+        }
+
+        #doc-content h2,
+        #doc-content h3,
+        #doc-content h4,
+        #doc-content h5,
+        #doc-content h6 {
+            padding-top: 0;
+            margin-top: 25px;
+            margin-bottom: 10px;
+            line-height: 1.4em;
+        }
+
+        #doc-content h2 {
+            border-bottom: 1px solid lightgrey;
+        }
+
+
+    </style>
+
+    <script type="text/javascript">
+
+        var _gaq = _gaq || [];
+        _gaq.push(['_setAccount', 'UA-36103647-1']);
+        _gaq.push(['_trackPageview']);
+
+        (function () {
+            var ga = document.createElement('script');
+            ga.type = 'text/javascript';
+            ga.async = true;
+            ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+            var s = document.getElementsByTagName('script')[0];
+            s.parentNode.insertBefore(ga, s);
+        })();
+
+    </script>
+</head>
+
+<body>
+
+<div class="navbar navbar-fixed-top">
+    <div class="navbar-inner">
+        <div class="container">
+            <a class="btn btn-navbar" data-toggle="collapse"
+               data-target=".nav-collapse"> <span class="icon-bar"></span> <span
+            class="icon-bar"></span> <span class="icon-bar"></span>
+            </a>
+            <a class="brand logocolor" href="../index.html">Apache DeltaSpike</a>
+
+            <div class="nav-collapse">
+
+                
+                <ul class="nav">
+                    <li><a href="../index.html">Home</a></li>
+                    <li class="active"><a href="../documentation">Documentation</a></li>
+                    <li  ><a href="../javadoc.html">Javadoc</a></li>
+                    <li ><a href="../source.html">Source</a></li>
+                    <li ><a href="../download.html">Download</a></li>
+                    <li ><a href="../community.html">Community</a></li>
+                    <!-- <li><a href="./support.html">Support</a></li>  -->
+                    <li ><a href="../news.html">News</a></li>
+                </ul>
+            </div>
+            <!--/.nav-collapse -->
+            <form id="search-form" action="https://www.google.com/search"
+                  method="get" class="navbar-search pull-right">
+                <input value="deltaspike.apache.org" name="sitesearch"
+                       type="hidden"> <input class="search-query" name="q"
+                                             id="query" type="text">
+            </form>
+        </div>
+    </div>
+</div>
+
+<div class="container">
+    <div class="row-fluid">
+
+        
+
+        <div class="span8">
+            <div class="page-title">
+                <h1>Test-Control Module</h1>
+            </div>
+
+            <div id="doc-content">
+                <div class="sect1">
+<h2 id="_overview">Overview</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>The Test-Control module enables you to write CDI-based tests easily. Calls to stop and start the CDI container are built into the Test-Control API, with simplified commands for customizing the management of contexts and other aspects during testing.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_project_setup">Project Setup</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>The configuration information provided here is for Maven-based projects and it assumes that you have already declared the DeltaSpike version and DeltaSpike Core module for your projects, as detailed in <a href="configure.html">Configure DeltaSpike in Your Projects</a>. For Maven-independent projects, see <a href="configure.html#config-maven-indep">Configure DeltaSpike in Maven-independent Projects</a>.</p>
+</div>
+<div class="sect2">
+<h3 id="_1_declare_test_control_module_dependencies">1. Declare Test-Control Module Dependencies</h3>
+<div class="paragraph">
+<p>Add the Test-Control module to the list of dependencies in the project <code>pom.xml</code> file using this code snippet:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="xml"><span class="tag">&lt;dependency&gt;</span>
+    <span class="tag">&lt;groupId&gt;</span>org.apache.deltaspike.modules<span class="tag">&lt;/groupId&gt;</span>
+    <span class="tag">&lt;artifactId&gt;</span>deltaspike-test-control-module-api<span class="tag">&lt;/artifactId&gt;</span>
+    <span class="tag">&lt;version&gt;</span>${deltaspike.version}<span class="tag">&lt;/version&gt;</span>
+    <span class="tag">&lt;scope&gt;</span>test<span class="tag">&lt;/scope&gt;</span>
+<span class="tag">&lt;/dependency&gt;</span>
+
+<span class="tag">&lt;dependency&gt;</span>
+    <span class="tag">&lt;groupId&gt;</span>org.apache.deltaspike.modules<span class="tag">&lt;/groupId&gt;</span>
+    <span class="tag">&lt;artifactId&gt;</span>deltaspike-test-control-module-impl<span class="tag">&lt;/artifactId&gt;</span>
+    <span class="tag">&lt;version&gt;</span>${deltaspike.version}<span class="tag">&lt;/version&gt;</span>
+    <span class="tag">&lt;scope&gt;</span>test<span class="tag">&lt;/scope&gt;</span>
+<span class="tag">&lt;/dependency&gt;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Or if you&#8217;re using Gradle, add these dependencies to your <code>build.gradle</code>:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="CodeRay highlight"><code>     testCompile 'org.apache.deltaspike.modules:deltaspike-test-control-module-impl'
+     testRuntime 'org.apache.deltaspike.modules:deltaspike-test-control-module-api'</code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_2_declare_cdi_implementation_specific_dependencies">2. Declare CDI-implementation-specific dependencies</h3>
+<div class="paragraph">
+<p>The Test-Control module depends on the Container-Control module, which provides adapters for several major CDI implementations. Therefore, to use Test-Control, declare dependency on a CDI implementation and a corresponding Container Control implementation in the <code>pom.xml</code>.</p>
+</div>
+<div class="sect3">
+<h4 id="_openwebbeans">OpenWebBeans</h4>
+<div class="paragraph">
+<p>If you are using OpenWebBeans, add an OpenWebBeans implementation and the OpenWebBeans-specific Container Control module to the list of dependencies:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="xml"> <span class="tag">&lt;dependency&gt;</span>
+     <span class="tag">&lt;groupId&gt;</span>org.apache.deltaspike.cdictrl<span class="tag">&lt;/groupId&gt;</span>
+     <span class="tag">&lt;artifactId&gt;</span>deltaspike-cdictrl-owb<span class="tag">&lt;/artifactId&gt;</span>
+     <span class="tag">&lt;version&gt;</span>${deltaspike.version}<span class="tag">&lt;/version&gt;</span>
+     <span class="tag">&lt;scope&gt;</span>test<span class="tag">&lt;/scope&gt;</span>
+ <span class="tag">&lt;/dependency&gt;</span>
+
+<span class="tag">&lt;dependency&gt;</span>
+    <span class="tag">&lt;groupId&gt;</span>org.apache.openwebbeans<span class="tag">&lt;/groupId&gt;</span>
+    <span class="tag">&lt;artifactId&gt;</span>openwebbeans-impl<span class="tag">&lt;/artifactId&gt;</span>
+    <span class="tag">&lt;version&gt;</span>${owb.version}<span class="tag">&lt;/version&gt;</span>
+    <span class="tag">&lt;scope&gt;</span>test<span class="tag">&lt;/scope&gt;</span>
+<span class="tag">&lt;/dependency&gt;</span></code></pre>
+</div>
+</div>
+</div>
+<div class="sect3">
+<h4 id="_weld">Weld</h4>
+<div class="paragraph">
+<p>If you are using Weld, add a Weld implementation and the Weld-specific Container Control module to the list of dependencies:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="xml"><span class="tag">&lt;dependency&gt;</span>
+    <span class="tag">&lt;groupId&gt;</span>org.apache.deltaspike.cdictrl<span class="tag">&lt;/groupId&gt;</span>
+    <span class="tag">&lt;artifactId&gt;</span>deltaspike-cdictrl-weld<span class="tag">&lt;/artifactId&gt;</span>
+    <span class="tag">&lt;version&gt;</span>${deltaspike.version}<span class="tag">&lt;/version&gt;</span>
+    <span class="tag">&lt;scope&gt;</span>test<span class="tag">&lt;/scope&gt;</span>
+<span class="tag">&lt;/dependency&gt;</span>
+
+<span class="tag">&lt;dependency&gt;</span>
+    <span class="tag">&lt;groupId&gt;</span>org.jboss.weld.se<span class="tag">&lt;/groupId&gt;</span>
+    <span class="tag">&lt;artifactId&gt;</span>weld-se-core<span class="tag">&lt;/artifactId&gt;</span>
+    <span class="tag">&lt;version&gt;</span>${weld.version}<span class="tag">&lt;/version&gt;</span>
+    <span class="tag">&lt;scope&gt;</span>test<span class="tag">&lt;/scope&gt;</span>
+<span class="tag">&lt;/dependency&gt;</span></code></pre>
+</div>
+</div>
+</div>
+<div class="sect3">
+<h4 id="_openejb">OpenEJB</h4>
+<div class="paragraph">
+<p>If you are using OpenWebBeans as the CDI implementation and you need to test
+EJBs as well, add the OpenEJB-specific Container Control module to the list
+of dependencies instead of the OpenWebBeans-specific Container Control module:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="xml"><span class="tag">&lt;dependency&gt;</span>
+    <span class="tag">&lt;groupId&gt;</span>org.apache.deltaspike.cdictrl<span class="tag">&lt;/groupId&gt;</span>
+    <span class="tag">&lt;artifactId&gt;</span>deltaspike-cdictrl-openejb<span class="tag">&lt;/artifactId&gt;</span>
+    <span class="tag">&lt;version&gt;</span>${deltaspike.version}<span class="tag">&lt;/version&gt;</span>
+    <span class="tag">&lt;scope&gt;</span>test<span class="tag">&lt;/scope&gt;</span>
+<span class="tag">&lt;/dependency&gt;</span>
+
+<span class="tag">&lt;dependency&gt;</span>
+    <span class="tag">&lt;groupId&gt;</span>org.apache.openejb<span class="tag">&lt;/groupId&gt;</span>
+    <span class="tag">&lt;artifactId&gt;</span>openejb-core<span class="tag">&lt;/artifactId&gt;</span>
+    <span class="tag">&lt;version&gt;</span>${openejb.version}<span class="tag">&lt;/version&gt;</span>
+    <span class="tag">&lt;scope&gt;</span>test<span class="tag">&lt;/scope&gt;</span>
+<span class="tag">&lt;/dependency&gt;</span></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_3_complete_additional_project_configuration">3. Complete Additional Project Configuration</h3>
+<div class="paragraph">
+<p>Add a <code>beans.xml</code> file in the project test module (e.g. src/test/resources/META-INF/beans.xml).</p>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_automated_container_booting_and_shutdown">Automated Container Booting and Shutdown</h2>
+<div class="sectionbody">
+<div class="sect2">
+<h3 id="_cditestrunner">CdiTestRunner</h3>
+<div class="paragraph">
+<p>Start and stop the CDI container automatically per test class with CdiTestRunner, a JUnit Test-Runner.
+This also starts and stops one request and session per test-method.</p>
+</div>
+<div class="listingblock">
+<div class="title">Example of CdiTestRunner Usage</div>
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="java"><span class="annotation">@RunWith</span>(CdiTestRunner.class)
+<span class="directive">public</span> <span class="type">class</span> <span class="class">ContainerAndInjectionControl</span>
+{
+    <span class="annotation">@Inject</span>
+    <span class="directive">private</span> ApplicationScopedBean applicationScopedBean;
+
+    <span class="annotation">@Inject</span>
+    <span class="directive">private</span> SessionScopedBean sessionScopedBean;
+
+    <span class="annotation">@Inject</span>
+    <span class="directive">private</span> RequestScopedBean requestScopedBean;
+
+    <span class="comment">//test the injected beans</span>
+}</code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_cditestsuiterunner">CdiTestSuiteRunner</h3>
+<div class="paragraph">
+<p>Extend automated CDI container start and stop actions to whole test suites with CdiTestSuiteRunner, a JUnit Test-Suite-Runner.</p>
+</div>
+<div class="listingblock">
+<div class="title">Example of CdiTestSuiteRunner Usage</div>
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="java"><span class="annotation">@RunWith</span>(CdiTestSuiteRunner.class)
+<span class="annotation">@Suite</span>.SuiteClasses({
+    TestX.class,
+    TestY.class
+})
+<span class="directive">public</span> <span class="type">class</span> <span class="class">SuiteLevelContainerControl</span>
+{
+}</code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_optional_shutdown_configuration">Optional Shutdown Configuration</h3>
+<div class="paragraph">
+<p>You can set <code>deltaspike.testcontrol.stop_container</code> to <code>false</code> (via the standard DeltaSpike config), resulting in the CDI Container being started just once for all tests.</p>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_test_customization">Test Customization</h2>
+<div class="sectionbody">
+<div class="sect2">
+<h3 id="__testcontrol">@TestControl</h3>
+<div class="paragraph">
+<p>Customize the default behavior of CdiTestRunner with @TestControl. In the following
+case only one session for all test-methods (of the test-class) will be
+created.</p>
+</div>
+<div class="listingblock">
+<div class="title">Example of @TestControl Usage</div>
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="java"><span class="annotation">@RunWith</span>(CdiTestRunner.class)
+<span class="annotation">@TestControl</span>(startScopes = SessionScoped.class)
+<span class="directive">public</span> <span class="type">class</span> <span class="class">CustomizedScopeHandling</span>
+{
+    <span class="comment">//inject beans and test them</span>
+}</code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_projectstage_control">ProjectStage Control</h3>
+<div class="paragraph">
+<p>Override the default ProjectStage for unit tests with <code>ProjectStage.UnitTest.class</code>.</p>
+</div>
+<div class="listingblock">
+<div class="title">Example of projectStage Usage</div>
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="java"><span class="annotation">@RunWith</span>(CdiTestRunner.class)
+<span class="annotation">@TestControl</span>(projectStage = CustomTestStage.class)
+<span class="directive">public</span> <span class="type">class</span> <span class="class">TestStageControl</span>
+{
+    <span class="comment">//tests here will see ProjectStage CustomTestStage.class</span>
+
+    <span class="annotation">@Test</span>
+    <span class="annotation">@TestControl</span>(projectStage = ProjectStage.Development.class)
+    <span class="directive">public</span> <span class="type">void</span> checkDevEnv()
+    {
+    }
+
+    <span class="comment">//tests here will see ProjectStage CustomTestStage.class</span>
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_optional_configuration">Optional Configuration</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>From DeltaSpike 1.2, it is possible to provide a configuration for the underlying test-container.
+However, currently only the adapter for OpenEJB embedded (available in CDI-Control) supports it out-of-the-box.
+To pass properties to the underlying test-container,
+you have to add <code>/META-INF/apache-deltaspike_test-container.properties</code>
+to the resources-directory of your test-classpath.
+The content of the file are key/value pairs which get passed to the container.
+Therefore, it is a configuration which is not used by DeltaSpike itself
+(it is just forwarded (as it is) to the underlying test-container).</p>
+</div>
+<div class="sect2">
+<h3 id="_reconfigure_the_config_file_name_or_location">Reconfigure the config-file Name or Location</h3>
+<div class="paragraph">
+<p>If you would like to point to an existing config-file, you have to add for example:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="Properties">deltaspike.testcontrol.test-container.config-file=META-INF/existingConfig.properties</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>to <code>/META-INF/apache-deltaspike.properties</code>.</p>
+</div>
+<div class="paragraph">
+<p>If you would like to do it per ProjectStage, you can use for example:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="Properties">deltaspike.testcontrol.test-container.config-file.UnitTest=META-INF/unit-test/existingConfig.properties</code></pre>
+</div>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_optional_integrations">Optional Integrations</h2>
+<div class="sectionbody">
+<div class="sect2">
+<h3 id="_mock_frameworks">Mock Frameworks</h3>
+<div class="paragraph">
+<p>From DeltaSpike 1.0, it is possible to mock CDI-Beans. Usually @Exclude (+
+ProjectStage) is enough, however, for some cases mocked beans might be
+easier. Therefore it is possible to create (mock-)instances manually or
+via a mocking framework and add them, for example, via <code>DynamicMockManager</code>.</p>
+</div>
+<div class="paragraph">
+<p><strong>Attention:</strong> Mocking CDI beans is not supported for every feature of CDI and/or
+every implementation version. For example, we can not mock intercepted CDI beans and
+with some implementations mocking specialized beans fails.
+Usually all features are active by default, however,
+due to those reasons we deactivated this feature by default.
+You can enable it by adding</p>
+</div>
+<div class="paragraph">
+<p><code>deltaspike.testcontrol.mock-support.allow_mocked_beans=true</code>
+and/or
+<code>deltaspike.testcontrol.mock-support.allow_mocked_producers=true</code></p>
+</div>
+<div class="paragraph">
+<p>to <code>/META-INF/apache-deltaspike.properties</code> in your test-folder.</p>
+</div>
+<div class="paragraph">
+<p>If you need dependency-injection in the mocked instances, you can use
+<code>BeanProvider.injectFields(myMockedBean);</code>.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="java"><span class="annotation">@RunWith</span>(CdiTestRunner.class)
+<span class="directive">public</span> <span class="type">class</span> <span class="class">MockedRequestScopedBeanTest</span>
+{
+    <span class="annotation">@Inject</span>
+    <span class="directive">private</span> RequestScopedBean requestScopedBean;
+
+    <span class="annotation">@Inject</span>
+    <span class="directive">private</span> DynamicMockManager mockManager;
+
+    <span class="annotation">@Test</span>
+    <span class="directive">public</span> <span class="type">void</span> manualMock()
+    {
+        mockManager.addMock(<span class="keyword">new</span> RequestScopedBean() {
+            <span class="annotation">@Override</span>
+            <span class="directive">public</span> <span class="type">int</span> getCount()
+            {
+                <span class="keyword">return</span> <span class="integer">7</span>;
+            }
+        });
+
+        Assert.assertEquals(<span class="integer">7</span>, requestScopedBean.getCount());
+        requestScopedBean.increaseCount();
+        Assert.assertEquals(<span class="integer">7</span>, requestScopedBean.getCount());
+    }
+}
+
+<span class="annotation">@RequestScoped</span>
+<span class="directive">public</span> <span class="type">class</span> <span class="class">RequestScopedBean</span>
+{
+    <span class="directive">private</span> <span class="type">int</span> count = <span class="integer">0</span>;
+
+    <span class="directive">public</span> <span class="type">int</span> getCount()
+    {
+        <span class="keyword">return</span> count;
+    }
+
+    <span class="directive">public</span> <span class="type">void</span> increaseCount()
+    {
+        <span class="local-variable">this</span>.count++;
+    }
+}</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Using a mocking framework makes no difference for adding the mock.</p>
+</div>
+<div class="listingblock">
+<div class="title">Example via Mockito</div>
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="java"><span class="annotation">@RunWith</span>(CdiTestRunner.class)
+<span class="directive">public</span> <span class="type">class</span> <span class="class">MockitoMockedRequestScopedBeanTest</span>
+{
+    <span class="annotation">@Inject</span>
+    <span class="directive">private</span> RequestScopedBean requestScopedBean;
+
+    <span class="annotation">@Inject</span>
+    <span class="directive">private</span> DynamicMockManager mockManager;
+
+    <span class="annotation">@Test</span>
+    <span class="directive">public</span> <span class="type">void</span> mockitoMockAsCdiBean()
+    {
+        RequestScopedBean mockedRequestScopedBean = mock(RequestScopedBean.class);
+        when(mockedRequestScopedBean.getCount()).thenReturn(<span class="integer">7</span>);
+        mockManager.addMock(mockedRequestScopedBean);
+
+        Assert.assertEquals(<span class="integer">7</span>, requestScopedBean.getCount());
+        requestScopedBean.increaseCount();
+        Assert.assertEquals(<span class="integer">7</span>, requestScopedBean.getCount());
+    }
+}</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Since CDI implementations like OpenWebBeans use a lot of optimizations,
+it is required to handle mocks for application-scoped beans differently, for example:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="java"><span class="annotation">@RunWith</span>(CdiTestRunner.class)
+<span class="directive">public</span> <span class="type">class</span> <span class="class">MockedApplicationScopedBeanTest</span>
+{
+    <span class="annotation">@Inject</span>
+    <span class="directive">private</span> ApplicationScopedBean applicationScopedBean;
+
+    <span class="annotation">@BeforeClass</span>
+    <span class="directive">public</span> <span class="directive">static</span> <span class="type">void</span> init()
+    {
+        ApplicationMockManager applicationMockManager = BeanProvider.getContextualReference(ApplicationMockManager.class);
+        applicationMockManager.addMock(<span class="keyword">new</span> MockedApplicationScopedBean());
+    }
+
+    <span class="annotation">@Test</span>
+    <span class="directive">public</span> <span class="type">void</span> manualMock()
+    {
+        Assert.assertEquals(<span class="integer">14</span>, applicationScopedBean.getCount());
+        applicationScopedBean.increaseCount();
+        Assert.assertEquals(<span class="integer">14</span>, applicationScopedBean.getCount());
+    }
+}
+
+<span class="annotation">@ApplicationScoped</span>
+<span class="directive">public</span> <span class="type">class</span> <span class="class">ApplicationScopedBean</span>
+{
+    <span class="directive">private</span> <span class="type">int</span> count = <span class="integer">0</span>;
+
+    <span class="directive">public</span> <span class="type">int</span> getCount()
+    {
+        <span class="keyword">return</span> count;
+    }
+
+    <span class="directive">public</span> <span class="type">void</span> increaseCount()
+    {
+        <span class="local-variable">this</span>.count++;
+    }
+}
+
+<span class="annotation">@Typed</span>() <span class="comment">//exclude it for the cdi type-check</span>
+<span class="directive">public</span> <span class="type">class</span> <span class="class">MockedApplicationScopedBean</span> <span class="directive">extends</span> ApplicationScopedBean
+{
+    <span class="annotation">@Override</span>
+    <span class="directive">public</span> <span class="type">int</span> getCount()
+    {
+        <span class="keyword">return</span> <span class="integer">14</span>;
+    }
+}</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>However, <code>ApplicationMockManager</code> can be used for adding all mocks, if
+they should be active for the lifetime of the CDI-container.</p>
+</div>
+<div class="paragraph">
+<p>It is also possible to mock qualified beans. Just add the
+literal-instance(s) as additional parameter(s), for example:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="java"><span class="annotation">@RunWith</span>(CdiTestRunner.class)
+<span class="directive">public</span> <span class="type">class</span> <span class="class">MockedQualifiedBeanTest</span>
+{
+    <span class="annotation">@Inject</span>
+    <span class="annotation">@MyQualifier</span>
+    <span class="directive">private</span> QualifiedBean qualifiedBean;
+
+    <span class="annotation">@Inject</span>
+    <span class="directive">private</span> DynamicMockManager mockManager;
+
+    <span class="annotation">@Test</span>
+    <span class="directive">public</span> <span class="type">void</span> manualMockWithQualifier()
+    {
+        mockManager.addMock(<span class="keyword">new</span> QualifiedBean() {
+            <span class="annotation">@Override</span>
+            <span class="directive">public</span> <span class="type">int</span> getCount()
+            {
+                <span class="keyword">return</span> <span class="integer">21</span>;
+            }
+        }, AnnotationInstanceProvider.of(MyQualifier.class));
+
+        Assert.assertEquals(<span class="integer">21</span>, qualifiedBean.getCount());
+        qualifiedBean.increaseCount();
+        Assert.assertEquals(<span class="integer">21</span>, qualifiedBean.getCount());
+    }
+}</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>In some cases it is necessary to use <code>@javax.enterprise.inject.Typed</code>.
+Mocking such typed beans can result in an
+<code>AmbiguousResolutionException</code>. Therefore it is necessary to exclude the
+mocked implementation via <code>@Exclude</code> or <code>@Typed()</code> (or a parametrized
+constructor) and specify the target-type via <code>@TypedMock</code>.</p>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_jsf_via_myfaces_test">JSF (via MyFaces-Test)</h3>
+<div class="paragraph">
+<p>add one of</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>org.apache.deltaspike.testcontrol.impl.jsf.MockedJsf2TestContainer</p>
+</li>
+<li>
+<p>org.apache.deltaspike.testcontrol.impl.jsf.MockedJsfTestContainerAdapter</p>
+</li>
+<li>
+<p>org.apache.deltaspike.testcontrol.impl.jsf.MyFacesContainerAdapter</p>
+</li>
+<li>
+<p>org.apache.deltaspike.testcontrol.impl.jsf.MyFacesContainerPerTestMethodAdapter</p>
+</li>
+</ul>
+</div>
+<div class="paragraph">
+<p>as content to</p>
+</div>
+<div class="paragraph">
+<p><code>/META-INF/services/org.apache.deltaspike.testcontrol.spi.ExternalContainer</code></p>
+</div>
+<div class="paragraph">
+<p>(in your config-folder for tests, e.g. test/resources)</p>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_using_jersey_test_with_test_control">Using jersey-test with test-control</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>Jersey-test starts jetty which answers requests in a separated thread. Since ds test-control just handles the thread of the test itself, it&#8217;s needed to integrate jetty and jersey with the cdi-container. Usually that&#8217;s done via a ServletRequestListener - the following part describes an alternative approach for jersey-test:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="java"><span class="comment">//use: -Djersey.config.test.container.factory=custom.CdiAwareJettyTestContainerFactory</span>
+
+<span class="annotation">@RunWith</span>(CdiTestRunner.class)
+<span class="directive">public</span> <span class="type">class</span> <span class="class">SimpleCdiAndJaxRsTest</span> <span class="directive">extends</span> JerseyTest
+{
+  <span class="comment">//...</span>
+}</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>or</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="java"><span class="directive">public</span> <span class="type">class</span> <span class="class">CdiAwareJerseyTest</span> <span class="directive">extends</span> JerseyTest
+{
+    <span class="directive">static</span>
+    {
+        <span class="predefined-type">System</span>.setProperty(<span class="string"><span class="delimiter">&quot;</span><span class="content">jersey.config.test.container.factory</span><span class="delimiter">&quot;</span></span>, CdiAwareJettyTestContainerFactory.class.getName());
+    }
+}
+
+<span class="annotation">@RunWith</span>(CdiTestRunner.class)
+<span class="directive">public</span> <span class="type">class</span> <span class="class">SimpleCdiAndJaxRsTest</span> <span class="directive">extends</span> CdiAwareJerseyTest
+{
+    <span class="comment">//...</span>
+}</code></pre>
+</div>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="java"><span class="directive">public</span> <span class="type">class</span> <span class="class">CdiAwareJettyTestContainerFactory</span> <span class="directive">implements</span> TestContainerFactory
+{
+    <span class="annotation">@Override</span>
+    <span class="directive">public</span> TestContainer create(<span class="directive">final</span> <span class="predefined-type">URI</span> baseUri, <span class="directive">final</span> DeploymentContext context) <span class="directive">throws</span> <span class="exception">IllegalArgumentException</span>
+    {
+        <span class="keyword">return</span> <span class="keyword">new</span> CdiAwareJettyTestContainer(baseUri, context);
+    }
+}</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>CdiAwareJettyTestContainer is a copy of JettyTestContainerFactory.JettyTestContainer but with</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="java">HandlerWrapper cdiHandlerWrapper = <span class="keyword">new</span> CdiAwareHandlerWrapper();
+cdiHandlerWrapper.setHandler(<span class="local-variable">this</span>.server.getHandler());
+<span class="local-variable">this</span>.server.setHandler(cdiHandlerWrapper);</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>after the line with JettyHttpContainerFactory#createServer</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="java"><span class="comment">//activate the request-context e.g. via:</span>
+<span class="directive">public</span> <span class="type">class</span> <span class="class">CdiAwareHandlerWrapper</span> <span class="directive">extends</span> HandlerWrapper
+{
+    <span class="annotation">@Override</span>
+    <span class="directive">public</span> <span class="type">void</span> handle(<span class="predefined-type">String</span> target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) <span class="directive">throws</span> <span class="exception">IOException</span>, ServletException
+    {
+        CdiContainer cdiContainer = CdiContainerLoader.getCdiContainer();
+
+        <span class="keyword">try</span>
+        {
+            cdiContainer.getContextControl().startContext(RequestScoped.class);
+            <span class="local-variable">super</span>.handle(target, baseRequest, request, response);
+        }
+        <span class="keyword">finally</span>
+        {
+            cdiContainer.getContextControl().stopContext(RequestScoped.class);
+        }
+    }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_mixed_tests">Mixed Tests</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>Usually you should have one kind of tests per test-module. However, if
+you need to add, for example, a test without an external-container to your
+test-module which uses external-containers, you can annotate your test
+with:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="java"><span class="annotation">@RunWith</span>(CdiTestRunner.class)
+<span class="annotation">@TestControl</span>(startExternalContainers = <span class="predefined-constant">false</span>)
+<span class="directive">public</span> <span class="type">class</span> <span class="class">JsfContainerTest</span>
+{
+    <span class="comment">//...</span>
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_known_restrictions">Known Restrictions</h2>
+<div class="sectionbody">
+<div class="sect2">
+<h3 id="_liquibase">Liquibase</h3>
+<div class="paragraph">
+<p>Liquibase invokes <code>#toString</code> in a <code>AfterDeploymentValidation</code> observer.
+<strong>that is not portable</strong> and therefore you have to deactivate the
+mocking-support via:</p>
+</div>
+<div class="listingblock">
+<div class="content">

[... 175 lines stripped ...]



Mime
View raw message