felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Felix > Apache Felix Sigil JUnit
Date Mon, 13 Jul 2009 21:06:00 GMT
<html>
<head>
    <base href="http://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1519/1/1/_/styles/combined.css?spaceKey=FELIX&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background-color: white" bgcolor="white">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="http://cwiki.apache.org/confluence/display/FELIX/Apache+Felix+Sigil+JUnit">Apache
Felix Sigil JUnit</a></h2>
    <h4>Page  <b>added</b> by             <a href="http://cwiki.apache.org/confluence/display/~dsavage@apache.org">David
Savage</a>
    </h4>
         <br/>
    <div class="notificationGreySide">
         <h2><a name="ApacheFelixSigilJUnit-Overview"></a>Overview</h2>

<p>The Sigil JUnit plugin is an OSGi bundle that when started in an OSGi enabled JVM
watches for other bundles that contain JUnit TestCase classes in the framework. The main access
point to the plugin is the <tt>org.cauldron.sigil.junit.server.JUnitService</tt>.</p>

<style type="text/css">
@import url(/confluence/download/resources/confluence.ext.code:code/shStyles.css);
</style>
<!--[if IE]>
<style type="text/css">
    .code textarea, .code input { padding: 0 !important; }
</style>
<![endif]-->
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shCore.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushCSharp.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushPhp.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushJScript.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushVb.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushSql.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushXml.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushShell.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushDelphi.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushPython.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushJava.js"></script>
<div class="code">
<textarea name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">package
org.cauldron.sigil.junit.server;

import java.util.Set;

import org.osgi.framework.BundleContext;

import junit.framework.TestSuite;

/**
 *
 */	
public interface JUnitService {
	/**
	 * Returns the names of all tests currently installed in the OSGi runtime
	 */	
	Set&lt;String&gt; getTests();

	/**
	 * Create a new instance of the specified test. Equivalent to calling createTest(test, null);
	 */	
	TestSuite createTest(String test);
	
	/**
	 * Create a new instance of the specified test passing the specified bundle context to the
test classes.
	 * If ctx is null the callers BundleContext is passed to the test.
	 */	
	TestSuite createTest(String test, BundleContext ctx);
}</textarea>
<script class="javascript">
    if(!window.newcodemacro_initialised)
    {
        window.newcodemacro_initialised = true;
        window.oldonloadmethod = window.onload;
        window.onload = function(){
            dp.SyntaxHighlighter.HighlightAll('newcodemacro');
            if(window.oldonloadmethod)
            {
                window.oldonloadmethod();
            }
        }
    }

</script>
</div>


<p>When a test is created the <tt>JUnitService</tt> introspects the test
class and looks for a method <tt>public void setBundleContext(BundleContext ctx);</tt>
if one is found then the BundleContext is injected into the test class before being returned
to the caller. </p>

<h2><a name="ApacheFelixSigilJUnit-CLI"></a>CLI</h2>

<p>For convenience we provide a simple newton command line interface to the JUnit plugin
in the bundle <tt>org.cauldron.sigil.junit.cli</tt>. This allows the user to find
and run tests currently installed in the container.</p>

<p>examples:</p>

<div class="code">
<textarea name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">junit
	org.cauldron.sigil.junit.example.Test1
	org.cauldron.sigil.junit.example.Test10
	org.cauldron.sigil.junit.example.Test2
	org.cauldron.sigil.junit.example.Test3
	org.cauldron.sigil.junit.example.Test4
	org.cauldron.sigil.junit.example.Test5
	org.cauldron.sigil.junit.example.Test6
	org.cauldron.sigil.junit.example.Test7
	org.cauldron.sigil.junit.example.Test8
	org.cauldron.sigil.junit.example.Test9</textarea>
<script class="javascript">
    if(!window.newcodemacro_initialised)
    {
        window.newcodemacro_initialised = true;
        window.oldonloadmethod = window.onload;
        window.onload = function(){
            dp.SyntaxHighlighter.HighlightAll('newcodemacro');
            if(window.oldonloadmethod)
            {
                window.oldonloadmethod();
            }
        }
    }

</script>
</div>


<div class="code">
<textarea name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">&gt;
junit org.cauldron.sigil.junit.example.Test1
Start testSuccess(org.cauldron.sigil.junit.example.Test1)
End testSuccess(org.cauldron.sigil.junit.example.Test1)
Start testFail(org.cauldron.sigil.junit.example.Test1)
Failure testFail(org.cauldron.sigil.junit.example.Test1): Failed
End testFail(org.cauldron.sigil.junit.example.Test1)
Ran 2 tests. 1 failures 0 errors.</textarea>
<script class="javascript">
    if(!window.newcodemacro_initialised)
    {
        window.newcodemacro_initialised = true;
        window.oldonloadmethod = window.onload;
        window.onload = function(){
            dp.SyntaxHighlighter.HighlightAll('newcodemacro');
            if(window.oldonloadmethod)
            {
                window.oldonloadmethod();
            }
        }
    }

</script>
</div>


<div class="code">
<textarea name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">&gt;
junit -q org.cauldron.sigil.junit.example.Test1
Ran 2 tests. 1 failures 0 errors.</textarea>
<script class="javascript">
    if(!window.newcodemacro_initialised)
    {
        window.newcodemacro_initialised = true;
        window.oldonloadmethod = window.onload;
        window.onload = function(){
            dp.SyntaxHighlighter.HighlightAll('newcodemacro');
            if(window.oldonloadmethod)
            {
                window.oldonloadmethod();
            }
        }
    }

</script>
</div>


<div class="code">
<textarea name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">&gt;
junit -q *
Ran 20 tests. 10 failures 0 errors.</textarea>
<script class="javascript">
    if(!window.newcodemacro_initialised)
    {
        window.newcodemacro_initialised = true;
        window.oldonloadmethod = window.onload;
        window.onload = function(){
            dp.SyntaxHighlighter.HighlightAll('newcodemacro');
            if(window.oldonloadmethod)
            {
                window.oldonloadmethod();
            }
        }
    }

</script>
</div>


<div class="code">
<textarea name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">&gt;
junit -q -d /tmp *
Writing results to /tmp
Ran 20 tests. 10 failures 0 errors.</textarea>
<script class="javascript">
    if(!window.newcodemacro_initialised)
    {
        window.newcodemacro_initialised = true;
        window.oldonloadmethod = window.onload;
        window.onload = function(){
            dp.SyntaxHighlighter.HighlightAll('newcodemacro');
            if(window.oldonloadmethod)
            {
                window.oldonloadmethod();
            }
        }
    }

</script>
</div>

    </div>
    <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href="http://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
       </div>
       <a href="http://cwiki.apache.org/confluence/display/FELIX/Apache+Felix+Sigil+JUnit">View
Online</a>
              |
       <a href="http://cwiki.apache.org/confluence/display/FELIX/Apache+Felix+Sigil+JUnit?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
           </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message