Cloak-db

Manages JNDI and an in memory db so you can concentrate on writing quick, clean DataSource unit tests.

License

License

GroupId

GroupId

io.github.codemumbler
ArtifactId

ArtifactId

cloak-db
Last Version

Last Version

1.0
Release Date

Release Date

Type

Type

jar
Description

Description

Cloak-db
Manages JNDI and an in memory db so you can concentrate on writing quick, clean DataSource unit tests.
Project URL

Project URL

https://github.com/codemumbler/cloak-db
Source Code Management

Source Code Management

https://github.com/codemumbler/cloak-db.git

Download cloak-db

How to add to project

<!-- https://jarcasting.com/artifacts/io.github.codemumbler/cloak-db/ -->
<dependency>
    <groupId>io.github.codemumbler</groupId>
    <artifactId>cloak-db</artifactId>
    <version>1.0</version>
</dependency>
// https://jarcasting.com/artifacts/io.github.codemumbler/cloak-db/
implementation 'io.github.codemumbler:cloak-db:1.0'
// https://jarcasting.com/artifacts/io.github.codemumbler/cloak-db/
implementation ("io.github.codemumbler:cloak-db:1.0")
'io.github.codemumbler:cloak-db:jar:1.0'
<dependency org="io.github.codemumbler" name="cloak-db" rev="1.0">
  <artifact name="cloak-db" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.github.codemumbler', module='cloak-db', version='1.0')
)
libraryDependencies += "io.github.codemumbler" % "cloak-db" % "1.0"
[io.github.codemumbler/cloak-db "1.0"]

Dependencies

compile (1)

Group / Artifact Type Version
org.hsqldb : hsqldb jar 2.3.2

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

cloak-db

Manages JNDI and an in memory db so you can concentrate on writing quick, clean DataSource unit tests.

Include the dependency using Maven:

  	<dependency>
	  <groupId>io.github.codemumbler</groupId>
	  <artifactId>cloak-db</artifactId>
	  <scope>test</scope>
	</dependency>

Then choose one of two ways to manage the mock database.

  1. Extend your test classes which touch the database with CloakAbstractTestCase and implement jdbcName to return your "jdbc/dbName".
  public class MyDBTestClass extends CloakAbstractTestCase {
    ....
    @Override
    protected String jdbcName() {
      return "jdbc/myDBName";
    }
    
    @Test
    public void testDBAction() {
      productionClass.doSomethingWithDatabase();
    }
    ...
  }
  1. Use the CloakDatabase class to have more control when the database resets.
  public class MyDBTestClass {
  
    private static CloakDatabase database;
    ...
    
    @BeforeClass
    public static void setUpClass() {
    	database = new CloakDatabase("jdbc/myDBName);
    }
    
    @After
    public void tearDown() {
    	database.reset();
    }
    ...
    
    @Test
    public void testDBAction() {
      productionClass.doSomethingWithDatabase();
    }
    ...
  }

Versions

Version
1.0