GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - ttddyy/datasource-assert: Provides assertion APIs for query executions with assertEquals and assertThat(AssertJ and Hamcrest)

This repository was archived by the owner on Dec 31, 2023. It is now read-only.
BranchesTags
Open more actions menu

Latest commit

 

History

85 Commits
85 Commits

Folders and files

NameName
Last commit message
Last commit date
.mvn/wrapper
.mvn/wrapper
 
 
src
src
 
 
.gitignore
.gitignore
 
 
.travis.yml
.travis.yml
 
 
CHANGELOG.md
CHANGELOG.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
jitpack.yml
jitpack.yml
 
 
mvnw
mvnw
 
 
mvnw.cmd
mvnw.cmd
 
 
pom.xml
pom.xml
 
 

Repository files navigation

datasource-assert

Maven Central

datasource-assert provides assertion API for DataSource to validate query executions.

The assertion API is used for assertion methods such as assertEquals in JUnit and TestNG. Also, it comes with support for assertThat in AssertJ and Hamcrest.

Artifacts

Released Version

<dependency>
  <groupId>net.ttddyy</groupId>
  <artifactId>datasource-assert</artifactId>
  <version>[LATEST_VERSION]</version>
</dependency>

Documentation

  • User Guide
    • Latest Released Version
    • Snapshot Version
  • Javadoc
    • Latest Released Version
    • Snapshot Version

How to use

Wrap your datasource with ProxyTestDataSource.

@Test
public void myTest() {
  ProxyTestDataSource ds = new ProxyTestDataSource(actualDataSource);
  // rest of test 
}

If you want to reuse the same ProxyTestDataSource instance, you could reset() it between tests.

@After  // @AfterEach, @AfterMethod
public void tearDown() {
   this.ds.reset();
}

Regular assertions

For normal assertions such as JUnit/TestNG assertEquals, use methods from ProxyTestDataSource.

assertEquals(3, ds.getQueryExecutions().size());
PreparedExecution pe = ds.getFirstPrepared();
assertTrue(pe.isSuccess());

See more details on "Usage examples".

AssertJ

Static import assertThat from DataSourceAssertAssertions.

import static net.ttddyy.dsproxy.asserts.assertj.DataSourceAssertAssertions.assertThat;
assertThat(ds.getQueryExecutions()).hasSize(1);
assertThat(ds.getQueryExecutions().get(0)).isStatement().asStatement().query().isEqualTo("SELECT id FROM emp");
assertThat(ds.getFirstPrepared()).containsParam(1, "foo");

See more details on "Usage examples".

Hamcrest

Use matchers from DataSourceAssertMatchers.

assertThat(ds, statementCount(3));
assertThat(ds, executions(1, is(statement())));
assertThat((StatementExecution) statements.get(0), query(is("SELECT id FROM emp")));
assertThat(ds.getFirstPrepared(), paramAsInteger(1, is(100)));

See more details on "Usage examples".

Usage examples

Regular assertions(assertEquals, etc)

  • SimpleAssertionApiCheck

With AssertJ

  • AssertJAssertionApiCheck

With Hamcrest

  • HamcrestAssertionApiCheck

About

Provides assertion APIs for query executions with assertEquals and assertThat(AssertJ and Hamcrest)

Topics

assertjdatasourcedatasource-proxyhamcrestjavajdbcjunittestingtestngunittest

Resources

Readme
Apache-2.0 license
Activity

Stars

36 stars

Watchers

1 watching

Forks

4 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.