Skip to content

Commit 25e3cf5

Browse files
committed
Clean up and documentation.
1 parent 2b13d6d commit 25e3cf5

29 files changed

+143
-114
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
### Local database with utPLSQL and utPLSQL-demo-project
55

6-
To usefully contribute you'll have to setup a local database with installed [latest utPLSQL v3](https://github.com/utPLSQL/utPLSQL) and [utPLSQL-demo-project](https://github.com/utPLSQL/utPLSQL-demo-project).
6+
To usefully contribute you'll have to set up a local database with installed [latest utPLSQL v3](https://github.com/utPLSQL/utPLSQL) and [utPLSQL-demo-project](https://github.com/utPLSQL/utPLSQL-demo-project).
77
The demo-project will serve as your test user. See .travis.yml to see an example on how it can be installed.
8-
By default tests are executed against `app/app` user of `localhost:1521/XE database`.
8+
By default, tests are executed against `app/app` user of `localhost:1521/XE database`.
99

1010
If you want to run tests against another database you may set `DB_URL`, `DB_USER`, `DB_PASS` environment variables.
1111

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ It also provides a more generic approach to Reporter-handling.
8787

8888
If you request the Reporter-Factory for a Reporter it has no specific implementation for it will just
8989
return an instance of a `DefaultReporter` with the given name as SQL-Type, assuming
90-
that it exists in the database. Therefore you can address custom reporters without the need
90+
that it exists in the database. Therefore, you can address custom reporters without the need
9191
of a specific java-side implementation.
9292

9393
```java

pom.xml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<licenses>
2525
<license>
2626
<name>Apache License, Version 2.0</name>
27-
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
27+
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
2828
<distribution>repo</distribution>
2929
</license>
3030
</licenses>
@@ -70,7 +70,18 @@
7070
</dependencies>
7171

7272
<build>
73+
<resources>
74+
<resource>
75+
<directory>src/main/resources</directory>
76+
<filtering>true</filtering>
77+
</resource>
78+
</resources>
7379
<plugins>
80+
<plugin>
81+
<groupId>org.apache.maven.plugins</groupId>
82+
<artifactId>maven-surefire-plugin</artifactId>
83+
<version>3.1.2</version>
84+
</plugin>
7485
<plugin>
7586
<groupId>org.apache.maven.plugins</groupId>
7687
<artifactId>maven-failsafe-plugin</artifactId>

src/main/java/org/utplsql/api/JavaApiVersionInfo.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
/**
99
* This class is getting updated automatically by the build process.
10-
* Please do not update its constants manually cause they will be overwritten.
10+
* Please do not update its constants manually because they will be overwritten.
1111
*
1212
* @author pesse
1313
*/
@@ -18,10 +18,11 @@ public class JavaApiVersionInfo {
1818

1919
static {
2020
try {
21-
22-
try (InputStream in = JavaApiVersionInfo.class.getClassLoader().getResourceAsStream("utplsql-api.version");
23-
BufferedReader reader = new BufferedReader(new InputStreamReader(in))) {
24-
MAVEN_PROJECT_VERSION = reader.readLine();
21+
try (InputStream in = JavaApiVersionInfo.class.getClassLoader().getResourceAsStream("utplsql-api.version")) {
22+
assert in != null;
23+
try (BufferedReader reader = new BufferedReader(new InputStreamReader(in))) {
24+
MAVEN_PROJECT_VERSION = reader.readLine();
25+
}
2526
}
2627
} catch (IOException e) {
2728
System.out.println("WARNING: Could not get Version information!");

src/main/java/org/utplsql/api/ResourceUtil.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ private ResourceUtil() {
2424
* @param targetDirectory If set to true it will only return files, not directories
2525
*/
2626
public static void copyResources(Path resourceAsPath, Path targetDirectory) {
27-
String resourceName = "/" + resourceAsPath.toString();
2827
try {
28+
String resourceName = "/" + resourceAsPath;
2929
Files.createDirectories(targetDirectory);
3030
URI uri = ResourceUtil.class.getResource(resourceName).toURI();
3131
Path myPath;
@@ -46,12 +46,10 @@ public static void copyResources(Path resourceAsPath, Path targetDirectory) {
4646
private static void copyRecursive(Path from, Path targetDirectory) throws IOException {
4747
Files.walkFileTree(from, new SimpleFileVisitor<Path>() {
4848

49-
private Path currentTarget;
50-
5149
@Override
5250
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
5351
super.preVisitDirectory(dir, attrs);
54-
currentTarget = targetDirectory.resolve(from.relativize(dir).toString());
52+
Path currentTarget = targetDirectory.resolve(from.relativize(dir).toString());
5553
Files.createDirectories(currentTarget);
5654
return FileVisitResult.CONTINUE;
5755
}
@@ -64,4 +62,4 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO
6462
}
6563
});
6664
}
67-
}
65+
}

src/main/java/org/utplsql/api/TestRunner.java

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ public TestRunner excludeObjects(List<String> obj) {
9999
return this;
100100
}
101101

102-
public TestRunner includeSchemaExpr(String expr) {
102+
public TestRunner includeSchemaExpr(String expr) {
103103
options.includeSchemaExpr = expr;
104104
return this;
105-
}
105+
}
106106

107107
public TestRunner excludeSchemaExpr(String expr) {
108108
options.excludeSchemaExpr = expr;
@@ -144,18 +144,18 @@ public TestRunner setReporterFactory(ReporterFactory reporterFactory) {
144144
return this;
145145
}
146146

147-
public TestRunner randomTestOrder(boolean randomTestOrder ) {
147+
public TestRunner randomTestOrder(boolean randomTestOrder) {
148148
this.options.randomTestOrder = randomTestOrder;
149149
return this;
150150
}
151151

152-
public TestRunner randomTestOrderSeed( Integer seed ) {
152+
public TestRunner randomTestOrderSeed(Integer seed) {
153153
this.options.randomTestOrderSeed = seed;
154-
if ( seed != null ) this.options.randomTestOrder = true;
154+
if (seed != null) this.options.randomTestOrder = true;
155155
return this;
156156
}
157157

158-
public TestRunner addTag( String tag ) {
158+
public TestRunner addTag(String tag) {
159159
this.options.tags.add(tag);
160160
return this;
161161
}
@@ -165,12 +165,14 @@ public TestRunner addTags(Collection<String> tags) {
165165
return this;
166166
}
167167

168-
public TestRunner oraStuckTimeout(Integer oraStuckTimeout ) {
168+
public TestRunner oraStuckTimeout(Integer oraStuckTimeout) {
169169
this.options.oraStuckTimeout = oraStuckTimeout;
170170
return this;
171171
}
172172

173-
public TestRunnerOptions getOptions() { return options; }
173+
public TestRunnerOptions getOptions() {
174+
return options;
175+
}
174176

175177
private void delayedAddReporters() {
176178
if (reporterFactory != null) {
@@ -182,10 +184,10 @@ private void delayedAddReporters() {
182184

183185
private void handleException(Throwable e) throws SQLException {
184186
// Just pass exceptions already categorized
185-
if ( e instanceof UtPLSQLNotInstalledException ) throw (UtPLSQLNotInstalledException)e;
186-
else if ( e instanceof SomeTestsFailedException ) throw (SomeTestsFailedException)e;
187-
else if ( e instanceof OracleCreateStatmenetStuckException ) throw (OracleCreateStatmenetStuckException)e;
188-
// Categorize exceptions
187+
if (e instanceof UtPLSQLNotInstalledException) throw (UtPLSQLNotInstalledException) e;
188+
else if (e instanceof SomeTestsFailedException) throw (SomeTestsFailedException) e;
189+
else if (e instanceof OracleCreateStatmenetStuckException) throw (OracleCreateStatmenetStuckException) e;
190+
// Categorize exceptions
189191
else if (e instanceof SQLException) {
190192
SQLException sqlException = (SQLException) e;
191193
if (sqlException.getErrorCode() == SomeTestsFailedException.ERROR_CODE) {
@@ -206,7 +208,7 @@ public void run(Connection conn) throws SQLException {
206208

207209
DatabaseInformation databaseInformation = new DefaultDatabaseInformation();
208210

209-
if ( options.skipCompatibilityCheck ) {
211+
if (options.skipCompatibilityCheck) {
210212
compatibilityProxy = new CompatibilityProxy(conn, Version.LATEST, databaseInformation);
211213
} else {
212214
compatibilityProxy = new CompatibilityProxy(conn, databaseInformation);
@@ -238,7 +240,7 @@ public void run(Connection conn) throws SQLException {
238240

239241
TestRunnerStatement testRunnerStatement = null;
240242
try {
241-
testRunnerStatement = ( options.oraStuckTimeout > 0 ) ? initStatementWithTimeout(conn, options.oraStuckTimeout) : initStatement(conn);
243+
testRunnerStatement = (options.oraStuckTimeout > 0) ? initStatementWithTimeout(conn, options.oraStuckTimeout) : initStatement(conn);
242244
logger.info("Running tests");
243245
testRunnerStatement.execute();
244246
logger.info("Running tests finished.");
@@ -252,17 +254,18 @@ public void run(Connection conn) throws SQLException {
252254
}
253255
}
254256

255-
private TestRunnerStatement initStatement( Connection conn ) throws SQLException {
257+
private TestRunnerStatement initStatement(Connection conn) throws SQLException {
256258
return compatibilityProxy.getTestRunnerStatement(options, conn);
257259
}
258260

259-
private TestRunnerStatement initStatementWithTimeout( Connection conn, int timeout ) throws OracleCreateStatmenetStuckException, SQLException {
261+
private TestRunnerStatement initStatementWithTimeout(Connection conn, int timeout) throws SQLException {
262+
TestRunnerStatement testRunnerStatement;
260263
ExecutorService executor = Executors.newSingleThreadExecutor();
261264
Callable<TestRunnerStatement> callable = () -> compatibilityProxy.getTestRunnerStatement(options, conn);
262265
Future<TestRunnerStatement> future = executor.submit(callable);
263266

264267
// We want to leave the statement open in case of stuck scenario
265-
TestRunnerStatement testRunnerStatement = null;
268+
testRunnerStatement = null;
266269
try {
267270
testRunnerStatement = future.get(timeout, TimeUnit.SECONDS);
268271
} catch (TimeoutException e) {

src/main/java/org/utplsql/api/Version.java

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@ public class Version implements Comparable<Version> {
3737
public final static Version V3_1_10 = new Version("3.1.10", 3, 1, 10, 3347, true);
3838
public final static Version V3_1_11 = new Version("3.1.11", 3, 1, 11, 3557, true);
3939
public final static Version V3_1_12 = new Version("3.1.12", 3, 1, 12, 3876, true);
40+
public final static Version V3_1_13 = new Version("3.1.13", 3, 1, 13, 3592, true);
41+
4042
private final static Map<String, Version> knownVersions =
41-
Stream.of(V3_0_0, V3_0_1, V3_0_2, V3_0_3, V3_0_4, V3_1_0, V3_1_1, V3_1_2, V3_1_3, V3_1_4, V3_1_5, V3_1_6, V3_1_7, V3_1_8, V3_1_9, V3_1_10, V3_1_11, V3_1_12)
43+
Stream.of(V3_0_0, V3_0_1, V3_0_2, V3_0_3, V3_0_4, V3_1_0, V3_1_1, V3_1_2, V3_1_3, V3_1_4, V3_1_5, V3_1_6, V3_1_7, V3_1_8, V3_1_9, V3_1_10, V3_1_11, V3_1_13)
4244
.collect(toMap(Version::toString, Function.identity()));
43-
public final static Version LATEST = V3_1_12;
45+
public final static Version LATEST = V3_1_13;
4446

4547
private final String origString;
4648
private final Integer major;
@@ -64,7 +66,8 @@ private Version(String origString, @Nullable Integer major, @Nullable Integer mi
6466
*/
6567
@Deprecated()
6668
public Version(String versionString) {
67-
assert versionString != null;
69+
Objects.requireNonNull(versionString);
70+
6871
Version dummy = parseVersionString(versionString);
6972

7073
this.origString = dummy.origString;
@@ -110,8 +113,7 @@ private static Version parseVersionString(String origString) {
110113
// We need a valid major version as minimum requirement for a Version object to be valid
111114
valid = major != null;
112115
}
113-
} catch (NumberFormatException e) {
114-
valid = false;
116+
} catch (NumberFormatException ignore) {
115117
}
116118

117119
return new Version(origString, major, minor, bugfix, build, valid);
@@ -149,7 +151,7 @@ public boolean isValid() {
149151
/**
150152
* Returns a normalized form of the parsed version information
151153
*
152-
* @return
154+
* @return normalized string
153155
*/
154156
public String getNormalizedString() {
155157
if (isValid()) {
@@ -213,9 +215,8 @@ public int compareTo(Version o, boolean nullMeansEqual) {
213215
}
214216

215217
curResult = compareToWithNulls(getBuild(), o.getBuild(), nullMeansEqual);
216-
if (curResult != 0) {
217-
return curResult;
218-
}
218+
219+
return curResult;
219220
}
220221

221222
return 0;
@@ -234,11 +235,11 @@ private void versionsAreValid(Version v) throws InvalidVersionException {
234235
/**
235236
* Compares this version to a given version and returns true if this version is greater or equal than the given one
236237
* If one of the version parts of the base version is null, this level is assumed equal no matter the comparing level's version part
237-
* Throws an InvalidVersionException if either this or the given version are invalid
238+
* Throws an {@link InvalidVersionException} if either this or the given version are invalid
238239
*
239240
* @param v Version to compare with
240-
* @return
241-
* @throws InvalidVersionException
241+
* @return true if is greater or equal
242+
* @throws InvalidVersionException If the version does not match
242243
*/
243244
public boolean isGreaterOrEqualThan(Version v) throws InvalidVersionException {
244245

@@ -247,7 +248,15 @@ public boolean isGreaterOrEqualThan(Version v) throws InvalidVersionException {
247248
return compareTo(v, true) >= 0;
248249
}
249250

250-
251+
/**
252+
* Compares this version to a given version and returns true if this version is greater than the given one
253+
* If one of the version parts of the base version is null, this level is assumed equal no matter the comparing level's version part
254+
* Throws an {@link InvalidVersionException} if either this or the given version are invalid
255+
*
256+
* @param v Version to compare with
257+
* @return true if is greater
258+
* @throws InvalidVersionException If the version does not match
259+
*/
251260
public boolean isGreaterThan(Version v) throws InvalidVersionException {
252261
versionsAreValid(v);
253262

@@ -257,11 +266,11 @@ public boolean isGreaterThan(Version v) throws InvalidVersionException {
257266
/**
258267
* Compares this version to a given version and returns true if this version is less or equal than the given one
259268
* If one of the version parts of the base version is null, this level is assumed equal no matter the comparing level's version part
260-
* Throws an InvalidVersionException if either this or the given version are invalid
269+
* Throws an {@link InvalidVersionException} if either this or the given version are invalid
261270
*
262271
* @param v Version to compare with
263-
* @return
264-
* @throws InvalidVersionException
272+
* @return if version is less or equal
273+
* @throws InvalidVersionException If version is invalid
265274
*/
266275
public boolean isLessOrEqualThan(Version v) throws InvalidVersionException {
267276

@@ -270,6 +279,15 @@ public boolean isLessOrEqualThan(Version v) throws InvalidVersionException {
270279
return compareTo(v, true) <= 0;
271280
}
272281

282+
/**
283+
* Compares this version to a given version and returns true if this version is less than the given one
284+
* If one of the version parts of the base version is null, this level is assumed equal no matter the comparing level's version part
285+
* Throws an {@link InvalidVersionException} if either this or the given version are invalid
286+
*
287+
* @param v Version to compare with
288+
* @return if version is less
289+
* @throws InvalidVersionException If version is invalid
290+
*/
273291
public boolean isLessThan(Version v) throws InvalidVersionException {
274292
versionsAreValid(v);
275293

0 commit comments

Comments
 (0)