Author: buildbot
Date: Wed May  1 12:45:29 2019
New Revision: 1044390

Log:
Staging update by buildbot for openwebbeans

Added:
    websites/staging/openwebbeans/trunk/content/openwebbeans-junit5.html
Modified:
    websites/staging/openwebbeans/trunk/content/   (props changed)
    websites/staging/openwebbeans/trunk/content/modules.html

Propchange: websites/staging/openwebbeans/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Wed May  1 12:45:29 2019
@@ -1 +1 @@
-1855322
+1858481

Modified: websites/staging/openwebbeans/trunk/content/modules.html
==============================================================================
--- websites/staging/openwebbeans/trunk/content/modules.html (original)
+++ websites/staging/openwebbeans/trunk/content/modules.html Wed May  1 
12:45:29 2019
@@ -96,6 +96,7 @@ h2:hover > .headerlink, h3:hover > .head
 <li><a href="openwebbeans-osgi.html">OSGi plugin</a></li>
 <li><a href="owbtest.html">CDI Test Framework</a></li>
 <li><a href="samples/index.html">OWB Samples</a></li>
+<li><a href="openwebbeans-junit5.html">JUnit 5</a></li>
 </ul>
         </div>
 

Added: websites/staging/openwebbeans/trunk/content/openwebbeans-junit5.html
==============================================================================
--- websites/staging/openwebbeans/trunk/content/openwebbeans-junit5.html (added)
+++ websites/staging/openwebbeans/trunk/content/openwebbeans-junit5.html Wed 
May  1 12:45:29 2019
@@ -0,0 +1,260 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+    <meta charset="utf-8">
+    <title>Apache OpenWebBeans</title>
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <meta name="description" content="">
+    <meta name="author" content="">
+
+    <!-- Le styles -->
+    <link href="./resources/css/bootstrap.css" rel="stylesheet">
+    <style type="text/css">
+        body {
+            padding-top: 60px;
+            padding-bottom: 40px;
+        }
+    </style>
+    <link href="./resources/css/main.css" rel="stylesheet">
+
+</head>
+
+<body>
+
+<nav class="navbar navbar-default navbar-inverse navbar-fixed-top" 
role="navigation">
+    <div class="container">
+        <div class="navbar-header">
+            <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="navbar-brand" href="index.html"><img 
src="./resources/images/logo_dbg-small.png" height="25px"
+                                                           
alt="owb_logo_small"/></a>
+        </div>
+
+        <div class="collapse navbar-collapse">
+            <ul class="nav navbar-nav">
+                <li><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="./news.html">News</a></li> -->
+                <li class="dropdown">
+                    <a class="dropdown-toggle" data-toggle="dropdown" href="#" 
aria-haspopup="true">Misc<span class="caret"></span></a>
+                    <ul class="dropdown-menu">
+                        <li><a href="https://www.apache.org";>Apache 
Home</a></li>
+                        <li><a href="./misc/contact.html">Contact</a></li>
+                        <li><a href="./misc/legal.html">Legal</a></li>
+                        <li><a 
href="https://www.apache.org/foundation/sponsorship.html";>Sponsorship</a></li>
+                        <li><a 
href="https://www.apache.org/foundation/thanks.html";>Thanks</a></li>
+                        <!-- <li class="divider"/> -->
+                    </ul>
+                </li>
+            </ul>
+            <!--/.nav-collapse -->
+            <form id="search-form" action="https://www.google.com/search"; 
method="get" class="navbar-search pull-right">
+                <input value="openwebbeans.apache.org" name="sitesearch" 
type="hidden"/>
+                <input class="search-query" name="q" id="query" type="search"/>
+            </form>
+            <script type="text/javascript" 
src="https://www.google.com/coop/cse/brand?form=search-form";></script>
+        </div>
+    </div>
+</nav>
+
+<div class="container">
+
+
+        <div id="OwbContent_" class="wiki-content">
+<style type="text/css">
+/* The following code is added by mdx_elementid.py
+   It was originally lifted from http://subversion.apache.org/style/site.css */
+/*
+ * Hide class="elementid-permalink", except when an enclosing heading
+ * has the :hover property.
+ */
+.headerlink, .elementid-permalink {
+  visibility: hidden;
+}
+h2:hover > .headerlink, h3:hover > .headerlink, h1:hover > .headerlink, 
h6:hover > .headerlink, h4:hover > .headerlink, h5:hover > .headerlink, 
dt:hover > .elementid-permalink { visibility: visible }</style>
+<h1 id="openwebbeans-junit-5">OpenWebBeans JUnit 5<a class="headerlink" 
href="#openwebbeans-junit-5" title="Permanent link">&para;</a></h1>
+<p>OpenWebBeans provides a JUnit 5 integration. It brings an extension which 
will be backed by CDI Standalone Edition API (<code>SeContainer</code>).</p>
+<p>The entry point is <code>@Cdi</code> API which maps the main methods of 
<code>SeContainerInitializer</code>.
+It typically enables you to define which classes you want to deploy for the 
test or if you want to use classpath scanning.</p>
+<p>Here is how a test can look like:</p>
+<div class="codehilite"><pre><span class="nd">@Cdi</span><span 
class="o">(</span><span class="n">disableDiscovery</span> <span 
class="o">=</span> <span class="kc">true</span><span class="o">,</span> <span 
class="n">classes</span> <span class="o">=</span> <span 
class="n">MyService</span><span class="o">.</span><span 
class="na">class</span><span class="o">)</span>
+<span class="kd">class</span> <span class="nc">CdiTest</span> <span 
class="o">{</span>
+    <span class="nd">@Inject</span>
+    <span class="kd">private</span> <span class="n">MyService</span> <span 
class="n">service</span><span class="o">;</span>
+
+    <span class="nd">@Test</span>
+    <span class="kt">void</span> <span class="nf">test</span><span 
class="o">()</span> <span class="o">{</span>
+        <span class="n">assertEquals</span><span class="o">(</span><span 
class="s">&quot;ok&quot;</span><span class="o">,</span> <span 
class="n">service</span><span class="o">.</span><span class="na">ok</span><span 
class="o">());</span>
+    <span class="o">}</span>
+<span class="o">}</span>
+</pre></div>
+
+
+<p>As you may notice, this test disable the default classpath scanning and 
only activate <code>MyService</code> bean.</p>
+<p>Once a test is marked <code>@Cdi</code> you get injections of the 
underlying container available in the test class. This is how previous snippet 
can inject <code>MyService</code> into the test class without having anything 
else to do.</p>
+<h2 id="dependency">Dependency<a class="headerlink" href="#dependency" 
title="Permanent link">&para;</a></h2>
+<div class="codehilite"><pre> <span class="nt">&lt;dependency&gt;</span>
+    <span class="nt">&lt;groupId&gt;</span>org.apache.openwebbeans<span 
class="nt">&lt;/groupId&gt;</span>
+    <span class="nt">&lt;artifactId&gt;</span>openwebbeans-junit5<span 
class="nt">&lt;/artifactId&gt;</span>
+    <span class="nt">&lt;version&gt;</span>${owb.version}<span 
class="nt">&lt;/version&gt;</span>
+  <span class="nt">&lt;/dependency&gt;</span>
+</pre></div>
+
+
+<p>IMPORTANT: this feature comes with OpenWebBeans &gt;= 2.0.11.</p>
+<h2 id="reusable-mode">Reusable mode<a class="headerlink" 
href="#reusable-mode" title="Permanent link">&para;</a></h2>
+<p><code>@Cdi</code> also adds a specific API called <code>reusable</code>. 
When this is set to <code>true</code>, the container is started and then reused 
by next test.
+This enables to speed up the test suite a lot when reusing the same JVM to run 
all tests.</p>
+<p>For example if you have these two tests:</p>
+<div class="codehilite"><pre><span class="nd">@Cdi</span><span 
class="o">(</span><span class="n">reusable</span> <span class="o">=</span> 
<span class="kc">true</span><span class="o">)</span>
+<span class="kd">class</span> <span class="nc">MyFirstTest</span> <span 
class="o">{</span>
+    <span class="nd">@Inject</span>
+    <span class="kd">private</span> <span class="n">MyService</span> <span 
class="n">service</span><span class="o">;</span>
+
+    <span class="nd">@Test</span>
+    <span class="kt">void</span> <span class="nf">test</span><span 
class="o">()</span> <span class="o">{</span>
+        <span class="n">assertEquals</span><span class="o">(</span><span 
class="s">&quot;ok&quot;</span><span class="o">,</span> <span 
class="n">service</span><span class="o">.</span><span class="na">ok</span><span 
class="o">());</span>
+    <span class="o">}</span>
+<span class="o">}</span>
+</pre></div>
+
+
+<p>and</p>
+<div class="codehilite"><pre><span class="nd">@Cdi</span><span 
class="o">(</span><span class="n">reusable</span> <span class="o">=</span> 
<span class="kc">true</span><span class="o">)</span>
+<span class="kd">class</span> <span class="nc">MySecondTest</span> <span 
class="o">{</span>
+    <span class="nd">@Inject</span>
+    <span class="kd">private</span> <span class="n">MyOtherService</span> 
<span class="n">service</span><span class="o">;</span>
+
+    <span class="nd">@Test</span>
+    <span class="kt">void</span> <span class="nf">test</span><span 
class="o">()</span> <span class="o">{</span>
+        <span class="n">assertEquals</span><span class="o">(</span><span 
class="s">&quot;ok2&quot;</span><span class="o">,</span> <span 
class="n">service</span><span class="o">.</span><span class="na">ok</span><span 
class="o">());</span>
+    <span class="o">}</span>
+<span class="o">}</span>
+</pre></div>
+
+
+<p>Then CDI container will be started only once.</p>
+<p>However if the first test is:</p>
+<div class="codehilite"><pre><span class="nd">@Cdi</span><span 
class="o">(</span><span class="n">reusable</span> <span class="o">=</span> 
<span class="kc">true</span><span class="o">,</span> <span 
class="n">disableDiscovery</span> <span class="o">=</span> <span 
class="kc">true</span><span class="o">,</span> <span class="n">classes</span> 
<span class="o">=</span> <span class="n">MyService</span><span 
class="o">.</span><span class="na">class</span><span class="o">)</span>
+<span class="kd">class</span> <span class="nc">MyFirstTest</span> <span 
class="o">{</span>
+    <span class="c1">// .. as before</span>
+<span class="o">}</span>
+</pre></div>
+
+
+<p>Then the second test will not have its <code>MyOtherService</code> bean 
since previous test will only deploy <code>MyService</code>.</p>
+<p>To avoid that it is recommended to follow these best practises:</p>
+<ul>
+<li>Never mix reusable and not reusable tests in the same suite (define 
multiple surefire executions for example),</li>
+<li>For reusable tests define a meta annotation which shares the configuration 
for all tests, this means you must have a single <code>reusable = true</code> 
in your whole code (per execution).</li>
+</ul>
+<p>To define a reusable setup you just define a new annotation decorated with 
<code>@Cdi</code>:</p>
+<div class="codehilite"><pre><span class="nd">@Target</span><span 
class="o">(</span><span class="n">TYPE</span><span class="o">)</span>
+<span class="nd">@Retention</span><span class="o">(</span><span 
class="n">RUNTIME</span><span class="o">)</span>
+<span class="nd">@Cdi</span><span class="o">(</span><span 
class="n">reusable</span> <span class="o">=</span> <span 
class="kc">true</span><span class="o">,</span> <span 
class="n">disableDiscovery</span> <span class="o">=</span> <span 
class="kc">true</span><span class="o">,</span> <span class="n">packages</span> 
<span class="o">=</span> <span class="n">MyService</span><span 
class="o">.</span><span class="na">class</span><span class="o">)</span>
+<span class="kd">public</span> <span class="nd">@interface</span> <span 
class="n">TestConfig</span> <span class="o">{</span>
+<span class="o">}</span>
+</pre></div>
+
+
+<p>Then your test class can look like:</p>
+<div class="codehilite"><pre><span class="nd">@TestConfig</span>
+<span class="kd">class</span> <span class="nc">MySecondTest</span> <span 
class="o">{</span>
+    <span class="nd">@Inject</span>
+    <span class="kd">private</span> <span class="n">MyService</span> <span 
class="n">service</span><span class="o">;</span>
+
+    <span class="nd">@Test</span>
+    <span class="kt">void</span> <span class="nf">test</span><span 
class="o">()</span> <span class="o">{</span>
+        <span class="n">assertEquals</span><span class="o">(</span><span 
class="s">&quot;ok&quot;</span><span class="o">,</span> <span 
class="n">service</span><span class="o">.</span><span class="na">ok</span><span 
class="o">());</span>
+    <span class="o">}</span>
+<span class="o">}</span>
+</pre></div>
+
+
+<h3 id="surefire">Surefire<a class="headerlink" href="#surefire" 
title="Permanent link">&para;</a></h3>
+<p>For reusable mode to be efficient, it is recommended to use this surefire 
configuration:</p>
+<div class="codehilite"><pre><span class="nt">&lt;plugin&gt;</span>
+  <span class="nt">&lt;groupId&gt;</span>org.apache.maven.plugins<span 
class="nt">&lt;/groupId&gt;</span>
+  <span class="nt">&lt;artifactId&gt;</span>maven-surefire-plugin<span 
class="nt">&lt;/artifactId&gt;</span>
+  <span class="nt">&lt;version&gt;</span>${surefire.version}<span 
class="nt">&lt;/version&gt;</span>
+  <span class="nt">&lt;configuration&gt;</span>
+    <span class="nt">&lt;forkCount&gt;</span>1<span 
class="nt">&lt;/forkCount&gt;</span>
+  <span class="nt">&lt;/configuration&gt;</span>
+<span class="nt">&lt;/plugin&gt;</span>
+</pre></div>
+
+
+<p>And here is how to define executions to mix reusable and not reusable tests 
- which can have a different deployment setup:</p>
+<div class="codehilite"><pre><span class="nt">&lt;plugin&gt;</span>
+    <span class="nt">&lt;groupId&gt;</span>org.apache.maven.plugins<span 
class="nt">&lt;/groupId&gt;</span>
+    <span class="nt">&lt;artifactId&gt;</span>maven-surefire-plugin<span 
class="nt">&lt;/artifactId&gt;</span>
+    <span class="nt">&lt;version&gt;</span>${surefire.version}<span 
class="nt">&lt;/version&gt;</span>
+    <span class="nt">&lt;executions&gt;</span>
+        <span class="nt">&lt;execution&gt;</span> <span class="c">&lt;!-- skip 
default setup since we redefine it --&gt;</span>
+            <span class="nt">&lt;id&gt;</span>default-test<span 
class="nt">&lt;/id&gt;</span>
+            <span class="nt">&lt;configuration&gt;</span>
+                <span class="nt">&lt;skip&gt;</span>true<span 
class="nt">&lt;/skip&gt;</span>
+            <span class="nt">&lt;/configuration&gt;</span>
+        <span class="nt">&lt;/execution&gt;</span>
+        <span class="nt">&lt;execution&gt;</span>
+            <span class="nt">&lt;id&gt;</span>not-reusable<span 
class="nt">&lt;/id&gt;</span>
+            <span class="nt">&lt;phase&gt;</span>test<span 
class="nt">&lt;/phase&gt;</span>
+            <span class="nt">&lt;goals&gt;</span>
+                <span class="nt">&lt;goal&gt;</span>test<span 
class="nt">&lt;/goal&gt;</span>
+            <span class="nt">&lt;/goals&gt;</span>
+            <span class="nt">&lt;configuration&gt;</span>
+                <span class="nt">&lt;includes&gt;</span>**/perclass/*<span 
class="nt">&lt;/includes&gt;</span>
+            <span class="nt">&lt;/configuration&gt;</span>
+        <span class="nt">&lt;/execution&gt;</span>
+        <span class="nt">&lt;execution&gt;</span>
+            <span class="nt">&lt;id&gt;</span>reusable<span 
class="nt">&lt;/id&gt;</span>
+            <span class="nt">&lt;phase&gt;</span>test<span 
class="nt">&lt;/phase&gt;</span>
+            <span class="nt">&lt;goals&gt;</span>
+                <span class="nt">&lt;goal&gt;</span>test<span 
class="nt">&lt;/goal&gt;</span>
+            <span class="nt">&lt;/goals&gt;</span>
+            <span class="nt">&lt;configuration&gt;</span>
+                <span class="nt">&lt;includes&gt;</span>**/reusable/*<span 
class="nt">&lt;/includes&gt;</span>
+            <span class="nt">&lt;/configuration&gt;</span>
+        <span class="nt">&lt;/execution&gt;</span>
+    <span class="nt">&lt;/executions&gt;</span>
+    <span class="nt">&lt;configuration&gt;</span>
+      <span class="nt">&lt;forkCount&gt;</span>1<span 
class="nt">&lt;/forkCount&gt;</span>
+    <span class="nt">&lt;/configuration&gt;</span>
+<span class="nt">&lt;/plugin&gt;</span>
+</pre></div>
+
+
+<p>This setup assumes not reusable tests are in a <code>perclass</code> 
package and reusable ones are in a <code>reusable</code> package.
+Alternatively you can use categories (just define markers in your test code) 
but this is generally less obvious to manage on the long run.</p>
+        </div>
+
+        <hr>
+
+        <footer class="text-center">
+            <p>
+                <a href="https://www.apache.org";><img class="img-responsive 
center-block" src="https://www.apache.org/images/asf_logo_wide.png"; 
height="55px" alt="asf_feather"/></a>
+            </p>
+            <p>Copyright &copy; 2008-2016 The Apache Software Foundation, 
Licensed under the Apache License, Version 2.0.</p>
+            <p>OpenWebBeans, 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/jquery-2.1.4.min.js"></script>
+    <script src="./resources/js/bootstrap.js"></script>
+
+</body></html>
+
+
+
+


Reply via email to