|
As described in the Problem Reporting guide to reproduce
problems we need something in a neutral format. Here we define our accepted format for
JDO usage.
-
Create a package "org.datanucleus.test"
-
Add the basic persistable classes to this package. Please give these simple names like
A, B, C. Calling your classes names that mean something in your language will likely
mean nothing to us and so we will not have much patience trying to understand them,
hence using A, B, C etc makes more sense.
-
If using XML metadata, add the
package.jdo
to this package
-
If your test case is to demonstrate a problem with DataNucleus SchemaTool or at
runtime then you need to provide a
datanucleus.properties
file containing the
PMF properties required for the datastore to demonstrate the issue. Alternatively
provide a
persistence.xml
defining the datastore connection.
-
If your test case is to demonstrate a problem with DataNucleus at runtime (NOT the
DataNucleus Enhancer/DataNucleus SchemaTool) you then
need to
-
Write a
Main.java
and add to this package org.datanucleus.test - see
below for an example.
-
Mark in the
Main.java
which line causes the error.
-
Provide information about which version of which datastore should be used.
-
Your test case should be runnable with JDK 1.5
-
Your test case should impose no additional external dependencies.
-
Do not
add lines for "System.out". Instead use NucleusLogger messages. This means that
the messages appear in the log next to the DataNucleus logged messages. System.out is as
much use as a chocolate teapot in the debugging process
-
Your test case should have at most 4 or 5 classes. Anything more than this is unlikely to
get our attention without a prior Donation.
We do not have the time to analyse your application. Of course if you donate then we can
look at it.
-
A testcase SHOULD NOT INCLUDE jar files, build files, log4j.properties files or any
other such environment specific stuff. A testcase should be the order of 5Kb NOT 5Mb.
Any testcase submitted with such unnecessary contents will be rejected.
This testcase
format is the simplest possible and the least users should do is abide by the simplicity
and just provide what is needed
The above can then be put in a
zip
file and attached to the JIRA issue or Forum thread.
The zip file should look like this
. If it doesnt then you will likely be asked to repackage it.
Using something other than zip (or gz) is non-portable so not accepted.
datanucleus.properties
org/
org/datanucleus/
org/datanucleus/test/
org/datanucleus/test/MyClass1.java
org/datanucleus/test/MyClass2.java
org/datanucleus/test/Main.java
org/datanucleus/test/package.jdo
As an alternative to the above, and where you are familiar with JUnit and are willing to
look at the existing DataNucleus unit tests in SVN, then please create a JUnit test case that
utilises our existing suite of sample data etc.
If you provide a testcase in this way your testcase should be a patch against current SVN trunk.
Again, this should be attached to the JIRA issue to which it relates. To add a JUnit testcase,
please follow the
new unit test guide
By attaching a test case to DataNucleus JIRA, you hereby agree that it is contribution
to DataNucleus under the terms of the
Apache 2.0 License.
A template
datanucleus.properties
is shown below. Use this as a framework
javax.jdo.PersistenceManagerFactoryClass=org.datanucleus.jdo.JDOPersistenceManagerFactory
javax.jdo.option.ConnectionDriverName=com.mysql.jdbc.Driver
javax.jdo.option.ConnectionURL=jdbc:mysql://localhost/datanucleus
javax.jdo.option.ConnectionUserName=mysql
javax.jdo.option.ConnectionPassword=
datanucleus.autoCreateSchema=true
datanucleus.autoCreateColumns=true
A template
Main.java
for JDO is shown below. Use this as a framework
package org.datanucleus.test;
import java.util.Collection;
import java.util.List;
import java.util.Properties;
import java.util.Iterator;
import javax.jdo.JDOHelper;
import javax.jdo.PersistenceManager;
import javax.jdo.PersistenceManagerFactory;
import javax.jdo.Extent;
import javax.jdo.Query;
import javax.jdo.Transaction;
import org.datanucleus.util.NucleusLogger;
public class Main
{
static public void main(String[] args)
{
PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory("datanucleus.properties");
// Persist some objects
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try
{
tx.begin();
... (replace this with your code to persist your objects required to reproduce the problem)
MyClass myobj = new MyClass("name");
pm.makePersistent(myobj);
tx.commit();
}
catch (Exception e)
{
NucleusLogger.GENERAL.info(">> Exception thrown persisting objects : " + e.getMessage());
}
finally
{
if (tx.isActive())
{
tx.rollback();
}
}
// Perform some operation
tx = pm.currentTransaction();
try
{
tx.begin();
... (add your code here)
tx.commit();
}
catch (Exception e)
{
NucleusLogger.GENERAL.info(">> Exception thrown retrieving objects : " + e.getMessage());
}
finally
{
if (tx.isActive())
{
tx.rollback();
}
}
pm.close();
}
}
|
|