This is Java API compatibility testing tools.
Main goal is to be able to create API signature and verify that library implementation conforms to defined specification.
The tool automates verification process of the API under test with a reference API. Also tool can create classes base on API descriptor XML.
Java reflection API is not used during tests so Object are not instantiated. Javassist is used to get the API description from classes.
There are other tools that do something like this:
java -cp jour-instrument-2.0.3.jar;javassist.jar net.sf.jour.SignatureGenerator \ --src myclasses.jar --packages com.api;com.ext --dst api-signature.xml
All command line options:
N.B javassist.jar should be in classpath when running jour.
See Schema for signature.xml http://jour.sourceforge.net/2.0/api-signature.xsd and XML Schema Documentation.
<?xml version="1.0" encoding="UTF-8"?> <signature> <interface name="uut.signature.AnInerface" modifiers="public"> <method name="getVoid" return="void" modifiers="public abstract"/> <method name="getInt" return="int" modifiers="public abstract"/> </interface> <class name="uut.signature.AClass" modifiers="public"> <implements> <interface name="uut.signature.AnInerface"/> </implements> <constructor modifiers="public"/> <constructor> <parameter type="int[]"/> <exception name="java.lang.Error"/> </constructor> <method name="getInt" return="int" modifiers="public"/> <method name="getProt" return="void" modifiers="protected"/> <method name="getVoid" return="void" modifiers="public"/> <field name="constData" type="int" modifiers="public static final" constant-value="10"/> <field name="data" type="short" modifiers="static"/> </class> <class name="uut.signature.AChildClass" modifiers="public" extends="uut.signature.AClass"> <constructor modifiers="protected"/> <method name="run" return="void" modifiers="public"/> <method name="run" return="java.lang.Long" modifiers="public"> <exception name="java.lang.Error"/> <parameter type="byte"/> </method> <field name="constData" type="int" modifiers="public static final" constant-value="10"/> <field name="data" type="short" modifiers="static"/> </class> </signature>
java -cp jour-instrument-2.0.3.jar net.sf.jour.SignatureVerify --src myclasses-v2.jar --signature api-signature.xml
All command line options:
N.B javassist.jar should be in classpath when running jour.
Extend your JUnit test from net.sf.jour.signature.SignatureTestCase and implement abstract methods
package javax.obex; import net.sf.jour.signature.SignatureTestCase; public class JSR82APIObexDeclarationsTest extends SignatureTestCase { public String getAPIPath() { return getClassPath(SessionNotifier.class); } public String getSignatureXMLPath() { return "jsr82-obex-signature.xml"; } }
Alternatively you can use class net.sf.jour.signature.APICompare
java -cp jour-instrument-2.0.3.jar net.sf.jour.SignatureExport --signature api-signature.xml --dst ./api-classes
All command line options: