Download castor1.3.1 example, and modify test.bat file as follow:
Test Code
create a xml file for testing the generated code.
@echo off
REM Change the following line to set your JDK path
set JAVA_HOME=%JAVA_HOME%
set JAVA=%JAVA_HOME%\bin\java
set JAVAC=%JAVA_HOME%\bin\javac
set TPCL=C:\dev\castor\castor-1.3.1-examples-sources\lib\
@echo Create the classpath
echo %TPCL%
set CP=.;%TPCL%\castor-1.3.1-xml.jar;%TPCL%\castor-1.3.1-xml-schema.jar;%TPCL%\castor-1.3.1-codegen.jar;%TPCL%\castor-1.3.1-core.jar;%TPCL%\xercesImpl.jar;%TPCL%\commons-logging.jar;%JAVA_HOME%\lib\tools.jar;%TPCL%\lib\castor-1.3.1.jar
@echo.
@echo Using classpath: %CP%
@echo Castor Test Cases
@echo.
@echo Generating classes...
@rem Java 2 style collection types
@rem %JAVA% org.exolab.castor.builder.SourceGeneratorMain -i invoice.xsd -f -types j2 -binding-file bindingInvoice.xml
@rem Java 1.1 collection types
%JAVA% -cp %CP% org.exolab.castor.builder.SourceGeneratorMain -i test.xsd -f -package test.configuration.mapping.xmlimpl -dest .
@echo.
@echo Finish
%JAVAC% -classpath %CP% test\configuration\mapping\xmlimpl\descriptors\*.java
%JAVAC% -classpath %CP%;. *.java
@echo.
@echo Ready to run test case...
%JAVA% -cp %CP% TransactionTest
Test Code
import java.io.FileReader;
import test.configuration.mapping.xmlimpl.Begin;
import test.configuration.mapping.xmlimpl.Checkpoint;
import test.configuration.mapping.xmlimpl.End;
import test.configuration.mapping.xmlimpl.Transaction;
public class CastorTest {
public static void main(String[] args) {
try {
System.out.println("Unmarshalling Transaction");
Transaction transaction = Transaction.unmarshal(new FileReader("Test.xml"));
System.out.println();
System.out.println("unmarshalled...performing tests...");
System.out.println();
System.out.println("-------");
System.out.println();
System.out.println("test: " + transaction.getName()+"|"+transaction.getTimeout()+"|"+transaction.getSlatimeout());
} catch (Exception e) {
e.printStackTrace();
}
}
}
create a xml file for testing the generated code.