cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Cayenne Website > Running Unit Tests
Date Sat, 21 Nov 2009 14:23:00 GMT
<html>
<head>
    <base href="http://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1519/1/1/_/styles/combined.css?spaceKey=CAYSITE&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/CAYSITE/Running+Unit+Tests">Running
Unit Tests</a></h2>
     <h4>Page <b>edited</b> by             <a href="http://cwiki.apache.org/confluence/display/~andrus">Andrus
Adamchik</a>
    </h4>
     
          <br/>
     <div class="notificationGreySide">
         <p>Cayenne provides a comprehensive suite of unit tests. To execute unit tests
you must first get Cayenne from SVN, install JDK 1.5 and obtain the latest Maven.</p>

<h2><a name="RunningUnitTests-Prerequisites"></a>Prerequisites</h2>

<p>On some systems (e.g. Ubuntu 8.x) the following line needs to be placed in <tt>"~/.mavenrc"</tt>
or otherwise there will be test failures in the unit tests relying on JGroups. This is a workaround
of a known JVM bug:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
panelContent">
<pre>MAVEN_OPTS="-Djava.net.preferIPv4Stack=true"</pre>
</div></div>


<h2><a name="RunningUnitTests-RunningAgainstEmbeddedHSQLDB"></a>Running
Against Embedded HSQLDB</h2>

<p>No extra setup is required. Just run Maven:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
panelContent">
<pre>$ cd cayenne
$ mvn install</pre>
</div></div>

<p>or </p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
panelContent">
<pre>$ cd cayenne
$ mvn clean test</pre>
</div></div>

<h2><a name="RunningUnitTests-RunningAgainstaSpecificDatabase"></a>Running
Against a Specific Database</h2>

<h4><a name="RunningUnitTests-Step1.InstallJDBCDriverJarsinaLocalMavenRepo"></a>Step
1. Install JDBC Driver Jars in a Local Maven Repo</h4>

<p>Most commercial drivers are not present in the public Maven repositories. So they
have to be installed by the tester locally. The group and artifact ids are arbitrarily assigned
in the main Cayenne POM, so users must follow the POM or the examples below.</p>

<p><b>FrontBase:</b></p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
panelContent">
<pre>$ mvn install:install-file -Dfile=frontbasejdbc.jar -DgroupId=com.frontbase \
       -DartifactId=frontbase-driver -Dversion=4.1 -Dpackaging=jar -DgeneratePom=true</pre>
</div></div>

<p><b>OpenBase:</b></p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
panelContent">
<pre>$ mvn install:install-file -Dfile=OpenBaseJDBC.jar -DgroupId=com.openbase \
       -DartifactId=openbase-driver -Dversion=9 -Dpackaging=jar -DgeneratePom=true</pre>
</div></div>

<p><b>Oracle:</b></p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
panelContent">
<pre>$ mvn install:install-file -Dfile=ojdbc5.jar -DgroupId=com.oracle \
       -DartifactId=oracle-driver -Dversion=11 -Dpackaging=jar -DgeneratePom=true</pre>
</div></div>

<p><b>SQLite:</b></p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
panelContent">
<pre>$ mvn install:install-file -Dfile=sqlitejdbc-v056.jar -DgroupId=org.sqlite \
       -DartifactId=sqlite-driver -Dversion=0.56 -Dpackaging=jar -DgeneratePom=true</pre>
</div></div>

<p><b>SQLServer:</b></p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
panelContent">
<pre>$ mvn install:install-file -Dfile=sqljdbc.jar -DgroupId=com.microsoft \
       -DartifactId=sqlserver-driver -Dversion=2.0 -Dpackaging=jar -DgeneratePom=true</pre>
</div></div>


<p><b>Sybase:</b></p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
panelContent">
<pre>$ mvn install:install-file -Dfile=jconn3.jar -DgroupId=com.sybase \
       -DartifactId=sybase-driver -Dversion=12 -Dpackaging=jar -DgeneratePom=true</pre>
</div></div>

<h4><a name="RunningUnitTests-Step2.RunTestsAgainstConfiguredDataSource"></a>Step
2. Run Tests Against Configured Data Source</h4>

<p>Database type and connection information can be specified either on the command line
or via a configuration file. First let's look at the command line options:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
panelContent">
<pre>$ mvn test -DcayenneTestConnection=&lt;profile_name&gt; \
   -DcayenneAdapter=org.apache.cayenne.dba.mysql.MySQLAdapter \
   -DcayenneJdbcUsername=myuser \
   -DcayenneJdbcPassword=mypassword \
   -DcayenneJdbcUrl=jdbc:mysql://localhost/cayenne \
   -DcayenneJdbcDriver=com.mysql.jdbc.Driver</pre>
</div></div>

<p><tt>cayenneTestConnection</tt> is a property activating a DB-specific
Maven profile. <tt>&lt;profile_name&gt;</tt> can be one of:</p>

<ul>
	<li>derby</li>
	<li>h2</li>
	<li>frontbase</li>
	<li>mysql</li>
	<li>openbase</li>
	<li>oracle</li>
	<li>postgres</li>
	<li>sqlite</li>
	<li>sqlserver</li>
	<li>sybase</li>
</ul>


<p>Another way to store this information permanently for each profile is to create a
directory <tt>$HOME/.cayenne/</tt> and place a file called <tt>connection.properties</tt>
in this directory. File contents should be similar to this example:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
panelContent">
<pre>mysql.cayenne.adapter = org.apache.cayenne.dba.mysql.MySQLAdapter
mysql.jdbc.username = someuser
mysql.jdbc.password = somepasswd
mysql.jdbc.url = jdbc:someurl1
mysql.jdbc.driver = com.xyz.MyDriverClass

oracle.cayenne.adapter = org.apache.cayenne.dba.oracle.OracleAdapter
oracle.jdbc.username = someuser
oracle.jdbc.password = somepasswd
oracle.jdbc.url = jdbc:someurl2
oracle.jdbc.driver = com.xyz.MyDriverClass</pre>
</div></div>

<p>Each property starts with the Maven profile name ("mysql" and "oracle" in the example
above). Note that in this case you should still use <tt>cayenneTestConnection</tt>.
E.g.:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
panelContent">
<pre>$ mvn test -DcayenneTestConnection=derby</pre>
</div></div>

<h2><a name="RunningUnitTests-Lookattestresults"></a>Look at test results</h2>

<p>To look for failed tests, grep the output files.</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
panelContent">
<pre>$ grep FAIL framework/cayenne-jdk1.5-unpublished/target/surefire-reports/*.txt</pre>
</div></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/CAYSITE/Running+Unit+Tests">View
Online</a>
       |
       <a href="http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=60455&revisedVersion=25&originalVersion=24">View
Change</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message