forked from eclipse-archived/reddeer
-
Notifications
You must be signed in to change notification settings - Fork 1
Database Requirement Extension
jpeterka edited this page Jun 30, 2014
·
5 revisions
Database requirement can help you to utilize external database configuration (like JDBC string, driver location) in your tests. Steps are similar as for general custom requirement extension:
- annotate tests and utilize requirement and it's configuration
- create configuration xml file following to xsd template
- run test with with given reddeer config file
@Database(name="dbtest")
@RunWith(RedDeerSuite.class)
class MyDBTest {
@InjectRequirement
DatabaseRequirement dbRequirement;
@Test
public void testMyH2Database {
DatabaseConfiguration cfg = dbRequirement.getConfiguration();
String jdbc = cfg.getJDBCString();<?xml version="1.0" encoding="UTF-8"?>
<testrun xmlns="http://www.jboss.org/NS/Req" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:db="http://www.jboss.org/NS/db-schema"
xsi:schemaLocation="http://www.jboss.org/NS/Req http://www.jboss.org/schema/reddeer/RedDeerSchema.xsd http://www.jboss.org/NS/db-schema http://www.jboss.org/schema/reddeer/DatabaseRequirement.xsd">
<requirements>
<db:database-requirement name="h2-sakila">
<db:driverName>My H2 Driver</db:driverName>
<db:driverType>Generic JDBC</db:driverType>
<db:driverTypeVersion>1.0</db:driverTypeVersion>
<db:driverPath>/opt/sakila-db/h2-1.3.161.jar</db:driverPath>
<db:driverClass>org.h2.Driver</db:driverClass>
<db:profileName>dbProfile</db:profileName>
<db:jdbcString>jdbc:h2:db://localhost/sakila</db:jdbcString>
<db:username>sa</db:username>
<db:password></db:password>
</db:database-requirement>
</requirements>
</testrun>-Dreddeer.config=/opt/rd-conf/
For more details you can follow more comprehensive tutorial tutorial article
JBoss Red Deer - Quick Links
- Home
- [Release notes] (/jboss-reddeer/reddeer/wiki/Release-notes)
- Articles
- JavaDoc
- User guide
- Contributor Guide
- FAQ