- Notifications
You must be signed in to change notification settings - Fork5
Java API for running utPLSQL v3+ unit tests from java applictions
License
utPLSQL/utPLSQL-java-api
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This is a collection of classes, that makes it easy to access theutPLSQL v3 database objects using Java.
- Usesut_runner.run methods to execute tests.
- Can gather results asynchronously from multiple reporters.
- Handles compatibility for all 3.x versions of utPLSQL
This is a Maven Library project, you can add on your Java project as a dependency.
The project is hosted onpackagecloud.io
You install this Maven repository by adding it to the section of your pom.xml. No special plugins or extensions are required.
<repositories> <repository> <id>utplsql-java-api</id> <url> https://packagecloud.io/utplsql/utplsql-java-api/maven2 </url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository></repositories>
To use the java-api library, add this to the<dependencies>
section of yourpom.xml
.
<dependency> <groupId>org.utplsql</groupId> <artifactId>java-api</artifactId> <version>3.1.2</version> <scope>compile</scope></dependency>
The latest Java-API is always compatible with all database frameworks of the same major version.For example API-3.0.4 is compatible with database framework 3.0.0-3.1.2 but not with database framework 2.x.
It is although recommended to always use the latest release of the API to build your tools for utPLSQL.
You can find examples for many features of the java-api in the Unit- and Integration tests.
Executing tests using default parameters:
try (Connectionconn =DriverManager.getConnection(url)) {newTestRunner().run(conn);}catch (SQLExceptione) {e.printStackTrace();}
Executing tests and printing results to screen:
try (Connectionconn =DriverManager.getConnection(url)) {ReporterdocumentationReporter =newDocumentationReporter().init(conn);newTestRunner() .addReporter(documentationReporter) .run(conn);documentationReporter .getOutputBuffer() .setFetchSize(1) .printAvailable(conn,System.out);}catch (SQLExceptione) {e.printStackTrace();}
There might be some features which are not available in previous versions of utPLSQL.These "optional features" are listed in the enum org.utplsql.api.compatibility.OptionalFeaturesand their availability can be checked against a connection or Version-object:
OptionalFeatures.CUSTOM_REPORTERS.isAvailableFor( databaseConnection );
To handle downwards-compatibility, java-api provides an easy to use CompatiblityProxy, which is instantiated with a connection.It will check the database-version of utPLSQL and is used in several other features likeTestRunner
andReporterFactory
.You can also ask it for the database-version.
try (Connectionconn =DriverManager.getConnection(url)) {CompatiblityProxyproxy =newCompatibilityProxy(conn );Versionversion =proxy.getDatabaseVersion();}catch (SQLExceptione) {e.printStackTrace();}
The java-api provides a ReporterFactory you can use to inject your own implementations of (java-side) reporters or reporter-handlers.It also provides a more generic approach to Reporter-handling.
If you request the Reporter-Factory for a Reporter it has no specific implementation for it will justreturn an instance of aDefaultReporter
with the given name as SQL-Type, assumingthat it exists in the database. Therefore you can address custom reporters without the needof a specific java-side implementation.
try (Connectionconn =DriverManager.getConnection(url)) {ReporterFactoryreporterFactory =ReporterFactory.createDefault(newCompatibilityProxy(conn ));reporterFactory.registerReporterFactoryMethod(CoreReporters.UT_DOCUMENTATION_REPORTER.name(),MyCustomReporterImplementation::new,"Custom handler for UT_DOCUMENTATION_REPORTER");Reporterreporter =reporterFactory.createReporter(CreateReporters.UT_DOCUMENTATION_REPORTER.name());}catch (SQLExceptione) {e.printStackTrace();}
About
Java API for running utPLSQL v3+ unit tests from java applictions
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors5
Uh oh!
There was an error while loading.Please reload this page.