Example: Using pass-through in database stubs
If you want a database virtualization stub to call the real database when a table contained in the SQL is unknown to the stub, then you can use the pass-through settings tab in the Database Stub editor. If the call to the database conforms to the settings that you select, then the SQL call is directed to the real database.
With the pass-through option, you can manage a small set of data related to your testing activities that appears as part of the real system. For example, a layer between the testing activities and the larger content.
Consider the scenario where the JDBC database application accesses some tables in the database. You have a stub that is used to virtualize the data in these tables. As your application is being developed, you may add more tables to your database or access more tables from the JDBC database application. But when running your application against the stub, you will receive exceptions when trying to access these tables because they are unknown to your stub.
The pass-through option enables the application to use the same stub and instead of passing an error if tables are unknown to the stub, the stub calls the real database instead. The following examples help to understand how Integration Tester can help in similar situations that occur during the testing and development cycle.
Pass-through unlearned tables
Consider you have a new table that the JDBC database application accesses to show a list of buildings. However, this table is not part of the stub. You need the data from the building table to completely test the application. So you must get the data from the real database instead.
This can be accomplished by following these steps:
- Select Enable Pass-through on the Pass-through tab of the Stub editor.
- Select the Pass-through unlearned tables check box.
- Save the stub and run it.
Now, when you run the JDBC database application, you can get the required data back from the real database and continue testing your application instead of receiving an exception about missing data.
Pass-through unlearned stored procedures
Consider that there have been several new stored procedures that were developed and that the JDBC database application uses. Unfortunately, the new stored procedures do not exist in the stub and you might get an error when you try to use them while virtualizing. You must test the stored procedures called by the application without modifying the stub data.
This can be accomplished by following these steps:
- Select Enable Pass-through on the Pass-through tab of the Stub editor.
- Select the Pass-through unlearned stored procedures check box.
- Save the stub and run it.
Now, the JDBC database application can use stored procedures in the real database that do not exist in the stub while virtualizing, without receiving any error about the missing data.
Pass-through unlearned INSERT/UPDATE/DELETE statements
Consider that there is a new table that the JDBC database application accesses to show detailed information about employees. However, the table is not part of the stub. You must test the manipulating data in the table by using the Insert/Update/Delete statements. You will get exceptions because the table does not exist in the stub.
This can be accomplished by following these steps:
- Select Enable Pass-through on the Pass-through tab of the Stub editor.
- Select the Pass-through unlearned INSERT/UPDATE/DELETE statements check box.
- Save the stub and run it.
When virtualizing, you can now run the stored procedures on the real database from the JDBC database application even though the procedures do not exist in the stub, without receiving any error.
Empty Results
Consider you have a table in the stub, called Employee which is queried by the JDBC database application, but the query returns no data and no errors are displayed. It means that the data you look for is not found in the data stored in the stub. When you further test, you must check the real database to see if any records exist, that match your query without altering the stub.
This can be accomplished by following these steps:
- Select Enable Pass-through on the Pass-through tab of the Stub editor.
- Select the Employee table in the Empty Results table.
- Save the stub and run it.
Now any records that match the JDBC database application’s query in the real database are returned instead of empty results from the stub and you can complete your testing.
Automatically Learn Queries after pass-through
Consider you have added new tables of data in your database that you access from the JDBC database application. Also, you must ensure to add the queries and data from those tables to the existing stub by not modifying the stub manually.
This can be accomplished by following these steps:
- Select Persistent on the Summary tab of the Stub editor.
- Select Enable Pass-through on the Pass-through tab of the Stub editor.
- Select the Pass-through unlearned tables check box to learn queries and data from tables that do not exist in the stub.
- Select tables in the Empty Results list to learn data from the real database when the stub returns empty results for a query.
- Select the Automatically learn Queries after pass-through (workbench only) check box.
After the stub is stopped, the new data and queries are added to the stub. The added items include any new tables, queries used by the JDBC database application, and data from the Employee table matching queries that previously returned no data from the stub. If you keep the stub open in the editor before starting the stub, then you must save the stub in the editor before you run the stub again to virtualize the newly learned data.