Skip to content

Commit b44e904

Browse files
committed
execute method structured
1 parent 3cc3f31 commit b44e904

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

src/main/java/org/utplsql/maven/plugin/UtPlsqlMojo.java

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -134,30 +134,19 @@ public void execute() throws MojoExecutionException {
134134
Connection connection = null;
135135
ReportWriter reportWriter = null;
136136
try {
137-
FileMapperOptions sourceMappingOptions = buildSourcesOptions();
138-
FileMapperOptions testMappingOptions = buildTestsOptions();
139-
setDbConfiguration();
140-
141-
OracleDataSource ds = new OracleDataSource();
142-
ds.setURL(url);
143-
ds.setUser(user);
144-
ds.setPassword(password);
145-
connection = ds.getConnection();
137+
connection = createConnection();
146138

147139
Version utlVersion = new DefaultDatabaseInformation().getUtPlsqlFrameworkVersion(connection);
148140
getLog().info("utPLSQL Version = " + utlVersion);
149141

150142
reportWriter = new ReportWriter(targetDir, utlVersion, getLog());
151143

152144
List<Reporter> reporterList = initReporters(connection, reportWriter, ReporterFactory.createEmpty());
145+
FileMapperOptions sourceMappingOptions = buildSourcesOptions();
146+
FileMapperOptions testMappingOptions = buildTestsOptions();
153147

154148
logParameters(sourceMappingOptions, testMappingOptions, reporterList);
155149

156-
if (dbmsOutput) {
157-
DBHelper.enableDBMSOutput(connection);
158-
getLog().info("Enabled dbms_output.");
159-
}
160-
161150
TestRunner runner = new TestRunner()
162151
.addPathList(paths)
163152
.addReporterList(reporterList)
@@ -180,7 +169,7 @@ public void execute() throws MojoExecutionException {
180169
runner.run(connection);
181170

182171
} catch (SomeTestsFailedException e) {
183-
if (!this.ignoreFailure) {
172+
if (!ignoreFailure) {
184173
throw new MojoExecutionException(e.getMessage(), e);
185174
}
186175
} catch (SQLException e) {
@@ -201,7 +190,8 @@ public void execute() throws MojoExecutionException {
201190
}
202191
}
203192

204-
private void setDbConfiguration() {
193+
194+
private Connection createConnection() throws SQLException {
205195
if (StringUtils.isEmpty(url)) {
206196
url = System.getProperty("dbUrl");
207197
}
@@ -211,6 +201,18 @@ private void setDbConfiguration() {
211201
if (StringUtils.isEmpty(password)) {
212202
password = System.getProperty("dbPass");
213203
}
204+
205+
OracleDataSource ds = new OracleDataSource();
206+
ds.setURL(url);
207+
ds.setUser(user);
208+
ds.setPassword(password);
209+
210+
Connection connection = ds.getConnection();
211+
if (dbmsOutput) {
212+
DBHelper.enableDBMSOutput(connection);
213+
getLog().info("Enabled dbms_output.");
214+
}
215+
return connection;
214216
}
215217

216218
FileMapperOptions buildSourcesOptions() throws MojoExecutionException {

0 commit comments

Comments
 (0)