castor-1.3.2.orig/0000755000000000000000000000000011544322215010634 5ustar castor-1.3.2.orig/src/0000755000000000000000000000000011656245645011442 5ustar castor-1.3.2.orig/src/howto/0000755000000000000000000000000011656245645012602 5ustar castor-1.3.2.orig/src/howto/how-to-use-jakarta-dbcp.xml0000644000000000000000000000461111544322135017640 0ustar How to use Jakarta's DBCP for connection pooling General information about using Jakarta's DBCP for connection pooling Final How to use Jakarta's DBCP for connection pooling

This HOW-TO provide users with instructions on hot to configure Castor JDO so that Apache Jakarta's DBCP package is used as a connection pool.

Anyone who wants to use DBCP as connection pool mechanism with Castor JDO.

Below are defined the steps to configure Castor JDO to use DBCP's BasicDataSource for connection pooling.

To use a DBCP BasicDataSource with Castor JDO, please provide the following <data-source> entry in the jdo-conf.xml file.

]]>

Above example makes use of the mySQL JDBC driver to establish a connection pool to a mySQL instance named 'test' running on the same machine as Castor itself. The pool initially holds 10 connections, but is configured to allow a maximum of 40 active connections at the same time.

castor-1.3.2.orig/src/howto/how-to-run-jdo-test-suite.xml0000644000000000000000000003603211544322136020210 0ustar How to run Castor JDO's test suite General information about running Castor JDO's test suite Final How to run Castor JDO's test suite

At the time of this writing Castor JDO has 3 kinds of test suites:

This document provides general information about running Castor JDO's test suite (CTF).

Anyone who wants to run the CTF test suite. This document outlines the basic steps to get people unfamiliar with this area started.

Anybody wishing to run the CTF test suite should have access to the source code of Castor. This can be obtained in one of the following ways:

At the moment we are in the middle of replacing the old CTF with a new one. While the old CTF still is our reference for refactorings of Castor does the new CTF contain some tests which could not be added to the old one due to its limitations. On the other hand are not all tests ported to the new CTF yet.

In the next sections we describe how to setup the environment to execute both CTF versions. While both versions of CTF are designed to be executed against every supported database engine, we will describe things with regard to mysql. Having said that there are only scripts for mysql at the new CTF at the moment. At a later step of the CTF refactoring we will add scripts for other databases as well. In addition we intend to allow its execution with an embedded derby database out of the box, but this have not been implemented yet.

For those who might be wondering about the numbering of tests, the numbers of the old tests are just random. The numbers of the new tests are the jira issue numbers.

To execute tests against mysql database you probably need access to a mysql server. To create a database for CTF, you have to execute the following commands on mysql consol.

# create database test; # grant all on test.* at "localhost" to "test" identified by "test"; # use test; # source [path-to-script];

If the server is not installed on your local maschine (the one you execute the tests on) you have to replace "localhost" with the IP of the maschine the tests get executed on. The script to execute can be found in "cpactf/src/old/ddl/" directory. For mysql it's "mysql.sql". If you like to use a different name for the database or use other user credential you can adjust them at "cpactf/src/old/resources/jdo/mysql.xml".

As we do not include JDBC drivers for every database with Castor you also have to add the driver you like to use to your classpath to execute the tests. The easiest way is to copy the driver to "lib/" directory as all jar's contained therein are added automatically. Another option is to modify "bin/test.sh" or "bin/test.bat" script depended on your operating system.

For mysql we still use "mysql-connector-java-3.1.13-bin", also for mysql server of version 5. This version has proven to be stable. While other versions of mysql connector may also work, some of them have bugs from our experience.

As already explained you will find JDO configurations for every supported database in "cpactf/src/old/resources/jdo". The JDO configurations are named mysql.xml, oracle.xml etc. In the same directory you will also find main mapping file "mapping.xml" that includes all other mappings which are located in the "cpactf/src/old/resources/ctf/jdo/..." directories. There is one more important file for the old tests "cpactf/src/old/resources/tests.xml", it is the main config file which defines which test should be executed against which database engine. As mentioned previously not every test works with every database engine as some missing some features or castor does not support everything of every engine.

From a command line (e.g a shell), please execute the following commands to run the whole test suite against mysql (where <castor-root> points to the directory where you installed the Castor sources:

cd <castor-root>/bin build clean build tests test castor.mysql

To execute just one of the many tests of the complete test suite, please change this to:

cd <castor-root>/bin build clean build tests test castor.mysql.TC30

NOTE: You have to execute "build clean" and "build tests" again if you have changed anything within eclipse (e.g. a configuration file or a class).

Now, let's see how we can run these old CPACTF tests through eclipse.

As some features are not supported by all database engines (e.g. sequence keygenerator) or a test have not been verified against a database, only a subset of the following tests will be executed if you run CTF.

To execute tests against mysql database you probably need access to a mysql server. To create a database for CTF, you have to execute the following commands on mysql consol.

# create database cpactf; # grant all on cpactf.* at "localhost" to "test" identified by "test"; # use cpactf; # source <path-to-script>;

If the server is not installed on your local maschine (the one you execute the tests on) you have to replace "localhost" with the IP of the maschine the tests get executed on. For mysql execute every "mysql.sql" script found in subdirectories of "cpactf/src/test/ddl/" directory. If you like to use a different name for the database or use other user credential you can adjust them at "cpactf/src/test/resources/cpactf-conf.xml".

As we do not include JDBC drivers for every database with Castor you also have to add the driver you like to use to your classpath to execute the tests. The easiest way is to copy the driver to "lib/" directory as all jar's contained therein are added automatically. Another option is to modify "bin/test.sh" or "bin/test.bat" script depended on your operating system.

For mysql we still use "mysql-connector-java-3.1.13-bin", also for mysql server of version 5. This version has proven to be stable. While other versions of mysql connector may also work, some of them have bugs from our experience.

Execution of the new test suite from within eclipse against mysql is very simple.

In in the configuration file "cpactf-conf.xml" mysql is configuerd as default database. To execute tests against another database engine or to force execution of tests that have been excluded you can pass VM parameter to the test framework. VM Arguments can also be specified in eclipse.

The following VM parameters are supported by CTF.

config
Path to an alternate configuration file.
database
Name of the database configuration.
transaction
Name of the transaction manager configuration.
force
Force execution of excluded tests (true/false).

For those who face the following problem in eclipse while executing the tests

#An unexpected error has been detected by HotSpot Virtual Machine: # #EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x7c918fea, pid=2460, tid=3712 # #Java VM: Java HotSpot(TM) Client VM (1.5.0-b64 mixed mode) #Problematic frame: #C [ntdll.dll+0x18fea] # #An error report file with more information is saved as hs_err_pid2460.log # # If you would like to submit a bug report, please visit: # http://java.sun.com/webapps/bugreport/crash.jsp #

It is a problem with memory configured for eclipse. It can be changed in eclipse.ini file which can be found in installation directory of Eclipse. By default it is -Xmx256m, just increase it and problem go away.

castor-1.3.2.orig/src/howto/how-to-map-enums.xml0000644000000000000000000000773011544322136016433 0ustar How to map typesafe enumerations with Castor General information about using typesafe enumerations with Castor Final How to map typesafe enumerations with Castor

Anyone who wants to persist object that refer to a typesafe enumeration.

This document addresses the basics and shows an example how to map an object that has a typesafe enumeration property.

Enumerations are a common method for ensuring data integrity, both in software and in relational databases. As a platform for linking the two, we added support for persisting class fields whose type is a Java typesafe enumeration to Castor JDO.

To use this new feature your typesafe enumeration should follow the enum pattern commonly used and provide a static valueOf(String) method. An enum of different kinds of computer equipment may look like:

public class KindEnum { private static final Map KINDS = new HashMap(); public static final KindEnum MOUSE = new KindEnum("Mouse"); public static final KindEnum KEYBOARD = new KindEnum("Keyboard"); public static final KindEnum COMPUTER = new KindEnum("Computer"); public static final KindEnum PRINTER = new KindEnum("Printer"); public static final KindEnum MONITOR = new KindEnum("Monitor"); private final String _kind; private KindEnum(final String kind) { _kind = kind; KINDS.put(kind, this); } public static KindEnum valueOf(final String kind) { return (KindEnum) KINDS.get(kind); } public String toString() { return _kind; } }

At your Product class you may want to have a property that tells you what kind of computer equipment a product is of.

public class Product { private int _id; private String _name; private KindEnum _kind; public Product() { } public int getId() { return _id; } public void setId(int id) { _id = id; } public String getName() { return _name; } public void setName(String name) { _name = name; } public KindEnum getKind() { return _kind; } public void setKind(KindEnum kind) { _kind = kind; } }

Your mapping for the Product class should be:

<class name="Product" identity="id"> <description>Product with kind enum</description> <map-to table="enum_prod"/> <field name="id" type="integer"> <sql name="id" type="integer"/> </field> <field name="name" type="string"> <sql name="name" type="char"/> </field> <field name="kind" type="KindEnum"> <sql name="kind" type="char"/> </field> </class>
castor-1.3.2.orig/src/howto/how-to-use-castor-with-distributed-transactions.xml0000644000000000000000000001344411544322135024613 0ustar How to use Castor with(in) distributed J2EE transactions General information about using Castor with(in) distributed J2EE transactions Final How to use Castor with(in) distributed J2EE transactions

J2EE applications depend on the J2EE container (hosting Servlet, EJB, etc) to configure a database connection (as well as other resource managers) and use JNDI to look it up. This model allows the application deployer to configure the database properties from a central place, and gives the J2EE container the ability to manage distributed transactions across multiple data sources.

This HOW-TO shows how to seamlessly use Castor JDO in such a managed environment, and how to make Castor participate in a distributed transaction.

Anyone who wants to use Castor JDO with(in) distributed J2EE transactions.

The following sections highlight the steps necessary to use Castor JDO seamlessly in such a (managed) environment, and how to make Castor participate in a distributed transaction.

The following code fragment shows how to use JNDI to lookup a database and how to use a JTA UserTransaction instance to manage the J2EE (aka distributed) transaction:

// Lookup databse in JNDI Context ctx = new InitialContext(); Database db = (Database) ctx.lookup( "java:comp/env/jdo/mydb" ); // Begin a transaction UserTransaction ut = (UserTransaction) ctx.lookup( "java:comp/UserTransaction" ); ut.begin(); // Do something . . . // Commit the transaction, close database ut.commit(); db.close();

If the transaction is managed by the container, a common case with EJB beans and in particular entity beans, there is no need to begin/commit the transaction explicitly. Instead the application server takes care of enlisting the database used by Castor JDO to insert domain entities into a database in the ongoing transaction and commiting/rolling back at the relevant time.

The following code snippet relies on the container to manage the transaction.

InitialContext ctx; UserTransaction ut; Database db; // Lookup databse in JNDI ctx = new InitialContext(); db = (Database) ctx.lookup( "java:comp/env/jdo/mydb" ); // Do something . . . // Close the database db.close();

As transaction enregistration is dealt with at the J2EE container, it is not necessary anymore to obtain a UserTransaction and start/commit the transaction manually.

Instead of constructing required resources directly, a typical J2EE application uses the JNDI API to look up resources from centrally managed place such as a naming and directory service. In such an environment, Castor JDO takes on the role of a managed resource as well. It follows that, instead of constructing a org.exolab.castor.jdo.JDOManager directly, a typical J2EE application should use JNDI to look it up.

We thus recommend enlisting the JDOManager object under the java:comp/env/jdo namespace, compatible with the convention for listing JDBC resources.

castor-1.3.2.orig/src/howto/how-to-run-jdo-performance-tests.xml0000644000000000000000000001057511544322136021547 0ustar How to run Castor JDO's performance tests General information about running Castor JDO's performance tests Final How to run Castor JDO's performance tests

At the time of this writing Castor JDO has 3 kinds of test suites:

This document provides general information about running Castor JDO's performance tests.

See: How to setup Castor project in eclipse

To execute performance tests against mysql database you probably need access to a mysql server. To create a database for PTF, you have to execute the following commands on mysql consol.

# create database cpaptf; # grant all on cpaptf.* at "localhost" to "test" identified by "test"; # use cpaptf; # source [path-to-script];

If the server is not installed on your local maschine (the one you execute the tests on) you have to replace "localhost" with the IP of the maschine the tests get executed on. The script to execute is "cpaptf/src/test/ddl/mysql.sql".

As we do not include JDBC drivers for every database with Castor you also have to add the driver you like to use to your classpath to execute the tests. The easiest way is to copy the driver to "lib/" directory as all jar's contained therein are added automatically.

For mysql we still use "mysql-connector-java-3.1.13-bin", also for mysql server of version 5. This version has proven to be stable. While other versions of mysql connector may also work, some of them have bugs from our experience.

Execution of the performance test suite from within eclipse is very simple.

By defeult the test uses 2000 service objects that get created, loaded with various configurations and deleted afterwords. Obviously this will take quite some time. Please be patient for normal termination of the tests as you will need to clean test tables by hand otherwise. To execute tests with a different number of objects you can adjust "FACTOR" constant in "TestCreate.java". For example, if you set "Factor" to 1.0 the tests will be executed with 10000 service objects. When using more test objects be aware that you may need to increase heap size of the virtual maschine for the test to finish.

By default you won't see any output of results on the consol as logging level of log4j is set to "warn" by default. But if you change log level of "org.castor.cpaptf" package to "info" you will see detailed execution times for every test on the consol. Be aware that there are quite some log4j.xml configurations in the whole Castor project at the moment of which the one first one on classpath will be used.

If you like to review some older test results you will find them under "cpaptf/src/site/resources/results/" but they depend heavy on the machine you are running the tests on.

castor-1.3.2.orig/src/howto/how-to-cascade-update.xml0000644000000000000000000001177211544322135017374 0ustar How to cascade update Describes the various possibilities Castor provides to cascade update Draft How to cascade update

When working with long transactions, you can cascade the db.update() operation, so that, for example, updating the root of a large object graph causes all connected entites to update as well (provided cascading update is enabled on the particular relationships, of course).

To enable cascading update on a relationship you simply set the cascading attribute of the <sql> field describing the relation to "update" (or "all"):

]]>

In case of bidirectional relationships, be aware that it matters on which end you enable cascading update. It is also possible to enable it on both ends.

Let's say we have the objects Author and Book and they are in a one-to-one relationship, with every Book having exactly one Author. The database looks like this:

Author
id name
1 "John Jackson"
Book
id title author_id
1 "My Life" 1

Now let's change the book's title. Note that we never directly load the book and that the change happens outside of any transaction:

Afterwards, the database looks like this:

Author
id name
1 "John Jackson"
Book
id title author_id
1 "My Fantastic Life" 1
castor-1.3.2.orig/src/howto/how-to-create-custom-cache.xml0000644000000000000000000001736111544322136020346 0ustar How to create a custom cache provider General information about creating a custom cache provider Final How to create a custom cache provider

In the context of a relational data-binding tool such as Castor JDO, caches enhance application performance by reducing the number of read operations against the persistence storage, by storing and reusing the last read or committed values of the object.

Castor provides a set of pre-built cache providers, offering a variety of different cache algorithms. Nevertheless, special needs might require the application developer to implement a custom cache algorithm.

Castor facilitates such need by making available a standardized process of how to integrate a custom cache provider.

Anyone who wants to develop his own custom cache provider and integrate it with Castor JDO.

The main component of Castor's cache system is the interface Cache, which declares required functionality of a performance cache provider. Existing (and future) cache implementations have to implement this interface, which is closely modelled after java.util.Map.

Below are defined the steps to build a custom cache provider and register it with Castor JDO.

Castor (as of release 0.9.6) allows for addition of user-defined cache provider implementations.

By default, performance caches are registered with Castor JDO through it's main configuratoin file castor.properties. This file includes a section as follows:

# # Cache implementations # org.castor.cache.Factories=\ org.castor.cache.simple.NoCacheFactory,\ org.castor.cache.simple.TimeLimitedFactory,\ org.castor.cache.simple.CountLimitedFactory,\ org.castor.cache.simple.UnlimitedFactory,\ org.castor.cache.distributed.FKCacheFactory,\ org.castor.cache.distributed.JcsCacheFactory,\ org.castor.cache.distributed.JCacheFactory,\ org.castor.cache.distributed.CoherenceCacheFactory,\ org.castor.cache.distributed.OsCacheFactory,\ org.castor.cache.hashbelt.FIFOHashbeltFactory,\ org.castor.cache.hashbelt.LRUHashbeltFactory

To add your own performance cache provider, please append the fully-qualified class name to this list as shown here:

# # Cache implementations # org.castor.cache.Factories=\ org.castor.cache.simple.NoCacheFactory,\ org.castor.cache.simple.TimeLimitedFactory,\ org.castor.cache.simple.CountLimitedFactory,\ org.castor.cache.simple.UnlimitedFactory,\ org.castor.cache.distributed.FKCacheFactory,\ org.castor.cache.distributed.JcsCacheFactory,\ org.castor.cache.distributed.JCacheFactory,\ org.castor.cache.distributed.CoherenceCacheFactory,\ org.castor.cache.distributed.OsCacheFactory,\ org.castor.cache.hashbelt.FIFOHashbeltFactory,\ org.castor.cache.hashbelt.LRUHashbeltFactory,\ org.whatever.somewhere.nevermind.CustomCache

You will have to provide implementations of the interfaces Cache and CacheFactory for your new cache provider.

For this, please add an implementation of CacheFactory and make sure that you provide valid values for the two properties name and className.

To assist users in this task, a AbstractCacheFactory class has been supplied, which users should derive their custom CacheFactory instances from, if they wish so. Please consult existing CacheFactory implementations such as TimeLimitedFactory} or CountLimitedFactory for code samples.

/** * My own cache factory implementation */ public class CustomCacheFactory extends AbstractCacheFactory { /** * The name of the factory */ private static final String NAME = "custom"; /** * Full class name of the underlying cache implementation. */ private static final String CLASS_NAME = "my.company.project.CustomCache"; /** * Returns the short alias for this factory instance. * @return The short alias name. */ public String getName() { return NAME; } /** * Returns the full class name of the underlying cache implementation. * @return The full cache class name. */ public String getCacheClassName() { return CLASS_NAME; } }

Please create an implementation of Cache.

To assist users in this task, a AbstractBaseCache class has been supplied, which users should derive their custom Cache instances from, if they wish so. Please consult existing Cache implementations such as TimeLimited} or CountLimited for complete code samples.

/** * My own cache implementation */ public class CustomCache extends AbstractBaseCache { ... }
castor-1.3.2.orig/src/howto/how-to-use-limit-clause.xml0000644000000000000000000001340111544322136017703 0ustar How to use a LIMIT clause with OQL General information about using a LIMIT clause with OQL Final How to use a LIMIT claue with OQL

Anyone who wants to execute an OQL statement and limit the result size.

The example given describes the addition of LIMIT/OFFEST clauses to an existing OQL statement.

You should have a valid class mapping for two Java classes Product and ProductGroup, similar to the following one:

package myapp; public class Product { private int _id; private String _name; private float _price; private ProductGroup _group; public int getId() { ... } public void setId( int anId ) { ... } public String getName() { ... } public void setName( String aName ) { ... } public float getPrice() { ... } public void setPrice( float aPrice ) { ... } public ProductGroup getProductGroup() { ... } public void setProductGroup( ProductGroup aProductGroup ) { ... } }

The following fragment shows the Java class declaration for the ProductGroup class:

public class ProductGroup { private int _id; private String _name; public int getId() { ... } public void setId( int id ) { ... } public String getName() { ... } public void setName( String name ) { ... } }

Here is how to proceed.

The following code fragment shows an OQL query to select the all ProductGroup instances.

OQLQuery query = db.getOQLQuery("select product from ProductGroup product"); query.bind(10); OQLResults results = query.execute();

The following code fragment shows the same OQL query as above, to this time the LIMIT keyword is added to select the first 10 ProductGroup instances only.

OQLQuery query = db.getOQLQuery("select product from ProductGroup product LIMIT $1"); query.bind(10); OQLResults results = query.execute();

Below is the same OQL query again, restricting the number of ProductGroup instances returned to 10, though this time it is specified that the ProductGroup instances 101 to 110 should be returned.

OQLQuery query = db.getOQLQuery("select product from ProductGroup as product LIMIT $1 OFFSET $2"); query.bind(10); query.bind(100); OQLResults results = query.execute();

The following RDBMS fully/partially support LIMIT/OFFSET clauses.

RDBMSLIMITOFFSET
postgreSQLYesYes
mySQLYesYes
Oracle 1) 2)YesYes
HSQLYesYes
MS SQLYes-
DB2Yes-

1) Caster has full support for LIMIT/OFFSET clauses for Oracle Releases 8.1.6 and later.

2) For the LIMIT/OFFSET clauses to work properly the OQL query is required to include an ORDER BY clause.

castor-1.3.2.orig/src/howto/how-to-setup-castor-project-in-eclipse.xml0000644000000000000000000000611111544322136022644 0ustar How to setup Castor project in eclipse Short decription of how to check out the latest Castor code from SVN into an eclipse project. Final How to setup Castor project in eclipse

Are you just interested in how Castor source looks like, want to report a bug or enhancement request or like to contribute to the project? The first step we suggest you to do is to setup a Castor project with eclipse IDE. As we use eclipse to work at Castor, there is everything in place to work with eclipse. While you are free to use other IDE's, you will need to configure things yourself with them.

If you have trouble with Subclipse behind a proxy server: In Windows development environment, open the file: C:\Documents and Settings\MyUserId\Application Data\Subversion\servers in text editor. Near the bottom of that file is a [global] section with http-proxy-host and http-proxy-port (user and password also) settings. Uncommented those lines, modified them for your proxy server and go back to the SVN Repository view in Eclipse. This should solve the problem.

castor-1.3.2.orig/src/howto/how-to-prepare-a-patch.xml0000644000000000000000000002053111544322136017474 0ustar How to prepare a patch General information about preparing a patch Final How to prepare a (unified) patch

A "patch" is the set of differences between two versions of the same file. Patches are used to send someone the exact changes that you have made to your version of a program or a document. They can then apply that patch to their version to merge the changes and bring their version up-to-date with your version.

As our example we use the contribution of a simple documentation patch for the Castor project. The principles apply to any project and to any type of file, e.g. *.xml, *.java, *.xsd, etc.

Anyone who wants to contribute to a project. This document addresses the basics, so as to get new people started.

Our example describes the use of command-line tools for a UNIX system. Other tools can be used, as long as they produce a "unified diff".

Contributers should have:

Here is how to proceed.

A "Patch" is the set of differences between two versions of the same file. A patch comprises one or more "diff" files. These diffs are produced by the program of the same name: diff.

Here is an example of a single diff for one of the Castor How-to pages, where we are suggesting a minor text change. Do not get frightened. These are just human-readable instructions to the "patch" program.

Index: contrib.xml =================================================================== RCS file: /home/projects/castor/src/doc/jdo-howto.xml,v retrieving revision 1.7 diff -u -r1.7 contrib.xml --- jdo-howto.xml 30 Apr 2002 07:44:52 -0000 1.7 +++ jdo-howto.xml 26 May 2002 04:08:23 -0000 @@ -208,7 +208,7 @@ to create a patch. (The commands are for Linux.) </p> - <s2 title="How to Establish your Local Repository"> + <s2 title="How to Establish your Local Working Copy"> <p> This will checkout the current copy of the master cvs repository and

That is a "unified diff" ... there a some lines of context on each side of the changes. This patch is basically saying "Change the text on line 208".

  • lines to be deleted are preceded with -
  • lines to be added are preceded with +
  • contextual lines with no leader remain the same

Let us now go though the process of preparing that patch. Go ahead and edit your local copy of the document at $CASTOR_HOME/src/doc/jdo-howto.xml.

Ensure that it is valid XML using your favourite XML editor or an external validating parser. Please do not leave it up to the poor committer to fix broken XML.

Run the 'build doc' target to be sure that links are not broken and that the new document is presented as you intend it to be.

If you are using the HEAD of SVN then ensure that your working copy is up-to-date. Of course, if you are using a previous public release version of Castor, then it is already up-to-date.

Prepare the diff file. SVN will contact the remote repository, ensure that your working copy is up-to-date, then compare your local copy with the master repository.

cd src/doc svn diff jdo-howto.xml > $TEMP/castor/patch/jdo-howto.xml.diff

Prepare a brief explanation of what your patch does. Get this ready in a text file before you go to Jira. See further hints about this in the "Description" section of the How-to Jira.

What revision of SVN did you patch against? Was it HEAD branch? Was it a nightly build? Was it a public release?

To contribute your patch to a specific project, use Jira - The Codehaus Issue Database. The procedure is explained in How to Contribute a Patch via Jira.

A patchfile can contain the differences to various individual documents. For example, the following command does that ...

cd src svn diff > $WORK/castor/patch/src.dir.diff

However, be careful not to go overboard with this technique. When producing multiple diffs in one patchfile, try to limit it to one particular topic, i.e when fixing the same broken external link in various pages, then it would be fine to produce a single diff. Consider the committer - they will find it hard to apply your patch if it also attempts to fix other things.

Ideally you will prepare your patches against a SVN repository. There are other ways to do this. They do create more work for the committers, however it may be the only way that you can do it. We would certainly rather receive your patch however it comes. As a matter of fact, we would politely ask you first to send us a unified patch.

You could get the source document via the web interface to SVN. Here are the steps ...

  • get the relevant XML file via FishEye
  • save the file to your local disk: ./jdo-howto.xml.orig
  • create a copy of the file: ./jdo-howto.xml
  • make your modifications and validate the XML
  • use the "diff" command (i.e. not 'cvs diff') as follows
  • diff -u jdo-howto.xml.orig jdo-howto.xml > $WORK/castor/patch/jdo-howto.xml.diff
  • proceed as for Step 5.
castor-1.3.2.orig/src/howto/how-to-use-castor-in-a-j2ee-cluster.xml0000644000000000000000000000753311544322135021742 0ustar How to use Castor in a J2EE cluster General information about using Castor in a J2EE cluster Final How to use Castor in a J2EE cluster

With release 0.9.9, several cache providers have been added that are distributed caches per se or can be configured to operate in such a mode. This effectively allows Castor JDO to be used in a clustered J2EE (multi-JVM) environment, where Castor JDO runs on each of the cluster instances, and where cache state is automatically snychronized between these instances.

In such an environment, Castor JDO will make use of the underlying cache provider to replicate/distribute the content of a specific cache between the various JDOManager instances. Through the distribution mechanism of the cache provider, a client of a Castor JDO instance on one JVM will see any updates made to domain objects performed against any other JVM/JDO instance.

Anyone who wants to use Castor JDO in a J2EE cluster.

The example given describes the use of the Coherence cache provider to enable distributed caching.

You should have a valid class mapping for a Java class, similar to the following one:

<mapping> <class name="com.xyz.MyOtherObject" identity="id"> <field name="id" type="integer"> ... </field> <field name="description" type="string"> ... </field> </class> </mapping>

Here is how to proceed.

Add a <cache-type> element as shown below, specifying the cache provider to use in the 'type' attribute.

<mapping> <class name="com.xyz.MyOtherObject" identity="id"> <cache-type type="coherence"/> <field name="id" type="integer"> ... </field> <field name="description" type="string"> ... </field> </class> </mapping>

This instructs Castor JDO to use the 'coherence' cache provider for objects of type com.xyz.MyOtherObject. It is the cache provider that is responsible to distribute any changes to the cache state to all other Castor JDO instances within the same cluster.

Add the Coherence JARs to the class path of your e.g. web application by putting the JARs into the WEB-INF/lib folder of your web application.

castor-1.3.2.orig/src/howto/how-to-connection-proxies.xml0000644000000000000000000000654611544322135020362 0ustar How to use Castor JDO's connection proxies General information about using Castor JDO's connection proxies. Final How to use Castor JDO's connection proxies

Castor JDO uses the Jakarta Common's Logging package for output information relevant to the execution of a specific JDO operations to a log file. The information output historically included the SQL statements used by Castor to execute the various persistence operations such as loading or updating domain entities. Unfortunately, the SQL statements logged did not include any information about the parameters being bound to the prepared statements immediately before execution, and hence made it very hard for users of Castor JDO to analyze these in teh case of an issue/problem

To improve this situation, proxy classes for the java.sql.Connection and java.sql.PreparedStatement interfaces have been added, to allow for complete and better JDBC statements to be output to the log files. As this might impose a performance penalty at run-time, we have allowed for this to be turned off completely through the standard Castor property file.

A new property has been added to the Castor property file (castor.properties) to allow configuration of this feature.

Anyone who wants to use the new JDBC proxy classes with Castor JDO selectively, i.e. enabling and disabling their use.

The example given describes how to turn the use of the proxy classes on/off.

You should have a valid castor.properties file as part of your application.

Here is how to proceed.

To enable the use of the JDBC proxy classes described above, please add the following section to your castor.properties file.

# True if JDBC proxy classes should be used to enable more detailed logging output of SQL # statements; false otherwise (logging of SQL statements will be turned off completely). # org.exolab.castor.persist.useProxy=true

This instructs Castor JDO to use the JDBC proxy classes and to output full information about the SQL statements used at run-time. When disabled, no logging of SQL statements will occur al all.

castor-1.3.2.orig/src/howto/how-to-run-jdo-unit-tests.xml0000644000000000000000000000332211544322136020215 0ustar How to run Castor JDO's database independend unit tests General information about running Castor JDO's database independend unit tests Final How to run Castor JDO's database independend unit tests

At the time of this writing Castor JDO has 3 kinds of test suites:

This document provides general information about running Castor JDO's database independend unit tests.

See: How to setup Castor project in eclipse

To execute tests in eclipse, go and right click on "cpa/src/test/java" source folder and select "Run As -> JUnit Test".

castor-1.3.2.orig/src/howto/how-to-use-a-cache.xml0000644000000000000000000000711211544322135016575 0ustar How to use a (performance) cache with Castor General information about using performance caches with Castor Final How to use a (performance) cache with Castor

Anyone who wants to enable caching for classes already mapped with Castor JDO.

This document addresses the basics to get people familiar with the basic concepts and discusses some implementation details.

The example given describes the addition of a <cache-type> element to an existing class mapping.

You should have a valid class mapping for a Java class, similar to the following one:

<mapping> <class name="com.xyz.MyOtherObject" identity="id"> <field name="id" type="integer"> ... </field> <field name="description" type="string"> ... </field> </class> </mapping>

Here is how to proceed.

Add a <cache-type> element as shown below, specifying the cache provider to use in the 'type' attribute.

<mapping> <class name="com.xyz.MyOtherObject" identity="id"> <cache-type type="time-limited"/> <field name="id" type="integer"> ... </field> <field name="description" type="string"> ... </field> </class> </mapping>

This, for example, defines the 'time-limited' cache provider to be used for the com.xyz.MyOtherObject. This cache provider applies internally a time-limited least-recently-used algorithm for com.xyz.MyObject instances

.
castor-1.3.2.orig/src/howto/how-to-use-cascading-operations.xml0000644000000000000000000001605411544322135021416 0ustar How to use cascading operations Describes the kind of cascading operations supported by Castor and provides examples of their use Draft How to use cascading operations

Up to Castor 1.3.1, users of Castor JDO have been able to automatically store/update or delete objects across relations by issueing ...

Database.setAutostore(true)

before going starting a transaction. This feature was useful, indeed, but on a second look its limitation (global definition across all entities) became obvious, especially on big projects. You might want to have cascading operations activated selectively (activated for one object, but not for another). Or even more tricky, you might like to automatically track changes across one relation from a starting object, but but not across another relation from the very same object.

As of Castor 1.3.2, a new cascading attribute has been introduced to the <sql> tag of the JDO mapping file.

This and all other cascading documents address people familiar with the basic concepts of mapping domain entities to database tables and defining relations between objects (on database level as well as on object level). But in particular, this document applies to the following user groups:

  1. Everyone who wants to cascade operations across (any type of) object relation(s).

  2. Everyone who now uses Database.setAutoStore(boolean) to have persistence operations cascaded across relations.

Especially the second user group should change their approach towards using cascading operations, and switch to using the new cascading attribute. As of Castor 1.3.2, the current Database.setAutoStore(boolean) methods will be deprecated, and in the long run, this operations will be removed from the JDO interfaces.

You should have a valid mapping file, containing at least two objects, being in relation with each other. For the remainder of this document, we'll be using the following example mapping file as a starting point.

<mapping> <class name="org.castor.cascading.Author" identity="id"> <cache-type type="none" /> <map-to table="OneToOne_Author" /> <field name="id" type="integer"> <sql name="id" type="integer" /> </field> <field name="timestamp" type="long"> <sql name="time_stamp" type="numeric" /> </field> <field name="name" type="string"> <sql name="name" type="char" /> </field> </class> <class name="org.castor.cascading.Book" identity="id"> <cache-type type="none" /> <map-to table="OneToOne_Book" /> <field name="id" type="integer"> <sql name="id" type="integer" /> </field> <field name="timestamp" type="long"> <sql name="time_stamp" type="numeric" /> </field> <field name="name" type="string"> <sql name="name" type="char" /> </field> <field name="author" type="org.castor.cascading.Author"> <sql name="author_id"/> </field> </class> </mapping>

In order to activate cascading for create operations for the author relation defined in the mapping file above, you have to add the following attribute to the field mapping of the author property:

<class name="org.castor.cascading.one_to_one.Book" identity="id"> <cache-type type="none" /> ... <field name="author" type="org.castor.cascading.one_to_one.Author"> <sql name="author_id" cascading="create"/> </field> </class>

Remember that the code above adding a cascading attribute with a value of create is only an example. You can define any combination of cascading attributes, delimiting those values by spaces, as shown in the following example:

<field name="author" type="org.castor.cascading.one_to_one.Author"> <sql name="author_id" cascading="create update"/> </field>

In order to achieve an optimal granulation of activating and de-activating functionality, there are 5 possible values, out of which 3 can be activated separately or in any combination.

In general, what you have to keep in mind is that some cascading types do not only affect the the (coincidentally) identically named database operation, but also other persistence operations. For more details please read the following references carefully.

If no cascading attribute is defined, its default value will be none.

castor-1.3.2.orig/src/howto/how-to-cascade-creation.xml0000644000000000000000000004646411544322135017724 0ustar How to cascade creation Describes the various possibilities Castor provides to cascade object creation Draft How to cascade object creation

Cascading creation allows you to transfer some of the responsibilities of creating objects to Castor JDO. To be more precise: if you enable cascading creation on a relation between two classes, all objects on one end of that relation that have not yet been created will be created when the other end gets persisted. This saves you from manually creating every single object, which is especially useful when dealing with large object graphs that have 1:M (one to many) relations or many objects in a single relationship.

To enable cascading creation on a relation, you simply set the cascading attribute of the <sql> field describing the relation to "create" (or "all"):

In other words, the field mapping for the Java property book ...

]]>

becomes

]]>

In case of bidirectional relations, it does matters on which end you enable cascading creation. It is also possible to enable it on both ends.

The most intuitive case is when you explicitly call db.create() on an object that has cascading creation enabled on one or more of his relations. If the objects in those relationships have not yet been created, they will be as part of the create() execution.

Here is a simple example, where the objects Author and Book are in a one-to-one relation (i.e. every Book has exactly one Author):

Once the commit operation has successfully completed, both the Author and the Book instance will have been persisted to your data store. To highlight this, lets's have a look at the corresponding database tables before and after the execution of above code fragment.

Before

Author
id name
(empty table)

Book
id title author_id
(empty table)

After

Author
id name
1 "John Jackson"

Book
id title author_id
1 "My Life" 1

Cascading creation also works implicitly: any objects that are on the receiving end of a cascaded relation will be created upon transaction commit, provided they do not exist yet and that the object on the primary end of that relation does. In other words: if you modify a relation property of a loaded object, any new objects that now need to be created will be created.

To demonstrate, let's continue the example from the previous section. We, again, have a Book and an Author, in a one-to-one relation, both already persisted. If we now change the book's author to someone new, any object that is not yet in the database will be persisted automatically. Just call db.commit() after setting the new author, and the new author will be persisted as well.

In terms of unit test assertions, the current state of the author and book instances can be expressed as follows:

db.begin(); Book book = db.load(Book.class, 1); assertNotNull(book); assertEquals(1, book.getId()); Author author = book.getAuthor(); assertNotNull(author); assertEquals(2, book.getId()); db.commit();

As above, let's have a look at the corresponding database tables for the entities Author and Book:

Before

Author
id name
1 "John Jackson"

Book
id title author_id
1 "My Life" 1

After

Author
id name
1 "John Jackson"
2 "Bruce Willis"

Book
id title author_id
1 "My Life" 2

Please note that we now have two authors stored, and that the book with an id value of '1' now has a foreign key relationship to the author with the id value '2'.

The real benefit of using cascading for object creation shows when dealing with 1:M relations, usually expressed through Java collections in your entity classes.

For the remainder of this secction, we will use the Java classes Department and Employee, which have a 1:M relationship (in other words, every department has one or more employees). On the Java side, this is expressed as the Department having a collection of Employee objects in form of a Java collection. In the database, this will obviously be the other way around, with the emp table referencing the dept table. Every example in this section will use the same database state as a starting point, as shown here:

dept
id name
23 "Accounting"
emp
id name dept_id
1 "John" 23
2 "Paul" 23
3 "Ringo" 23

Example 1: Adding objects

db.begin(); Employee employee = new Employee(); employee.setId(4); employee.setName("George"); Department department = db.load(Department.class, 23); department.getEmployees().add(employee); db.commit();

After

dept
id name
23 "Accounting"
emp
id name dept_id
1 "John" 23
2 "Paul" 23
3 "Ringo" 23
4 "George" 23

Example 2: Removing objects

db.begin(); Department department = db.load(Department.class, 23); department.getEmployees().remove(2); db.commit();

After

dept
id name
23 "Accounting"
emp
id name dept_id
1 "John" 23
2 "Paul" 23
3 "Ringo" NULL

Note: this of course only works if you allow the employee's foreign key dept_id to be NULL or, alternatively, also delete the Employee when you remove the relationship (either by manually calling db.remove() or TODO)

Example 3: Adding & removing objects

Database after:

dept
id name
23 "Accounting"
emp
id name dept_id
1 "John" NULL
2 "Paul" NULL
3 "Ringo" NULL
4 "George" 23
5 "Joe" 23
6 "Jack" 23

The note to example 2 also applies here.

castor-1.3.2.orig/src/howto/how-to-use-castor-with-j2ee-transactions.xml0000644000000000000000000000303311544322136023110 0ustar How to use Castor JDO in a J2EE environment with global (XA) transactions General information about using Castor JDO in a J2EE environment with global (XA) transactions Final How to use Castor JDO in a J2EE environment with global (XA) transactions

Anyone who wants to execute ...

The example given describes ...

You should have ...

Here is how to proceed.

...

...

castor-1.3.2.orig/src/howto/how-to-submit-a-bug.xml0000644000000000000000000002160511544322136017022 0ustar Submitting a bug report General information about submitting a bug report Final Submitting a bug report

Most of the traffic on the Castor Users mailing list is about people asking for help on various features of Castor (whether JDO or XML). Whilst there is nothing wrong about asking questions and looking for help if you are stuck, it seems that there is room to improve the structure of this 'conversation'.

If you have a look at some of these threads (e.g. at the searchable mailing list archive), it's quite easy to see that most of the time ...

  1. An initial question is posted.

  2. An initial reply is posted with some follow-up questions, e.g. request for code fragments, mapping files, etc.

  3. One or more code fragments, mapping files, etc. are being posted.

  4. etc.

This document will establish guidelines with regards to step 3) above.

This document provides step-by-step instructions on how to submit a problem report (when being asked to do so). It does so by walking you through a fictive problem and its resulting bug report, and providing instructions based upon this scenario.

Per definition, any problem report submitted (in other words, most likely attached to a bug report at http://jira.codehaus.org/browse/CASTOR) by the means of a patch has to include the following artefacts:

  • A JUnit test case that 'showcases' your problem.
  • Castor JDO configuration file.
  • Castor JDO mapping file.
  • One or more 'entity' classes required to run your test case.
  • A SQL schema file (to help in the creation of required tables).
  • A README file (with any additional information/instructions required to understand /run your test case.

Note: Whilst we can and will not impose these guidelines in their strictest sense, I think that the use of technologies such as JUnit will simplify problem resolution and as a result lead to shorter turn-around times. Which is ultimately where you, the user, gains..

To facilitate creation of a fully featured patch as discussed above, we have provided you with an already existing bug template at 'src/bugs/jdo/template'.

Note:Please note that this directory is distributed only as part of the source archive(s).

This directory holds all artefacts mentioned above, as is structured as follows:

srcSource code src/bugsCommon root for bug reports src/bugs/jdoCommon root for JDO bug reports src/bugs/jdo/templatePatch template src/bugs/jdo/template/TestTemplate.javaJUnit test case. src/bugs/jdo/template/EntityOne.javaEntity required by the test case src/bugs/jdo/template/jdo-conf.xmlCastor JDO configuration src/bugs/jdo/template/mapping.xmlCastor mapping file src/bugs/jdo/template/create.sqlSQL schema to create database table(s) src/bugs/jdo/template/READMETest instructions

To create you own bug report, please copy 'template' to e.g. bug1820, assuming that 1820 is the number assigned to your BugZilla problem report). Subsequently, please amend the files provided to match your own requirements. After you have consolidated your changes, the original directory structure in src/bugs could look as follows:

srcSource code src/bugsCommon root for bug reports src/bugs/jdoCommon root for JDO bug reports src/bugs/jdo/templatePatch template src/bugs/jdo/template/TestTemplate.javaJUnit test case. src/bugs/jdo/template/EntityOne.javaEntity required by the test case src/bugs/jdo/template/jdo-conf.xmlCastor JDO configuration src/bugs/jdo/template/mapping.xmlCastor mapping file src/bugs/jdo/template/create.sqlSQL schema to create database table(s) src/bugs/jdo/template/READMETest instructions src/bugs/jdo/bug1820Your specific bug (as per BugZilla bug number) src/bugs/jdo/bug1820/TestCase.javaJUnit test case. src/bugs/jdo/bug1820/Entity1.javaEntity required src/bugs/jdo/bug1820/Entity2.javaEntity required src/bugs/jdo/bug1820/jdo-conf.xmlCastor JDO configuration src/bugs/jdo/bug1820/mapping.xmlCastor mapping file src/bugs/jdo/bug1820/schema.sqlSQL schema to create database table(s) src/bugs/jdo/bug1820/READMETest instructions

Once you have successfully executed your JUnit test case, please add this test to the master test suite available in src/bugs/AllTests.java as follows. To add a test to this suite, please duplicate the line

suite.addTestSuite(template.TestTemplate.class);

and replace the term 'jdo.template.TestTemplate.class' with 'jdo.bug1820.TestCase'.

This will allow us to run all tests related to all open bugs in one go by executing just this test suite.

As explained in cvs.html, we ask you to submit your code changes in the form of a unified patch by attaching it to the relevant bug report.

To create a unified patch for submission, you can either use the command line SVN client (which you find instructions to download for at http://subversion.tigris.org/ or any IDE that offers support or SVN (such as Eclipse with Subclipse plugin)

In any case, please note that we are trying to standardize on the use of unified patches only, and that you should always update your code (against the SVN repository) before creating the patch. If you have never used SVN before, there will be ways to convince us to accept e.g. a Zip file includig your changes.

Whilst we cannot assume that every Castor (JDO) user is an expert in the use of JUnit, we do believe that they are quite easy to get acquainted with. As a starting point, please find below some references:

  • JUnit - A well-known framework for writing integration-level and functional tests.
  • SVN Home - many useful SVN related items
castor-1.3.2.orig/src/howto/how-to-cascade-deletion.xml0000644000000000000000000001140411544322135017705 0ustar How to cascade deletion Describes the various possibilities Castor provides to cascade deletion Draft How to cascade deletion

If you enable cascading deletion on a relationship, deleting the object on one end of the relationship (i.e. calling db.remove() on the object) will also delete the object on the other end.

To enable cascading deletion on a relationship you simply set the cascading attribute of the <sql> field describing the relation to "delete" (or "all"):

]]>

In case of bidirectional relationships, be aware that it matters on which end you enable cascading deletion. It is also possible to enable it on both ends.

Let's say we have the objects Author and Book and they are in a one-to-one relationship, with every Book having exactly one Author. The database looks like this:

Author
id name
1 "John Jackson"
Book
id title author_id
1 "My Life" 1

Now, since we specified the relationship to cascade deletion, if we remove the book, the author gets removed too (after all, an author without a book isn't really an author).

Afterwards, the database predictably looks like this:

Author
id name
(empty table)
Book
id title author_id
(empty table)

Cascading the deletion of objects in to-many relationships works in exactly the same way.

Note: You need to explicitly invoke db.remove() to delete an object. Simply setting a relational property to NULL or removing an item from a collection will not remove the corresponding entity from the database, even with cascading deletion enabled.

castor-1.3.2.orig/src/bugs/0000755000000000000000000000000011656245645012402 5ustar castor-1.3.2.orig/src/bugs/castor.properties0000644000000000000000000000205111544322136015774 0ustar # Example properties indent the output, require validation # on input and turn debugging on. # org.exolab.castor.validation=false org.exolab.castor.indent=true org.exolab.castor.debug=false # True if database configuration should be initalization # when loading it (default: true). # #org.exolab.castor.jdo.DatabaseInitializeAtLoad=true # # TransactionManagerFactory implementations # org.castor.transactionmanager.Factories=\ org.castor.transactionmanager.WebSphereTransactionManagerFactory,\ org.castor.transactionmanager.WebSphere5TransactionManagerFactory,\ org.castor.transactionmanager.WebSphere51TransactionManagerFactory,\ org.castor.transactionmanager.LocalTransactionManagerFactory,\ org.castor.transactionmanager.JNDIENCTransactionManagerFactory,\ org.castor.transactionmanager.JOTMTransactionManagerFactory # # Shell the TransactionManager be initialized at registration or lazily when # requested for the first time? Defaults to false. # org.castor.transactionmanager.InitializeAtRegistration=false castor-1.3.2.orig/src/bugs/xml/0000755000000000000000000000000011544322135013164 5ustar castor-1.3.2.orig/src/bugs/xml/c1342/0000755000000000000000000000000011656245645013736 5ustar castor-1.3.2.orig/src/bugs/xml/c1342/Bean.java0000644000000000000000000000156711544322136015442 0ustar package xml.c1342; public class Bean { private Integer _attribute; private String _element; private Bean _reference; public Bean() { } public Bean(final Integer attribute, final String element, final Bean reference) { _attribute = attribute; _element = element; _reference = reference; } public Integer getAttribute() { return _attribute; } public void setAttribute(final Integer attribute) { _attribute = attribute; } public String getElement() { return _element; } public void setElement(final String element) { _element = element; } public Bean getReference() { return _reference; } public void setReference(final Bean reference) { _reference = reference; } } castor-1.3.2.orig/src/bugs/xml/c1342/mapping.xml0000644000000000000000000000110211544322136016070 0ustar castor-1.3.2.orig/src/bugs/xml/c1342/Proxy.java0000644000000000000000000000153211544322136015706 0ustar package xml.c1342; import java.lang.reflect.Method; import net.sf.cglib.proxy.Enhancer; import net.sf.cglib.proxy.MethodInterceptor; import net.sf.cglib.proxy.MethodProxy; public class Proxy implements MethodInterceptor { public static Object newInstance(final Object object){ try{ Proxy proxy = new Proxy(object); return Enhancer.create(object.getClass(), new Class[] {}, proxy); } catch (Throwable e){ e.printStackTrace(); throw new Error(e.getMessage()); } } private final Object _object; private Proxy(final Object object) { _object = object; } public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable { return method.invoke(_object, args); } } castor-1.3.2.orig/src/bugs/xml/c1342/Test1342.java0000644000000000000000000002371711544322135016026 0ustar package xml.c1342; import java.io.StringReader; import java.io.StringWriter; import junit.framework.TestCase; import net.sf.cglib.proxy.Factory; import org.castor.xml.XMLProperties; import org.exolab.castor.mapping.Mapping; import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; import org.exolab.castor.xml.XMLContext; public final class Test1342 extends TestCase { private static final String MAPPING_FILE = "mapping.xml"; public Test1342() { super(); } /** * Test unmarshalling of simple bean without proxy. * * @throws Exception For any exception thrown. */ public void testUnmarshalSimpleBean() throws Exception { Mapping mapping = new Mapping(); mapping.loadMapping(getClass().getResource(MAPPING_FILE).toExternalForm()); Unmarshaller unmarshaller = new Unmarshaller(Bean.class); unmarshaller.setMapping(mapping); String input = "\n" + "" + "element of 999" + ""; Bean bean = (Bean) unmarshaller.unmarshal(new StringReader(input)); assertNotNull(bean); assertEquals(999, bean.getAttribute().intValue()); assertEquals("element of 999", bean.getElement()); assertNull(bean.getReference()); } /** * Test unmarshalling of bean refering to another one without proxy. * * @throws Exception For any exception thrown. */ public void testUnmarshalReferingBean() throws Exception { Mapping mapping = new Mapping(); mapping.loadMapping(getClass().getResource(MAPPING_FILE).toExternalForm()); Unmarshaller unmarshaller = new Unmarshaller(Bean.class); unmarshaller.setMapping(mapping); String input = "\n" + "" + "element of 100" + "" + "element of 999" + "" + ""; Bean referer = (Bean) unmarshaller.unmarshal(new StringReader(input)); assertNotNull(referer); assertEquals(100, referer.getAttribute().intValue()); assertEquals("element of 100", referer.getElement()); assertNotNull(referer.getReference()); Bean refered = referer.getReference(); assertNotNull(refered); assertEquals(999, refered.getAttribute().intValue()); assertEquals("element of 999", refered.getElement()); assertNull(refered.getReference()); } /** * Test marshalling of simple bean without proxy. * * @throws Exception For any exception thrown. */ public void testMarshalSimpleBean() throws Exception { Mapping mapping = new Mapping(); mapping.loadMapping(getClass().getResource(MAPPING_FILE).toExternalForm()); StringWriter out = new StringWriter(); Marshaller marshaller = new Marshaller(out); marshaller.setMapping(mapping); Bean bean = new Bean(new Integer(999), "element of 999", null); marshaller.marshal(bean); String output = out.toString(); String expected = "\n" + "" + "element of 999" + ""; assertEquals(expected, output); } /** * Test marshalling of bean refering to another one without proxy. * * @throws Exception For any exception thrown. */ public void testMarshalReferingBean() throws Exception { Mapping mapping = new Mapping(); mapping.loadMapping(getClass().getResource(MAPPING_FILE).toExternalForm()); StringWriter out = new StringWriter(); Marshaller marshaller = new Marshaller(out); marshaller.setMapping(mapping); Bean refered = new Bean(new Integer(999), "element of 999", null); Bean referer = new Bean(new Integer(100), "element of 100", refered); marshaller.marshal(referer); String output = out.toString(); String expected = "\n" + "" + "element of 100" + "" + "element of 999" + "" + ""; assertEquals(expected, output); } /** * Test marshalling of simple bean with proxy. * * @throws Exception For any exception thrown. */ public void testMarshalSimpleBeanProxy() throws Exception { XMLContext xmlContext = new XMLContext(); xmlContext.setProperty(XMLProperties.PROXY_INTERFACES, "net.sf.cglib.proxy.Factory"); Mapping mapping = xmlContext.createMapping(); mapping.loadMapping(getClass().getResource(MAPPING_FILE).toExternalForm()); StringWriter out = new StringWriter(); Marshaller marshaller = xmlContext.createMarshaller(); marshaller.setWriter(out); marshaller.setMapping(mapping); // Joachim 2007-09-04 before XMLContext was introduced it looked like: // Configuration config = LocalConfiguration.getInstance(); // config.getProperties().setProperty( // XMLConfiguration.PROXY_INTERFACES, "net.sf.cglib.proxy.Factory"); // // Mapping mapping = new Mapping(); // mapping.loadMapping(getClass().getResource(MAPPING_FILE).toExternalForm()); // // StringWriter out = new StringWriter(); // Marshaller marshaller = new Marshaller(out); // marshaller.setMapping(mapping); Bean bean = new Bean(new Integer(999), "element of 999", null); Bean proxy = (Bean) Proxy.newInstance(bean); assertNotNull(proxy); assertEquals(Bean.class, proxy.getClass().getSuperclass()); assertEquals(1, proxy.getClass().getInterfaces().length); assertEquals(Factory.class, proxy.getClass().getInterfaces()[0]); assertEquals(999, proxy.getAttribute().intValue()); assertEquals("element of 999", proxy.getElement()); assertNull(proxy.getReference()); marshaller.marshal(proxy); String output = out.toString(); String expected = "\n" + "" + "element of 999" + ""; assertEquals(expected, output); } /** * Test marshalling of bean refering to another one with proxy. * * @throws Exception For any exception thrown. */ public void testMarshalReferingBeanProxy() throws Exception { XMLContext xmlContext = new XMLContext(); xmlContext.setProperty(XMLProperties.PROXY_INTERFACES, "net.sf.cglib.proxy.Factory"); Mapping mapping = xmlContext.createMapping(); mapping.loadMapping(getClass().getResource(MAPPING_FILE).toExternalForm()); StringWriter out = new StringWriter(); Marshaller marshaller = xmlContext.createMarshaller(); marshaller.setWriter(out); marshaller.setMapping(mapping); // Joachim 2007-09-04 before XMLContext was introduced it looked like: // Configuration config = LocalConfiguration.getInstance(); // config.getProperties().setProperty( // XMLConfiguration.PROXY_INTERFACES, "net.sf.cglib.proxy.Factory"); // // Mapping mapping = new Mapping(); // mapping.loadMapping(getClass().getResource(MAPPING_FILE).toExternalForm()); // // StringWriter out = new StringWriter(); // Marshaller marshaller = new Marshaller(out); // marshaller.setMapping(mapping); Bean refered = new Bean(new Integer(999), "element of 999", null); Bean referedProxy = (Bean) Proxy.newInstance(refered); assertNotNull(referedProxy); assertEquals(Bean.class, referedProxy.getClass().getSuperclass()); assertEquals(1, referedProxy.getClass().getInterfaces().length); assertEquals(Factory.class, referedProxy.getClass().getInterfaces()[0]); assertEquals(999, referedProxy.getAttribute().intValue()); assertEquals("element of 999", referedProxy.getElement()); assertNull(referedProxy.getReference()); Bean referer = new Bean(new Integer(100), "element of 100", referedProxy); Bean refererProxy = (Bean) Proxy.newInstance(referer); assertNotNull(refererProxy); assertEquals(Bean.class, refererProxy.getClass().getSuperclass()); assertEquals(1, refererProxy.getClass().getInterfaces().length); assertEquals(Factory.class, refererProxy.getClass().getInterfaces()[0]); assertEquals(100, refererProxy.getAttribute().intValue()); assertEquals("element of 100", refererProxy.getElement()); assertNotNull(refererProxy.getReference()); marshaller.marshal(refererProxy); String output = out.toString(); String expected = "\n" + "" + "element of 100" + "" + "element of 999" + "" + ""; assertEquals(expected, output); } } castor-1.3.2.orig/src/bugs/xml/template/0000755000000000000000000000000011656245645015015 5ustar castor-1.3.2.orig/src/bugs/xml/template/Entity.java0000644000000000000000000000061611544322136017122 0ustar package xml.template; public final class Entity { private Integer _id; private String _name; public Integer getId() { return _id; } public void setId(final Integer id) { _id = id; } public String getName() { return _name; } public void setName(final String name) { _name = name; } } castor-1.3.2.orig/src/bugs/xml/template/TestTemplate.java0000644000000000000000000000355211544322135020262 0ustar package xml.template; import java.io.StringWriter; import junit.framework.TestCase; import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; import org.exolab.castor.xml.XMLContext; import org.xml.sax.InputSource; public final class TestTemplate extends TestCase { private static final String SAMPLE_FILE = "input.xml"; private XMLContext context; public TestTemplate() { super(); } public TestTemplate(final String name) { super(name); } protected void setUp() throws Exception { this.context = new XMLContext(); context.setProperty("org.exolab.castor.indent", "true"); } /** * Test method. * @throws Exception For any exception thrown. */ public void testUnmarshalEntity() throws Exception { Unmarshaller unmarshaller = getXMLContext().createUnmarshaller(); unmarshaller.setClass(Entity.class); Entity entity = (Entity) unmarshaller.unmarshal(new InputSource(getClass().getResource(SAMPLE_FILE).toExternalForm())); assertNotNull (entity); assertEquals (1, entity.getId().intValue()); assertEquals("name", entity.getName()); } /** * Test method. * @throws Exception For any exception thrown. */ public void testMarshalEntity() throws Exception { StringWriter out = new StringWriter(); Marshaller marshaller = getXMLContext().createMarshaller(); marshaller.setWriter(out); Entity entity = new Entity(); entity.setId(new Integer(100)); entity.setName("entity 100"); marshaller.marshal(entity); System.out.println(out.toString()); } private XMLContext getXMLContext() { return this.context; } } castor-1.3.2.orig/src/bugs/xml/template/TestTemplateWithMapping.java0000644000000000000000000000453711544322135022436 0ustar package xml.template; import java.io.StringWriter; import junit.framework.TestCase; import org.exolab.castor.mapping.Mapping; import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; import org.exolab.castor.xml.XMLContext; import org.xml.sax.InputSource; public final class TestTemplateWithMapping extends TestCase { private static final String SAMPLE_FILE = "input.xml"; private static final String MAPPING_FILE = "mapping.xml"; private XMLContext context; public TestTemplateWithMapping() { super(); } public TestTemplateWithMapping(final String name) { super(name); } protected void setUp() throws Exception { this.context = new XMLContext(); context.setProperty("org.exolab.castor.indent", "true"); } /** * Test method. * @throws Exception For any exception thrown. */ public void testUnmarshalEntity() throws Exception { Mapping mapping = new Mapping(); mapping.loadMapping(getClass().getResource(MAPPING_FILE).toExternalForm()); Unmarshaller unmarshaller = getXMLContext().createUnmarshaller(); unmarshaller.setClass(Entity.class); unmarshaller.setMapping(mapping); Entity entity = (Entity) unmarshaller.unmarshal(new InputSource(getClass().getResource(SAMPLE_FILE).toExternalForm())); assertNotNull (entity); assertEquals (1, entity.getId().intValue()); assertEquals("name", entity.getName()); } /** * Test method. * @throws Exception For any exception thrown. */ public void testMarshalEntity() throws Exception { Mapping mapping = new Mapping(); mapping.loadMapping(getClass().getResource(MAPPING_FILE).toExternalForm()); StringWriter out = new StringWriter(); Marshaller marshaller = getXMLContext().createMarshaller(); marshaller.setWriter(out); marshaller.setMapping(mapping); Entity entity = new Entity(); entity.setId(new Integer(100)); entity.setName("entity 100"); marshaller.marshal(entity); System.out.println(out.toString()); } private XMLContext getXMLContext() { return this.context; } } castor-1.3.2.orig/src/bugs/xml/template/mapping.xml0000644000000000000000000000066211544322136017161 0ustar castor-1.3.2.orig/src/bugs/xml/template/input.xml0000644000000000000000000000011311544322136016654 0ustar 1 name castor-1.3.2.orig/src/bugs/xml/template/README.txt0000644000000000000000000000016611544322135016500 0ustar bug number: 1368 description: Bug report template for castor xml. castor: version 1.0M4 or CVS of 2005-03-31 13:44 castor-1.3.2.orig/src/bugs/xml/c1586/0000755000000000000000000000000011656245645013750 5ustar castor-1.3.2.orig/src/bugs/xml/c1586/TextContentTest.java0000644000000000000000000000646311544322135017725 0ustar package xml.c1586; import junit.framework.TestCase; import org.exolab.castor.mapping.Mapping; import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; import org.exolab.castor.xml.XMLContext; import org.xml.sax.InputSource; import java.io.StringWriter; /** * Unit Test */ public class TextContentTest extends TestCase { private static final String MAPPING_FILE = "mapping.xml"; private XMLContext xmlContext; private Mapping mapping; private Marshaller marshaller; private StringWriter writer; private Unmarshaller unmarshaller; /* (non-Javadoc) * @see junit.framework.TestCase#setUp() */ protected void setUp() throws Exception { super.setUp(); this.xmlContext = new XMLContext(); // das Test Objekt vorbereiten this.writer = new StringWriter(); } /* (non-Javadoc) * @see junit.framework.TestCase#tearDown() */ protected void tearDown() throws Exception { super.tearDown(); this.writer = null; this.xmlContext = null; } /** * Will throw exception when setting mapping in unmarshaller */ public void testTextContentNotWorking() throws Exception { // das Mapping laden mapping = new Mapping(getClass().getClassLoader()); mapping.loadMapping(new InputSource(getClass().getResourceAsStream(MAPPING_FILE))); // den Marshaller erzeugen marshaller = xmlContext.createMarshaller(); marshaller.setWriter(writer); // marshaller = new Marshaller(writer); marshaller.setMapping(mapping); marshaller.setEncoding("UTF-8"); marshaller.setValidation(true); // den Unmarshaller erzeugen unmarshaller = xmlContext.createUnmarshaller(); // unmarshaller = new Unmarshaller(); unmarshaller.setClassLoader(getClass().getClassLoader()); unmarshaller.setValidation(false); unmarshaller.setMapping(mapping); unmarshaller.setWhitespacePreserve(true); // den Marshaller erzeugen marshaller = xmlContext.createMarshaller(); marshaller.setWriter(writer); // marshaller = new Marshaller(writer); marshaller.setMapping(mapping); marshaller.setEncoding("UTF-8"); marshaller.setValidation(true); } /** * Everything works */ public void testTextContentWorking() throws Exception { // das Mapping laden mapping = new Mapping(getClass().getClassLoader()); mapping.loadMapping(getClass().getResource(MAPPING_FILE)); // den Marshaller erzeugen marshaller = xmlContext.createMarshaller(); marshaller.setWriter(writer); // marshaller = new Marshaller(writer); marshaller.setMapping(mapping); marshaller.setEncoding("UTF-8"); marshaller.setValidation(true); // den Unmarshaller erzeugen unmarshaller = xmlContext.createUnmarshaller(); // unmarshaller = new Unmarshaller(); unmarshaller.setClassLoader(getClass().getClassLoader()); unmarshaller.setValidation(false); unmarshaller.setMapping(mapping); unmarshaller.setWhitespacePreserve(true); } } castor-1.3.2.orig/src/bugs/xml/c1586/mapping.xml0000644000000000000000000000117211544322135016110 0ustar castor-1.3.2.orig/src/bugs/xml/c1586/TextContent.java0000644000000000000000000000201211544322136017050 0ustar package xml.c1586; import org.exolab.castor.types.AnyNode; /** * Test Klasse zum Testen des Castor Any-Nodes */ public class TextContent { private AnyNode contentNode = new AnyNode(AnyNode.ELEMENT, "content-node", null, null, null); private String contentString; /** * Default Constrcutor */ public TextContent() { } /** * @return the contentNode */ public AnyNode getContentNode() { return contentNode; } /** * @return the contentString */ public String getContentString() { return contentString; } /** * @param contentNode the contentNode to set */ public void setContentNode(AnyNode contentNode) { this.contentNode = contentNode; } /** * @param contentString the contentString to set */ public void setContentString(String contentString) { this.contentString = contentString; } } castor-1.3.2.orig/src/bugs/xml/schema/0000755000000000000000000000000011656245645014442 5ustar castor-1.3.2.orig/src/bugs/xml/schema/test.xsd0000644000000000000000000000453211544322135016127 0ustar castor-1.3.2.orig/src/bugs/xml/schema/TestCastorReader.java0000644000000000000000000000247511544322136020516 0ustar package xml.schema; import java.io.FileNotFoundException; import java.io.IOException; import org.exolab.castor.xml.schema.Schema; import org.exolab.castor.xml.schema.reader.SchemaReader; import org.xml.sax.InputSource; public class TestCastorReader { public static void main(String[] args) { try { InputSource source = new InputSource(TestCastorReader.class.getResource("test.xsd").toExternalForm()); SchemaReader schemaReader = new SchemaReader(source); schemaReader.setCacheIncludedSchemas(true); Schema schema = schemaReader.read(); System.out.println("**** Schema is loaded successfully"); int tnum = schema.getSimpleTypes().size(); System.out.println("**** Total " + tnum + " simply types in the schema."); tnum = schema.getComplexTypes().size(); System.out.println("**** Total " + tnum + " complex types in the schema."); } catch (FileNotFoundException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } catch (IOException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } } castor-1.3.2.orig/src/bugs/log4j.xml0000644000000000000000000000262611544322135014133 0ustar castor-1.3.2.orig/src/xml-howto/0000755000000000000000000000000011656245645013400 5ustar castor-1.3.2.orig/src/xml-howto/how-to-map-both-structure-and-content.xml0000644000000000000000000000545411544322136023305 0ustar How to map 'text' content General information about using a mapping file to map towards XML text content. Final How to map 'text' content

Any user who needs to unmarshal/marshal XML that has data represented as text as well as attributes/elements.

Consider you have XML with a structure defined as follows:

<xml version="1.0" encoding="UTF-08"?> <person> <name>Jennifer</name> <age dob="21-feb-1987">21</age> <employment> <company name="unesco" /> </employment> </person>

Notice the structure the element age, which has both text as well as XML markup as its content. A mapping for above XML would be as follows:

<xml version="1.0" encoding="UTF-08"?> <mapping> <class name="abc.Person"> <map-to xml="Person"/> <field name="name" type="java.lang.String"> <bind-xml name="name" node="element"/> </field> <field name="age" type="abc.Age"> <bind-xml name="age" node="element"/> </field> <field name="company" type="abc.Company"> <bind-xml name="company" node="element" location="employment"/> </field> </class> <class name="abc.Age"> <map-to xml="age"/> <field name="dob" type="java.lang.String"> <bind-xml name="dob" node="attribute"/> </field> <field name="ageValue" type="java.lang.String"> <bind-xml node="text"/> </field> </class> <class name="abc.Company"> <field name="name" type="java.lang.String"> <bind-xml name="name" node="attribute"/> </field> </class> </mapping>

Please note the different node types of the members of the abc.Age class, especially where the Java member ageValue is mapped to a node of type text.

castor-1.3.2.orig/src/xml-howto/how-to-run-xml-ctf-suite.xml0000644000000000000000000000720511544322135020626 0ustar How to run Castor XML's CTF suite General information about running Castor XML's CTF suite Final How to run Castor XML's CTF suite

Castor XML has a JUnit test suite that is used to perform various functional and regression tests, to give developers/committers some reassurance when changing the codebase.

Anyone who wants to run the CTF test suite. This document outlines the basic steps to get people unfamiliar with this area started.

Our example describes the use of command-line tools for a UNIX system.

Anybody wishing to run the CTF test suite should have access to the source code of Castor. This can be obtained in one of the following ways:

Note:The CTF currently requires the Sun JDK (or SDK) to execute, although it may be possible to execute fine with GNU gcj or with JRockit. The CTF will not work if you are using only a JRE. This is because the CTF uses the Sun Java compiler API to compile code as needed for Source Generator and Marshaling Framework tests. The CTF code is written to allow easy extension for additional compiler frameworks, so if you use a compiler or runtime that is not supported, you should be able to easily add support for a new framework. If you want to do this, contact Castor committors for assistance and direction and they'll set you on the right course.

Once you have obtained the Castor sources in one of the ways highlighted above, here is how to proceed. In general, more information about how to execute the CTF test suite can be found here.

From a command line (e.g a shell), please execute the following commands to run the Castor XML master test suite (default suite).

> cd <castor-root> > mvn install > cd <castor-root>/xmlctf > mvn test

To execute just a subset of the master test suite, please change this to:

> cd <castor-root> > mvn install > cd <castor-root>/xmlctf > mvn test
castor-1.3.2.orig/src/xml-howto/how-to-map-a-collection.xml0000644000000000000000000000675111544322136020455 0ustar How to map a collection of elements Final How to map a collection of elements

Anyone who wants to map a collection of elements.

This document helps people to get familiar with the basic concepts of mapping and shows an example.

None.

Assume you have two classes Order and OrderItem, where an order holds a list of order items.

public class Order { private List orderItems; private String orderNumber; public List getOrderItems() { return orderItems; } public void setOrderItems(List orderItems) { this.orderItems = orderItems; } public String getOrderNumber() { return orderNumber; } public void setOrderNumber(String orderNumber) { this.orderNumber = orderNumber; } } public class OrderItem { private String id; private Integer quantity; public String getId() { return id; } public void setId(String id) { this.id = id; } public Integer getQuantity() { return quantity; } public void setQuantity(Integer quantity) { this.quantity = quantity; } }

As shown above, the Order instance has a field 'OrderItems' to hold a list of OrderItem instances.

Here's the mapping file to instruct Castor XML about the relation of those two classes, Order and OrderItem respectively:

]]>

Using the Castor XML marshaller with the mapping file shown above, the XML generated by Castor XML might look as follows:

]]>
castor-1.3.2.orig/src/xml-howto/how-to-work-with-wrapper-elements-around-collections.xml0000644000000000000000000001043711544322136026352 0ustar How to work with wrapper elements around collections Final How to work with wrapper elements around collections

How to work with wrapper elements around collections.

This document helps people to get familiar with the basic concepts and shows an example.

None.

When you have a class that holds a collection of objects of the same type, and you want to wrap the XML produced for the collection members with an additional XML artefact, then read on.

For example, assume you have the following Java class Foo:

and you want to have Castor generate XML which looks like:

<foo:foo xmlns:foo="http://example.com/foo" name="foo"> <foo:children> <foo:foo name="foo1" /> <foo:foo name="foo2" /> </foo:children> </foo:foo>

where the structure of the output is defined by the following XML schema:

<?xml version="1.0" encoding="UTF-8"?> <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://example.com/foo" xmlns:tns="http://example.com/foo" elementFormDefault="qualified"> <complexType name="fooType"> <sequence> <element name="children" minOccurs="0"> <complexType> <sequence> <element name="foo" type="tns:fooType" maxOccurs="unbounded"> </element> </sequence> </complexType> </element> </sequence> <attribute name="name"></attribute> </complexType> </schema>

then you would use a mapping like where the location attribute on the field mapping for children defines the wrapper XML artifact to be used:

<?xml version="1.0"?> <!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN" "http://castor.org/mapping.dtd"> <mapping> <class name="com.example.Foo" auto-complete="false"> <map-to xml="foo" ns-uri="http://example.com/foo" ns-prefix="foo" /> <field name="name" type="java.lang.String"> <bind-xml name="name" node="attribute" /> </field> <field name="children" collection="collection" type="com.example.Foo"> <bind-xml name="foo" location="children" /> </field> </class> </mapping>
castor-1.3.2.orig/src/xml-howto/how-to-write-a-configurablefieldhandler.xml0000644000000000000000000002232211544322135023670 0ustar How to write a ConfigurableFieldHandler Describes how to write a custom configurable field handler. Final How to write a ConfigurableFieldHandler

Anyone who wants to write a configurable field hander.

If you want to have a custom FieldHandler that works in a fixed manner, you should consider subclassing GeneralizedFieldHandler , or implementing FieldHandler.

However if you want your FieldHandler to operate more flexibly, based on configuration, ConfigurableFieldHandler may be what you're looking for.

Basically, two approaches exist for implementing a configurable field handler.

The most straightforward one is simply to implement the ConfigurableFieldHandler interface. This interface extends the FieldHandler interface.

The other approach is to subclass any of the convenience FieldHandler implementations. These are AbstractFieldHandler and GeneralizedFieldHandler. Both classes already implement the ConfigurableFieldHandler interface, so you don't have to implement it yourself explicitly. However the implementation of the single ConfigurableFieldHandler method (setConfiguration) is an empty method. So you'd have to override this method yourself in order to do something useful with the configuration.

The two approaches differ only marginally. If the convenience classes provide useful functionality for you, you'd probably be better off using them. Otherwise simply implementing the ConfigurableFieldHandler interface is a good choice.

For this exercise, we choose to implement the ConfigurableFieldHandler, and decide to convert dates, using a configurable date pattern:

import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Properties; import org.exolab.castor.mapping.ConfigurableFieldHandler; import org.exolab.castor.mapping.ValidityException; public class FieldHandlerImpl implements ConfigurableFieldHandler { private SimpleDateFormat formatter; public FieldHandlerImpl() { // } /** * Sets the configuration for this field handler. The config object is supposed to have one * property, named "date-format", with a date format pattern compatible with * java.text.SimpleDateFormat. * * @param config the configuration object. * @throws ValidityException if config doesn't have the required parameter, or if the parameter * value is not a valid date pattern. */ public void setConfiguration(Properties config) throws ValidityException { String pattern = config.getProperty("date-format"); if (pattern == null) { throw new ValidityException("Required parameter \"date-format\" is missing for CustomDateFieldHandler."); } try { formatter = new SimpleDateFormat(pattern); } catch (IllegalArgumentException e) { throw new ValidityException("Pattern \""+pattern+"\" is not a valid date format."); } } /** * Returns the value of the field from the object. * * @param object The object * @return The value of the field * @throws IllegalStateException The Java object has changed and * is no longer supported by this handler, or the handler is not * compatible with the Java object */ public Object getValue( Object object ) throws IllegalStateException { Root root = (Root)object; Date value = root.getDate(); if (value == null) return null; return formatter.format(value); } /** * Sets the value of the field on the object. * * @param object The object * @param value The new value * @throws IllegalStateException The Java object has changed and * is no longer supported by this handler, or the handler is not * compatible with the Java object * @throws IllegalArgumentException The value passed is not of * a supported type */ public void setValue( Object object, Object value ) throws IllegalStateException, IllegalArgumentException { Root root = (Root)object; Date date = null; try { date = formatter.parse((String)value); } catch(ParseException px) { throw new IllegalArgumentException(px.getMessage()); } root.setDate(date); } /** * Creates a new instance of the object described by this field. * * @param parent The object for which the field is created * @return A new instance of the field's value * @throws IllegalStateException This field is a simple type and * cannot be instantiated */ public Object newInstance( Object parent ) throws IllegalStateException { //-- Since it's marked as a string...just return null, //-- it's not needed. return null; } /** * Sets the value of the field to a default value. * * Reference fields are set to null, primitive fields are set to * their default value, collection fields are emptied of all * elements. * * @param object The object * @throws IllegalStateException The Java object has changed and * is no longer supported by this handler, or the handler is not * compatible with the Java object */ public void resetValue( Object object ) throws IllegalStateException, IllegalArgumentException { ((Root)object).setDate(null); } /** * @deprecated No longer supported */ public void checkValidity( Object object ) throws ValidityException, IllegalStateException { // do nothing } }

For a ConfigurableFieldHandler, we have to override the method setConfiguration of the superclass AbstractFieldHandler. AbstractFieldHandler implements this method on behalf of the ConfigurableFieldHandler interface, but does not do anything.

All we have to do now is define the ConfigurableFieldHandler in the mapping file (using a <field-handler> element), configure it, and use it in some xml field.

<?xml version="1.0"?> <mapping> <field-handler name="myHandler" class="org.some.package.CustomFieldHandlerImpl"> <param name="date-format" value="yyyyMMddHHmmss"/> </field-handler> <class name="Root"> <field name="date" type="string" handler="myHandler"/> </class> </mapping>

This mapping file defines a custom configurable field handler instance named "myHandler", of the type we've just implemented, and configures it with some fancy date pattern. A regular class mapping defines a field called "date", and specifies that conversion to and from this field will be performed by the "myHandler" instance.

It would be perfectly legal to use "myHandler" for other fields as well, and also to define other field-handler instances of the class FieldHandlerImpl (or any other class).

To complete the example, here's the "Root" class that is used in the example mapping file:

import java.util.Date; public class Root { private Date _date = null; public Root() { } public Date getDate() { return _date; } public void setDate(Date date) { this._date = date; } }

And here a sample XML document:

<?xml version="1.0" encoding="UTF-8"?> <root> <date>20070711234859</date> </root>

With these classes, xml mapping file and xml sample file, you should be able to marshall and unmarshall the date field.

castor-1.3.2.orig/src/xml-howto/how-to-map-an-inner-class.xml0000644000000000000000000000613611544322135020712 0ustar How to map an innner class Final How to map an innner class

Anyone who wants to map an inner class with Castor XML for XML data binding.

This document helps people to get familiar with the basic concepts of mapping and shows an example.

A general understanding about XML data binding and its usage.

Assume you have the following classes Outer and Inner:

package test; public class Outer { private Inner member; public Inner getMember() { return member; } public void setMember (Inner member) { this.member = member; } public static class Inner { private String innerMember; public String getInnerMember() { return innerMember; } public void setInnerMember(String innerMember) { this.innerMember = innerMember; } } }

Please note that the i nner class needs to be declared public and static.

Here's the mapping file for Castor XML, showing the class mapping for the OrderItem class:

]]>

Using the Castor XML Unmarshaller with the mapping file shown above, the code to unmarshal the following XML ...

blah ]]>

... into a variable of type test.Outer is as follows:

InputSource mappingSource = ...; Mapping mapping = new Mapping(); mapping.loadMapping(mappingSource); InputSource inputSource = ...; Unmarshaller unmarshaller = new Unmarshaller(test.Outer.class); unmarshaller.setMapping(mapping); test.Outer outer = (test.Outer) unmarshaller.unmarshal(inputSource);
castor-1.3.2.orig/src/xml-howto/how-to-map-a-hashtable.xml0000644000000000000000000001707611544322135020256 0ustar How to map a map of elements Final How to map a map/hashtable of elements

Anyone who wants to map a Map/Hashtable of elements.

This document helps people to get familiar with the basic concepts of mapping and shows an example.

None.

Assume you have two classes Items and Item, where an Items instance holds a Map/Hashtable of Item instances.

public class Items { private Map itemlist; public Map getItemlist() { return itemlist; } public void setItemlist(Map itemlist) { this.itemlist = itemlist; } } public class Item { private String id; private String description; private String supplier; private String contact; public String getContact() { return contact; } public void setContact(String contact) { this.contact = contact; } public String getSupplier() { return supplier; } public void setSupplier(String supplier) { this.supplier = supplier; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public String getId() { return id; } public void setId(String id) { this.id = id; } }

As shown above, the Items instance has a field 'itemList' to hold a Map of Item instances.

Here's the mapping file to instruct Castor XML about the relation of those two classes, Items and Item respectively:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <mapping> <class name="nl.vodafone.castorbinding.demo.Items"> <map-to xml="Items"/> <field name="Itemlist" collection="hashtable"> <bind-xml name="MyItem"> <class name="org.exolab.castor.mapping.MapItem"> <field name="key" type="java.lang.String"> <bind-xml name="id" node="attribute"/> </field> <field name="value" type="nl.vodafone.castorbinding.demo.Item"> <bind-xml name="Item"/> </field> </class> </bind-xml> </field> </class> <class name="nl.vodafone.castorbinding.demo.Item"> <map-to xml="Item"/> <field name="Id" type="java.lang.String"> <bind-xml name="id" node="element"/> </field> <field name="Description" type="java.lang.String"> <bind-xml name="description" node="element"/> </field> <field name="Supplier" type="java.lang.String"> <bind-xml name="supplier" node="element"/> </field> <field name="Contact" type="java.lang.String"> <bind-xml name="contact" node="element"/> </field> </class> </mapping>

Please note the use of the org.exolab.castor.mapping.MapItem definition within the <bind-xml> element in above mapping to map the elements contained in the Map/Hashtable.

Using the Castor XML marshaller with the mapping file shown above, the XML generated by Castor XML might look as follows:

1 desc1 supp1 cont1 2 desc2 supp2 cont2 3 desc3 supp3 cont3 ]]>

It is equally possible to nest Collections/Arrays within Maps, incl. Maps within Maps. The following Java class has a member 'map' of type java.util.Map.

public class MapOfArrays { private Map map; public Map getMap() { return this.map; } public void setMap(Map map) { this.map = map; } }

The following code shows how this Map instance is filled with String arrays before marshalling.

this.map.put("key1", new String[] { "key1_value1", "key1_Value2" }); this.map.put("key2", new String[] { "key2_value1", "key2_Value2" });

Based upon the following mapping file, ...

]]>

the following XML will be generated during marshalling.

key1_value1 key1_Value2 key2_value1 key2_Value2 ]]>
castor-1.3.2.orig/src/xml-howto/how-to-map-a-list-at-root.xml0000644000000000000000000000712111544322135020647 0ustar How to map a list of elements at the root Final How to map a list of elements at the root

Anyone who wants to map a list of elements at the document root.

This document helps people to get familiar with the basic concepts of mapping and shows an example.

None.

Assume you have a java.util.List (java.util.ArrayList) and an OrderItem classes, where the List instance simply holds a list of order items.

public class OrderItem { private String id; private Integer quantity; public String getId() { return id; } public void setId(String id) { this.id = id; } public Integer getQuantity() { return quantity; } public void setQuantity(Integer quantity) { this.quantity = quantity; } }

Here's the mapping file for Castor XML, showing the class mapping for the OrderItem class:

]]>

Using the Castor XML Unmarshaller with the mapping file shown above, the code to unmarshal the XML shown below ...

]]>

... into a variable of type java.util.ArrayList is shown subsequently:

InputSource mappingSource = ...; Mapping mapping = new Mapping(); mapping.loadMapping(mappingSource); InputSource inputSource = ...; Unmarshaller unmarshaller = new Unmarshaller(ArrayList.class); unmarshaller.setMapping(mapping); ArrayList orders = (ArrayList) unmarshaller.unmarshal(inputSource);

Using the Castor XML Marshaller with the mapping file shown above, the code to marshal a List of OrderItem instances to XML is shown below.

PrintWriter writer = ...; List orders = new ArrayList(); Mapping mapping = new Mapping(); mapping.loadMapping(mappingSource); Marshaller marshaller = new Marshaller(writer); marshaller.setRootElement("orders"); marshaller.setMapping(mapping); marshaller.marshal(orders);
castor-1.3.2.orig/src/xml-howto/how-to-wrap-a-collection-with-a-wrapper-element.xml0000644000000000000000000000700111544322136025132 0ustar How to wrap a collection with a wrapper element Final How to wrap a collection with a wrapper element

Anyone who wants to wrap a collection with a wrapper element.

This document helps people to get familiar with the basic concepts and shows an example.

None.

When you have a field which is a list collection, and you want for each element of the list collection to be encapsulated in a containing element, then set container="false" in the field element for the list collection. By setting this attribute Castor recognizes that you want an element wrapping the members of the list.

By default Castor treats collections as "containers". Containers to Castor are simple objects whose only purpose is to hold other objects. Containers are not considered "first-class" objects and therefore have no direct XML representation. By setting container="false", you are telling Castor that the collection is not be treated as a container, but rather a first class object which should have an XML-representation.

For example, if you have the following two classes:

itemsList = new ArrayList(); public List getItemsList() { return this.itemsList; } public void addItem(Item item) { this.itemsList.add(item); } }]]>

and you want to have Castor generate XML which looks like:

broccoli 1 orange 4 ]]>

then you would use a mapping like:

]]>
castor-1.3.2.orig/src/xml-howto/how-to-submit-an-xml-bug.xml0000644000000000000000000002130511544322135020570 0ustar Submitting an XML bug report General information about submitting a bug report specific to Castor XML Final Submitting a bug report

Most of the traffic on the Castor Users mailing list is about people asking for help on various features of Castor (whether JDO or XML). Whilst there is nothing wrong about asking questions and looking for help if you are stuck, it seems that there is room to improve the structure of this 'conversation'.

If you have a look at some of these threads (e.g. at the searchable mailing list archive), it's quite easy to see that most of the time ...

  1. An initial question is posted.

  2. An initial reply is posted with some follow-up questions, e.g. request for code fragments, mapping files, etc.

  3. One or more code fragments, mapping files, etc. are being posted.

  4. etc.

This document will establish guidelines with regards to step 3) above.

This document provides step-by-step instructions on how to submit a problem report (when being asked to do so). It does so by walking you through a fictive problem and its resulting bug report, and providing instructions based upon this scenario.

Per definition, any problem report submitted (in other words, most likely attached to a bug report at http://jira.codehaus.org/browse/CASTOR) by the means of a patch should include one of the following artefacts:

  • A JUnit test case that 'showcases' your problem.
  • Castor XML mapping file.
  • One or more 'entity' classes required to run your test case.
  • An XML Schema instance.
  • An Ant build script to generate classes from the XMl Schema provided.
  • A README file (with any additional information/instructions required to understand /run your test case.

Note: Whilst we can and will not impose these guidelines in their strictest sense, I think that the use of the aforementioned artefacts will simplify problem resolution and as a result lead to shorter turn-around times. Which is ultimately where you, the user, gains.

To facilitate creation of a fully featured patch as discussed above, we have provided you with an already existing bug template at 'src/bugs/xml/template'.

Note:Please note that this directory is distributed only as part of the source archive(s).

This directory holds some of the artefacts mentioned above, and is structured as follows:

srcSource code src/bugsCommon root for bug reports src/bugs/xmlCommon root for XML bug reports src/bugs/xml/templatePatch template src/bugs/xml/template/TestTemplate.javaJUnit test case. src/bugs/xml/template/Entity.javaEntity required by the test case src/bugs/xml/template/mapping.xmlCastor XML mapping file src/bugs/xml/template/READMETest instructions

To create you own bug report, please copy 'template' to e.g. bug1368, assuming that 1368 is the number assigned to your Jira issue). Subsequently, please amend the files provided to match your own requirements. After you have consolidated your changes, the original directory structure in src/bugs could look as follows:

srcSource code src/bugsCommon root for bug reports src/bugs/xmlCommon root for XML bug reports src/bugs/xml/templatePatch template src/bugs/xml/template/TestTemplate.javaJUnit test case. src/bugs/xml/template/Entity.javaEntity required by the test case src/bugs/xml/template/mapping.xmlCastor mapping file src/bugs/xml/template/READMETest instructions src/bugs/xml/bug1368Your specific bug (as per Jira bug number) src/bugs/xml/bug1368/build.xmlAnt build script. src/bugs/xml/bug1368/custom.xsdXML Schema instance src/bugs/xml/bug1368/READMETest instructions

To facilitate creation of a fully featured but report/patch for the XML code generator, we have provided you with an already existing bug template at 'codegen/src/test/java' and 'codegen/src/test/resources'.

Note:Please note that these directories are distributed only as part of the source archive(s).

These directory holds some of the artefacts mentioned above, and is structured as follows (all paths shown relative to codegen/src/test):

File Description java/xml/srcgen/template/TestSourceGenerator.javaJUnit test case. resources/xml/srcgen/template/test.xsdXML schema file

To create you own bug report, please copy 'xml.srcgen.template' in both locations to e.g. xml.bug1368, assuming that 1368 is the number assigned to your Jira issue). Subsequently, please amend the files provided to match your own requirements. After you have consolidated your changes, the original directory structure in codegen/src/test could look as follows:

File Description java/xml/srcgen/template/TestSourceGenerator.javaJUnit test case. java/xml/bug1368/TestSourceGenerator.javaJUnit test case. resources/xml/srcgen/template/test.xsdXML schema file resources/xml/bug1368/test.xsdXML schema file resources/xml/bug1368/binding.xmlXML code generator binding file resources/xml/bug1368/builder.propertiesCode generator properties

As a last step, we ask you submit your code changes in the form of a unified patch by attaching it to the relevant Jira issue. Please simply follow the instructions provided here.

Whilst we cannot assume that every Castor (XML) user is an expert in the use of JUnit, we do believe that they are quite easy to get acquainted with. As a starting point, please find below some references:

  • JUnit - A well-known framework for writing integration-level and functional tests.
castor-1.3.2.orig/src/xml-howto/how-to-enable-xml-validation.xml0000644000000000000000000002343411544322136021502 0ustar How to use XML validation with Castor General information about using XML validation with Castor Final How to use XML validation with Castor

Anyone who wants to enable XML validation with Castor XML.

This document helps people to get familiar with the basic concepts and discusses some implementation details.

The example given describes the steps required to enble XML validation with Castor XML.

None.

The code given are based on examples from the XML Schema Part 0: Primer Second Edition from w3.org.

The XML Schema instance (po1.xsd) used here looks as follows:

]]>

Surprisingly, the schema isn't complete, so the example XML document invalid-po1.xml is actually invalid.

Alice Smith 123 Maple Street Robert Smith 8 Oak Avenue Hurry, my lawn is going wild ]]>

I then corrected the errors (removed the attributes that they didn't bother to define in their schema) and created valid-po1.xml

Alice Smith 123 Maple Street Robert Smith 8 Oak Avenue Hurry, my lawn is going wild ]]>

Now, to bring Castor into the mix, I created two Java classes, PurchaseOrder and Address.

public class PurchaseOrder { public Address shipTo; public Address billTo; public String comment; } public class Address { public String name; public String street; }

And created a mapping file from the xml to the Java classes.

]]>

Note that the mapping file refers to mapping.xsd, which can be found in the Castor JAR file, as the schema for the Castor namespace. I'm also using relative paths for all the schemas, so the xml files and the schemas must all reside in current working directory (the directory from which you call java).

Now for Castor to do validation, the correct castor.properties file must be in the current working directory.

org.exolab.castor.indent=true org.exolab.castor.parser.namespaces=true org.exolab.castor.sax.features=http://xml.org/sax/features/validation,\ http://apache.org/xml/features/validation/schema,\ http://apache.org/xml/features/validation/schema-full-checking

The indent property is just to make the output XML easy to read, and because I'm using Xerces, the apache.org properties come into the mix. Other XML parsers will probably have different flags that need to be set.

Finally, I created a driver class to run Castor:

import java.io.FileReader; import java.io.IOException; import java.io.StringReader; import java.io.StringWriter; import org.exolab.castor.mapping.Mapping; import org.exolab.castor.mapping.MappingException; import org.exolab.castor.xml.MarshalException; import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; import org.exolab.castor.xml.ValidationException; public class ValidationDriver { public static void main( String[] args ) { String filename = args[0]; try { Mapping myMap = new Mapping(); myMap.loadMapping( "po1Map.xml" ); Unmarshaller um1 = new Unmarshaller( myMap ); PurchaseOrder po1 = (PurchaseOrder)um1.unmarshal(new FileReader(filename)); StringWriter myWriter = new StringWriter(); Marshaller m1 = new Marshaller( myWriter ); m1.setMapping( myMap ); m1.setNamespaceMapping("", "http://www.example.com/PO1"); m1.setSchemaLocation("http://www.example.com/PO1 po1.xsd"); m1.marshal( po1 ); System.out.println( "Castor Output:" ); System.out.println( myWriter.getBuffer().toString() ); System.out.println( "" ); StringReader myReader = new StringReader(myWriter.getBuffer().toString()); PurchaseOrder po2 = (PurchaseOrder)um1.unmarshal( myReader ); System.out.println( "Comment from reconstructed class:" ); System.out.println( po2.comment ); } catch( IOException e ) { e.printStackTrace(); } catch( MarshalException e ) { e.printStackTrace(); } catch( ValidationException e ) { e.printStackTrace(); } catch( MappingException e ) { e.printStackTrace(); } } }

With Castor, Xerces, and Commons-Logging in the classpath, one can run this ValidationDriver and pass in an xml filename (valid-po1.xml or invalid-po1.xml). The invalid file will print out an exception stack trace that is due to a Xerces validation error. The valid xml should produce the roundtrip xml (that's xml->Java->xml), and the comment from the purchase order from the Java object (after it has gone xml->Java->xml->Java). Note that the xml is being validated against the schema each time it is going from xml->Java (though with this example there is no validation going from Java->xml). The extra round trips might seem excesive, but they helped me work out some kinks in my mapping file when I had to do this the first time.

castor-1.3.2.orig/src/xml-howto/how-to-prevent-collection-from-being-exposed.xml0000644000000000000000000000567111544322136024635 0ustar How to prevent a collection from being exposed by getters/setters General information about data encapsulation. Final How to prevent a collection from being exposed by getters/setters

Anyone who does not want to expose their collection fields.

Enumerations or iterators can be used to list all elements of a container without providing means of modifications (well, Iterators provide a remove method, but its up to the implementation if this method really does anything). Castor can use enumerations or iterators instead of a getter method to marshal a collection.

By using add methods collections can also be unmarshalled without a setter method.

Consider the following container object:

public class ObjectWithCollection { protected Vector strings = new Vector(); public void addString(String string) { strings.add(string); } public Iterator iterateStrings() { return strings.iterator(); } }

To provide better data encapsulation, only the addString() and iterateStrings() methods are made available publically, and as a result, the collection strings is not exposed via getters or setters.

The mapping file for above ObjectWithCollection - with the intention to instruct Castor to use the method iterateString() - looks as follows:

<mapping> <class name="ObjectWithContainer"> <field name="strings" type="string" collection="vector" get-method="iterateStrings" set-method="addString"/> </class> </mapping>

Please note that for this mechanism to work, the method returning an java.util.Iterator for your collection member has to start with the prefix iterate.

The same mechanism works for methods returning java.util.Enumeration as well. In this case, the method prefix needs to be enum, and the method specified needss to return java.util.Enumeration.

castor-1.3.2.orig/src/xml-howto/how-to-implement-custom-serializer.xml0000644000000000000000000001452211544322135022774 0ustar How to implement a custom XML serialier for Castor XML General information about implementing a custom XML Serializer for Castor XML Final How to implement a custom XML Serializer for Castor XML

Anyone who is using Castor XML for marshalling, and wants to implement a custom XML Serializer specific to the parser used.

This document addresses the basics to get people familiar with the main concepts and discusses some implementation details.

The example given implements the XML Serializer interface specific to WebLogic's XML parser (which happens to be an extension to Apache Xerces).

You should have downloaded the Castor sources and expanded them into a custom folder of yours.

Here is how to proceed.

To implement your custom XML serialization mechanism, you'll have to provide implementations of the following interfaces:

  • org.castor.exolab.xml.Serializer
  • org.castor.exolab.xml.OutputFormat

A possible implementation for Weblogic's (enhanced) Xerces implementation could look as follows.

package org.somewhere.custom; import java.io.IOException; import java.io.OutputStream; import java.io.Writer; import org.apache.xml.serialize.OutputFormat; import org.apache.xml.serialize.XMLSerializer; import org.xml.sax.DocumentHandler; public class XercesSerializer implements org.exolab.castor.xml.Serializer { private org.apache.xml.serialize.Serializer _serializer; public XercesSerializer() { _serializer = new XMLSerializer(); } public void setOutputCharStream(Writer out) { _serializer.setOutputCharStream(out); } public DocumentHandler asDocumentHandler() throws IOException { return _serializer.asDocumentHandler(); } public void setOutputFormat(org.exolab.castor.xml.OutputFormat format) { _serializer.setOutputFormat((OutputFormat) format.getFormat()); } public void setOutputByteStream(OutputStream output) { _serializer.setOutputByteStream(output); } } package org.somewhere.custom; import org.apache.xml.serialize.OutputFormat; import org.exolab.castor.util.Messages; public class XercesOutputFormat implements org.exolab.castor.xml.OutputFormat { private org.apache.xml.serialize.OutputFormat _outputFormat; public XercesOutputFormat() { _outputFormat = new org.apache.xml.serialize.OutputFormat(); } public void setMethod(String method) { _outputFormat.setMethod(method); } public void setIndenting(boolean indent) { _outputFormat.setIndenting(indent); } public void setPreserveSpace(boolean preserveSpace) { _outputFormat.setPreserveSpace(preserveSpace); } public Object getFormat() { return _outputFormat; } public void setDoctype (String type1, String type2) { _outputFormat.setDoctype(type1, type2); } public void setOmitXMLDeclaration(boolean omitXMLDeclaration) { _outputFormat.setOmitXMLDeclaration(omitXMLDeclaration); } public void setOmitDocumentType(boolean omitDocumentType) { _outputFormat.setOmitDocumentType(omitDocumentType); } public void setEncoding(String encoding) { _outputFormat.setEncoding(encoding); } }

In order to be able to use these custom implementations, you will have to provide a new custom org.castor.exolab.xml.XMLSerializerFactory instance and instruct Castor XML to start using it (instead of the default Xerces XML serializer factory).

The former can be achieved by providing a new implementation of the org.castor.exolab.xml.XMLSerializerFactory interface as follows:

package org.somewhere.custom; /** * Weblogic Xerces-specific implementation of the {@link XMLSerializerFactory} interface. * Returns Weblogic Xerces-specific instances of the {@link Serializer} and * {@link OutputFormat} interfaces. */ public class WeblogicXMLSerializerFactory implements XMLSerializerFactory { /** * @inheritDoc */ public Serializer getSerializer() { return new WeblogicSerializer(); } /** * @inheritDoc */ public OutputFormat getOutputFormat() { return new WeblogicOutputFormat(); } }

The latter can be achieved by pointing the org.exolab.castor.xml.serializer.factory property of the castor.properties to your new custom XMLSerializerFactory implementation as shown below:

# Defines the (default) XML serializer factory to use by Castor, # which must implement org.exolab.castor.xml.SerializerFactory; # default is org.exolab.castor.xml.XercesXMLSerializerFactory org.exolab.castor.xml.serializer.factory=org.somewhere.custom.WeblogicXMLSerializerFactory
castor-1.3.2.orig/src/xml-howto/how-to-unmarshal-raw-xml.xml0000644000000000000000000001065711544322135020707 0ustar How to Unmarshal raw XML segments into arbitrary types Final How to Unmarshal raw XML segments into arbitrary types

Anyone who wants to map raw XML segments into data types.

None.

Lets say you have an XML structure:

Data 1 Data 2 Regular String Data Misc xml to be dealt with later ]]>

And you want to save off portions of this XML in your objects, instead of having Castor map them immediately.

package bizobj; public class Root { private Object anyType; private String stringData; private String stringXML; public Object getAnyType() { return anyType; } public void setAnyType(Object anyType) { this.anyType = anyType; } public String getStringData() { return stringData; } public void setStringData(String stringData) { this.stringData = stringData; } public String getStringXML() { return stringXML; } public void setStringXML(String stringXML) { this.stringXML = stringXML; } }

There are two approaches that can be used for this. The first, approach would be to use the AnyNode type. The benefits of this approach is that you do not have to do anything special to get the data in the mapping file, and can both unmarshal and marshal the xml data. The drawback is that you have to call toString() on the object to get the XML.

The second approach is to use a custom FieldHandler implementation to convert the values. The benefit of this approach is that you are able to convert into any type you want. The drawback is that there is currently no way to marshal the xml data back into XML. It ends up as XML encoded data inside the marshalled XML.

Here is an example mapping file that includes both examples.

]]>

The anyType field is set to java.lang.Object. Behind the scenes it is actually an AnyType object.

Also, notice that the stringXML field is of type java.lang.Object. This is because Castor looks at that first to determine what type of parsing needs to be done, then passes it on to the Field Handler, which converts it into whatever is desired.

Here is an example Field Handler that converts the input into a string.

import org.exolab.castor.mapping.GeneralizedFieldHandler; public class MyHandler extends GeneralizedFieldHandler { public Object convertUponGet(Object value) { return (value == null) ? null : value.toString(); } public Object convertUponSet(Object value) { return (value == null) ? null : value.toString(); } public Class getFieldType() { return String.class; } }
castor-1.3.2.orig/src/xml-howto/how-to-map-hibernate-proxies.xml0000644000000000000000000001451011544322135021523 0ustar How to marshal Hibernate proxies Final How to marshal Hibernate proxies

Anyone who want’s to marshal Hibernate POJOs. This document shows how prevent undesirable XML output caused by Hibernate's lazy-loading technique.

A general understanding about the Hibernate persistence framework, its use of dynamic proxies for lazy-loading and Castor XML.

Assume that we have a Hibernate POJO named Person, which stores basic information about persons and set of Address objects. Address itself is another Hibernate POJO. This set of address objects is mapped in the Hibernate mapping file to load lazily, as shown below in the Hibernate mapping for the Person object:

<hibernate-mapping> <class name="xxx.yyy.Person" table="person"> <id name="id" type="integer"> <column name="id" length="10" /> <generator class="native" /> </id> <!-- Properties section --> <property name="firstName" type="string"> <column name="first_name" length="80" not-null="true" /> </property> <property name="lastName" type="string"> <column name="last_name" length="128" not-null="true" /> </property> <set name="Address" table="address" inverse="true" cascade="all-delete-orphan" lazy="true"> <key column="person_id" /> <one-to-many class="xxx.yyy.Address" /> </set> </class> </hibernate-mapping>

When we want to marshal a Person object to XML, we use a standard Castor XML mapping file to map the Person class to the desired XML layout.

]]>

As shown below, marshalling the Person instance produces undesirable XML output. This is because hibernate (or other ORM frameworks) use dynamic proxy classes for lazy-loading.

John Smith
street England xxx.yyy.Address street England
]]>

As Hibernate returns dynamic proxies for lazy-loaded objects, Castor won't be able to find a mapping for these (proxy) classes, and in this case fall back to using introspection. To avoid this behaviour, Castor XML during marshalling must be (en)able(d) to detect such proxy classes and handle them in a special way.

As proxy objects usually implement proxy interfaces, Castor XML can be instructed to check for such interfaces at marshal time, and marshal classes that implement these interfaces in a different way. Castor XML, in its castor.properties configuration file, allows you to enlist (proxy) interfaces that should be used for checking. The property org.exolab.castor.xml.proxyInterfaces can be used to specify whether or not to search for interfaces. If the property is set, the objects to be marshalled will be analysed if they implement one of the given interface names. If that's the case, the superclass will be marshalled instead of the proxy class itself.

org.exolab.castor.xml.proxyInterfaces = net.sf.cglib.proxy.Factory, org.hibernate.proxy.HibernateProxy

Setting this property as hown above now enables Castor XML to produce the desired output.

John Smith
street Engand
]]>
castor-1.3.2.orig/src/xml-howto/how-to-marshall-version-1.1-xml.xml0000644000000000000000000000440611544322135021704 0ustar How to marshal XML documents with version 1.1 Final How to marshal XML documents with version 1.1

Anyone who wants to use Castor XML for XML data binding, namely marshalling operations, and produce XML document instances that carry a the version 1.1 in the XML preamble.

Before release 1.3.2, Castor was able to produce XML documents upon marshalling that had the following XML preamble (if not omitted on purpose) only:

<?xml version="1.0" encoding="UTF-8"?> <foo/>

With the release of the XML document standard version 1.1, it was necessary to add an option to have the following preamble generated:

<?xml version="1.1" encoding="UTF-8"?> <foo/>

To make Castor output version 1.1 in the XML preamble as produced upon marshalling an object instance to XML, the org.exolab.castor.xml.version property has to be overriden in a custom, user-specific castor.properties> file.

org.exolab.castor.xml.version=1.1

Alternatively, you can set the property directly on the XMLContext instance using ...

XMLContext.setProperty(XMLProperties.XML_VERSION, "1.1");

before creating Marshaller instances from the XMLContext instance using XMLContext.createMarshaller().

castor-1.3.2.orig/src/xml-howto/how-to-use-a-binding-file-with-source-generation.xml0000644000000000000000000002636411544322136025272 0ustar How to use a binding file with source generation General information about using a binding file with source generation Final How to use a binding file with source generation

Anyone who wants to use a binding file with the Castor XML source generator. This document discusses various main concepts in the context of a non-trivial real word example, and intends to help people to get familiar with the basic concepts and discusses some implementation details.

The example given describes the steps required to build a binding file that helps users to overcome typical problems related to the use of more complex XML Schemas.

Two companies wish to trade with each other using a Supply Chain messaging system. This system sends and receives Purchase Orders and Order Receipt messages. After many months of discussion they have finally decided upon the structure of the Version 1.0 of their message XSD and both are presently developing solutions for it. One of the companies decides to use Java and Castor XML supprt for (un)marshalling and Castor's code generator to accelerate their development process.

<?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:element name="Data"> <xs:annotation> <xs:documentation>This section contains the supply chain message data</xs:documentation> </xs:annotation> <xs:complexType> <xs:choice> <xs:element name="PurchaseOrder"> <xs:complexType> <xs:sequence> <xs:element name="LineItem" type="LineItemType" maxOccurs="unbounded"/> </xs:sequence> <xs:attribute name="OrderNumber" type="xs:string" use="required"/> </xs:complexType> </xs:element> <xs:element name="OrderReceipt"> <xs:complexType> <xs:sequence> <xs:element name="LineItem" type="ReceiptLineItemType" maxOccurs="unbounded"/> </xs:sequence> <xs:attribute name="OrderNumber" type="xs:string" use="required"/> </xs:complexType> </xs:element> </xs:choice> </xs:complexType> </xs:element> <xs:complexType name="SkuType"> <xs:annotation> <xs:documentation>Contains Product Identifier</xs:documentation> </xs:annotation> <xs:sequence> <xs:element name="Number" type="xs:integer"/> <xs:element name="ID" type="xs:string"/> </xs:sequence> </xs:complexType> <xs:complexType name="ReceiptSkuType"> <xs:annotation> <xs:documentation>Contains Product Identifier</xs:documentation> </xs:annotation> <xs:complexContent> <xs:extension base="SkuType"> <xs:sequence> <xs:element name="InternalID" type="xs:string"/> </xs:sequence> </xs:extension> </xs:complexContent> </xs:complexType> <xs:complexType name="LineItemType"> <xs:sequence> <xs:element name="Sku" type="SkuType"/> <xs:element name="Value" type="xs:double"/> <xs:element name="BillingInstructions" type="xs:string"/> <xs:element name="DeliveryDate" type="xs:date"/> <xs:element name="Number" type="xs:integer"/> </xs:sequence> </xs:complexType> <xs:complexType name="ReceiptLineItemType"> <xs:sequence> <xs:element name="Sku" type="ReceiptSkuType"/> <xs:element name="Value" type="xs:double"/> <xs:element name="PackingDescription" type="xs:string"/> <xs:element name="ShipDate" type="xs:dateTime"/> <xs:element name="Number" type="xs:integer"/> </xs:sequence> </xs:complexType> </xs:schema>

If you run the Castor CodeGenerator on the above XSD you end up with the following set of classes. [You also get lots of warning messages with the present 0.99 version.]

Data.java DataDescriptor.java LineItem.java LineItemDescriptor.java LineItemType.java LineItemTypeDescriptor.java OrderReceipt.java OrderReceiptDescriptor.java PurchaseOrder.java PurchaseOrderDescriptor.java ReceiptLineItemType.java ReceiptLineItemTypeDescriptor.java ReceiptSkuType.java ReceiptSkuTypeDescriptor.java Sku.java SkuDescriptor.java SkuType.java SkuTypeDescriptor.java

The problem here is that there are two different elements with the same name in different locations in the XSD. This causes a java code generation conflict. Castor uses the element name as the name of the class. So the second class generated for the LineItem definition, which is different than the first, overwrites the first class generated.

A binding file is therefore necessary to help the Castor code generator differentiate between these generated classes. [i.e. You can 'bind' an element in the XSD to a differently named class file that you want to generate. Thus keeping different elements seperate]

The warning messages for Castor 0.99+ are very usefull in assisting you in your creation of the binding file. For the example the warning messages for the example are;
Warning: A class name generation conflict has occured between element '/Data/OrderReceipt/LineItem' and element '/Data/PurchaseOrder/LineItem'. Please use a Binding file to solve this problem.Continue anyway [not recommended] (y|n|?)y
Warning: A class name generation conflict has occured between element '/Data/OrderReceipt/LineItem' and element '/Data/PurchaseOrder/LineItem'. Please use a Binding file to solve this problem.Continue anyway [not recommended] (y|n|?)y
Warning: A class name generation conflict has occured between element '/Data/OrderReceipt/LineItem' and element '/Data/PurchaseOrder/LineItem'. Please use a Binding file to solve this problem.Continue anyway [not recommended] (y|n|?)y
Warning: A class name generation conflict has occured between element 'complexType:ReceiptLineItemType/Sku' and element 'complexType:LineItemType/Sku'. Please use a Binding file to solve this problem.Continue anyway [not recommended] (y|n|?)y
Warning: A class name generation conflict has occured between element 'complexType:ReceiptLineItemType/Sku' and element 'complexType:LineItemType/Sku'. Please use a Binding file to solve this problem.Continue anyway [not recommended] (y|n|?)y
Warning: A class name generation conflict has occured between element 'complexType:ReceiptLineItemType/Sku' and element 'complexType:LineItemType/Sku'. Please use a Binding file to solve this problem.Continue anyway [not recommended] (y|n|?)y

The following binding file definition will overcome the naming issues for the generated classes.

<binding xmlns="http://www.castor.org/SourceGenerator/Binding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.castor.org/SourceGenerator/Binding C:\\Castor\\xsd\\binding.xsd" defaultBinding="element"> <elementBinding name="/Data/PurchaseOrder/LineItem"> <java-class name="PurchaseOrderLineItem"/> </elementBinding> <elementBinding name="/Data/OrderReceipt/LineItem"> <java-class name="OrderReceiptLineItem"/> </elementBinding> <elementBinding name="/complexType:ReceiptLineItemType/Sku"> <java-class name="OrderReceiptSku"/> </elementBinding> <elementBinding name="/complexType:LineItemType/Sku"> <java-class name="PurchaseOrderSku"/> </elementBinding> </binding>

Things to notice in the above binding.xml file are that the name path used is relative to the root of the XSD NOT the root of the target XML. Also notice that the two complex types have the "complexType:" prefix to identify them, and then the name path relative to the root of the XSD.

The new list of generated classes is:

Data.java DataDescriptor.java LineItem.java LineItemDescriptor.java LineItemType.java LineItemTypeDescriptor.java OrderReceipt.java OrderReceiptDescriptor.java OrderReceiptLineItem.java OrderReceiptLineItemDescriptor.java OrderReceiptSku.java OrderReceiptSkuDescriptor.java PurchaseOrder.java PurchaseOrderDescriptor.java PurchaseOrderLineItem.java PurchaseOrderLineItemDescriptor.java PurchaseOrderSku.java PurchaseOrderSkuDescriptor.java ReceiptLineItemType.java ReceiptLineItemTypeDescriptor.java ReceiptSkuType.java ReceiptSkuTypeDescriptor.java Sku.java SkuDescriptor.java SkuType.java SkuTypeDescriptor.java

The developers can now use these generated classes with Castor to (un)marshal the supply chain messages sent by their business partner.

castor-1.3.2.orig/src/xml-howto/how-to-use-xmlcontext.xml0000644000000000000000000001136011544322136020320 0ustar How to use Castor's XMLContext for un-/marshalling Final How to use Castor's XMLContext for un-/marshalling

Anyone who wants to use Castor XML for XML data binding, namely marshalling and unmarshalling operations.

You should have downloaded the Castor binaries or included Castor as a dependency in a Maven project.

For the purpose of showcasing the use of the XMLContext class, let's assume we have a simple Person class as follows:

import java.util.Date; /** An simple person class */ public class Person implements java.io.Serializable { /** The name of the person */ private String name = null; /** The Date of birth */ private Date dob = null; /** Creates a Person with no name */ public Person() { super(); } /** Creates a Person with the given name */ public Person(String name) { this.name = name; } /** * @return date of birth of the person */ public Date getDateOfBirth() { return dob; } /** * @return name of the person */ public String getName() { return name; } /** * Sets the date of birth of the person * @param name the name of the person */ public void setDateOfBirth(Date dob) { this.dob = dob; } /** * Sets the name of the person * @param name the name of the person */ public void setName(String name) { this.name = name; } }

Starting with Castor 1.1.2, the XMLContext class provides a bootstrap mechanism for Castor XML, and allows easy (and efficient) instantiation of Marshaller and Unmarshaller instances, which can be used to perform basic XML data binding operations.

Below is a code sample that shows how to use the XMLContext class for umarshalling a Person instance using an Unmarshaller. In this example, a mapping file is used.

import org.exolab.castor.xml.XMLContext; import org.exolab.castor.mapping.Mapping; import org.exolab.castor.xml.Unmarshaller; //create a Mapping instance Mapping mapping = XMLContext.createMapping(); mapping.loadMapping("mapping.xml"); // create an XMLContext instance and set mapping XMLContext context = new XMLContext(); context.addMapping(mapping); // create a new Unmarshaller Unmarshaller unmarshaller = context.createUnmarshaller(); unmarshaller.setClass(Person.class); // Create a Reader to the file to unmarshal from Reader reader = new FileReader("test.xml"); // Unmarshal the person object Person person = (Person) unmarshaller.unmarshal(reader);

As shown above, the XMLContext class offers various factory methods to obtain a new Marshaller, Unmarshaller or Mapping instance.

When you need more than one Unmarshaller instance in your application, please call createUnmarshaller as required. As all Unmarshaller instances are created from the very same XMLContext instance, overhead will be minimal. Please note, though, that an Unmarshaller instance is not thread-safe.

castor-1.3.2.orig/src/xml-howto/how-to-use-references-in-xml.xml0000644000000000000000000001472111544322135021441 0ustar How to use references in XML and Castor Describes how to use references to save space and create appropriate object relations in XML. Final How to use references in XML and Castor

Anyone who wants to model non-hierarchical object relations in XML using Castor.

This document helps people to get familiar with the basic concepts and discusses some implementation details.

None.

As a motivating example for this HOW-To, consider a graph consisting of nodes and branches. For this example we're going to take a node-centric view of the graph, so each node is a Java object that contains a list of other nodes it is connected to (thus modeling the branches). The node class might look like:

import java.util.List; public class Node { protected int nodeNum; protected List siblings; /* ... business fields ... */ public Node() {}; public Node( int nodeNum, List siblings ) { this.nodeNum = nodeNum; this.siblings = siblings; } public int getNodeNum() { return nodeNum; } public void setNodeNum( int nodeNum ) { this.nodeNum = nodeNum; } public List getSiblings() { return siblings; } public void setSiblings( List siblings ) { this.siblings = siblings; } /* ... business logic ... */ }

The default marshalling behavior in Castor is to create a new element for each object contained by the object being marshalled. For a lot of applications this is acceptable as the Java object model being marshalled is hierarchical. The same goes for unmarshalling but in the opposite direction; i.e. a new object is created for each element in the XML.

Now consider the graph example above. If that model is marshalled or unmarshalled with the default behavior, all the relations between the nodes will be broken. Even using a mapping file like the one below won't help.

]]>

After unmarshalling each Node object will contain a list of siblings, but those siblings will be specific to that Node. They may be populated with the right data (nodeNum etc.) to begin with, but any changes won't propogate to the other nodes.

Enter identities and references -- using a mapping file, it is possible to tell Castor how to identify specific instances of a class and when to simply reference an object rather than create a new one. In the example above, assume nodeNum is unique across all nodes and thus can be used to identify each node individually. Once an identity is defined it is possible to instruct Castor to only reference instances of the class rather than creating new objects.

For the graph example above, the correct mapping file would look like this:

identity="nodeNum"> reference="true" ]]>

The key attributes in the mapping file are identity in the class element, and reference in the bind-xml element. When reference is set to true, Castor knows to create only a reference to the object rather than a full object. This accomplishes two things: first, it reduces the size of the XML file created during marshalling because each object is completely written out only once, and two, on unmarshal, the objects will maintain the correct relations to each other.

Marshalling an ArrayList of these Node objects then looks like:

2 3 1 3 1 2 ]]>
castor-1.3.2.orig/src/xml-howto/how-to-map-a-class-with-constructors.xml0000644000000000000000000000453711544322136023146 0ustar How to map a classcollection of elements Final How to map field(s) as constructor argument

Anyone who wants to map a class in Castor XML and wants to map fields as constructor arguments.

This document helps people to get familiar with the basic/advanced concepts of mapping and shows an example.

None.

Assume you have a class Foo, as shown below

public class Foo { private int size = 20; public Foo() { } public Foo(int size) { this.size = size; } public int getSize() { return size; } public void setSize(int size) { this.size = size; } }

As shown above, the Foo class has - in addition to the default constructor, which is required by Castor XML - a second constructor that allows you to specify a custom size at object initialization.

Here's the mapping file to instruct Castor XML about the existence of Foo respectively:

<?xml version="1.0"?> <mapping> <class name="Foo"> <field name="size" get-method="getSize" set-method="%1" type="int"> <bind-xml node="attribute"/> </field> </class> </mapping>

The setMethod="%1" fragment above tells Castor to use the size attribute as a constructor argument when calling Foo(int) during instantiation.

castor-1.3.2.orig/src/xml-howto/how-to-fetch-dtds-and-schemas-from-jars.xml0000644000000000000000000002101511544322136023423 0ustar How to fetch DTDs and XML Schemas from JAR files using Castor Introduction to using an EntityResolver to fetch XML dependencies from JAR files rather than the network. Final How to fetch DTDs and XML Schemas from JAR files using Castor

Anyone who wants to retrieve DTDs and/or schemas from a local JAR file rather than the network.

This document helps people to get familiar with the basic concepts and discusses some implementation details.

None. All the required files reside in the Castor JAR, but what version of Castor you have will determine the public/system IDs are recognized by the DTDResolver.

XML files often reference other files. The most common dependencies are either document type definitions (DTDs) from the DOCTYPE declaration or XML Schemas from the schemaLocation attribute.

Parsers usually only request schemas for validation, but more parsers are now requesting the DTDs whether validation is on or off. This allows the parser to resolve any entity references (i.e. &amp; or &lt;) that might be used in the document and defined in the DTD. This behavior can cause problems for machines with limited network connectivity, and in certain situations it is simply undesirable to have the parser going to the internet for each dependency.

The org.xml.sax.EntityResolver interface is the key to retrieving XML dependencies from locations other than the defined system location. The interface has one method:

public InputSource resolveEntity( String publicId, String systemId ) throws SAXException, IOException

During parsing, before it attempts to retrieve any external files, the parser will call the above method, giving the public and/or system ID for the file. The implementing object can then either return an InputSource through which the parser can access the file, or null if the parser should fetch the file via normal channels.

In Castor, the org.exolab.castor.util.DTDResolver class provides an implementation of EntityResolver that is designed to fetch all the Castor dependencies from the Castor JAR file. This includes:

  • Mapping file DTD
  • Mapping file schema
  • JDOConf DTD
  • JDOConf schema
  • XML Schema Part 1: Structures DTD
  • XML Schema Part 1: Structures schema
  • XML Schema Part 2: Datatypes DTD

Castor automatically uses a DTDResolver when loading a mapping file, but must be told to use one during unmarshalling:

public static void main( String[] args ) { String filename = args[0]; try { Mapping mapping = new Mapping(); // Castor will internally create and use a DTDResolver here mapping.loadMapping( "fooMap.xml" ); Unmarshaller um1 = new Unmarshaller( mapping ); // Castor needs to be told to use a DTDResolver here um1.setEntityResolver( new DTDResolver() ); Foo foo = (foo)um1.unmarshal(new FileReader(filename)); } catch( IOException e ) { e.printStackTrace(); } catch( MappingException e ) { e.printStackTrace(); } }

The DTDResolver can also wrap another EntityResolver to allow resolver chaining. DTDResolver calls the nested EntityResolver before attempting to resolve the ID(s) itself.

For the DTDResolver to retrieve the desired file from the Castor JAR, either the public ID or the system ID must match exactly. Below are lists of public and system IDs for the versions of Castor, but when in doubt, check the code of DTDResolver.

Since Castor v0.9.9.1 the following IDs are preferred:

Mapping DTD
Public: -//EXOLAB/Castor Mapping DTD Version 1.0//EN
System: http://castor.org/mapping.dtd
Mapping Schema
Public: -//EXOLAB/Castor Mapping Schema Version 1.0//EN
System: http://castor.org/mapping.xsd
JDO Configuration DTD
Public: -//EXOLAB/Castor JDO Configuration DTD Version 1.0//EN
System: http://castor.org/jdo-conf.dtd
JDO Configuration Schema
Public: -//EXOLAB/Castor JDO Configuration Schema Version 1.0//EN
System: http://castor.org/jdo-conf.xsd
XML Schema Part 1: Structures DTD
Public: -//W3C//DTD XMLSCHEMA 19991216//EN
System: http://www.w3.org/TR/2000/WD-xmlschema-1-20000225/structures.dtd
XML Schema Part 1: Structures Schema
System: http://www.w3.org/TR/2000/WD-xmlschema-1-20000225/structures.xsd
XML Schema Part 2: Datatypes DTD
System: http://www.w3.org/TR/2000/WD-xmlschema-2-20000225/datatypes.dtd

For older distributions, the following IDs have been accepted since Castor v0.9.5:

Mapping DTD
Public: -//EXOLAB/Castor Mapping DTD Version 1.0//EN
System: http://castor.exolab.org/mapping.dtd
Mapping Schema
Public: -//EXOLAB/Castor Mapping Schema Version 1.0//EN
System: http://castor.exolab.org/mapping.xsd
JDO Configuration DTD
Public: -//EXOLAB/Castor JDO Configuration DTD Version 1.0//EN
System: http://castor.exolab.org/jdo-conf.dtd
JDO Configuration Schema
Public: -//EXOLAB/Castor JDO Configuration Schema Version 1.0//EN
System: http://castor.exolab.org/jdo-conf.xsd
XML Schema Part 1: Structures DTD
Public: -//W3C//DTD XMLSCHEMA 19991216//EN
System: http://www.w3.org/TR/2000/WD-xmlschema-1-20000225/structures.dtd
XML Schema Part 1: Structures Schema
System: http://www.w3.org/TR/2000/WD-xmlschema-1-20000225/structures.xsd
XML Schema Part 2: Datatypes DTD
System: http://www.w3.org/TR/2000/WD-xmlschema-2-20000225/datatypes.dtd

castor-1.3.2.orig/src/test/0000755000000000000000000000000011544322135012403 5ustar castor-1.3.2.orig/src/test/java/0000755000000000000000000000000011544322135013324 5ustar castor-1.3.2.orig/src/test/java/org/0000755000000000000000000000000011544322135014113 5ustar castor-1.3.2.orig/src/test/java/org/exolab/0000755000000000000000000000000011544322135015365 5ustar castor-1.3.2.orig/src/test/java/org/exolab/castor/0000755000000000000000000000000011544322136016661 5ustar castor-1.3.2.orig/src/test/java/org/exolab/castor/util/0000755000000000000000000000000011656245645017653 5ustar castor-1.3.2.orig/src/test/java/org/exolab/castor/util/TestDTDResolver.java0000644000000000000000000000435711544322136023507 0ustar /* * Copyright 2005 Werner Guttmann * * Licensed under the Apache License, Version 2.0 (the "License"); * 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 "AS IS" 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. */ package org.exolab.castor.util; import junit.framework.TestCase; import org.xml.sax.InputSource; public class TestDTDResolver extends TestCase { /** * Castor-specific EntityResolver to test. */ private DTDResolver _entityResolver; protected void setUp() throws Exception { super.setUp(); _entityResolver = new DTDResolver(); } private void testSystemId(final String systemId) throws Exception { InputSource inputSource = _entityResolver.resolveEntity(null, systemId); assertNotNull(inputSource); assertEquals(systemId, inputSource.getSystemId()); } public void testMappingDTD() throws Exception { testSystemId("http://castor.org/mapping.dtd"); } public void testMappingDTDOld() throws Exception { testSystemId("http://castor.exolab.org/mapping.dtd"); } public void testJDODTD() throws Exception { testSystemId("http://castor.org/jdo-conf.dtd"); } public void testJdoDTDOld() throws Exception { testSystemId("http://castor.exolab.org/jdo-conf.dtd"); } public void testMappingXSD() throws Exception { testSystemId("http://castor.org/mapping.xsd"); } public void testMappingXSDOld() throws Exception { testSystemId("http://castor.exolab.org/mapping.xsd"); } public void testJDOXSD() throws Exception { testSystemId("http://castor.org/jdo-conf.xsd"); } public void testJdoXSDOld() throws Exception { testSystemId("http://castor.exolab.org/jdo-conf.xsd"); } } castor-1.3.2.orig/src/test/java/org/exolab/castor/xml/0000755000000000000000000000000011656245645017476 5ustar castor-1.3.2.orig/src/test/java/org/exolab/castor/xml/UnmarshalFranz.java0000644000000000000000000000177211544322135023265 0ustar /* * Copyright 2007 Joachim Grueneis * * Licensed under the Apache License, Version 2.0 (the "License"); * 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 "AS IS" 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. */ package org.exolab.castor.xml; /** * A class for simple Unmarshal tests. * * @author Joachim Grueneis, jgrueneis_at_gmail_dot_com * @version $Id$ */ public class UnmarshalFranz { private String _content; public UnmarshalFranz() { super(); } public void setContent(String content) { _content = content; } public String getContent() { return _content; } }castor-1.3.2.orig/src/test/java/org/exolab/castor/xml/XMLContextTest.java0000644000000000000000000000641311544322135023174 0ustar package org.exolab.castor.xml; import junit.framework.TestCase; import org.castor.test.entity.Entity; import org.castor.xml.AbstractInternalContext; import org.exolab.castor.mapping.Mapping; import org.xml.sax.InputSource; public class XMLContextTest extends TestCase { private static final String MAPPING_FILE = "org/castor/test/entity/mapping.xml"; /** * Test {@link AbstractInternalContext} by providing a generated package. * @throws Exception */ public void testXMLContextByPackage() throws Exception { XMLContext context = new XMLContext(); context.addPackage("org.castor.test.entity"); assertNotNull (context); Unmarshaller unmarshaller = context.createUnmarshaller(); assertNotNull(unmarshaller); unmarshaller.setClass(Entity.class); String resource = getResource("org/castor/test/entity/input.xml"); InputSource source = new InputSource(resource); Entity entity = (Entity) unmarshaller.unmarshal(source); assertNotNull(entity); } /** * Test XMLContext with a mapping file. * @throws Exception */ public void testXMLContextByMapping() throws Exception { XMLContext xmlContext = new XMLContext(); Mapping mapping = xmlContext.createMapping(); mapping.loadMapping(new InputSource(getResource(MAPPING_FILE))); xmlContext.addMapping(mapping); Unmarshaller unmarshaller = xmlContext.createUnmarshaller(); assertNotNull(unmarshaller); unmarshaller.setClass(Entity.class); String resource = getResource("org/castor/test/entity/input.xml"); InputSource source = new InputSource(resource); Entity entity = (Entity) unmarshaller.unmarshal(source); assertNotNull(entity); } // public void testGetDescriptor() throws Exception { // Mapping mapping = XMLContext.createMapping(); // mapping.loadMapping(new InputSource(getResource(MAPPING_FILE))); // // XMLContext context = XMLContext.newInstance(); // context.addMapping(mapping); // assertNotNull (context); // // XMLClassDescriptor descriptor = context.getDescriptor(Entity.class); // assertNotNull(descriptor); // assertEquals(Entity.class, descriptor.getJavaClass()); // // } // // public void testGetMissingDescriptor() throws Exception { // Mapping mapping = XMLContext.createMapping(); // mapping.loadMapping(new InputSource(getResource(MAPPING_FILE))); // // XMLContext context = XMLContext.newInstance(); // context.addMapping(mapping); // assertNotNull (context); // // XMLClassDescriptor descriptor = context.getDescriptor(EntitySecond.class); // assertNull(descriptor); // } // /** * Returns absolute path for resource. * @param resource Relative path to resource * * @return Absolute path to resource. */ private String getResource(final String resource) { ClassLoader loader = getClass().getClassLoader(); return loader.getResource(resource).toExternalForm(); } } castor-1.3.2.orig/src/test/java/org/exolab/castor/xml/TestUnmarshaller.java0000644000000000000000000002755111544322135023632 0ustar /* * Copyright 2007 Werner Guttmann * * Licensed under the Apache License, Version 2.0 (the "License"); * 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 "AS IS" 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. */ package org.exolab.castor.xml; import java.io.Reader; import java.io.StringReader; import junit.framework.Assert; import junit.framework.TestCase; import org.castor.xml.InternalContext; import org.castor.xml.XMLConfiguration; /** * Test case for testing various pieces of functionality of {@link Unmarshaller}. */ public class TestUnmarshaller extends TestCase { private static final String testXML = ""; private Reader _reader; private InternalContext _internalContext; /** * The Unmarshaller tests need an internal context and an input reader. * @see junit.framework.TestCase#setUp() */ public void setUp() { XMLContext xmlContext = new XMLContext(); _internalContext = xmlContext.getInternalContext(); _reader = new StringReader(testXML); } /** * Closing the reader. * @see junit.framework.TestCase#tearDown() */ public void tearDown() throws Exception { _reader.close(); _reader = null; } /** * Tests usage of get-/setProperty() methods. */ public void testSetProperty() { XMLContext xmlContext = new XMLContext(); Unmarshaller unmarshaller = xmlContext.createUnmarshaller(); assertNotNull(unmarshaller); String lenientSequenceValidation = unmarshaller.getProperty(XMLConfiguration.LENIENT_SEQUENCE_ORDER); assertNotNull(lenientSequenceValidation); assertEquals("false", lenientSequenceValidation); unmarshaller.setProperty(XMLConfiguration.LENIENT_SEQUENCE_ORDER, "true"); lenientSequenceValidation = unmarshaller.getProperty(XMLConfiguration.LENIENT_SEQUENCE_ORDER); assertNotNull(lenientSequenceValidation); assertEquals("true", lenientSequenceValidation); } /** * Creates an Unmarshaller instance without any argument; sets the * root class and calls unmarshal. * @throws Exception in case of unmarshal problems */ public void testUnmarshallerNoArgs() throws Exception { Unmarshaller u = new Unmarshaller(); u.setClass(UnmarshalFranz.class); UnmarshalFranz f = (UnmarshalFranz)u.unmarshal(_reader); Assert.assertNotNull(f); Assert.assertEquals("Bla Bla Bla", f.getContent()); } /** * Creates an Unmarshaller instance without any argument; sets the * root object and calls unmarshal. * @throws Exception in case of unmarshal problems */ public void testUnmarshallerNoArgs2() throws Exception { Unmarshaller u = new Unmarshaller(); u.setObject(new UnmarshalFranz()); UnmarshalFranz f = (UnmarshalFranz)u.unmarshal(_reader); Assert.assertNotNull(f); Assert.assertEquals("Bla Bla Bla", f.getContent()); } /** * Creates an Unmarshaller instance with root class * and calls unmarshal. * @throws Exception in case of unmarshal problems */ public void testUnmarshallerClassArg() throws Exception { Unmarshaller u = new Unmarshaller(UnmarshalFranz.class); UnmarshalFranz f = (UnmarshalFranz)u.unmarshal(_reader); Assert.assertNotNull(f); Assert.assertEquals("Bla Bla Bla", f.getContent()); } /** * Creates an Unmarshaller instance with root class * and calls unmarshal. * @throws Exception in case of unmarshal problems */ public void testUnmarshallerClassArgNull() throws Exception { Unmarshaller u = new Unmarshaller((Class)null); u.setClass(UnmarshalFranz.class); UnmarshalFranz f = (UnmarshalFranz)u.unmarshal(_reader); Assert.assertNotNull(f); Assert.assertEquals("Bla Bla Bla", f.getContent()); } /** * Creates an Unmarshaller instance with context only; * sets root class and calls unmarshal. * @throws Exception in case of unmarshal problems */ public void testUnmarshallerCtxArg() throws Exception { Unmarshaller u = new Unmarshaller(_internalContext); u.setClass(UnmarshalFranz.class); UnmarshalFranz f = (UnmarshalFranz)u.unmarshal(_reader); Assert.assertNotNull(f); Assert.assertEquals("Bla Bla Bla", f.getContent()); } /** * Creates an Unmarshaller instance with context only; * sets root class and calls unmarshal. * @throws Exception in case of unmarshal problems */ public void testUnmarshallerCtxArgNull() throws Exception { try { new Unmarshaller((InternalContext)null); Assert.fail("It must not be possible to instantiate Unmarshaller with internalContext == null"); } catch (IllegalArgumentException e) { // expected! } } /** * Creates an Unmarshaller instance with context and root class * and calls unmarshal. * @throws Exception in case of unmarshal problems */ public void testUnmarshallerCtxClassArg() throws Exception { Unmarshaller u = new Unmarshaller(_internalContext, UnmarshalFranz.class); UnmarshalFranz f = (UnmarshalFranz)u.unmarshal(_reader); Assert.assertNotNull(f); Assert.assertEquals("Bla Bla Bla", f.getContent()); } /** * Creates an Unmarshaller instance with context and root class * and calls unmarshal. * @throws Exception in case of unmarshal problems */ public void testUnmarshallerCtxClassArgNullNull() throws Exception { try { new Unmarshaller((InternalContext)null, (Class)null); Assert.fail("It must not be possible to instantiate Unmarshaller with internalContext == null"); } catch (IllegalArgumentException e) { // expected! } } /** * Creates an Unmarshaller instance with context and root class * and calls unmarshal. * @throws Exception in case of unmarshal problems */ public void testUnmarshallerCtxClassArgNull() throws Exception { Unmarshaller u = new Unmarshaller(_internalContext, (Class)null); u.setClass(UnmarshalFranz.class); UnmarshalFranz f = (UnmarshalFranz)u.unmarshal(_reader); Assert.assertNotNull(f); Assert.assertEquals("Bla Bla Bla", f.getContent()); } /** * Creates an Unmarshaller instance with context, class and class loader * arguments and calls unmarshal. * @throws Exception in case of unmarshal problems */ public void testUnmarshallerCtxClassClassloaderArg() throws Exception { Unmarshaller u = new Unmarshaller(_internalContext, UnmarshalFranz.class, UnmarshalFranz.class.getClassLoader()); UnmarshalFranz f = (UnmarshalFranz)u.unmarshal(_reader); Assert.assertNotNull(f); Assert.assertEquals("Bla Bla Bla", f.getContent()); } /** * Creates an Unmarshaller instance with context, class and class loader * arguments and calls unmarshal. * @throws Exception in case of unmarshal problems */ public void testUnmarshallerCtxClassClassloaderArgNullNullNull() throws Exception { try { new Unmarshaller((InternalContext)null, (Class)null, (ClassLoader)null); Assert.fail("It must not be possible to instantiate Unmarshaller with internalContext == null"); } catch (IllegalArgumentException e) { // expected! } } /** * Creates an Unmarshaller instance with context, class and class loader * arguments and calls unmarshal. * @throws Exception in case of unmarshal problems */ public void testUnmarshallerCtxClassClassloaderArgNullNull() throws Exception { Unmarshaller u = new Unmarshaller(_internalContext, (Class)null, (ClassLoader)null); u.setClass(UnmarshalFranz.class); UnmarshalFranz f = (UnmarshalFranz)u.unmarshal(_reader); Assert.assertNotNull(f); Assert.assertEquals("Bla Bla Bla", f.getContent()); } /** * Creates an Unmarshaller instance with context, class and class loader * arguments and calls unmarshal. * @throws Exception in case of unmarshal problems */ public void testUnmarshallerCtxClassClassloaderArgNull() throws Exception { Unmarshaller u = new Unmarshaller(_internalContext, UnmarshalFranz.class, (ClassLoader)null); u.setClass(UnmarshalFranz.class); UnmarshalFranz f = (UnmarshalFranz)u.unmarshal(_reader); Assert.assertNotNull(f); Assert.assertEquals("Bla Bla Bla", f.getContent()); } /** * Creates an Unmarshaller instance with an root object instance * and calls unmarshal. * @throws Exception in case of unmarshal problems */ public void testUnmarshallerObjectArg() throws Exception { Unmarshaller u = new Unmarshaller(new UnmarshalFranz()); UnmarshalFranz f = (UnmarshalFranz)u.unmarshal(_reader); Assert.assertNotNull(f); Assert.assertEquals("Bla Bla Bla", f.getContent()); } /** * Creates an Unmarshaller instance with an root object instance * and calls unmarshal. * @throws Exception in case of unmarshal problems */ public void testUnmarshallerObjectArgNull() throws Exception { Unmarshaller u = new Unmarshaller((Object)null); u.setObject(new UnmarshalFranz()); UnmarshalFranz f = (UnmarshalFranz)u.unmarshal(_reader); Assert.assertNotNull(f); Assert.assertEquals("Bla Bla Bla", f.getContent()); } /** * Creates an Unmarshaller instance withcontext and an object instance argument * and calls unmarshal. * @throws Exception in case of unmarshal problems */ public void testUnmarshallerCtxObjectArg() throws Exception { Unmarshaller u = new Unmarshaller(_internalContext, new UnmarshalFranz()); UnmarshalFranz f = (UnmarshalFranz)u.unmarshal(_reader); Assert.assertNotNull(f); Assert.assertEquals("Bla Bla Bla", f.getContent()); } /** * Creates an Unmarshaller instance withcontext and an object instance argument * and calls unmarshal. * @throws Exception in case of unmarshal problems */ public void testUnmarshallerCtxObjectArgNullNull() throws Exception { try { new Unmarshaller((InternalContext)null, (Object)null); Assert.fail("It must not be possible to instantiate Unmarshaller with internalContext == null"); } catch (IllegalArgumentException e) { // expected! } } /** * Creates an Unmarshaller instance withcontext and an object instance argument * and calls unmarshal. * @throws Exception in case of unmarshal problems */ public void testUnmarshallerCtxObjectArgNull() throws Exception { Unmarshaller u = new Unmarshaller(_internalContext, (Object)null); u.setObject(new UnmarshalFranz()); UnmarshalFranz f = (UnmarshalFranz)u.unmarshal(_reader); Assert.assertNotNull(f); Assert.assertEquals("Bla Bla Bla", f.getContent()); } } castor-1.3.2.orig/src/test/java/org/castor/0000755000000000000000000000000011656245645015424 5ustar castor-1.3.2.orig/src/test/java/org/castor/test/0000755000000000000000000000000011544322135016365 5ustar castor-1.3.2.orig/src/test/java/org/castor/test/entity/0000755000000000000000000000000011656245645017717 5ustar castor-1.3.2.orig/src/test/java/org/castor/test/entity/Entity.java0000644000000000000000000000312111544322135022015 0ustar /* * Copyright 2007 Werner Guttmann * * Licensed under the Apache License, Version 2.0 (the "License"); * 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 "AS IS" 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. */ package org.castor.test.entity; /** * Domain entity for XMLContext JUnit test case. * * @author Werner Guttmann * @since 1.1.2 */ public class Entity { /** * Unique identifier. */ private int _id; /** * Entity name. */ private String _name; /** * Retrusn the unique identifier. * @return the unique identifier. */ public int getId() { return _id; } /** * Sets a new unique identifier. * @param id a new unique identifier. */ public void setId(final int id) { this._id = id; } /** * Retrusn the entity name. * @return the entity name. */ public String getName() { return _name; } /** * Sets a new entity name. * @param _id a new entity name. */ public void setName(final String name) { this._name = name; } } castor-1.3.2.orig/src/test/java/org/castor/util/0000755000000000000000000000000011656245645016401 5ustar castor-1.3.2.orig/src/test/java/org/castor/util/TestBase64Decoder.java0000644000000000000000000001133611544322135022404 0ustar /* * Copyright 2005 Ralf Joachim * * Licensed under the Apache License, Version 2.0 (the "License"); * 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 "AS IS" 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. */ package org.castor.util; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; public final class TestBase64Decoder extends TestCase { private static final String[] MAP = { "AA==", "AQ==", "Ag==", "Aw==", "BA==", "BQ==", "Bg==", "Bw==", "CA==", "CQ==", "Cg==", "Cw==", "DA==", "DQ==", "Dg==", "Dw==", "EA==", "EQ==", "Eg==", "Ew==", "FA==", "FQ==", "Fg==", "Fw==", "GA==", "GQ==", "Gg==", "Gw==", "HA==", "HQ==", "Hg==", "Hw==", "IA==", "IQ==", "Ig==", "Iw==", "JA==", "JQ==", "Jg==", "Jw==", "KA==", "KQ==", "Kg==", "Kw==", "LA==", "LQ==", "Lg==", "Lw==", "MA==", "MQ==", "Mg==", "Mw==", "NA==", "NQ==", "Ng==", "Nw==", "OA==", "OQ==", "Og==", "Ow==", "PA==", "PQ==", "Pg==", "Pw==", "QA==", "QQ==", "Qg==", "Qw==", "RA==", "RQ==", "Rg==", "Rw==", "SA==", "SQ==", "Sg==", "Sw==", "TA==", "TQ==", "Tg==", "Tw==", "UA==", "UQ==", "Ug==", "Uw==", "VA==", "VQ==", "Vg==", "Vw==", "WA==", "WQ==", "Wg==", "Ww==", "XA==", "XQ==", "Xg==", "Xw==", "YA==", "YQ==", "Yg==", "Yw==", "ZA==", "ZQ==", "Zg==", "Zw==", "aA==", "aQ==", "ag==", "aw==", "bA==", "bQ==", "bg==", "bw==", "cA==", "cQ==", "cg==", "cw==", "dA==", "dQ==", "dg==", "dw==", "eA==", "eQ==", "eg==", "ew==", "fA==", "fQ==", "fg==", "fw==", "gA==", "gQ==", "gg==", "gw==", "hA==", "hQ==", "hg==", "hw==", "iA==", "iQ==", "ig==", "iw==", "jA==", "jQ==", "jg==", "jw==", "kA==", "kQ==", "kg==", "kw==", "lA==", "lQ==", "lg==", "lw==", "mA==", "mQ==", "mg==", "mw==", "nA==", "nQ==", "ng==", "nw==", "oA==", "oQ==", "og==", "ow==", "pA==", "pQ==", "pg==", "pw==", "qA==", "qQ==", "qg==", "qw==", "rA==", "rQ==", "rg==", "rw==", "sA==", "sQ==", "sg==", "sw==", "tA==", "tQ==", "tg==", "tw==", "uA==", "uQ==", "ug==", "uw==", "vA==", "vQ==", "vg==", "vw==", "wA==", "wQ==", "wg==", "ww==", "xA==", "xQ==", "xg==", "xw==", "yA==", "yQ==", "yg==", "yw==", "zA==", "zQ==", "zg==", "zw==", "0A==", "0Q==", "0g==", "0w==", "1A==", "1Q==", "1g==", "1w==", "2A==", "2Q==", "2g==", "2w==", "3A==", "3Q==", "3g==", "3w==", "4A==", "4Q==", "4g==", "4w==", "5A==", "5Q==", "5g==", "5w==", "6A==", "6Q==", "6g==", "6w==", "7A==", "7Q==", "7g==", "7w==", "8A==", "8Q==", "8g==", "8w==", "9A==", "9Q==", "9g==", "9w==", "+A==", "+Q==", "+g==", "+w==", "/A==", "/Q==", "/g==", "/w==" }; public static Test suite() { TestSuite suite = new TestSuite("Base64Decoder Tests"); suite.addTest(new TestBase64Decoder("testAllBytes")); suite.addTest(new TestBase64Decoder("testPadding")); return suite; } public TestBase64Decoder(final String name) { super(name); } public void testAllBytes() { for (int i = 0; i < 256; i++) { byte[] content = Base64Decoder.decode(MAP[i]); assertTrue(1 == content.length); if (i < 128) { assertTrue(i == content[0]); } else { assertTrue((i - 256) == content[0]); } } } public void testPadding() { byte[] content; content = Base64Decoder.decode("IQ=="); assertTrue(1 == content.length); assertTrue(33 == content[0]); content = Base64Decoder.decode("ISE="); assertTrue(2 == content.length); assertTrue(33 == content[0]); assertTrue(33 == content[1]); content = Base64Decoder.decode("ISEh"); assertTrue(3 == content.length); assertTrue(33 == content[0]); assertTrue(33 == content[1]); assertTrue(33 == content[2]); content = Base64Decoder.decode("ISEhIg=="); assertTrue(4 == content.length); assertTrue(33 == content[0]); assertTrue(33 == content[1]); assertTrue(33 == content[2]); assertTrue(34 == content[3]); } } castor-1.3.2.orig/src/test/java/org/castor/util/TestIdentitySet.java0000644000000000000000000001660611544322136022345 0ustar /* * Copyright 2005 Ralf Joachim * * Licensed under the Apache License, Version 2.0 (the "License"); * 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 "AS IS" 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. */ package org.castor.util; import java.util.ArrayList; import java.util.Iterator; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; /** * Run tests of the org.castor.util.IdentitySet. * * @author Ralf Joachim * @version $Revision: 6907 $ $Date: 2006-04-29 04:11:14 -0600 (Sat, 29 Apr 2006) $ */ public final class TestIdentitySet extends TestCase { public static Test suite() { TestSuite suite = new TestSuite("IdentitySet Tests"); suite.addTest(new TestIdentitySet("testConstructor")); suite.addTest(new TestIdentitySet("testAdd")); suite.addTest(new TestIdentitySet("testClear")); suite.addTest(new TestIdentitySet("testContains")); suite.addTest(new TestIdentitySet("testRemove")); suite.addTest(new TestIdentitySet("testIterator")); suite.addTest(new TestIdentitySet("testRehash")); suite.addTest(new TestIdentitySet("testToArray")); return suite; } public TestIdentitySet(final String name) { super(name); } protected void setUp() { } protected void tearDown() { } public void testConstructor() { IdentitySet set1 = new IdentitySet(); assertTrue(set1.isEmpty()); assertTrue(set1.size() == 0); IdentitySet set2 = new IdentitySet(123); assertTrue(set2.isEmpty()); assertTrue(set2.size() == 0); } public void testAdd() { IdentitySet set = new IdentitySet(); Object key = new Integer(123); assertTrue(set.add(key)); assertFalse(set.isEmpty()); assertTrue(set.size() == 1); assertFalse(set.add(key)); assertFalse(set.isEmpty()); assertTrue(set.size() == 1); assertTrue(set.add(new Integer(123))); assertFalse(set.isEmpty()); assertTrue(set.size() == 2); } public void testClear() { IdentitySet set = new IdentitySet(); set.add(new Integer(123)); assertFalse(set.isEmpty()); assertTrue(set.size() == 1); set.clear(); assertTrue(set.isEmpty()); assertTrue(set.size() == 0); } public void testContains() { IdentitySet map = new IdentitySet(); Object key1 = new Integer(123); Object key2 = new Integer(123); assertFalse(map.contains(key1)); assertFalse(map.contains(key2)); map.add(key1); assertTrue(map.contains(key1)); assertFalse(map.contains(key2)); map.add(key1); assertTrue(map.contains(key1)); assertFalse(map.contains(key2)); map.add(key2); assertTrue(map.contains(key1)); assertTrue(map.contains(key2)); } public void testRemove() { IdentitySet set = new IdentitySet(); Object key1 = new Integer(123); Object key2 = new Integer(123); Object key3 = new Integer(123); set.add(key1); set.add(key2); set.add(key3); assertTrue(set.size() == 3); assertTrue(set.contains(key1)); assertTrue(set.contains(key2)); assertTrue(set.contains(key3)); set.remove(key2); assertTrue(set.size() == 2); assertTrue(set.contains(key1)); assertFalse(set.contains(key2)); assertTrue(set.contains(key3)); set.remove(key3); assertTrue(set.size() == 1); assertTrue(set.contains(key1)); assertFalse(set.contains(key2)); assertFalse(set.contains(key3)); set.remove(key1); assertTrue(set.size() == 0); assertFalse(set.contains(key1)); assertFalse(set.contains(key2)); assertFalse(set.contains(key3)); } public void testIterator() { IdentitySet set = new IdentitySet(); Object key1 = new Integer(123); Object key2 = new Integer(123); Object key3 = new Integer(123); set.add(key1); set.add(key2); set.add(key3); assertTrue(set.size() == 3); Iterator iter = set.iterator(); while (iter.hasNext()) { Object test = iter.next(); assertTrue((test == key1) || (test == key2) || (test == key3)); } } public void testRehash() { ArrayList keys = new ArrayList(); IdentitySet set = new IdentitySet(); for (int i = 0; i < 100; i++) { Object key = new Integer(i); keys.add(key); set.add(key); } for (int i = 0; i < 100; i++) { Object key = keys.get(i); assertTrue(set.contains(key)); } } public void testToArray() { IdentitySet set = new IdentitySet(); Object key1 = new Integer(123); Object key2 = new Integer(123); Object key3 = new Integer(123); set.add(key1); set.add(key2); set.add(key3); assertTrue(set.size() == 3); Object[] oArr = set.toArray(); if (oArr[0] == key1) { if (oArr[1] == key2) { assertTrue(oArr[2] == key3); } else { assertTrue(oArr[2] == key2); assertTrue(oArr[1] == key3); } } else if (oArr[0] == key2) { if (oArr[1] == key1) { assertTrue(oArr[2] == key3); } else { assertTrue(oArr[2] == key1); assertTrue(oArr[1] == key3); } } else { assertTrue(oArr[0] == key3); if (oArr[1] == key1) { assertTrue(oArr[2] == key2); } else { assertTrue(oArr[2] == key1); assertTrue(oArr[1] == key2); } } Integer[] iArr = new Integer[1]; iArr = (Integer[]) set.toArray(iArr); if (iArr[0] == key1) { if (iArr[1] == key2) { assertTrue(iArr[2] == key3); } else { assertTrue(iArr[2] == key2); assertTrue(iArr[1] == key3); } } else if (iArr[0] == key2) { if (iArr[1] == key1) { assertTrue(iArr[2] == key3); } else { assertTrue(iArr[2] == key1); assertTrue(iArr[1] == key3); } } else { assertTrue(iArr[0] == key3); if (iArr[1] == key1) { assertTrue(iArr[2] == key2); } else { assertTrue(iArr[2] == key1); assertTrue(iArr[1] == key2); } } } } castor-1.3.2.orig/src/test/java/org/castor/util/StringUtilTest.java0000644000000000000000000000551011544322135022173 0ustar /* * Copyright 2005 Werner Guttmann * * Licensed under the Apache License, Version 2.0 (the "License"); * 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 "AS IS" 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. */ package org.castor.util; import org.castor.util.StringUtil; import junit.framework.TestCase; /** * JUnit test case for {@link StringUtil}. * @since 1.1.2 */ public class StringUtilTest extends TestCase { /** * Tests various combinations of replacement functionality. */ public void testReplaceAll() { String source, expected; String toReplace = "hello"; String replacement = "bonjour"; /* no replacement */ source = "hallo world"; expected = source; assertEquals("no replacement exist", expected, StringUtil.replaceAll( source, toReplace, replacement)); } public void testOneReplacement() throws Exception { String source = "hello world"; String expected = "bonjour world"; String toReplace = "hello"; String replacement = "bonjour"; assertEquals("one replacement", expected, StringUtil.replaceAll(source, toReplace, replacement)); assertEquals("one replacement", expected, StringUtil.replaceAll(source, toReplace, replacement)); } public void testMultipleeplacement() throws Exception { String source = "hello Bob, hello Alice, hello hell, hello world!"; String expected = "bonjour Bob, bonjour Alice, bonjour hell, bonjour world!"; String toReplace = "hello"; String replacement = "bonjour"; assertEquals("multiple replacements", expected, StringUtil.replaceAll( source, toReplace, replacement)); } public void testEmptyString() throws Exception { String source = ""; String expected = ""; String toReplace = "hello"; String replacement = "bonjour"; assertEquals("empty source string", expected, StringUtil.replaceAll( source, toReplace, replacement)); } public void testNull() throws Exception { String source = null; String expected = null; String toReplace = "hello"; String replacement = "bonjour"; assertEquals("null source string", expected, StringUtil.replaceAll( source, toReplace, replacement)); } } castor-1.3.2.orig/src/test/java/org/castor/util/TestIdentityMap.java0000644000000000000000000001731011544322136022320 0ustar /* * Copyright 2005 Ralf Joachim * * Licensed under the Apache License, Version 2.0 (the "License"); * 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 "AS IS" 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. */ package org.castor.util; import java.util.ArrayList; import java.util.Iterator; import java.util.Map; import java.util.Set; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; /** * Run tests of the org.castor.util.IdentityMap. * * @author Ralf Joachim * @version $Revision: 6907 $ $Date: 2006-04-29 04:11:14 -0600 (Sat, 29 Apr 2006) $ */ public final class TestIdentityMap extends TestCase { public static Test suite() { TestSuite suite = new TestSuite("IdentityMap Tests"); suite.addTest(new TestIdentityMap("testConstructor")); suite.addTest(new TestIdentityMap("testPut")); suite.addTest(new TestIdentityMap("testClear")); suite.addTest(new TestIdentityMap("testContainsKey")); suite.addTest(new TestIdentityMap("testGet")); suite.addTest(new TestIdentityMap("testRemove")); suite.addTest(new TestIdentityMap("testKeySet")); suite.addTest(new TestIdentityMap("testEntrySet")); suite.addTest(new TestIdentityMap("testRehash")); return suite; } public TestIdentityMap(final String name) { super(name); } protected void setUp() { } protected void tearDown() { } public void testConstructor() { IdentityMap map = new IdentityMap(); assertTrue(map.isEmpty()); assertTrue(map.size() == 0); } public void testPut() { IdentityMap map = new IdentityMap(); Object key = new Integer(123); Object original = "original value"; Object replaced = "replaced value"; Object result; result = map.put(key, original); assertFalse(map.isEmpty()); assertTrue(map.size() == 1); assertNull(result); result = map.put(key, replaced); assertFalse(map.isEmpty()); assertTrue(map.size() == 1); assertTrue(result == original); result = map.put(new Integer(123), "value"); assertFalse(map.isEmpty()); assertTrue(map.size() == 2); assertNull(result); } public void testClear() { IdentityMap map = new IdentityMap(); map.put(new Integer(123), "value"); assertFalse(map.isEmpty()); assertTrue(map.size() == 1); map.clear(); assertTrue(map.isEmpty()); assertTrue(map.size() == 0); } public void testContainsKey() { IdentityMap map = new IdentityMap(); Object key1 = new Integer(123); Object key2 = new Integer(123); assertFalse(map.containsKey(key1)); assertFalse(map.containsKey(key2)); map.put(key1, "original value"); assertTrue(map.containsKey(key1)); assertFalse(map.containsKey(key2)); map.put(key1, "replaced value"); assertTrue(map.containsKey(key1)); assertFalse(map.containsKey(key2)); map.put(key2, "value"); assertTrue(map.containsKey(key1)); assertTrue(map.containsKey(key2)); } public void testGet() { IdentityMap map = new IdentityMap(); Object key1 = new Integer(123); Object original = "original value"; Object replaced = "replaced value"; Object key2 = new Integer(123); Object value = "value"; assertNull(map.get(key1)); assertNull(map.get(key2)); map.put(key1, original); assertTrue(map.get(key1) == original); assertNull(map.get(key2)); map.put(key1, replaced); assertTrue(map.get(key1) == replaced); assertNull(map.get(key2)); map.put(key2, value); assertTrue(map.get(key1) == replaced); assertTrue(map.get(key2) == value); } public void testRemove() { IdentityMap map = new IdentityMap(); Object key1 = new Integer(123); Object key2 = new Integer(123); Object key3 = new Integer(123); map.put(key1, "value 1"); map.put(key2, "value 2"); map.put(key3, "value 3"); assertTrue(map.size() == 3); assertTrue(map.containsKey(key1)); assertTrue(map.containsKey(key2)); assertTrue(map.containsKey(key3)); map.remove(key2); assertTrue(map.size() == 2); assertTrue(map.containsKey(key1)); assertFalse(map.containsKey(key2)); assertTrue(map.containsKey(key3)); map.remove(key3); assertTrue(map.size() == 1); assertTrue(map.containsKey(key1)); assertFalse(map.containsKey(key2)); assertFalse(map.containsKey(key3)); map.remove(key1); assertTrue(map.size() == 0); assertFalse(map.containsKey(key1)); assertFalse(map.containsKey(key2)); assertFalse(map.containsKey(key3)); } public void testKeySet() { IdentityMap map = new IdentityMap(); Object key1 = new Integer(123); Object key2 = new Integer(123); Object key3 = new Integer(123); map.put(key1, "value 1"); map.put(key2, "value 2"); map.put(key3, "value 3"); Set set = map.keySet(); assertTrue(set.size() == 3); Iterator iter = set.iterator(); while (iter.hasNext()) { Object test = iter.next(); assertTrue((test == key1) || (test == key2) || (test == key3)); } } public void testEntrySet() { IdentityMap map = new IdentityMap(); Object key1 = new Integer(123); Object key2 = new Integer(123); Object key3 = new Integer(123); map.put(key1, "value 1"); map.put(key2, "value 2"); map.put(key3, "value 3"); Set set = map.entrySet(); assertTrue(set.size() == 3); Iterator iter = set.iterator(); while (iter.hasNext()) { Object test = iter.next(); assertTrue(test instanceof Map.Entry); Map.Entry entry = (Map.Entry) test; Object key = entry.getKey(); Object value = entry.getValue(); assertTrue((key == key1) || (key == key2) || (key == key3)); if (key == key1) { assertEquals(value, "value 1"); } if (key == key2) { assertEquals(value, "value 2"); } if (key == key3) { assertEquals(value, "value 3"); } } } public void testRehash() { ArrayList keys = new ArrayList(); IdentityMap map = new IdentityMap(); for (int i = 0; i < 100; i++) { Object key = new Integer(i); Object value = "value " + i; keys.add(key); map.put(key, value); } for (int i = 0; i < 100; i++) { Object key = keys.get(i); assertTrue(map.containsKey(key)); Object value = "value " + i; assertTrue(value.equals(map.get(key))); } } } castor-1.3.2.orig/src/test/java/org/castor/util/TestAll.java0000644000000000000000000000262611544322135020604 0ustar /* * Copyright 2005 Ralf Joachim * * Licensed under the Apache License, Version 2.0 (the "License"); * 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 "AS IS" 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. */ package org.castor.util; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; /** * Run all tests of the org.castor.util package. * * @author Ralf Joachim * @version $Revision: 6907 $ $Date: 2006-04-29 03:57:35 -0600 (Sat, 29 Apr 2006) $ */ public final class TestAll extends TestCase { public static Test suite() throws Exception { TestSuite suite = new TestSuite("All org.castor.util tests"); suite.addTest(TestIdentitySet.suite()); suite.addTest(TestIdentityMap.suite()); suite.addTest(TestBase64Encoder.suite()); suite.addTest(TestBase64Decoder.suite()); return suite; } public TestAll(final String name) { super(name); } } castor-1.3.2.orig/src/test/java/org/castor/util/TestBase64Encoder.java0000644000000000000000000001034711544322135022417 0ustar /* * Copyright 2005 Ralf Joachim * * Licensed under the Apache License, Version 2.0 (the "License"); * 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 "AS IS" 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. */ package org.castor.util; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; public final class TestBase64Encoder extends TestCase { private static final String[] MAP = { "AA==", "AQ==", "Ag==", "Aw==", "BA==", "BQ==", "Bg==", "Bw==", "CA==", "CQ==", "Cg==", "Cw==", "DA==", "DQ==", "Dg==", "Dw==", "EA==", "EQ==", "Eg==", "Ew==", "FA==", "FQ==", "Fg==", "Fw==", "GA==", "GQ==", "Gg==", "Gw==", "HA==", "HQ==", "Hg==", "Hw==", "IA==", "IQ==", "Ig==", "Iw==", "JA==", "JQ==", "Jg==", "Jw==", "KA==", "KQ==", "Kg==", "Kw==", "LA==", "LQ==", "Lg==", "Lw==", "MA==", "MQ==", "Mg==", "Mw==", "NA==", "NQ==", "Ng==", "Nw==", "OA==", "OQ==", "Og==", "Ow==", "PA==", "PQ==", "Pg==", "Pw==", "QA==", "QQ==", "Qg==", "Qw==", "RA==", "RQ==", "Rg==", "Rw==", "SA==", "SQ==", "Sg==", "Sw==", "TA==", "TQ==", "Tg==", "Tw==", "UA==", "UQ==", "Ug==", "Uw==", "VA==", "VQ==", "Vg==", "Vw==", "WA==", "WQ==", "Wg==", "Ww==", "XA==", "XQ==", "Xg==", "Xw==", "YA==", "YQ==", "Yg==", "Yw==", "ZA==", "ZQ==", "Zg==", "Zw==", "aA==", "aQ==", "ag==", "aw==", "bA==", "bQ==", "bg==", "bw==", "cA==", "cQ==", "cg==", "cw==", "dA==", "dQ==", "dg==", "dw==", "eA==", "eQ==", "eg==", "ew==", "fA==", "fQ==", "fg==", "fw==", "gA==", "gQ==", "gg==", "gw==", "hA==", "hQ==", "hg==", "hw==", "iA==", "iQ==", "ig==", "iw==", "jA==", "jQ==", "jg==", "jw==", "kA==", "kQ==", "kg==", "kw==", "lA==", "lQ==", "lg==", "lw==", "mA==", "mQ==", "mg==", "mw==", "nA==", "nQ==", "ng==", "nw==", "oA==", "oQ==", "og==", "ow==", "pA==", "pQ==", "pg==", "pw==", "qA==", "qQ==", "qg==", "qw==", "rA==", "rQ==", "rg==", "rw==", "sA==", "sQ==", "sg==", "sw==", "tA==", "tQ==", "tg==", "tw==", "uA==", "uQ==", "ug==", "uw==", "vA==", "vQ==", "vg==", "vw==", "wA==", "wQ==", "wg==", "ww==", "xA==", "xQ==", "xg==", "xw==", "yA==", "yQ==", "yg==", "yw==", "zA==", "zQ==", "zg==", "zw==", "0A==", "0Q==", "0g==", "0w==", "1A==", "1Q==", "1g==", "1w==", "2A==", "2Q==", "2g==", "2w==", "3A==", "3Q==", "3g==", "3w==", "4A==", "4Q==", "4g==", "4w==", "5A==", "5Q==", "5g==", "5w==", "6A==", "6Q==", "6g==", "6w==", "7A==", "7Q==", "7g==", "7w==", "8A==", "8Q==", "8g==", "8w==", "9A==", "9Q==", "9g==", "9w==", "+A==", "+Q==", "+g==", "+w==", "/A==", "/Q==", "/g==", "/w==" }; public static Test suite() { TestSuite suite = new TestSuite("Base64Encoder Tests"); suite.addTest(new TestBase64Encoder("testAllBytes")); suite.addTest(new TestBase64Encoder("testPadding")); return suite; } public TestBase64Encoder(final String name) { super(name); } public void testAllBytes() { for (int i = 0; i < 256; i++) { assertEquals(MAP[i], new String(Base64Encoder.encode(new byte[] {(byte) i}))); } } public void testPadding() { String str; str = new String(Base64Encoder.encode(new byte[] {33})); assertEquals("IQ==", str); str = new String(Base64Encoder.encode(new byte[] {33, 33})); assertEquals("ISE=", str); str = new String(Base64Encoder.encode(new byte[] {33, 33, 33})); assertEquals("ISEh", str); str = new String(Base64Encoder.encode(new byte[] {33, 33, 33, 34})); assertEquals("ISEhIg==", str); } } castor-1.3.2.orig/src/test/java/org/castor/util/TestHex.java0000644000000000000000000000347011544322136020617 0ustar /* * Copyright 2007 Werner Guttmann * * Licensed under the Apache License, Version 2.0 (the "License"); * 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 "AS IS" 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. */ package org.castor.util; import java.util.Arrays; import java.util.Random; import junit.framework.TestCase; /** * JUnit test case for HEX en-/coding. * @author Johan Lindquist * @version $Revision$ */ public class TestHex extends TestCase { public void testEncodeDecode() { byte[] bytes = new byte[256]; new Random(1L).nextBytes(bytes); final String encodedBytes = HexDecoder.encode(bytes); assertEquals( "Bad encoded data", "73D51ABBD89CB8196F0EFB6892F94D68FCCC2C35F0B84609E5F12C55DD85ABA8D5D9BEF76808F3B572E5900112B81927BA5BB5F67E1BDA28B4049BF0E4AED78DB15D7BF2FC0C34E9A99DE4EF3BC2B17C8137AD659878F9E93DF1F658367ACA286452474B9EF3765E24E9A88173724DDDFB04B01DCCEB0C8AEAD641C58DAD569581BAEEA87C10D40A47902028E61CFDC243D9D16008AABC9FB77CC723A56017E14F1CE8B1698341734A6823CE02043E016B544901214A2DDAB82FEC85C0B9FE0549C475BE5B887BB4B8995B24FB5C6846F88B527B4F9D4C1391F1678B23BA4F9C9CD7BC93EB5776F4F03675344864294661C5949FAF17B130FCF6482F971A5500", encodedBytes); final byte[] decodedBytes = HexDecoder.decode(encodedBytes); assertTrue("Bad decoded bytes", Arrays.equals(bytes, decodedBytes)); } } castor-1.3.2.orig/src/test/java/org/castor/xml/0000755000000000000000000000000011656245645016224 5ustar castor-1.3.2.orig/src/test/java/org/castor/xml/XMLConfigurationTest.java0000644000000000000000000001017311544322135023103 0ustar /* * Copyright 2007 Joachim Grueneis * * Licensed under the Apache License, Version 2.0 (the "License"); * 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 "AS IS" 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. */ package org.castor.xml; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.castor.core.util.Configuration; import junit.framework.Assert; import junit.framework.TestCase; /** * The XMLConfiguration test has one goal - check if the proper defaults * are in place. * * @author Joachim Grueneis, jgrueneis_at_gmail_dot_com * @version $Id$ */ public class XMLConfigurationTest extends TestCase { private static final Log LOG = LogFactory.getLog(XMLConfigurationTest.class); private Configuration _configuration; public XMLConfigurationTest(final String name) { super(name); } public void setUp() { _configuration = XMLConfiguration.newInstance(); Assert.assertNotNull( "Configuration must exist after call to newInstance()", _configuration); Assert.assertNotNull( "Application class loader must not be null", _configuration.getApplicationClassLoader()); Assert.assertNotNull( "Domain class loader must not be null", _configuration.getDomainClassLoader()); } public void testNewInstanceClassLoaderClassLoader() { Configuration c = XMLConfiguration.newInstance(null, null); Assert.assertNotNull( "Configuration must exist after call to newInstance()", c); // Assert.assertNotNull( // "Application class loader must not be null", // c.getApplicationClassLoader()); // Assert.assertNotNull( // "Domain class loader must not be null", // c.getDomainClassLoader()); } public void testGetBooleanString() { Boolean notExistingProperty = _configuration.getBoolean("Something which doesn't exist"); Assert.assertNull("A not existing property needs to return null", notExistingProperty); } public void testGetBooleanStringBoolean() { boolean notExistingPropertyWithDefault = _configuration.getBoolean("Something which doesn't exist", true); Assert.assertTrue( "A not existing property with default true", notExistingPropertyWithDefault); } /** * Tests wether the expected defaults are present or not. */ public void testDefaults() { Boolean loadPackageMapping = _configuration.getBoolean(XMLConfiguration.LOAD_PACKAGE_MAPPING); Assert.assertEquals( "load package mapping is expected to be set to: true", Boolean.TRUE, loadPackageMapping); String serialzierFactory = _configuration.getString(XMLConfiguration.SERIALIZER_FACTORY); Assert.assertEquals( "check serializer factory default", "org.exolab.castor.xml.XercesXMLSerializerFactory", serialzierFactory); Boolean strictElements = _configuration.getBoolean(XMLConfiguration.STRICT_ELEMENTS); Assert.assertEquals("strict elements default", Boolean.FALSE, strictElements); Boolean marshallingValidation = _configuration.getBoolean(XMLConfiguration.MARSHALLING_VALIDATION); Assert.assertEquals("marshallingValidation", Boolean.TRUE, marshallingValidation); Boolean useIntrospection = _configuration.getBoolean(XMLConfiguration.USE_INTROSPECTION); Assert.assertEquals("useIntrospection", Boolean.TRUE, useIntrospection); } } castor-1.3.2.orig/src/test/java/org/castor/xml/JavaNamingTest.java0000644000000000000000000002146711544322136021737 0ustar /* * Copyright 2007 Joachim Grueneis * * Licensed under the Apache License, Version 2.0 (the "License"); * 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 "AS IS" 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. */ package org.castor.xml; import junit.framework.Assert; import junit.framework.TestCase; /** * @author Joachim Grueneis, jgrueneis_at_gmail_dot_com * @version $Id$ */ public class JavaNamingTest extends TestCase { private static final String[] VALID_NAMES = {"name", "myName", "my_name", "NAME"}; private static final String[] INVALID_NAMES = {"my-name", "my----name"}; private static final String PS = System.getProperty("file.separator"); private JavaNaming _javaNaming = new JavaNamingImpl(); /** * @param arg0 */ public JavaNamingTest(final String arg0) { super(arg0); } /** * Test method for * {@link org.castor.xml.JavaNamingImpl#isKeyword(java.lang.String)}. */ public final void testIsKeyword() { Assert.assertFalse("A null String is no keyword", _javaNaming.isKeyword(null)); Assert.assertFalse("An empty String is no keyword", _javaNaming.isKeyword("")); for (int i = 0; i < VALID_NAMES.length; i++) { String aName = VALID_NAMES[i]; Assert.assertFalse( "Name: " + aName + " is no keyword!", _javaNaming.isKeyword(aName)); } } /** * Test method for * {@link org.castor.xml.JavaNamingImpl#isValidJavaIdentifier(java.lang.String)}. */ public final void testIsValidJavaIdentifier() { Assert.assertFalse( "A null String is no identifier", _javaNaming.isValidJavaIdentifier(null)); Assert.assertFalse( "An empty String is no identifier", _javaNaming.isValidJavaIdentifier("")); for (int i = 0; i < VALID_NAMES.length; i++) { String aName = VALID_NAMES[i]; Assert.assertTrue( "Name: " + aName + " should be valid!", _javaNaming.isValidJavaIdentifier(aName)); } for (int i = 0; i < INVALID_NAMES.length; i++) { String aName = INVALID_NAMES[i]; Assert.assertFalse( "Name: " + aName + " should be invalid!", _javaNaming.isValidJavaIdentifier(aName)); } } /** * Test method for * {@link org.castor.xml.JavaNamingImpl#toJavaClassName(java.lang.String)}. */ public final void testToJavaClassName() { Assert.assertEquals("For null in and out should be equals", null, _javaNaming.toJavaClassName(null)); Assert.assertEquals("For an empty string in and out should be equals", "", _javaNaming.toJavaClassName("")); } /** * Test method for * {@link org.castor.xml.JavaNamingImpl#toJavaMemberName(java.lang.String)}. */ public final void testToJavaMemberNameString() { Assert.assertEquals("For null in and out should be equals", null, _javaNaming.toJavaMemberName(null)); Assert.assertEquals("For an empty string in and out should be equals", "", _javaNaming.toJavaMemberName("")); } /** * Test method for * {@link org.castor.xml.JavaNamingImpl#toJavaMemberName(java.lang.String, boolean)}. */ public final void testToJavaMemberNameStringBoolean() { Assert.assertEquals("For null in and out should be equals", null, _javaNaming.toJavaMemberName(null, true)); Assert.assertEquals("For an empty string in and out should be equals", "", _javaNaming.toJavaMemberName("", true)); Assert.assertEquals("For null in and out should be equals", null, _javaNaming.toJavaMemberName(null, false)); Assert.assertEquals("For an empty string in and out should be equals", "", _javaNaming.toJavaMemberName("", false)); } /** * Test method for * {@link org.castor.xml.JavaNamingImpl#packageToPath(java.lang.String)}. */ public final void testPackageToPath() { Assert.assertEquals("For null in and out should be equals", null, _javaNaming.packageToPath(null)); Assert.assertEquals("For an empty string in and out should be equals", "", _javaNaming.packageToPath("")); Assert.assertEquals("org" + PS + "castor" + PS + "xml", _javaNaming.packageToPath("org.castor.xml")); try { _javaNaming.packageToPath("."); Assert.fail("Invalid package name must not be converted!"); } catch (IllegalArgumentException e) { // expected!! } Assert.assertEquals("org", _javaNaming.packageToPath("org")); try { _javaNaming.packageToPath(".org"); Assert.fail("Invalid package name must not be converted!"); } catch (IllegalArgumentException e) { // expected!! } try { _javaNaming.packageToPath("org."); Assert.fail("Invalid package name must not be converted!"); } catch (IllegalArgumentException e) { // expected!! } } /** * Test method for * {@link org.castor.xml.JavaNamingImpl#getQualifiedFileName(java.lang.String,java.lang.String)}. */ public final void testGetQualifiedFileName() { Assert.assertEquals("For null in and out should be equals", null, _javaNaming.getQualifiedFileName(null, null)); Assert.assertEquals("For an empty string in and out should be equals", "", _javaNaming.getQualifiedFileName("", "")); Assert.assertEquals("For an empty string in and out should be equals", null, _javaNaming.getQualifiedFileName(null, "")); Assert.assertEquals("For an empty string in and out should be equals", "", _javaNaming.getQualifiedFileName("", null)); Assert.assertEquals("org" + PS + "castor" + PS + "xml/", _javaNaming.getQualifiedFileName("", "org.castor.xml")); Assert.assertEquals("org" + PS + "castor" + PS + "xml/A.b", _javaNaming.getQualifiedFileName("A.b", "org.castor.xml")); Assert.assertEquals("A.b", _javaNaming.getQualifiedFileName("A.b", null)); Assert.assertEquals("A.b", _javaNaming.getQualifiedFileName("A.b", "")); Assert.assertEquals("org/A.b", _javaNaming.getQualifiedFileName("A.b", "org")); Assert.assertEquals("org/Anton", _javaNaming.getQualifiedFileName("Anton", "org")); try { _javaNaming.getQualifiedFileName("A.b", "."); Assert.fail("Shouldn't succeed with invalid package name!"); } catch (IllegalArgumentException e) { // expected } try { _javaNaming.getQualifiedFileName("A.b", ".org"); Assert.fail("Shouldn't succeed with invalid package name!"); } catch (IllegalArgumentException e) { // expected } try { _javaNaming.getQualifiedFileName("A.b", "org."); Assert.fail("Shouldn't succeed with invalid package name!"); } catch (IllegalArgumentException e) { // expected } } /** * Test method for * {@link org.castor.xml.JavaNamingImpl#getPackageName(java.lang.String)}. */ public final void testGetPackageName() { Assert.assertEquals("For null in and out should be equals", null, _javaNaming.getPackageName(null)); Assert.assertEquals("For an empty string in and out should be equals", "", _javaNaming.getPackageName("")); Assert.assertEquals("Extracted package name doesn't match", JavaNamingImpl.class.getPackage().getName(), _javaNaming.getPackageName(JavaNamingImpl.class.getName())); Assert.assertEquals("Extracted package name doesn't match", "", _javaNaming.getPackageName("A")); } /** * Test method for * {@link org.castor.xml.JavaNamingImpl#isAddMethod(java.lang.reflect.Method)}. */ public final void testIsAddMethod() { Assert.assertFalse(_javaNaming.isAddMethod(null)); } private class ForTestingPurposes {} public final void testGetClassName() { Assert.assertNull(_javaNaming.getClassName(null)); Assert.assertEquals("JavaNamingTest", _javaNaming.getClassName(JavaNamingTest.class)); Assert.assertEquals("JavaNamingTest$ForTestingPurposes", _javaNaming.getClassName(ForTestingPurposes.class)); } } castor-1.3.2.orig/src/test/java/org/castor/TestAll.java0000644000000000000000000000237011544322136017624 0ustar /* * Copyright 2005 Ralf Joachim * * Licensed under the Apache License, Version 2.0 (the "License"); * 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 "AS IS" 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. */ package org.castor; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; /** * Run all tests of the org.castor package. * * @author Ralf Joachim * @version $Revision: 7018 $ $Date: 2006-04-29 05:45:43 -0600 (Sat, 29 Apr 2006) $ */ public final class TestAll extends TestCase { public static Test suite() throws Exception { TestSuite suite = new TestSuite("All org.castor tests"); suite.addTest(org.castor.util.TestAll.suite()); return suite; } public TestAll(final String name) { super(name); } } castor-1.3.2.orig/src/test/java/org/castor/mapping/0000755000000000000000000000000011656245645017057 5ustar castor-1.3.2.orig/src/test/java/org/castor/mapping/TestMappingLoaderRegistry.java0000644000000000000000000000664711544322136025035 0ustar /* * Copyright 2006 Werner Guttmann * * Licensed under the Apache License, Version 2.0 (the "License"); * 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 "AS IS" 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. */ package org.castor.mapping; import java.util.Collection; import java.util.Iterator; import junit.framework.TestCase; import org.castor.core.CoreConfiguration; import org.castor.core.util.Configuration; import org.exolab.castor.mapping.MappingLoader; /** * UTF test case for {@see org.castor.jdo.drivers.PointbaseFactory}. */ public class TestMappingLoaderRegistry extends TestCase { public final void testGetInstance() throws Exception { Configuration config = new CoreConfiguration(); MappingLoaderRegistry registry = new MappingLoaderRegistry(config); assertNotNull(registry); } public final void testEnlistMappingLoaders() throws Exception { Configuration config = new CoreConfiguration(); MappingLoaderRegistry registry = new MappingLoaderRegistry(config); assertNotNull(registry); Collection factories = registry.getMappingLoaderFactories(); assertNotNull(factories); assertTrue(factories.size() > 0); assertEquals(2, factories.size()); Iterator iter = factories.iterator(); MappingLoaderFactory factory = (MappingLoaderFactory) iter.next(); assertNotNull(factory); assertEquals("JDO", factory.getName()); assertEquals("org.castor.mapping.JDOMappingLoaderFactory", factory.getClass().getName()); assertEquals("CastorXmlMapping", factory.getSourceType()); factory = (MappingLoaderFactory) iter.next(); assertNotNull(factory); assertEquals("XML", factory.getName()); assertEquals("org.castor.mapping.XMLMappingLoaderFactory", factory.getClass().getName()); assertEquals("CastorXmlMapping", factory.getSourceType()); } public final void testGetXMLMappingLoader() throws Exception { Configuration config = new CoreConfiguration(); MappingLoaderRegistry registry = new MappingLoaderRegistry(config); assertNotNull(registry); MappingLoader mappingLoader = registry.getMappingLoader( "CastorXmlMapping", BindingType.XML); assertNotNull(mappingLoader); assertEquals(mappingLoader.getClass().getName(), "org.exolab.castor.xml.XMLMappingLoader"); } // public final void testGetJDOMappingLoader() throws Exception { // Configuration config = Configuration.getInstance(); // MappingLoaderRegistry registry = new MappingLoaderRegistry(config); // assertNotNull(registry); // // MappingLoader mappingLoader = registry.getMappingLoader( // "CastorXmlMapping", BindingType.JDO); // assertNotNull(mappingLoader); // assertEquals(mappingLoader.getClass().getName(), // "org.exolab.castor.jdo.engine.JDOMappingLoader"); // } } castor-1.3.2.orig/src/test/resources/0000755000000000000000000000000011544322135014415 5ustar castor-1.3.2.orig/src/test/resources/org/0000755000000000000000000000000011544322135015204 5ustar castor-1.3.2.orig/src/test/resources/org/castor/0000755000000000000000000000000011544322135016477 5ustar castor-1.3.2.orig/src/test/resources/org/castor/test/0000755000000000000000000000000011544322135017456 5ustar castor-1.3.2.orig/src/test/resources/org/castor/test/entity/0000755000000000000000000000000011656245645021010 5ustar castor-1.3.2.orig/src/test/resources/org/castor/test/entity/mapping.xml0000644000000000000000000000067211544322135023154 0ustar castor-1.3.2.orig/src/test/resources/org/castor/test/entity/input.xml0000644000000000000000000000011511544322135022650 0ustar 1 name castor-1.3.2.orig/src/rss/0000755000000000000000000000000011656245645012251 5ustar castor-1.3.2.orig/src/rss/castor-announce.xml0000644000000000000000000013641111544322135016062 0ustar Castor -- Announcements http://castor.codehaus.org/ Announcements for Castor en-us http://www.rssboard.org/rss-2-0-8 1.3.1 GA available Sun, 03 Jan 200 21:23:22 +0100 Werner Guttmann http://castor.codehaus.org/news.html#item73 http://castor.codehaus.org/news.html#item73 Castor 1.3.1 has been made available at http://dist.codehaus.org/castor/1.3.1/

For details about the features added and the bugs fixed, please have a look at the release notes at http://castor.codehaus.org/release-notes.html

]]>
(Re)Added project Wiki Thu, 24 Jul 2009 22:21:23 +0100 Werner Guttmann http://castor.codehaus.org/news.html#item71 http://castor.codehaus.org/news.html#item71 I am very pleased to announce the immediate availability of a project Wiki for the Castor project.

As always, we encourage the users of Castor to contribute additional examples, tips, errata or how-tos to the project. The contributions collected at this place will be migrated into the standard HTML documentation.

]]>
JDO extensions for the Castor XML code generator - Preview Sun, 19 Apr 2009 22:21:23 +0100 Werner Guttmann http://castor.codehaus.org/news.html#item70 http://castor.codehaus.org/news.html#item70 I am very pleased to announce the immediate availability of the JDO extensions for the Castor XML code generator in form of a technology preview as part of the first snapshot release of Castor 1.3.1, which can be found at and downloaded from the Codehaus snapshot repository (http://snapshots.repository.codehaus.org/org/codehaus/castor).

]]>
Castor and Google Summer of Code 2009 Mon, 30 Mar 2009 20:21:22 +0100 Werner Guttmann http://castor.codehaus.org/news.html#item69 http://castor.codehaus.org/news.html#item69 Castor is - again - putting up numerous project proposals with Google's Summer of Code 2009 program (http://code.google.com/soc/).

Please find the current project proposal ideas available at http://gsoc.codehaus.org/Castor+Ideas.

]]>
1.3 GA available Mon, 10 Feb 2009 14:12:13 +0100 Werner Guttmann http://castor.codehaus.org/news.html#item68 http://castor.codehaus.org/news.html#item68 Castor 1.3 has been made available at http://dist.codehaus.org/castor/1.3/

For details about the features added and the bugs fixed, please have a look at the release notes at http://castor.codehaus.org/release-notes.html

]]>
1.3 RC1 release available Wed, 01 Oct 2008 23:59:04 +0100 Werner Guttmann http://castor.codehaus.org/news.html#item67 http://castor.codehaus.org/news.html#item67 Castor 1.3 release candidate 1 has been made available at http://dist.codehaus.org/castor/1.3rc1/

This is a first release candidate for the upcoming 1.3 release. For details about the features added and the bugs fixed, please have a look at the release notes at http://castor.codehaus.org/release-notes.html.

]]>
Welcome Lukas Lang to the team Sat, 12 Jul 2008 20:21:22 +0100 Werner Guttmann http://castor.codehaus.org/news.html#item66 http://castor.codehaus.org/news.html#item66 I'm very happy to announce that Lukas Lang has joined the Castor team as committer. Lukas' initial focus will be on the JDO extensions for the Castor XML code generator, where he is currently working with me (and a group of students) on completing this new (and exciting) feature.

]]>
Castor mailing lists available for browsing and searching at http://castor.markmail.org Wed, 13 Feb 2008 12:11:10 +0100 Werner Guttmann http://castor.codehaus.org/news.html#item64 http://castor.codehaus.org/news.html#item64 Castor's mailing lists are now available for browsing and searching at http://castor.markmail.org.

More info about the site, its features and its inner workings is in the FAQ at http://markmail.org/docs/faq.xqy.

]]>
1.2 GA available Mon, 04 Feb 2008 20:21:22 +0100 Werner Guttmann http://castor.codehaus.org/news.html#item63 http://castor.codehaus.org/news.html#item63 Castor 1.2 has been made available at http://dist.codehaus.org/castor/1.2/

For details about the features added and the bugs fixed, please have a look at the release notes at http://castor.codehaus.org/release-notes.html

]]>
Article series on Castor available at IBM developerWorks Sun, 02 Feb 2008 20:21:22 +0100 Werner Guttmann http://castor.codehaus.org/news.html#item62 http://castor.codehaus.org/news.html#item62 Brett McLaughlin has written an article series on (XML) data binding with Castor on IBM developerWorks. The first article is available http://www.ibm.com/developerworks/xml/library/x-xjavacastor1/.

]]>
Welcome Joachim Grueneis to the team Tue, 11 Sep 2007 20:21:22 +0100 Werner Guttmann http://castor.codehaus.org/news.html#item61 http://castor.codehaus.org/news.html#item61 I'm very happy to announce that Joachim Grueneis has joined the Castor team as committer. Joachim's initial focus will be on the XML side of things, where he is currently working on JAXB compliance for Castor XML.

]]>
Welcome Joachim Grueneis to the team Werner Guttmann Sep 11 2006 I'm very happy to announce that Joachim Grueneis has joined the Castor team as committer. Joachim's initial focus will be on the XML side of things, where he is currently working on JAXB compliance for Castor XML. 1.1.2.1 final release available Thu, 28 Jun 2007 20:21:22 +0100 Werner Guttmann http://castor.codehaus.org/news.html#item60 http://castor.codehaus.org/news.html#item60 Castor 1.1.2.1 has been made available at http://dist.codehaus.org/castor/1.1.2.1/

For details about the features added and the bugs fixed, please have a look at the release notes at http://castor.codehaus.org/release-notes.html

]]>
1.1.2 final release available Sun, 17 Jun 2007 22:33:44 +0100 Werner Guttmann http://castor.codehaus.org/news.html#item59 http://castor.codehaus.org/news.html#item59 Castor 1.1.2 has been made available at http://dist.codehaus.org/castor/1.1.2/

For details about the features added and the bugs fixed, please have a look at the release notes at http://castor.codehaus.org/release-notes.html

]]>
1.1.1 final release available Sun, 22 Apr 2007 10:11:12 +0100 Werner Guttmann http://castor.codehaus.org/news.html#item58 http://castor.codehaus.org/news.html#item58 Castor 1.1.1 has been made available at http://dist.codehaus.org/castor/1.1.1/

For details about the features added and the bugs fixed, please have a look at the release notes at http://castor.codehaus.org/release-notes.html

]]>
1.1 final release available Sat, 10 Feb 2007 23:22:21 +0100 Werner Guttmann http://castor.codehaus.org/news.html#item57 http://castor.codehaus.org/news.html#item57 Castor 1.1 GA has been made available at http://dist.codehaus.org/castor/1.1/

For details about the features added and the bugs fixed, please have a look at the release notes at http://castor.codehaus.org/release-notes.html

]]>
1.1 M3 release available Mon, 29 Jan 2007 22:23:24 +0100 Werner Guttmann http://castor.codehaus.org/news.html#item56 http://castor.codehaus.org/news.html#item56 The Castor 1.1 M3 release has been made available at http://dist.codehaus.org/castor/1.1/

This is a second milestone build for the upcoming 1.1 release.

For details about the features added and the bugs fixed, please have a look at the release notes at http://castor.codehaus.org/release-notes.html

]]>
1.1 M2 release available Fri, 29 Dec 2006 22:23:24 +0100 Werner Guttmann http://castor.codehaus.org/news.html#item55 http://castor.codehaus.org/news.html#item55 The Castor 1.1 M2 release has been made available at http://dist.codehaus.org/castor/1.1/

This is a second milestone build for the upcoming 1.1 release. As part of this release, there are a few noteworthy changes:

  • A Castor DDL generator has been added to Castor JDO, allowing generation of DDL scripts from a Castor JDO mapping file.
  • New binaries packaging; both the DDL generator as well as the XML code generator have been moved to separate (and new JARs).
    • For details about the features added and the bugs fixed, please have a look at the release notes at http://castor.codehaus.org/release-notes.html

      ]]> 1.1 M1 release available Sat, 23 Dec 2006 22:23:24 +0100 Werner Guttmann http://castor.codehaus.org/news.html#item54 http://castor.codehaus.org/news.html#item54 The Castor 1.1 M1 release has been made available at http://dist.codehaus.org/castor/1.1/

      This is a milestone build for the upcoming 1.1 release. For details about the features added and the bugs fixed, please have a look at the release notes at http://castor.codehaus.org/release-notes.html.

      ]]>
      Castor 1.0.5 available Sat, 11 Nov 2006 20:22:21 GMT Werner Guttmann http://castor.codehaus.org/news.html#item53 http://castor.codehaus.org/news.html#item53 Castor 1.0.5 has been made available at http://dist.codehaus.org/castor/1.0.5/

      For details about the features added and the bugs fixed, please have a look at the release notes at http://castor.codehaus.org/release-notes.html.

      ]]>
      Castor 1.0.4 available Sun, 22 Oct 2006 20:22:21 GMT Werner Guttmann http://castor.codehaus.org/news.html#item51 http://castor.codehaus.org/news.html#item51 Castor 1.0.4 has been made available at http://dist.codehaus.org/castor/1.0.4/

      For details about the features added and the bugs fixed, please have a look at the release notes at http://castor.codehaus.org/release-notes.html.

      ]]>
      Snapshot release of Spring factory beans for Castor XML available Sun, 10 Sep 2006 07:18:19 GMT Werner Guttmann http://castor.codehaus.org/news.html#item50 http://castor.codehaus.org/news.html#item50 I've made a first snapshot release of the new Spring factory beans for Castor XML available. This new module provides seamless integration of several Castor XML artifacts (e.g. its Unmarshaller and Marshaller components) into the application framework (http://www.springframework.org).

      • Download instructions (http://castor.org/download.html#Castor-XML-Spring-factory-beans)
      • Introduction, including several small HOW-TOs (http://castor.org/spring-xml-intro.html)
      ]]>
      Castor 1.0.3 available Thu, 7 Sep 2006 20:22:21 GMT Werner Guttmann http://castor.codehaus.org/news.html#item49 http://castor.codehaus.org/news.html#item49 Castor 1.0.3 has been made available at http://dist.codehaus.org/castor/1.0.3/

      For details about the features added and the bugs fixed, please have a look at the release notes at http://castor.codehaus.org/release-notes.html.

      ]]>
      Castor 1.0.2 available Thu, 3 Aug 2006 20:22:21 GMT Werner Guttmann http://castor.codehaus.org/news.html#item48 http://castor.codehaus.org/news.html#item48 Castor 1.0.2 has been made available at http://dist.codehaus.org/castor/1.0.2/

      For details about the features added and the bugs fixed, please have a look at the release notes at http://castor.codehaus.org/release-notes.html.

      ]]>
      Spring ORM for Castor JDO RC1 released Thu, 06 Jul 2006 20:21:22 GMT Werner Guttmann http://castor.codehaus.org/news.html#item47 http://castor.codehaus.org/news.html#item47 I've placed the first release candidate of the Spring ORM implementation for Castor JDO at the Codehaus at http://dist.codehaus.org/castor/.

      For details about the functionality provided, please have a look at the documentation available at http://castor.codehaus.org/castor-spring-site/.

      ]]>
      Work on JPA 3.0 support started Sun, 25 Jun 2006 10:01:12 GMT Werner Guttmann http://castor.codehaus.org/news.html#item46 http://castor.codehaus.org/news.html#item46 Work has been started on adding support for the Java Persistence Architecture (JPA) 3.0 to Castor JDO

      The SVN repository is available at http://svn.codehaus.org/castor/castor-jpa/trunk

      ]]>
      Castor 1.0.1 available Thu, 8 Jun 2006 20:22:21 GMT Werner Guttmann http://castor.codehaus.org/news.html#item45 http://castor.codehaus.org/news.html#item45 Castor 1.0.1 has been made available at http://dist.codehaus.org/castor/1.0/

      For details about the features added and the bugs fixed, please have a look at the release notes at http://castor.codehaus.org/release-notes.html.

      ]]>
      Jira and notifications Tue, 30 May 2006 13:07:43 GMT Werner Guttmann http://castor.codehaus.org/news.html#item43 http://castor.codehaus.org/news.html#item43 This is a short message for those who have created Jira issues in the past two or three months or so, or have commented upon existing issues.

      It looks like during some Jira upgrade a few months ago, a couple of Jira settings got disabled. As a result, the original reporter of a Jira issue did not get notified about any changes to the issue (incl. e.g. state changes, comments, questions, etc.)...

      ]]>
      Castor up again ... Tue, 23 May 2006 13:07:43 GMT Werner Guttmann http://castor.codehaus.org/news.html#item42 http://castor.codehaus.org/news.html#item42 Google Summer of Code and Castor Fri, 05 May 2006 13:07:43 GMT Werner Guttmann http://castor.codehaus.org/news.html#item41 http://castor.codehaus.org/news.html#item41 we are proud to participate in the Summer of Code initiative (http://code.google.com/soc/) sponsored by Google, and you are invited to join in the fun.

      At http://docs.codehaus.org/display/CASTOR/CastorSocProjects, you'll find some suggestions we find suitable for the program, and per definition we would be glad to support a few projects.

      Please understand, though, that mentoring capacities will be limited, though we will try to dedicate as much time as possible to the suggested projects. That implies that we depend on your dedication during the preparation of the detailed specification and description of the outcome.

      The timeframe for applications is May 1 - May 8. So have a look at the projects offered before you sign up to the program and apply as a student to be mentored by us.

      ]]>
      New source repository Sun, 16 Apr 2006 13:07:43 GMT Ralf Joachim http://castor.codehaus.org/news.html#item40 http://castor.codehaus.org/news.html#item40 On April 14, 2006 we migrated the Castor source repository from CVS to SVN. At the moment we still have read-only access to CVS, but CVS does not reflect commits to SVN after the migration. The read-only access to CVS is intended for you to create patches of your current work and move it over to SVN. Be aware that we will switch off CVS soon.

      For details about SVN access please have a look at: http://castor.codehaus.org/cvs.html.

      ]]>
      Final 1.0 release available Thu, 6 Apr 2006 23:22:21 GMT Werner Guttmann http://castor.codehaus.org/news.html#item39 http://castor.codehaus.org/news.html#item39 The final Castor 1.0 release has been made available at http://dist.codehaus.org/castor/1.0/

      For details about the features added and the bugs fixed, please have a look at the release notes at http://castor.codehaus.org/release-notes.html.

      ]]>
      1.0M4 release available Thu, 23 Mar 2006 23:22:21 GMT Werner Guttmann http://castor.codehaus.org/news.html#item38 http://castor.codehaus.org/news.html#item38 The Castor 1.0M4 release has been made available at http://dist.codehaus.org/castor/1.0/

      This is the last milestone build for the upcoming 1.0 release. For details about the features added and the bugs fixed, please have a look at the release notes at http://castor.codehaus.org/release-notes.html.

      ]]>
      1.0M3 release available Tue, 07 Mar 2006 11:12:13 GMT Werner Guttmann http://castor.codehaus.org/news.html#item37 http://castor.codehaus.org/news.html#item37 The Castor 1.0M3 release has been made available at http://dist.codehaus.org/castor/1.0/

      This is a milestone build for the upcoming 1.0 release. For details about the features added and the bugs fixed, please have a look at the release notes at http://castor.codehaus.org/release-notes.html.

      ]]>
      1.0M2 release available Fri, 03 Feb 2006 11:12:13 GMT Werner Guttmann http://castor.codehaus.org/news.html#item36 http://castor.codehaus.org/news.html#item36 The Castor 1.0M2 release has been made available at http://dist.codehaus.org/castor/1.0/

      This is a milestone build for the upcoming 1.0 release. For details about the features added and the bugs fixed, please have a look at the release notes at http://castor.codehaus.org/release-notes.html.

      ]]>
      1.0M1 release available Thu, 22 Dec 2005 10:11:12 GMT Werner Guttmann http://castor.codehaus.org/news.html#item35 http://castor.codehaus.org/news.html#item35 The Castor 1.0M1 release has been made available at http://dist.codehaus.org/castor/1.0/

      This is a milestone build for the upcoming 1.0 release, and has no correlation to Christmas at all ... ;-). For details about the features added and the bugs fixed, please have a look at the release notes at http://castor.codehaus.org/release-notes.html.

      ]]>
      0.9.9.1 release available Sat, 15 Oct 2005 10:11:12 GMT Werner Guttmann http://castor.codehaus.org/news.html#item34 http://castor.codehaus.org/news.html#item34 The Castor 0.9.9.1 release has been made available at http://dist.codehaus.org/castor/0.9.9.1/

      This is a maintenance release. For details about the features added and the bugs fixed, please have a look at the release notes at http://castor.codehaus.org/release-notes.html.

      ]]>
      0.9.9 release - Final release available Thu, 22 Sep 2005 10:11:12 GMT Werner Guttmann http://castor.codehaus.org/news.html#item33 http://castor.codehaus.org/news.html#item33 The final release of Castor 0.9.9 has been made available at http://dist.codehaus.org/castor/0.9.9/

      This is a major feature release. For details about the features added and the bugs fixed, please have a look at the release notes at http://castor.codehaus.org/release-notes.html.

      ]]>
      0.9.9 release - 2nd milestone build available Tue, 13 Sep 2005 23:23:32 GMT Werner Guttmann http://castor.codehaus.org/news.html#item32 http://castor.codehaus.org/news.html#item32 0.9.9 release - 1st milestone build available Wed, 24 Aug 2005 23:23:32 GMT Werner Guttmann http://castor.codehaus.org/news.html#item31 http://castor.codehaus.org/news.html#item31 Castor 0.9.7 released Thu, 9 Jun 2005 13:12:11 GMT Werner Guttmann http://castor.codehaus.org/news.html#item30 http://castor.codehaus.org/news.html#item30 0.9.7 release - 1st milestone build available Thu, 19 May 2005 23:25:00 GMT Werner Guttmann http://castor.codehaus.org/news.html#item29 http://castor.codehaus.org/news.html#item29 Werner Guttmann Promoted to Castor JDO Lead Thu, 19 May 2005 14:08:00 GMT Bruce Snyder http://castor.codehaus.org/news.html#item28 http://castor.codehaus.org/news.html#item28 New Castor roadmap Wed, 11 May 2005 20:22:21 GMT Werner Guttmann http://castor.codehaus.org/news.html#item27 http://castor.codehaus.org/news.html#item27 Castor forums currently unavailable Wed, 20 Apr 2005 22:22:21 GMT Werner Guttmann http://castor.codehaus.org/news.html#item26 http://castor.codehaus.org/news.html#item26 New issue tracking tool Wed, 20 Apr 2005 21:22:21 GMT Werner Guttmann http://castor.codehaus.org/news.html#item25 http://castor.codehaus.org/news.html#item25 How to submit a patch - New guidelines Fri, 08 Apr 2005 21:22:21 GMT Werner Guttmann http://castor.codehaus.org/news.html#item24 http://castor.codehaus.org/news.html#item24 Support for polymorphism - A test drive Thu, 31 Mar 2005 21:22:26 GMT Werner Guttmann http://castor.codehaus.org/news.html#item23 http://castor.codehaus.org/news.html#item23 Mailing list changes Wed, 30 Mar 2005 22:23:24 GMT Werner Guttmann http://castor.codehaus.org/news.html#item22 http://castor.codehaus.org/news.html#item22 RSS feed available Thu, 10 Mar 2005 13:35:00 GMT Werner Guttmann http://castor.codehaus.org/news.html#item21 http://castor.codehaus.org/news.html#item21 A new home Mon, 14 Feb 2005 22:21:20 GMT Werner Guttmann http://castor.codehaus.org/news.html#item20 http://castor.codehaus.org/news.html#item20 After over five years of Exolab (http://www.exolab.org) sponsoring Castor, the Castor team recently decided to move the entire project to a new home over at the Codehaus (http://www.codehaus.org). The team would like to thank Exolab and its parent company Intalio, Inc. for its long-standing support of the project.

      Please use the below links for access to ...

      • Main documentation (http://castor.codehaus.org)
      • CVS repository (http://cvs.castor.codehaus.org)
      • Download (http://dist.codehaus.org/castor)
      ]]>
      Castor JDO - new committers Mon, 14 Feb 2005 21:21:21 GMT Werner Guttmann http://castor.codehaus.org/news.html#item19 http://groups.yahoo.com/group/rss-dev/message/7047 Final 0.9.6 release available Wed, 09 Feb 2005 22:22:22 GMT Werner Guttmann http://castor.codehaus.org/news.html#item18 http://castor.codehaus.org/news.html#item18 0.9.6 release candidate 3 available Tue, 11 Jan 2005 23:25:00 GMT Werner Guttmann http://castor.codehaus.org/news.html#item17 http://castor.codehaus.org/news.html#item17 0.9.6 release candidate 2 available Fri, 14 Jan 2005 23:35:32 GMT Werner Guttmann http://castor.codehaus.org/news.html http://castor.codehaus.org/news.html 0.9.6 release candidate 1 available Thu, 28 Oct 2004 23:35:32 GMT Werner Guttmann http://castor.codehaus.org/news.html#item15 http://castor.codehaus.org/news.html#item15 castor-1.3.2.orig/src/changes/0000755000000000000000000000000011656245645013052 5ustar castor-1.3.2.orig/src/changes/changes.xml0000644000000000000000000000231611544322135015170 0ustar Castor - Release Notes Werner Guttmann Refactored reporting tools usage in Maven POM. Tbd. Fixed problem with source distro files that prevented users from being able to build Castor themselves. Removed any references to 'maven.net' Maven repositories. castor-1.3.2.orig/src/changes/changes.1.3.1.xml0000644000000000000000000000050611544322136015627 0ustar Refactored reporting tools usage in Maven POM. Tbd. castor-1.3.2.orig/src/build.xml0000644000000000000000000016020711544322136013254 0ustar ----------------------------------------------------------- ANT build for ${name} ${version} ----------------------------------------------------------- The following targets are available: targets Lists the build targets clean Cleans the build and distribution directories all Cleans and builds all the packages and examples release Cleans and builds all the release packages (JAR, source, doc, tarball) in the dist directory main Builds the main packages (including debugging info) tests (shorthand for compile.tests) compile.commons Compile the Castor COMMONS packages compile.all Compile all Castor packages compile.examples Builds the example packages (including debugging info) compile.tests Builds the test packages (including debugging info) jdo.tests Executes the JUnit tests for Castor JDO (CTF-JDO) jar Builds the binary JAR in the dist directory CTFjar Builds the JAR of the Castor Testing Framework in the dist directory doc Builds the documentation javadoc Builds the full JavaDocs source Builds the source tarball in the dist directory tarball Builds the binary distribution in the dist directory gen.jdo.parser Use the Source Generator to create the Java classes for CastorQL Parser gen.jdo.conf Use the Source Generator to create the Java classes for jdo-conf.xsd gen.cpactf.conf Use the Source Generator to create the Java classes for cpactf-conf.xsd gen.mapping Use the Source Generator to create the Java classes for mapping.xsd gen.pvd Use the Source Generator to create the Java classes for the pvd.xsd run.unit.tests Executes the unit tests for the complete project ----------------------------------------------------------- Executing test category: ${test.category} - +------------------------------------------------------------------------------- | FAILURE CAUSE: Please set the test.category property to the test(s) to execute. | (examples: -Dtest.category=castor.mysql | or -Dtest.category=castor.mysql.TC01) +-------------------------------------------------------------------------------