Actually with 44% coverage
The project is born as a future extension of HttpAnsweringMachine (on github too)
The idea is to create a proxy Jdbc driver able to translate all JDBC calls into something serializable, therefore able to be passed through simple http calls, and easy to modify.
The Server (Actually a simple serializer-deserializer) create the real connections/statements/resultsets and exposes them via String data
So using the driver means
- Passing a "real" connection string to the db like "jdbc:h2:mem:test"
- Connect to the Janus-server like "jdbc:janus:http://localhost/db?fetchSize=3&charset=UTF-8"
- loadRsOnExec: load resultset on ".exec(" calls (useful to simplify recording)
- Look all messages passing
Tested with Hibernate
Add this to your repositories in poms
<repositories>
<repository>
<id>kendar</id>
<name>Kendar Repository</name>
<url>https://maven.kendar.org/maven2/releases</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>kendar2</id>
<name>Kendar Repository2</name>
<url>https://maven.kendar.org/maven2/snapshots</url>
<layout>default</layout>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
Actually only a "fake" implementation exists on tests: JsonServer
- private JdbcCommand getIjCommand(JdbcCommand command) translate the commands to serializable
- private JdbcResult getIjResult(JdbcResult command) translate the results to serializable
Simple index based reproduction of dataset interactions
A custom serializer is built to guarantee the type integrity. You can implement wetheaver you want: JsonTypedSerializer
An example of what is serialized
{ "command": { "database": "jdbc:janus:http://localhost/db?fetchSize=3&charset=UTF-8", ":database:": "java.lang.String", "clientinfo": [{ "_key": "janus.client.address", ":_key:": "java.lang.String", "_value": "192.168.1.20", ":_value:": "java.lang.String" }, { "_key": "janus.client.name", ":_key:": "java.lang.String", "_value": "XPS15-KENDAR", ":_value:": "java.lang.String" }], ":clientinfo:": "java.util.Properties" }, ":command:": "org.kendar.janus.cmd.connection.ConnectionConnect" }
Here a command remotely invoked via reflection
{ "command": { "name": "cancel", ":name:": "java.lang.String", "paramtype": [], ":paramtype:": "[Ljava.lang.Class;", "[paramtype]": "0", "parameters": [], ":parameters:": "[Ljava.lang.Object;", "[parameters]": "0" }, ":command:": "org.kendar.janus.cmd.Exec" }
The things are
- "name":"value" parameter content
- ":name:":"JAVA_CLASS" parameter type
- "[name]":"1,10" array dimensions
- "_key":"value" key of hashmap
- "_value":"value" value of hashmap
- "_":"value" value of array
- The Updatable ResultSets are fetched one by one
- RowId is handled as RowId when present, converted to long/String/byte[] if founded matching
- Conversions extending "Java Type Conversion (Done Well)"