You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltaspike.apache.org by bu...@apache.org on 2013/12/05 11:58:17 UTC

svn commit: r889217 - in /websites/staging/deltaspike/trunk/content: ./ test-control.html

Author: buildbot
Date: Thu Dec  5 10:58:17 2013
New Revision: 889217

Log:
Staging update by buildbot for deltaspike

Added:
    websites/staging/deltaspike/trunk/content/test-control.html
Modified:
    websites/staging/deltaspike/trunk/content/   (props changed)

Propchange: websites/staging/deltaspike/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Thu Dec  5 10:58:17 2013
@@ -1 +1 @@
-1548085
+1548086

Added: websites/staging/deltaspike/trunk/content/test-control.html
==============================================================================
--- websites/staging/deltaspike/trunk/content/test-control.html (added)
+++ websites/staging/deltaspike/trunk/content/test-control.html Thu Dec  5 10:58:17 2013
@@ -0,0 +1,193 @@
+<!DOCTYPE html>
+<html lang="en">
+<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">
+
+    <title>Apache DeltaSpike - 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 &quot;License&quot;); 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 &quot;AS IS&quot; 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="./resources/css/bootstrap.css" rel="stylesheet">    
+    <!--<link href="./resources/css/prettify.css" rel="stylesheet" /> -->
+    <link href="./resources/css/codehilite.css" rel="stylesheet" />
+    <link href="./resources/css/bootstrap-responsive.css" rel="stylesheet">
+    <style type="text/css">
+        body {
+            padding-top: 60px;
+            padding-bottom: 40px;
+        }
+    </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" href="index.html"><img src="./resources/images/deltaspike-logo-medium.png"/></a>
+                <div class="nav-collapse">
+                    <ul class="nav">
+                        <li class="active"><a href="./index.html">Home</a></li>
+                        <li><a href="./documentation.html">Documentation</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>
+                        <li><a href="./migration-guide.html">Migration</a></li>
+                    </ul>
+                </div><!--/.nav-collapse -->
+                <form id="search-form" action="http://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">
+          <div class="span12">
+              <div class="page-title">
+                <h1>Test-Control Module</h1>
+              </div>
+              <div class="toc">
+<ul>
+<li><a href="#intro">Intro</a></li>
+<li><a href="#cditestrunner">CdiTestRunner</a></li>
+<li><a href="#testcontrol">@TestControl</a></li>
+<li><a href="#cditestsuiterunner">CdiTestSuiteRunner</a></li>
+<li><a href="#project-stage-control">Project-Stage Control</a></li>
+<li><a href="#hints">Hints</a></li>
+<li><a href="#spi">SPI</a></li>
+</ul>
+</div>
+<hr />
+<h1 id="intro">Intro</h1>
+<p>This module is available since version 0.6 and allows to write CDI based tests easily.</p>
+<h1 id="cditestrunner">CdiTestRunner</h1>
+<p>JUnit Test-Runner to start/stop the CDI-Container autom. (per test-class) and one request and session per test-method:</p>
+<div class="codehilite"><pre><span class="nd">@RunWith</span><span class="o">(</span><span class="n">CdiTestRunner</span><span class="o">.</span><span class="na">class</span><span class="o">)</span>
+<span class="kd">public</span> <span class="kd">class</span> <span class="nc">ContainerAndInjectionControl</span>
+<span class="o">{</span>
+    <span class="nd">@Inject</span>
+    <span class="kd">private</span> <span class="n">ApplicationScopedBean</span> <span class="n">applicationScopedBean</span><span class="o">;</span>
+
+    <span class="nd">@Inject</span>
+    <span class="kd">private</span> <span class="n">SessionScopedBean</span> <span class="n">sessionScopedBean</span><span class="o">;</span>
+
+    <span class="nd">@Inject</span>
+    <span class="kd">private</span> <span class="n">RequestScopedBean</span> <span class="n">requestScopedBean</span><span class="o">;</span>
+
+    <span class="c1">//test the injected beans</span>
+<span class="o">}</span>
+</pre></div>
+
+
+<h1 id="testcontrol">@TestControl</h1>
+<p>@TestControl allows to change the default-behavior. In the following case only one session for all test-methods (of the test-class) will be created:</p>
+<div class="codehilite"><pre><span class="nd">@RunWith</span><span class="o">(</span><span class="n">CdiTestRunner</span><span class="o">.</span><span class="na">class</span><span class="o">)</span>
+<span class="nd">@TestControl</span><span class="o">(</span><span class="n">startScopes</span> <span class="o">=</span> <span class="n">SessionScoped</span><span class="o">.</span><span class="na">class</span><span class="o">)</span>
+<span class="kd">public</span> <span class="kd">class</span> <span class="nc">CustomizedScopeHandling</span>
+<span class="o">{</span>
+    <span class="c1">//inject beans and test them</span>
+<span class="o">}</span>
+</pre></div>
+
+
+<h1 id="cditestsuiterunner">CdiTestSuiteRunner</h1>
+<p>JUnit Test-Suite-Runner to start/stop the CDI-Container autom. (per test-suite):</p>
+<div class="codehilite"><pre><span class="nd">@RunWith</span><span class="o">(</span><span class="n">CdiTestSuiteRunner</span><span class="o">.</span><span class="na">class</span><span class="o">)</span>
+<span class="nd">@Suite.SuiteClasses</span><span class="o">({</span>
+    <span class="n">TestX</span><span class="o">.</span><span class="na">class</span><span class="o">,</span>
+    <span class="n">TestY</span><span class="o">.</span><span class="na">class</span>
+<span class="o">})</span>
+<span class="kd">public</span> <span class="kd">class</span> <span class="nc">SuiteLevelContainerControl</span>
+<span class="o">{</span>
+<span class="o">}</span>
+</pre></div>
+
+
+<h1 id="project-stage-control">Project-Stage Control</h1>
+<p>It's possible to overrule the default-project-stage for unit-tests (ProjectStage.UnitTest.class):</p>
+<div class="codehilite"><pre><span class="nd">@RunWith</span><span class="o">(</span><span class="n">CdiTestRunner</span><span class="o">.</span><span class="na">class</span><span class="o">)</span>
+<span class="nd">@TestControl</span><span class="o">(</span><span class="n">projectStage</span> <span class="o">=</span> <span class="n">CustomTestStage</span><span class="o">.</span><span class="na">class</span><span class="o">)</span>
+<span class="kd">public</span> <span class="kd">class</span> <span class="nc">TestStageControl</span>
+<span class="o">{</span>
+    <span class="c1">//tests here will see project-stage CustomTestStage.class</span>
+
+    <span class="nd">@Test</span>
+    <span class="nd">@TestControl</span><span class="o">(</span><span class="n">projectStage</span> <span class="o">=</span> <span class="n">ProjectStage</span><span class="o">.</span><span class="na">Development</span><span class="o">.</span><span class="na">class</span><span class="o">)</span>
+    <span class="kd">public</span> <span class="kt">void</span> <span class="nf">checkDevEnv</span><span class="o">()</span>
+    <span class="o">{</span>
+    <span class="o">}</span>
+
+    <span class="c1">//tests here will see project-stage CustomTestStage.class</span>
+<span class="o">}</span>
+</pre></div>
+
+
+<h1 id="hints">Hints</h1>
+<p>Don't forget to add a beans.xml in the test-module (e.g. src/test/resources/META-INF/beans.xml).</p>
+<h1 id="spi">SPI</h1>
+<p>[TODO]</p>
+          </div>
+      </div>
+
+      <hr>
+
+      <footer>
+        <p>Copyright © 20011-2012 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> <!-- /container -->
+
+    <!-- Javascript
+    ================================================== -->
+    <!-- Placed at the end of the document so the pages load faster -->
+    <!--<script src="./resources/js/prettyfy.js"></script> -->
+    <script src="./resources/js/prettyprint.js"></script>
+    <script src="./resources/js/jquery.js"></script>
+    <script src="./resources/js/bootstrap-transition.js"></script>
+    <script src="./resources/js/bootstrap-alert.js"></script>
+    <script src="./resources/js/bootstrap-modal.js"></script>
+    <script src="./resources/js/bootstrap-dropdown.js"></script>
+    <script src="./resources/js/bootstrap-scrollspy.js"></script>
+    <script src="./resources/js/bootstrap-tab.js"></script>
+    <script src="./resources/js/bootstrap-tooltip.js"></script>
+    <script src="./resources/js/bootstrap-popover.js"></script>
+    <script src="./resources/js/bootstrap-button.js"></script>
+    <script src="./resources/js/bootstrap-collapse.js"></script>
+    <script src="./resources/js/bootstrap-carousel.js"></script>
+    <script src="./resources/js/bootstrap-typeahead.js"></script>
+
+</body>
+</html>