Skip to content

Latest commit

 

History

History
200 lines (138 loc) · 6.56 KB

moddb.md

File metadata and controls

200 lines (138 loc) · 6.56 KB

In this demo you will

  • Start locally HAM server
  • Start the sample application
  • Connect to it through proxy
  • Record the simplified db interactions of the sample application
  • Modify db data on the recording!

For more infos check here

Download the last release

Download the two tar.gz, ham and ham-samples from github releases and extract them in the same directory

Starting the sample application

Go on the "calendar" directory and run "runcalendardbproxy.bat/sh"

This will start

First you should choose if you want to recreate the db go for Y the first time

Then you will have to wait a bit. Now DO NOT START THE BE!!

The calendar sample project

It's composed of three parts

  • FE, that calls gateway for all its needs
  • GATEWAY, that acts a "middleman" between FE and BE
  • BE, with the database that is called only by the GATEWAY

Configure proxy

Should set the proxy to 127.0.0.1 And port 1080 for socks5 or 1081 for http/https

Click me for more explanations
  • Chrome:

    • Install Proxy Switch Omega
    • Go to options
    • Add http and https proxy server with
      • Address: 127.0.0.1

      • Port 1081.

        Ham Proxyes
    • Select "proxy" from the extension menu and back to "direct" when you want to disconnect
    • Ham Proxyes
  • Firefox

    • Navigate to about:preferences

    • Search for "proxy"

    • Click on "Settings"

    • Go to "Manual proxy Configuration"

    • Select the socks5 proxy

      • Address: 127.0.0.1
      • Port 1080
    • Check the "Proxy DNS when using SOCKS v5" flag

    • Clean the settings when needed

      Ham Proxyes

Record some interaction

  • Now you can start the application on the command line :) and wait for its readiness
  • Stop it
  • Run the benogen.bat/sh but do not press a key to continue!

You can now check the configuration

  • Going on ham proxyes you can verify that all proxies are ok if they don't work just "Refresh Status"

Ham Proxyes

  • And a db proxy for be

Ham Proxyes

Create recording

  • Set the recording with the simplified recording! This will record only "most important" stuffs. What can't be simulated will be recorded

Create recording

  • Once you create the recording you can start recording! CHECKING THE "Record db calls" and the "Use simulated engine"

Start recording

  • Now you can press the key on the benogen! And start the application

  • Wait for its start

  • Go then on the application and do some interaction

    • Add an Employee "John Doe"
    • Go on Appointements
    • Add an Appointment with "Doctor" as description
    • Change the state of the appointament till it shows "Confirmed"
    • Delete the appointment
    • Back on employee, delete the employee too
  • And stop the recording!

  • Now you will se all the calls on the just created recording

  • First the hibernate initialization phase

Start recording

  • ..or see how an employee is created.
    • First a post to the gateway
    • Forwarded to the be
    • Then the be opens the connections and run the query

Start recording

  • You can even see the details of the queries there are many visualisations available
    • JSON: the native format of Janus-Jdbc (editable)
    • Component: the "easy editable visualisation", when available
    • Tree: the structure of the json message (that include the data types)

Start recording

Analyzing the Json we identify a prepared statement with one Long parameter with set the index 1 (the first to set JDBC prepared statement parameters)

{
	"command": {
		"sql": "
            select 
              employee0_.id as id1_1_0_, 
              employee0_.name as name2_1_0_, 
              employee0_.role as role3_1_0_ 
            from 
              employee employee0_ 
            where employee0_.id=?",
		":sql:": "java.lang.String",
		"parameters": [
			{
				"_": {
					"columnindex": 1,
					":columnindex:": "java.lang.Integer",
					"value": 0,
					":value:": "java.lang.Long"
				},
				":_:": "org.kendar.janus.cmd.preparedstatement.parameters.LongParameter"
			}
		],
		":parameters:": "java.util.ArrayList"
	},
	":command:": "org.kendar.janus.cmd.preparedstatement.PreparedStatementExecuteQuery"
}

Replay everything!

  • Select all 'http' type calls and delete them

Create recording

  • "Download" the recording as "SimplifiedDb.json"
  • Look for the first PreparedStatement/executeQuery and edit it

Create recording

  • Go then on RESDATA/COMPONENT

Create recording

  • Add a row (1), save the JdbcResultSet (2) and the Selected item (3)

Create recording

  • Stop the benogen
  • Play the recording with the "Use simulated engine" checked

Create recording

  • Restart the benogen!
  • Go on www.sample test and be happy :)

Create recording