*/
@@ -129,6 +133,6 @@ default void accept(final T elem) {
}
}
- void acceptThrows( T t ) throws IOException;
+ void acceptThrows(T t) throws IOException;
}
}
diff --git a/src/main/java/org/utplsql/api/reporter/DefaultReporter.java b/src/main/java/org/utplsql/api/reporter/DefaultReporter.java
index 073115d..b478355 100644
--- a/src/main/java/org/utplsql/api/reporter/DefaultReporter.java
+++ b/src/main/java/org/utplsql/api/reporter/DefaultReporter.java
@@ -5,18 +5,19 @@
import java.sql.SQLException;
-/** This is a basic Reporter implementation, using ORAData interface
+/**
+ * This is a basic Reporter implementation, using ORAData interface
*
* @author pesse
*/
public class DefaultReporter extends Reporter {
- public DefaultReporter(String typeName, Object[] attributes ) {
+ public DefaultReporter(String typeName, Object[] attributes) {
super(typeName, attributes);
}
@Override
- protected void initOutputBuffer( OracleConnection oraConn, CompatibilityProxy compatibilityProxy ) throws SQLException {
+ protected void initOutputBuffer(OracleConnection oraConn, CompatibilityProxy compatibilityProxy) throws SQLException {
outputBuffer = compatibilityProxy.getOutputBuffer(this, oraConn);
}
}
diff --git a/src/main/java/org/utplsql/api/reporter/DefaultReporterFactoryMethodRegistrator.java b/src/main/java/org/utplsql/api/reporter/DefaultReporterFactoryMethodRegistrator.java
index 8760f55..f1880df 100644
--- a/src/main/java/org/utplsql/api/reporter/DefaultReporterFactoryMethodRegistrator.java
+++ b/src/main/java/org/utplsql/api/reporter/DefaultReporterFactoryMethodRegistrator.java
@@ -2,13 +2,14 @@
import org.utplsql.api.compatibility.CompatibilityProxy;
-/** Helper-class which registers default ReporterFactoryMethods based on the given databaseVersion
+/**
+ * Helper-class which registers default ReporterFactoryMethods based on the given databaseVersion
*
* @author pesse
*/
class DefaultReporterFactoryMethodRegistrator {
- public static void registerDefaultReporters(ReporterFactory reporterFactory, CompatibilityProxy compatibilityProxy ) {
+ public static void registerDefaultReporters(ReporterFactory reporterFactory, CompatibilityProxy compatibilityProxy) {
// At the moment we don't have version-specific reporters which need a special MethodFactory
reporterFactory.registerReporterFactoryMethod(CoreReporters.UT_DOCUMENTATION_REPORTER.name(), DocumentationReporter::new, "Provides additional properties lvl and failed");
diff --git a/src/main/java/org/utplsql/api/reporter/DocumentationReporter.java b/src/main/java/org/utplsql/api/reporter/DocumentationReporter.java
index 19edd01..6e36613 100644
--- a/src/main/java/org/utplsql/api/reporter/DocumentationReporter.java
+++ b/src/main/java/org/utplsql/api/reporter/DocumentationReporter.java
@@ -8,23 +8,13 @@ public class DocumentationReporter extends DefaultReporter {
private int failed;
public DocumentationReporter() {
- super( CoreReporters.UT_DOCUMENTATION_REPORTER.name(), null );
+ super(CoreReporters.UT_DOCUMENTATION_REPORTER.name(), null);
}
- public DocumentationReporter(String selfType, Object[] attributes ) {
+ public DocumentationReporter(String selfType, Object[] attributes) {
super(selfType, attributes);
}
- @Override
- protected void setAttributes(Object[] attributes) {
- super.setAttributes(attributes);
-
- if ( attributes != null ) {
- lvl = ((BigDecimal)attributes[3]).intValue();
- failed = ((BigDecimal)attributes[4]).intValue();
- }
- }
-
@Override
protected Object[] getAttributes() {
Object[] attributes = super.getAttributes();
@@ -33,6 +23,16 @@ protected Object[] getAttributes() {
return attributes;
}
+ @Override
+ protected void setAttributes(Object[] attributes) {
+ super.setAttributes(attributes);
+
+ if (attributes != null) {
+ lvl = ((BigDecimal) attributes[3]).intValue();
+ failed = ((BigDecimal) attributes[4]).intValue();
+ }
+ }
+
public int getLvl() {
return lvl;
}
diff --git a/src/main/java/org/utplsql/api/reporter/Reporter.java b/src/main/java/org/utplsql/api/reporter/Reporter.java
index 639e0c6..6edd853 100644
--- a/src/main/java/org/utplsql/api/reporter/Reporter.java
+++ b/src/main/java/org/utplsql/api/reporter/Reporter.java
@@ -14,44 +14,41 @@
import java.sql.Connection;
import java.sql.SQLException;
-/** This is a basic Reporter implementation, using ORAData interface
+/**
+ * This is a basic Reporter implementation, using ORAData interface
*
* @author pesse
*/
public abstract class Reporter implements ORAData {
private static final Logger logger = LoggerFactory.getLogger(Reporter.class);
-
+ protected OutputBuffer outputBuffer;
private String selfType;
private String id;
private Object[] attributes;
private boolean init = false;
- protected OutputBuffer outputBuffer;
- public Reporter( String typeName, Object[] attributes ) {
+ public Reporter(String typeName, Object[] attributes) {
setTypeName(typeName);
- setAttributes( attributes );
- }
-
- protected void setTypeName( String typeName ) {
- this.selfType = typeName.replaceAll("[^0-9a-zA-Z_\\.]", "");
+ setAttributes(attributes);
}
+ public Reporter init(Connection con, CompatibilityProxy compatibilityProxy, ReporterFactory reporterFactory) throws SQLException {
- public Reporter init(Connection con, CompatibilityProxy compatibilityProxy, ReporterFactory reporterFactory ) throws SQLException {
-
- if ( compatibilityProxy == null )
+ if (compatibilityProxy == null) {
compatibilityProxy = new CompatibilityProxy(con);
- if ( reporterFactory == null )
+ }
+ if (reporterFactory == null) {
reporterFactory = new ReporterFactory();
+ }
OracleConnection oraConn = con.unwrap(OracleConnection.class);
- initDbReporter( oraConn, reporterFactory );
+ initDbReporter(oraConn, reporterFactory);
init = true;
- initOutputBuffer( oraConn, compatibilityProxy);
+ initOutputBuffer(oraConn, compatibilityProxy);
return this;
}
@@ -60,16 +57,17 @@ public Reporter init(Connection con) throws SQLException {
return init(con, null, null);
}
- protected abstract void initOutputBuffer( OracleConnection oraConn, CompatibilityProxy compatibilityProxy ) throws SQLException;
+ protected abstract void initOutputBuffer(OracleConnection oraConn, CompatibilityProxy compatibilityProxy) throws SQLException;
- /** Initializes the Reporter from database
+ /**
+ * Initializes the Reporter from database
* This is necessary because we set up DefaultOutputBuffer (and maybe other stuff) we don't want to know and care about
* in the java API. Let's just do the instantiation of the Reporter in the database and map it into this object.
*
* @param oraConn
* @throws SQLException
*/
- private void initDbReporter( OracleConnection oraConn, ReporterFactory reporterFactory ) throws SQLException {
+ private void initDbReporter(OracleConnection oraConn, ReporterFactory reporterFactory) throws SQLException {
OracleCallableStatement callableStatement = (OracleCallableStatement) oraConn.prepareCall("{? = call " + selfType + "()}");
callableStatement.registerOutParameter(1, OracleTypes.STRUCT, "UT_REPORTER_BASE");
callableStatement.execute();
@@ -81,17 +79,17 @@ private void initDbReporter( OracleConnection oraConn, ReporterFactory reporterF
logger.debug("Database-reporter initialized, Type: {}, ID: {}", selfType, id);
}
- protected void setAttributes(Object[] attributes ) {
+ protected Object[] getAttributes() {
+ return attributes;
+ }
+
+ protected void setAttributes(Object[] attributes) {
if (attributes != null) {
- this.id = DatatypeConverter.printHexBinary((byte[])attributes[1]);
+ this.id = DatatypeConverter.printHexBinary((byte[]) attributes[1]);
}
this.attributes = attributes;
}
- protected Object[] getAttributes() {
- return attributes;
- }
-
public boolean isInit() {
return init;
}
@@ -100,14 +98,17 @@ public String getTypeName() {
return this.selfType;
}
+ protected void setTypeName(String typeName) {
+ this.selfType = typeName.replaceAll("[^0-9a-zA-Z_\\.]", "");
+ }
+
public String getId() {
return this.id;
}
- public Datum toDatum(Connection c) throws SQLException
- {
- return (Datum)c.createStruct(getTypeName(), getAttributes());
+ public Datum toDatum(Connection c) throws SQLException {
+ return (Datum) c.createStruct(getTypeName(), getAttributes());
}
public OutputBuffer getOutputBuffer() {
diff --git a/src/main/java/org/utplsql/api/reporter/ReporterFactory.java b/src/main/java/org/utplsql/api/reporter/ReporterFactory.java
index 510896b..4b733e3 100644
--- a/src/main/java/org/utplsql/api/reporter/ReporterFactory.java
+++ b/src/main/java/org/utplsql/api/reporter/ReporterFactory.java
@@ -12,67 +12,87 @@
import java.util.Map;
import java.util.function.BiFunction;
-/** This class manages the instantiation of reporters.
+/**
+ * This class manages the instantiation of reporters.
* One can register a supplier method for a specific name which will then be callable via createReporter(name)
- *
+ *
* Use the static createEmpty or createDefault methods to get a new instance.
* We don't allow direct instantiation because we want
*
- * - Register default ReporterFactoryMethods for Core-Reporters
- * - Be able to add more than one ReporterFactory implementation due to backwards-compatibility in future
+ * - Register default ReporterFactoryMethods for Core-Reporters
+ * - Be able to add more than one ReporterFactory implementation due to backwards-compatibility in future
*
*
* @author pesse
*/
public final class ReporterFactory implements ORADataFactory {
- public static class ReporterFactoryMethodInfo {
- public ReporterFactoryMethodInfo(BiFunction factoryMethod, String description) {
- this.factoryMethod = factoryMethod;
- this.description = description;
- }
- public final BiFunction factoryMethod;
- public final String description;
+ private final Map reportFactoryMethodMap = new HashMap<>();
+
+ ReporterFactory() {
}
- private final Map reportFactoryMethodMap = new HashMap<>();
+ /**
+ * Returns a new instance of an empty ReporterFactory with no registered ReporterFactoryMethods
+ * Normally, you should be using createDefault-method instead.
+ *
+ * @return a new ReporterFactory instance
+ */
+ public static ReporterFactory createEmpty() {
+ return new ReporterFactory();
+ }
- ReporterFactory() { }
+ /**
+ * Returns a new instance of a ReporterFactory with the default ReporterFactoryMethods registered.
+ * This can depend on the version of utPLSQL, therefore you have to provide a CompatibilityProxy
+ *
+ * @param proxy Compatibility proxy
+ * @return a new ReporterFactory instance with all default ReporterFactoryMethods registered
+ */
+ public static ReporterFactory createDefault(CompatibilityProxy proxy) {
+ ReporterFactory reporterFactory = new ReporterFactory();
+ DefaultReporterFactoryMethodRegistrator.registerDefaultReporters(reporterFactory, proxy);
+ return reporterFactory;
+ }
- /** Registers a creation method for a specified reporter name. Overrides eventually existing creation method
+ /**
+ * Registers a creation method for a specified reporter name. Overrides eventually existing creation method
*
- * @param reporterName the reporter's name to register
+ * @param reporterName the reporter's name to register
* @param factoryMethod the method which will return the reporter
- * @param description the description of the reporter
+ * @param description the description of the reporter
* @return Object with information about the registered reporter
*/
public synchronized ReporterFactoryMethodInfo registerReporterFactoryMethod(String reporterName, BiFunction factoryMethod, String description) {
return reportFactoryMethodMap.put(reporterName.toUpperCase(), new ReporterFactoryMethodInfo(factoryMethod, description));
}
- /** Unregisters a specified reporter name.
+ /**
+ * Unregisters a specified reporter name.
*
* @param reporterName the reporter's name to unregister
* @return information about the reporter which was previously registered or null
*/
- public synchronized ReporterFactoryMethodInfo unregisterReporterFactoryMethod(String reporterName ) {
+ public synchronized ReporterFactoryMethodInfo unregisterReporterFactoryMethod(String reporterName) {
return reportFactoryMethodMap.remove(reporterName.toUpperCase());
}
- /** Checks whether a given reporter has a registered FactoryMethod or not
+ /**
+ * Checks whether a given reporter has a registered FactoryMethod or not
*
* @param reporterName the reporter's name
* @return true or false
*/
- public synchronized boolean hasRegisteredFactoryMethodFor( String reporterName ) {
+ public synchronized boolean hasRegisteredFactoryMethodFor(String reporterName) {
return reportFactoryMethodMap.containsKey(reporterName.toUpperCase());
}
- /** Returns a new reporter of the given name.
+ /**
+ * Returns a new reporter of the given name.
* If no specific ReporterFactoryMethod is registered, returns a default {Reporter}
*
* @param reporterName the reporter's name to create a new instance of
- * @param attributes attributes from STRUCT
+ * @param attributes attributes from STRUCT
* @return A reporter
*/
public Reporter createReporter(String reporterName, @Nullable Object[] attributes) {
@@ -80,29 +100,33 @@ public Reporter createReporter(String reporterName, @Nullable Object[] attribute
reporterName = reporterName.toUpperCase();
BiFunction supplier = DefaultReporter::new;
- if ( reportFactoryMethodMap.containsKey(reporterName)) {
+ if (reportFactoryMethodMap.containsKey(reporterName)) {
ReporterFactoryMethodInfo ri = reportFactoryMethodMap.get(reporterName);
- if (ri == null)
+ if (ri == null) {
throw new RuntimeException("ReporterFactoryMethodInfo for " + reporterName + " was null");
+ }
supplier = ri.factoryMethod;
}
- if ( supplier == null )
+ if (supplier == null) {
throw new RuntimeException("No factory method for " + reporterName);
+ }
- return supplier.apply( reporterName, attributes );
+ return supplier.apply(reporterName, attributes);
}
- /** Returns a new reporter of the given name (or should do so).
+ /**
+ * Returns a new reporter of the given name (or should do so).
* If no specific ReporterFactoryMethod is registered, returns a default {Reporter}
*/
- public Reporter createReporter( String reporterName ) {
+ public Reporter createReporter(String reporterName) {
return createReporter(reporterName, null);
}
- /** Returns a set of all registered reporter's names
+ /**
+ * Returns a set of all registered reporter's names
*
* @return Set of reporter names
*/
@@ -118,32 +142,21 @@ public Map getRegisteredReporterInfo() {
@Override
public ORAData create(Datum d, int sqlType) throws SQLException {
if (d == null) return null;
- if ( d instanceof Struct) {
- String sqlName = ((Struct)d).getSQLTypeName();
- return createReporter(sqlName, ((Struct)d).getAttributes());
+ if (d instanceof Struct) {
+ String sqlName = ((Struct) d).getSQLTypeName();
+ return createReporter(sqlName, ((Struct) d).getAttributes());
}
return null;
}
- /** Returns a new instance of an empty ReporterFactory with no registered ReporterFactoryMethods
- * Normally, you should be using createDefault-method instead.
- *
- * @return a new ReporterFactory instance
- */
- public static ReporterFactory createEmpty() {
- return new ReporterFactory();
- }
+ public static class ReporterFactoryMethodInfo {
+ public final BiFunction factoryMethod;
+ public final String description;
- /** Returns a new instance of a ReporterFactory with the default ReporterFactoryMethods registered.
- * This can depend on the version of utPLSQL, therefore you have to provide a CompatibilityProxy
- *
- * @param proxy Compatibility proxy
- * @return a new ReporterFactory instance with all default ReporterFactoryMethods registered
- */
- public static ReporterFactory createDefault(CompatibilityProxy proxy) {
- ReporterFactory reporterFactory = new ReporterFactory();
- DefaultReporterFactoryMethodRegistrator.registerDefaultReporters(reporterFactory, proxy);
- return reporterFactory;
+ public ReporterFactoryMethodInfo(BiFunction factoryMethod, String description) {
+ this.factoryMethod = factoryMethod;
+ this.description = description;
+ }
}
}
diff --git a/src/main/java/org/utplsql/api/reporter/inspect/AbstractReporterInspector.java b/src/main/java/org/utplsql/api/reporter/inspect/AbstractReporterInspector.java
index 11a8798..bbab916 100644
--- a/src/main/java/org/utplsql/api/reporter/inspect/AbstractReporterInspector.java
+++ b/src/main/java/org/utplsql/api/reporter/inspect/AbstractReporterInspector.java
@@ -4,12 +4,12 @@
import java.sql.Connection;
-abstract class AbstractReporterInspector implements ReporterInspector {
+abstract class AbstractReporterInspector implements ReporterInspector {
protected final ReporterFactory reporterFactory;
protected final Connection connection;
- AbstractReporterInspector(ReporterFactory reporterFactory, Connection conn ) {
+ AbstractReporterInspector(ReporterFactory reporterFactory, Connection conn) {
this.reporterFactory = reporterFactory;
this.connection = conn;
}
diff --git a/src/main/java/org/utplsql/api/reporter/inspect/ReporterInfo.java b/src/main/java/org/utplsql/api/reporter/inspect/ReporterInfo.java
index a987bdd..fb805d5 100644
--- a/src/main/java/org/utplsql/api/reporter/inspect/ReporterInfo.java
+++ b/src/main/java/org/utplsql/api/reporter/inspect/ReporterInfo.java
@@ -1,20 +1,17 @@
package org.utplsql.api.reporter.inspect;
-/** Holds information about utPLSQL Reporter-Types
+/**
+ * Holds information about utPLSQL Reporter-Types
*
* @author pesse
*/
public class ReporterInfo {
- public enum Type {
- SQL, JAVA, SQL_WITH_JAVA
- }
-
private final String name;
private final Type type;
private final String description;
- ReporterInfo( String name, Type type, String description ) {
+ ReporterInfo(String name, Type type, String description) {
this.name = name;
this.type = type;
this.description = description;
@@ -31,4 +28,8 @@ public Type getType() {
public String getDescription() {
return description;
}
+
+ public enum Type {
+ SQL, JAVA, SQL_WITH_JAVA
+ }
}
diff --git a/src/main/java/org/utplsql/api/reporter/inspect/ReporterInspector.java b/src/main/java/org/utplsql/api/reporter/inspect/ReporterInspector.java
index 436b939..bf4c287 100644
--- a/src/main/java/org/utplsql/api/reporter/inspect/ReporterInspector.java
+++ b/src/main/java/org/utplsql/api/reporter/inspect/ReporterInspector.java
@@ -19,12 +19,6 @@
*/
public interface ReporterInspector {
- List getReporterInfos();
-
- default Map getReporterInfoMap() {
- return getReporterInfos().stream().collect(Collectors.toMap(ReporterInfo::getName, Function.identity()));
- }
-
/**
* Returns a new instance of a ReporterInspector, based on the utPLSQL version used in the connection
*
@@ -37,10 +31,17 @@ static ReporterInspector create(ReporterFactory reporterFactory, Connection conn
CompatibilityProxy proxy = new CompatibilityProxy(conn);
- if (proxy.getDatabaseVersion().isGreaterOrEqualThan(Version.V3_1_0))
+ if (proxy.getDatabaseVersion().isGreaterOrEqualThan(Version.V3_1_0)) {
return new ReporterInspector310(reporterFactory, conn);
- else
+ } else {
return new ReporterInspectorPre310(reporterFactory, conn);
+ }
+ }
+
+ List getReporterInfos();
+
+ default Map getReporterInfoMap() {
+ return getReporterInfos().stream().collect(Collectors.toMap(ReporterInfo::getName, Function.identity()));
}
}
diff --git a/src/main/java/org/utplsql/api/reporter/inspect/ReporterInspector310.java b/src/main/java/org/utplsql/api/reporter/inspect/ReporterInspector310.java
index cd1b8ea..091e0f4 100644
--- a/src/main/java/org/utplsql/api/reporter/inspect/ReporterInspector310.java
+++ b/src/main/java/org/utplsql/api/reporter/inspect/ReporterInspector310.java
@@ -13,7 +13,8 @@
import java.sql.SQLException;
import java.util.*;
-/** ReporterInspector for v3.1.0 upwards
+/**
+ * ReporterInspector for v3.1.0 upwards
*
* @author pesse
*/
@@ -22,15 +23,16 @@ class ReporterInspector310 extends AbstractReporterInspector {
private final Map registeredReporterFactoryMethods;
private final Set infos;
- ReporterInspector310(ReporterFactory reporterFactory, Connection conn ) throws SQLException {
+ ReporterInspector310(ReporterFactory reporterFactory, Connection conn) throws SQLException {
super(reporterFactory, conn);
registeredReporterFactoryMethods = reporterFactory.getRegisteredReporterInfo();
Set reporterInfos = new HashSet<>();
try (PreparedStatement stmt = connection.prepareStatement("select * from table(ut_runner.get_reporters_list) order by 1")) {
- try (ResultSet rs = stmt.executeQuery() ) {
- while (rs.next())
+ try (ResultSet rs = stmt.executeQuery()) {
+ while (rs.next()) {
reporterInfos.add(getReporterInfo(rs.getString(1)));
+ }
}
}
this.infos = reporterInfos;
@@ -42,13 +44,13 @@ public List getReporterInfos() {
return new ArrayList<>(infos);
}
- private ReporterInfo getReporterInfo(String reporterNameWithOwner ) throws SQLException {
- String reporterName = reporterNameWithOwner.substring(reporterNameWithOwner.indexOf(".")+1).toUpperCase();
+ private ReporterInfo getReporterInfo(String reporterNameWithOwner) throws SQLException {
+ String reporterName = reporterNameWithOwner.substring(reporterNameWithOwner.indexOf(".") + 1).toUpperCase();
ReporterInfo.Type type = ReporterInfo.Type.SQL;
String description = getDescription(reporterName);
- if ( registeredReporterFactoryMethods.containsKey(reporterName) ) {
+ if (registeredReporterFactoryMethods.containsKey(reporterName)) {
type = ReporterInfo.Type.SQL_WITH_JAVA;
description += "\n" + registeredReporterFactoryMethods.get(reporterName);
}
@@ -56,7 +58,7 @@ private ReporterInfo getReporterInfo(String reporterNameWithOwner ) throws SQLEx
return new ReporterInfo(reporterName, type, description);
}
- private String getDescription( String reporterName ) throws SQLException {
+ private String getDescription(String reporterName) throws SQLException {
CompatibilityProxy compatibilityProxy = new CompatibilityProxy(connection);
Reporter reporter = reporterFactory.createReporter(reporterName).init(connection, compatibilityProxy, reporterFactory);
OracleConnection oraCon = connection.unwrap(OracleConnection.class);
diff --git a/src/main/java/org/utplsql/api/testRunner/AbstractTestRunnerStatement.java b/src/main/java/org/utplsql/api/testRunner/AbstractTestRunnerStatement.java
index 147065a..dbd5086 100644
--- a/src/main/java/org/utplsql/api/testRunner/AbstractTestRunnerStatement.java
+++ b/src/main/java/org/utplsql/api/testRunner/AbstractTestRunnerStatement.java
@@ -21,8 +21,8 @@
abstract class AbstractTestRunnerStatement implements TestRunnerStatement {
protected final TestRunnerOptions options;
- private final Connection conn;
protected final CallableStatement callableStatement;
+ private final Connection conn;
public AbstractTestRunnerStatement(TestRunnerOptions options, Connection conn) throws SQLException {
this.options = options;
@@ -95,7 +95,8 @@ public void execute() throws SQLException {
@Override
public void close() throws SQLException {
- if (callableStatement != null)
+ if (callableStatement != null) {
callableStatement.close();
+ }
}
}
diff --git a/src/main/java/org/utplsql/api/testRunner/ActualTestRunnerStatement.java b/src/main/java/org/utplsql/api/testRunner/ActualTestRunnerStatement.java
index 05a05ce..8625f95 100644
--- a/src/main/java/org/utplsql/api/testRunner/ActualTestRunnerStatement.java
+++ b/src/main/java/org/utplsql/api/testRunner/ActualTestRunnerStatement.java
@@ -5,15 +5,16 @@
import java.sql.Connection;
import java.sql.SQLException;
-/** Provides the call to run tests for the most actual Framework version.
+/**
+ * Provides the call to run tests for the most actual Framework version.
* Includes fail on error
*
- * @author pesse
+ * @author pesse
*/
class ActualTestRunnerStatement extends AbstractTestRunnerStatement {
- public ActualTestRunnerStatement(TestRunnerOptions options, Connection connection ) throws SQLException {
- super( options, connection);
+ public ActualTestRunnerStatement(TestRunnerOptions options, Connection connection) throws SQLException {
+ super(options, connection);
}
@Override
diff --git a/src/main/java/org/utplsql/api/testRunner/Pre303TestRunnerStatement.java b/src/main/java/org/utplsql/api/testRunner/Pre303TestRunnerStatement.java
index b741459..d2d53cb 100644
--- a/src/main/java/org/utplsql/api/testRunner/Pre303TestRunnerStatement.java
+++ b/src/main/java/org/utplsql/api/testRunner/Pre303TestRunnerStatement.java
@@ -5,7 +5,8 @@
import java.sql.Connection;
import java.sql.SQLException;
-/** TestRunner-Statement for Framework version before 3.0.3
+/**
+ * TestRunner-Statement for Framework version before 3.0.3
* Does not know about failOnErrors option
*
* @author pesse
diff --git a/src/main/java/org/utplsql/api/testRunner/Pre312TestRunnerStatement.java b/src/main/java/org/utplsql/api/testRunner/Pre312TestRunnerStatement.java
index c8e5f5f..129413b 100644
--- a/src/main/java/org/utplsql/api/testRunner/Pre312TestRunnerStatement.java
+++ b/src/main/java/org/utplsql/api/testRunner/Pre312TestRunnerStatement.java
@@ -5,15 +5,16 @@
import java.sql.Connection;
import java.sql.SQLException;
-/** TestRunner-Statement for Framework version before 3.0.3
+/**
+ * TestRunner-Statement for Framework version before 3.0.3
* Does not know about client character set
*
- * @author pesse
+ * @author pesse
*/
class Pre312TestRunnerStatement extends AbstractTestRunnerStatement {
- public Pre312TestRunnerStatement(TestRunnerOptions options, Connection connection ) throws SQLException {
- super( options, connection);
+ public Pre312TestRunnerStatement(TestRunnerOptions options, Connection connection) throws SQLException {
+ super(options, connection);
}
@Override
diff --git a/src/main/java/org/utplsql/api/testRunner/TestRunnerStatementProvider.java b/src/main/java/org/utplsql/api/testRunner/TestRunnerStatementProvider.java
index eb8722f..77a9204 100644
--- a/src/main/java/org/utplsql/api/testRunner/TestRunnerStatementProvider.java
+++ b/src/main/java/org/utplsql/api/testRunner/TestRunnerStatementProvider.java
@@ -7,38 +7,43 @@
import java.sql.Connection;
import java.sql.SQLException;
-/** Provides different implementations of TestRunnerStatement based on the version of the database framework
+/**
+ * Provides different implementations of TestRunnerStatement based on the version of the database framework
*
* @author pesse
*/
public class TestRunnerStatementProvider {
- /** Returns the TestRunnerStatement-implementation compatible with the given databaseVersion.
+ private TestRunnerStatementProvider() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Returns the TestRunnerStatement-implementation compatible with the given databaseVersion.
*
* @param databaseVersion Version of the database framework
- * @param options TestRunnerOptions to be used
- * @param conn Active Connection
+ * @param options TestRunnerOptions to be used
+ * @param conn Active Connection
* @return TestRunnerStatment compatible with the database framework
* @throws SQLException
*/
- public static TestRunnerStatement getCompatibleTestRunnerStatement(Version databaseVersion, TestRunnerOptions options, Connection conn ) throws SQLException {
+ public static TestRunnerStatement getCompatibleTestRunnerStatement(Version databaseVersion, TestRunnerOptions options, Connection conn) throws SQLException {
AbstractTestRunnerStatement stmt = null;
try {
- if (databaseVersion.isLessThan(Version.V3_0_3))
+ if (databaseVersion.isLessThan(Version.V3_0_3)) {
stmt = new Pre303TestRunnerStatement(options, conn);
- else if (databaseVersion.isLessThan(Version.V3_1_2))
+ } else if (databaseVersion.isLessThan(Version.V3_1_2)) {
stmt = new Pre312TestRunnerStatement(options, conn);
+ }
- } catch ( InvalidVersionException ignored ) {}
+ } catch (InvalidVersionException ignored) {
+ }
- if ( stmt == null )
+ if (stmt == null) {
stmt = new ActualTestRunnerStatement(options, conn);
+ }
return stmt;
}
-
- private TestRunnerStatementProvider() {
- throw new UnsupportedOperationException();
- }
}
diff --git a/src/test/java/org/utplsql/api/AbstractDatabaseTest.java b/src/test/java/org/utplsql/api/AbstractDatabaseTest.java
index 4332721..393c31e 100644
--- a/src/test/java/org/utplsql/api/AbstractDatabaseTest.java
+++ b/src/test/java/org/utplsql/api/AbstractDatabaseTest.java
@@ -14,8 +14,9 @@ public abstract class AbstractDatabaseTest {
private static String sUrl;
private static String sUser;
private static String sPass;
+
static {
- sUrl = EnvironmentVariableUtil.getEnvValue("DB_URL", "192.168.99.100:1521:XE");
+ sUrl = EnvironmentVariableUtil.getEnvValue("DB_URL", "192.168.99.100:1521:XE");
sUser = EnvironmentVariableUtil.getEnvValue("DB_USER", "app");
sPass = EnvironmentVariableUtil.getEnvValue("DB_PASS", "app");
}
@@ -23,6 +24,10 @@ public abstract class AbstractDatabaseTest {
private Connection conn;
private List connectionList = new ArrayList<>();
+ public static String getUser() {
+ return sUser;
+ }
+
@BeforeEach
public void setupConnection() throws SQLException {
conn = newConnection();
@@ -38,13 +43,13 @@ protected synchronized Connection newConnection() throws SQLException {
return conn;
}
- public static String getUser() {
- return sUser;
- }
-
@AfterEach
public void teardownConnection() {
- for (Connection conn : connectionList)
- try { conn.close(); } catch (SQLException ignored) {}
+ for (Connection conn : connectionList) {
+ try {
+ conn.close();
+ } catch (SQLException ignored) {
+ }
+ }
}
}
diff --git a/src/test/java/org/utplsql/api/EnvironmentVariableUtilTest.java b/src/test/java/org/utplsql/api/EnvironmentVariableUtilTest.java
index 8a0487f..e437cd1 100644
--- a/src/test/java/org/utplsql/api/EnvironmentVariableUtilTest.java
+++ b/src/test/java/org/utplsql/api/EnvironmentVariableUtilTest.java
@@ -20,8 +20,9 @@ void testGetVariableFromEnvironment() {
.filter((e) -> !props.contains(e.getKey()) && e.getValue() != null && !e.getValue().isEmpty())
.findFirst();
- if ( !envVariable.isPresent() )
- fail ("Can't test for there is no environment variable not overridden by property");
+ if (!envVariable.isPresent()) {
+ fail("Can't test for there is no environment variable not overridden by property");
+ }
assertEquals(envVariable.get().getValue(), EnvironmentVariableUtil.getEnvValue(envVariable.get().getKey()));
}
@@ -36,7 +37,7 @@ void testGetVariableFromProperty() {
@Test
void testGetVariableFromDefault() {
- assertEquals("defaultValue", EnvironmentVariableUtil.getEnvValue("RANDOM"+String.valueOf(System.currentTimeMillis()), "defaultValue"));
+ assertEquals("defaultValue", EnvironmentVariableUtil.getEnvValue("RANDOM" + String.valueOf(System.currentTimeMillis()), "defaultValue"));
}
}
\ No newline at end of file
diff --git a/src/test/java/org/utplsql/api/FileMapperIT.java b/src/test/java/org/utplsql/api/FileMapperIT.java
index 0db0163..20ff1b4 100644
--- a/src/test/java/org/utplsql/api/FileMapperIT.java
+++ b/src/test/java/org/utplsql/api/FileMapperIT.java
@@ -31,8 +31,9 @@ void testFileMapper() throws SQLException {
List fileMappings = FileMapper.buildFileMappingList(getConnection(), mapperOptions);
- if (fileMappings.size() != 2)
+ if (fileMappings.size() != 2) {
fail("Wrong mapping list size.");
+ }
assertMapping(fileMappings.get(0), "APP", "AWARD_BONUS", "PROCEDURE");
assertMapping(fileMappings.get(1), "APP", "BETWNSTR", "FUNCTION");
diff --git a/src/test/java/org/utplsql/api/OptionalFeaturesIT.java b/src/test/java/org/utplsql/api/OptionalFeaturesIT.java
index dad6263..c7ce27e 100644
--- a/src/test/java/org/utplsql/api/OptionalFeaturesIT.java
+++ b/src/test/java/org/utplsql/api/OptionalFeaturesIT.java
@@ -22,10 +22,11 @@ void failOnError() throws SQLException, InvalidVersionException {
boolean available = OptionalFeatures.FAIL_ON_ERROR.isAvailableFor(getConnection());
- if (getDatabaseVersion().isGreaterOrEqualThan(Version.V3_0_3))
+ if (getDatabaseVersion().isGreaterOrEqualThan(Version.V3_0_3)) {
assertTrue(available);
- else
+ } else {
assertFalse(available);
+ }
}
@Test
@@ -33,10 +34,11 @@ void frameworkCompatibilityCheck() throws SQLException, InvalidVersionException
boolean available = OptionalFeatures.FRAMEWORK_COMPATIBILITY_CHECK.isAvailableFor(getConnection());
- if (getDatabaseVersion().isGreaterOrEqualThan(Version.V3_0_3))
+ if (getDatabaseVersion().isGreaterOrEqualThan(Version.V3_0_3)) {
assertTrue(available);
- else
+ } else {
assertFalse(available);
+ }
}
@Test
@@ -44,9 +46,10 @@ void customReporters() throws SQLException, InvalidVersionException {
boolean available = OptionalFeatures.CUSTOM_REPORTERS.isAvailableFor(getConnection());
- if (getDatabaseVersion().isGreaterOrEqualThan(Version.V3_1_0))
+ if (getDatabaseVersion().isGreaterOrEqualThan(Version.V3_1_0)) {
assertTrue(available);
- else
+ } else {
assertFalse(available);
+ }
}
}
diff --git a/src/test/java/org/utplsql/api/OutputBufferIT.java b/src/test/java/org/utplsql/api/OutputBufferIT.java
index 18ee3ee..c6fea1f 100644
--- a/src/test/java/org/utplsql/api/OutputBufferIT.java
+++ b/src/test/java/org/utplsql/api/OutputBufferIT.java
@@ -88,11 +88,13 @@ void printAvailableLines() throws SQLException {
Object res1 = task1.get();
Object res2 = task2.get();
- if (res1 instanceof Exception)
+ if (res1 instanceof Exception) {
fail((Exception) res1);
+ }
- if (res2 instanceof Exception)
+ if (res2 instanceof Exception) {
fail((Exception) res2);
+ }
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
@@ -129,7 +131,7 @@ void getOutputFromSonarReporter() throws SQLException {
void sonarReporterHasEncodingSet() throws SQLException, InvalidVersionException {
CompatibilityProxy proxy = new CompatibilityProxy(newConnection());
- if ( proxy.getDatabaseVersion().isGreaterOrEqualThan(Version.V3_1_2)) {
+ if (proxy.getDatabaseVersion().isGreaterOrEqualThan(Version.V3_1_2)) {
Reporter reporter = new DefaultReporter(CoreReporters.UT_SONAR_TEST_REPORTER.name(), null).init(getConnection());
TestRunner tr = new TestRunner()
diff --git a/src/test/java/org/utplsql/api/ReporterInspectorIT.java b/src/test/java/org/utplsql/api/ReporterInspectorIT.java
index b076351..367d9d1 100644
--- a/src/test/java/org/utplsql/api/ReporterInspectorIT.java
+++ b/src/test/java/org/utplsql/api/ReporterInspectorIT.java
@@ -31,15 +31,15 @@ void testGetReporterInfo() throws SQLException, InvalidVersionException {
Map infos = inspector.getReporterInfoMap();
- assertEquals( infos.get(CoreReporters.UT_COVERAGE_HTML_REPORTER.name()).getType(), ReporterInfo.Type.SQL_WITH_JAVA );
- assertEquals( infos.get(CoreReporters.UT_COVERAGE_SONAR_REPORTER.name()).getType(), ReporterInfo.Type.SQL );
- assertEquals( infos.get(CoreReporters.UT_COVERALLS_REPORTER.name()).getType(), ReporterInfo.Type.SQL );
- assertEquals( infos.get(CoreReporters.UT_DOCUMENTATION_REPORTER.name()).getType(), ReporterInfo.Type.SQL_WITH_JAVA );
- assertEquals( infos.get(CoreReporters.UT_SONAR_TEST_REPORTER.name()).getType(), ReporterInfo.Type.SQL);
- assertEquals( infos.get(CoreReporters.UT_TEAMCITY_REPORTER.name()).getType(), ReporterInfo.Type.SQL);
- assertEquals( infos.get(CoreReporters.UT_XUNIT_REPORTER.name()).getType(), ReporterInfo.Type.SQL);
-
- if ( CoreReporters.UT_COVERAGE_COBERTURA_REPORTER.isAvailableFor(proxy.getDatabaseVersion())) {
+ assertEquals(infos.get(CoreReporters.UT_COVERAGE_HTML_REPORTER.name()).getType(), ReporterInfo.Type.SQL_WITH_JAVA);
+ assertEquals(infos.get(CoreReporters.UT_COVERAGE_SONAR_REPORTER.name()).getType(), ReporterInfo.Type.SQL);
+ assertEquals(infos.get(CoreReporters.UT_COVERALLS_REPORTER.name()).getType(), ReporterInfo.Type.SQL);
+ assertEquals(infos.get(CoreReporters.UT_DOCUMENTATION_REPORTER.name()).getType(), ReporterInfo.Type.SQL_WITH_JAVA);
+ assertEquals(infos.get(CoreReporters.UT_SONAR_TEST_REPORTER.name()).getType(), ReporterInfo.Type.SQL);
+ assertEquals(infos.get(CoreReporters.UT_TEAMCITY_REPORTER.name()).getType(), ReporterInfo.Type.SQL);
+ assertEquals(infos.get(CoreReporters.UT_XUNIT_REPORTER.name()).getType(), ReporterInfo.Type.SQL);
+
+ if (CoreReporters.UT_COVERAGE_COBERTURA_REPORTER.isAvailableFor(proxy.getDatabaseVersion())) {
assertEquals(infos.get(CoreReporters.UT_COVERAGE_COBERTURA_REPORTER.name()).getType(), ReporterInfo.Type.SQL);
}
}
diff --git a/src/test/java/org/utplsql/api/TestRunnerIT.java b/src/test/java/org/utplsql/api/TestRunnerIT.java
index 95368ca..414b9f9 100644
--- a/src/test/java/org/utplsql/api/TestRunnerIT.java
+++ b/src/test/java/org/utplsql/api/TestRunnerIT.java
@@ -26,7 +26,8 @@ void runWithDefaultParameters() throws SQLException {
}
- /** This can only be run against versions >= 3.0.3
+ /**
+ * This can only be run against versions >= 3.0.3
*/
@Test
void runWithoutCompatibilityCheck() throws SQLException, InvalidVersionException {
@@ -55,7 +56,8 @@ void runWithManyReporters() throws SQLException {
}
- /** This can only be tested on frameworks >= 3.0.3
+ /**
+ * This can only be tested on frameworks >= 3.0.3
*/
@Test
void failOnErrors() throws SQLException, InvalidVersionException {
diff --git a/src/test/java/org/utplsql/api/VersionObjectTest.java b/src/test/java/org/utplsql/api/VersionObjectTest.java
index d0f4ed4..22dcd24 100644
--- a/src/test/java/org/utplsql/api/VersionObjectTest.java
+++ b/src/test/java/org/utplsql/api/VersionObjectTest.java
@@ -11,10 +11,10 @@ class VersionObjectTest {
void versionPatternRecognitionFull() {
Version v = Version.create("v3.1.3.1234");
- assertEquals(3, (long)v.getMajor());
- assertEquals(1, (long)v.getMinor());
- assertEquals(3, (long)v.getBugfix());
- assertEquals(1234, (long)v.getBuild());
+ assertEquals(3, (long) v.getMajor());
+ assertEquals(1, (long) v.getMinor());
+ assertEquals(3, (long) v.getBugfix());
+ assertEquals(1234, (long) v.getBuild());
assertTrue(v.isValid());
assertEquals("3.1.3.1234", v.getNormalizedString());
}
@@ -23,10 +23,10 @@ void versionPatternRecognitionFull() {
void versionPatternRecognitionDevelop() {
Version v = Version.create("v3.1.3.2140-develop");
- assertEquals(3, (long)v.getMajor());
- assertEquals(1, (long)v.getMinor());
- assertEquals(3, (long)v.getBugfix());
- assertEquals(2140, (long)v.getBuild());
+ assertEquals(3, (long) v.getMajor());
+ assertEquals(1, (long) v.getMinor());
+ assertEquals(3, (long) v.getBugfix());
+ assertEquals(2140, (long) v.getBuild());
assertTrue(v.isValid());
assertEquals("3.1.3.2140", v.getNormalizedString());
}
@@ -35,8 +35,8 @@ void versionPatternRecognitionDevelop() {
void versionPatternRecognitionPartial() {
Version v = Version.create("3.1.etc");
- assertEquals(3, (long)v.getMajor());
- assertEquals(1, (long)v.getMinor());
+ assertEquals(3, (long) v.getMajor());
+ assertEquals(1, (long) v.getMinor());
assertNull(v.getBugfix());
assertNull(v.getBuild());
assertTrue(v.isValid());
@@ -56,8 +56,7 @@ void versionPatternRecognitionInvalid() {
}
@Test
- void versionCompareTo()
- {
+ void versionCompareTo() {
Version base = Version.create("2.3.4.5");
// Less than
@@ -80,8 +79,7 @@ void versionCompareTo()
}
@Test
- void isGreaterOrEqualThan() throws InvalidVersionException
- {
+ void isGreaterOrEqualThan() throws InvalidVersionException {
Version base = Version.create("2.3.4.5");
assertTrue(base.isGreaterOrEqualThan(Version.create("1")));
@@ -101,30 +99,26 @@ void isGreaterOrEqualThan() throws InvalidVersionException
}
@Test
- void isGreaterOrEqualThanFails()
- {
+ void isGreaterOrEqualThanFails() {
// Given version is invalid
try {
Version.create("2.3.4.5").isGreaterOrEqualThan(Version.create("aerfvf"));
fail("Given Version is invalid - not recognized");
- }
- catch ( InvalidVersionException ignored ) {
+ } catch (InvalidVersionException ignored) {
}
// Base version is invalid
try {
Version.create("erefs").isGreaterOrEqualThan(Version.create("1.2.3"));
fail("Base version is invalid - not recognized");
- }
- catch ( InvalidVersionException ignored ) {
+ } catch (InvalidVersionException ignored) {
}
// Both versions are invalid
try {
Version.create("erefs").isGreaterOrEqualThan(Version.create("aerfvf"));
fail("Both versions are invalid - not recognized");
- }
- catch ( InvalidVersionException ignored ) {
+ } catch (InvalidVersionException ignored) {
}
}
}
diff --git a/src/test/java/org/utplsql/api/reporter/CoverageHTMLReporterAssetTest.java b/src/test/java/org/utplsql/api/reporter/CoverageHTMLReporterAssetTest.java
index 31abc01..41dd399 100644
--- a/src/test/java/org/utplsql/api/reporter/CoverageHTMLReporterAssetTest.java
+++ b/src/test/java/org/utplsql/api/reporter/CoverageHTMLReporterAssetTest.java
@@ -14,6 +14,27 @@ class CoverageHTMLReporterAssetTest {
private static final String TEST_FOLDER = "__testAssets";
+ @AfterAll
+ static void clearTestAssetsFolder() {
+ try {
+ Files.walkFileTree(Paths.get(TEST_FOLDER), new SimpleFileVisitor() {
+ @Override
+ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
+ Files.delete(file);
+ return FileVisitResult.CONTINUE;
+ }
+
+ @Override
+ public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
+ Files.delete(dir);
+ return FileVisitResult.CONTINUE;
+ }
+ });
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
private void testFileExists(Path filePath) {
File f = new File(filePath.toUri());
@@ -56,25 +77,4 @@ void writeReporterAssetsTo() throws RuntimeException {
testFileExists(targetPath.resolve(Paths.get("magnify.png")));
}
-
- @AfterAll
- static void clearTestAssetsFolder() {
- try {
- Files.walkFileTree(Paths.get(TEST_FOLDER), new SimpleFileVisitor() {
- @Override
- public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
- Files.delete(file);
- return FileVisitResult.CONTINUE;
- }
-
- @Override
- public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
- Files.delete(dir);
- return FileVisitResult.CONTINUE;
- }
- });
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
}