2222import org .utplsql .maven .plugin .model .ReporterParameter ;
2323import org .utplsql .maven .plugin .reporter .ReporterWriter ;
2424
25+ import java .io .ByteArrayOutputStream ;
2526import java .io .File ;
27+ import java .io .PrintStream ;
2628import java .sql .Connection ;
2729import java .util .ArrayList ;
2830import java .util .List ;
3941import static org .powermock .api .mockito .PowerMockito .when ;
4042
4143@ RunWith (PowerMockRunner .class )
42- @ PrepareForTest ({ DBHelper .class , ReporterFactory .class })
44+ @ PrepareForTest ({DBHelper .class , ReporterFactory .class })
4345public class UtPLSQLMojoTest {
4446
4547 @ Rule
@@ -68,7 +70,7 @@ public void setUp() throws Exception {
6870
6971 /**
7072 * testInvalidSourcesDirectory.
71- *
73+ * <p>
7274 * Given : a pom.xml with invalid sources' directory When : pom is read and
7375 * buildSourcesOptions is run Then : it should throw a MojoExecutionException
7476 */
@@ -84,12 +86,11 @@ public void testInvalidSourcesDirectory() throws Exception {
8486 thrown .expectMessage ("Invalid <SOURCES> in your pom.xml" );
8587
8688 Whitebox .invokeMethod (utplsqlMojo , "buildSourcesOptions" );
87-
8889 }
8990
9091 /**
9192 * testInvalidTestsDirectory.
92- *
93+ * <p>
9394 * Given : a pom.xml with invalid tests' directory When : pom is read and
9495 * buildTestsOptions is run Then : it should throw a MojoExecutionException
9596 */
@@ -109,7 +110,7 @@ public void testInvalidTestsDirectory() throws Exception {
109110
110111 /**
111112 * testSourcesTestsParameters.
112- *
113+ * <p>
113114 * Given : a pom.xml with sources and tests with a lot of parameters When : pom
114115 * is read and buildSourcesOptions / buildTestsOptions are run Then : it should
115116 * fill all parameters correctly
@@ -150,12 +151,11 @@ public void testSourcesTestsParameters() throws Exception {
150151 assertEquals (1 , tests .getTypeMappings ().size ());
151152 assertEquals ("def" , tests .getTypeMappings ().get (0 ).getKey ());
152153 assertEquals ("abc" , tests .getTypeMappings ().get (0 ).getValue ());
153-
154154 }
155155
156156 /**
157157 * testSourcesAndTestsParameterDoesNotExist.
158- *
158+ * <p>
159159 * Given : a pom.xml with no sources / tests tags and default directory does not
160160 * exist. When : pom is read and buildSourcesOptions / buildTestsOptions are run
161161 * Then : it should not find any source files
@@ -177,7 +177,7 @@ public void testSourcesAndTestsParameterDoesNotExist() throws Exception {
177177
178178 /**
179179 * testSourcesAndTestsParameterDoesNotExistButDefaultDirectoryExists.
180- *
180+ * <p>
181181 * Given : a pom.xml with no sources / tests tags but default directory exists.
182182 * When : pom is read and buildSourcesOptions / buildTestsOptions are run Then :
183183 * it should find all sources/tests files in default directories
@@ -199,12 +199,11 @@ public void testSourcesAndTestsParameterDoesNotExistButDefaultDirectoryExists()
199199 assertEquals (2 , tests .getFilePaths ().size ());
200200 assertTrue (tests .getFilePaths ().contains ("src/test/plsql/foo/f1.pkg" ));
201201 assertTrue (tests .getFilePaths ().contains ("src/test/plsql/f2.pkg" ));
202-
203202 }
204203
205204 /**
206205 * testSourcesAndTestsParameterHaveNotDirectoryTag.
207- *
206+ * <p>
208207 * Given : a pom.xml with source and test tag not containing a directory tag.
209208 * When : pom is read and buildSourcesOptions / buildTestsOptions are run Then :
210209 * it should find all sources/tests files in default directories
@@ -231,7 +230,7 @@ public void testSourcesAndTestsParameterHaveNotDirectoryTag() throws Exception {
231230
232231 /**
233232 * testSourcesAndTestsParameterHaveNotDirectoryTag.
234- *
233+ * <p>
235234 * Given : a pom.xml with source and test tag not containing a directory tag.
236235 * When : pom is read and buildSourcesOptions / buildTestsOptions are run Then :
237236 * it should find all sources/tests files in default directories
@@ -284,8 +283,7 @@ public void testDefaultConsoleBehaviour() throws Exception {
284283
285284 // Assert that we added only the necessary reporters to the writer.
286285 ReporterWriter reporterWritter = Whitebox .getInternalState (utplsqlMojo , "reporterWriter" );
287- List <Pair <Reporter , ReporterParameter >> listReporters =
288- Whitebox .getInternalState (reporterWritter , "listReporters" );
286+ List <Pair <Reporter , ReporterParameter >> listReporters = Whitebox .getInternalState (reporterWritter , "listReporters" );
289287 assertEquals (3 , listReporters .size ());
290288
291289 ReporterParameter reporterParameter1 = listReporters .get (0 ).getRight ();
@@ -324,4 +322,20 @@ public void testAddDefaultReporter() throws Exception {
324322 assertEquals ("UT_DOCUMENTATION_REPORTER" , reporterList .get (0 ).getTypeName ());
325323 verify (reporterList .get (0 )).init (mockConnection );
326324 }
325+
326+ @ Test
327+ public void testSkipUtplsqlTests () throws Exception {
328+ UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo ) rule
329+ .lookupConfiguredMojo (new File ("src/test/resources/skipUtplsqlTests/" ), "test" );
330+ Assert .assertNotNull (utplsqlMojo );
331+
332+ final ByteArrayOutputStream console = new ByteArrayOutputStream ();
333+ System .setOut (new PrintStream (console ));
334+
335+ utplsqlMojo .execute ();
336+
337+ String standardOutput = console .toString ();
338+
339+ Assert .assertTrue (standardOutput .contains ("utPLSQLTests are skipped." ));
340+ }
327341}
0 commit comments