Skip to content

Commit dfdd18c

Browse files
committed
Rearanged tests
1 parent 4c3c08c commit dfdd18c

File tree

33 files changed

+68
-35
lines changed

33 files changed

+68
-35
lines changed

src/test/java/org/utplsql/maven/plugin/UtPlsqlMojoTest.java

Lines changed: 68 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ public class UtPlsqlMojoTest {
3131
* Then : it should throw a MojoExecutionException
3232
*/
3333
@Test
34-
public void invalidSourcesDirectory() throws Exception {
35-
UtPlsqlMojo utPlsqlMojo = (UtPlsqlMojo) rule
36-
.lookupConfiguredMojo(new File("src/test/resources/unit-tests/invalid-sources-directories/"), "test");
34+
public void invalid_sources_directory() throws Exception {
35+
UtPlsqlMojo utPlsqlMojo = createUtPlsqlMojo("invalid_sources_directory");
3736
assertNotNull(utPlsqlMojo);
3837

3938
MojoExecutionException exception = assertThrows(MojoExecutionException.class, utPlsqlMojo::execute);
@@ -49,9 +48,8 @@ public void invalidSourcesDirectory() throws Exception {
4948
* Then : it should throw a MojoExecutionException
5049
*/
5150
@Test
52-
public void invalidTestsDirectory() throws Exception {
53-
UtPlsqlMojo utPlsqlMojo = (UtPlsqlMojo) rule
54-
.lookupConfiguredMojo(new File("src/test/resources/unit-tests/invalid-tests-sources-directories/"), "test");
51+
public void invalid_tests_directory() throws Exception {
52+
UtPlsqlMojo utPlsqlMojo = createUtPlsqlMojo("invalid_tests_directory");
5553
assertNotNull(utPlsqlMojo);
5654

5755
MojoExecutionException exception = assertThrows(MojoExecutionException.class, utPlsqlMojo::execute);
@@ -67,9 +65,8 @@ public void invalidTestsDirectory() throws Exception {
6765
* Then : it should fill all parameters correctly
6866
*/
6967
@Test
70-
public void sourcesTestsParameters() throws Exception {
71-
UtPlsqlMojo utPlsqlMojo = (UtPlsqlMojo) rule
72-
.lookupConfiguredMojo(new File("src/test/resources/unit-tests/test-sources-tests-params/"), "test");
68+
public void sources_tests_parameters() throws Exception {
69+
UtPlsqlMojo utPlsqlMojo = createUtPlsqlMojo("sources_tests_parameters");
7370
assertNotNull(utPlsqlMojo);
7471

7572
assertEquals(2, utPlsqlMojo.reporters.size());
@@ -110,9 +107,8 @@ public void sourcesTestsParameters() throws Exception {
110107
* Then : it should not find any source files
111108
*/
112109
@Test
113-
public void sourcesAndTestsParameterDoesNotExist() throws Exception {
114-
UtPlsqlMojo utPlsqlMojo = (UtPlsqlMojo) rule.lookupConfiguredMojo(
115-
new File("src/test/resources/unit-tests/test-no-sources-tests-params/directory-does-not-exist/"), "test");
110+
public void sources_and_tests_parameter_does_not_exist() throws Exception {
111+
UtPlsqlMojo utPlsqlMojo = createUtPlsqlMojo("sources_and_tests_parameter_does_not_exist");
116112
assertNotNull(utPlsqlMojo);
117113

118114
// check sources
@@ -132,9 +128,8 @@ public void sourcesAndTestsParameterDoesNotExist() throws Exception {
132128
* Then : it should find all sources/tests files in default directories
133129
*/
134130
@Test
135-
public void sourcesAndTestsParameterDoesNotExistButDefaultDirectoryExists() throws Exception {
136-
UtPlsqlMojo utPlsqlMojo = (UtPlsqlMojo) rule
137-
.lookupConfiguredMojo(new File("src/test/resources/unit-tests/test-no-sources-tests-params/directory-exists/"), "test");
131+
public void sources_and_tests_parameter_does_not_exist_but_default_directory_exists() throws Exception {
132+
UtPlsqlMojo utPlsqlMojo = createUtPlsqlMojo("sources_and_tests_parameter_does_not_exist_but_default_directory_exists");
138133
assertNotNull(utPlsqlMojo);
139134

140135
// check sources
@@ -158,9 +153,8 @@ public void sourcesAndTestsParameterDoesNotExistButDefaultDirectoryExists() thro
158153
* Then : it should find all sources/tests files in default directories
159154
*/
160155
@Test
161-
public void sourcesAndTestsParameterHaveNotDirectoryTag() throws Exception {
162-
UtPlsqlMojo utPlsqlMojo = (UtPlsqlMojo) rule
163-
.lookupConfiguredMojo(new File("src/test/resources/unit-tests/partial-source-and-test-tag/missing-directory/"), "test");
156+
public void sources_and_tests_parameter_have_not_directory_tag() throws Exception {
157+
UtPlsqlMojo utPlsqlMojo = createUtPlsqlMojo("sources_and_tests_parameter_have_not_directory_tag");
164158
assertNotNull(utPlsqlMojo);
165159

166160
// check sources
@@ -185,9 +179,8 @@ public void sourcesAndTestsParameterHaveNotDirectoryTag() throws Exception {
185179
* Then : it should find all sources/tests files in default directories
186180
*/
187181
@Test
188-
public void sourcesAndTestsParameterHaveNotIncludesTag() throws Exception {
189-
UtPlsqlMojo utPlsqlMojo = (UtPlsqlMojo) rule
190-
.lookupConfiguredMojo(new File("src/test/resources/unit-tests/partial-source-and-test-tag/missing-includes/"), "test");
182+
public void sources_and_tests_parameter_have_not_includes_tag() throws Exception {
183+
UtPlsqlMojo utPlsqlMojo = createUtPlsqlMojo("sources_and_tests_parameter_have_not_includes_tag");
191184
assertNotNull(utPlsqlMojo);
192185

193186
// check sources
@@ -205,11 +198,14 @@ public void sourcesAndTestsParameterHaveNotIncludesTag() throws Exception {
205198

206199
/**
207200
* Default Console Behaviour
201+
* <p>
202+
* Given : a pom.xml with file and console output
203+
* When : pom is read
204+
* Then : it should set the correct output channels
208205
*/
209206
@Test
210-
public void defaultConsoleBehaviour() throws Exception {
211-
UtPlsqlMojo utPlsqlMojo = (UtPlsqlMojo) rule
212-
.lookupConfiguredMojo(new File("src/test/resources/unit-tests/default-console-output-behaviour/"), "test");
207+
public void default_console_output_behaviour() throws Exception {
208+
UtPlsqlMojo utPlsqlMojo = createUtPlsqlMojo("default_console_output_behaviour");
213209
assertNotNull(utPlsqlMojo);
214210

215211
utPlsqlMojo.execute();
@@ -233,11 +229,14 @@ public void defaultConsoleBehaviour() throws Exception {
233229

234230
/**
235231
* Default Reporter
232+
* <p>
233+
* Given : a pom.xml without reporters
234+
* When : pom is read
235+
* Then : it should set the default reporter
236236
*/
237237
@Test
238-
public void defaultReporter() throws Exception {
239-
UtPlsqlMojo utPlsqlMojo = (UtPlsqlMojo) rule
240-
.lookupConfiguredMojo(new File("src/test/resources/unit-tests/default-reporter/"), "test");
238+
public void default_reporter() throws Exception {
239+
UtPlsqlMojo utPlsqlMojo = createUtPlsqlMojo("default_reporter");
241240
assertNotNull(utPlsqlMojo);
242241

243242
utPlsqlMojo.execute();
@@ -247,12 +246,15 @@ public void defaultReporter() throws Exception {
247246
}
248247

249248
/**
250-
* Skip utPLSQL Tests
249+
* Default Reporter
250+
* <p>
251+
* Given : a pom.xml with skipUtplsqlTests=true
252+
* When : pom is read
253+
* Then : Tests are skipped
251254
*/
252255
@Test
253-
public void skipUtplsqlTests() throws Exception {
254-
UtPlsqlMojo utPlsqlMojo = (UtPlsqlMojo) rule
255-
.lookupConfiguredMojo(new File("src/test/resources/unit-tests/skip-utplsql-tests/"), "test");
256+
public void skip_utplsql_tests() throws Exception {
257+
UtPlsqlMojo utPlsqlMojo = createUtPlsqlMojo("skip_utplsql_tests");
256258
assertNotNull(utPlsqlMojo);
257259

258260
final ByteArrayOutputStream console = new ByteArrayOutputStream();
@@ -266,15 +268,46 @@ public void skipUtplsqlTests() throws Exception {
266268
}
267269

268270
/**
269-
* DBMS_OUTPUT
271+
* Enable DBMS_OUTPUT
272+
* <p>
273+
* Given : a pom.xml with dbmsOutput=true
274+
* When : pom is read
275+
* Then : DBMS_OUTPUT is enabled
270276
*/
271277
@Test
272-
public void dbmsOutput() throws Exception {
273-
UtPlsqlMojo utPlsqlMojo = (UtPlsqlMojo) rule
274-
.lookupConfiguredMojo(new File("src/test/resources/unit-tests/dbms-output/"), "test");
278+
public void dbms_output() throws Exception {
279+
UtPlsqlMojo utPlsqlMojo = createUtPlsqlMojo("dbms_output");
275280
assertNotNull(utPlsqlMojo);
276281

277282
utPlsqlMojo.execute();
278283
}
279284

285+
/**
286+
* DB configuration from System Properties
287+
* <p>
288+
* Given : a pom.xml without dbUrl, dbUser and dbPass configured
289+
* When : pom is read
290+
* Then : System Properties must be used to configure database
291+
*/
292+
@Test
293+
public void db_config_using_system_properties() throws Exception {
294+
System.setProperty("dbUrl", "jdbc:oracle:thin:@localhost:1521:xe");
295+
System.setProperty("dbUser", "UT3");
296+
System.setProperty("dbPass", "UT3");
297+
298+
UtPlsqlMojo utPlsqlMojo = createUtPlsqlMojo("dbms_output");
299+
assertNotNull(utPlsqlMojo);
300+
301+
utPlsqlMojo.execute();
302+
303+
System.setProperty("dbUrl", "");
304+
System.setProperty("dbUser", "");
305+
System.setProperty("dbPass", "");
306+
307+
}
308+
309+
private UtPlsqlMojo createUtPlsqlMojo(String directory) throws Exception {
310+
return (UtPlsqlMojo) rule.lookupConfiguredMojo(new File("src/test/resources/unit-tests/" + directory), "test");
311+
}
312+
280313
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)