2
2
3
3
import org .apache .maven .plugin .MojoExecutionException ;
4
4
import org .apache .maven .project .MavenProject ;
5
- import org .junit .BeforeClass ;
6
5
import org .junit .Test ;
7
6
import org .utplsql .api .reporter .CoreReporters ;
8
7
import org .utplsql .maven .plugin .model .ReporterParameter ;
15
14
16
15
public class UtPlsqlMojoTest {
17
16
18
- private static UtPlsqlMojo utPLSQLMojo ;
17
+ private UtPlsqlMojo createUtPlsqlMojo () {
18
+ System .setProperty ("org.slf4j.simpleLogger.defaultLogLevel" , "debug" );
19
19
20
- @ BeforeClass
21
- public static void setUp () {
22
- utPLSQLMojo = new UtPlsqlMojo ();
23
- utPLSQLMojo .project = new MavenProject ();
24
- utPLSQLMojo .targetDir = "target" ;
20
+ UtPlsqlMojo utPlsqlMojo = new UtPlsqlMojo ();
21
+ utPlsqlMojo .project = new MavenProject ();
22
+ utPlsqlMojo .targetDir = "target" ;
25
23
26
- utPLSQLMojo .url = "jdbc:oracle:thin:@127.0.0.1:1521:XE" ;
27
- utPLSQLMojo .user = "UT3" ;
28
- utPLSQLMojo .password = "UT3" ;
24
+ utPlsqlMojo .url = "jdbc:oracle:thin:@127.0.0.1:1521:XE" ;
25
+ utPlsqlMojo .user = "UT3" ;
26
+ utPlsqlMojo .password = "UT3" ;
27
+
28
+ return utPlsqlMojo ;
29
29
}
30
30
31
31
@ Test
32
32
public void junitReporter () throws MojoExecutionException {
33
+ UtPlsqlMojo utPlsqlMojo = createUtPlsqlMojo ();
34
+
33
35
ReporterParameter junitReporter = new ReporterParameter ();
34
36
junitReporter .setConsoleOutput (true );
35
37
junitReporter .setFileOutput ("junit-report.xml" );
36
38
junitReporter .setName (CoreReporters .UT_JUNIT_REPORTER .name ());
37
- utPLSQLMojo .reporters .add (junitReporter );
39
+ utPlsqlMojo .reporters .add (junitReporter );
38
40
39
- utPLSQLMojo .execute ();
41
+ utPlsqlMojo .execute ();
40
42
41
43
assertTrue (new File ("target/junit-report.xml" ).exists ());
42
44
}
43
45
44
46
@ Test
45
47
public void absolutPath () throws MojoExecutionException {
48
+ UtPlsqlMojo utPlsqlMojo = createUtPlsqlMojo ();
49
+
46
50
ReporterParameter junitReporter = new ReporterParameter ();
47
51
junitReporter .setConsoleOutput (true );
48
52
@@ -53,9 +57,9 @@ public void absolutPath() throws MojoExecutionException {
53
57
junitReporter .setFileOutput ("/tmp/junit-report.xml" );
54
58
}
55
59
junitReporter .setName (CoreReporters .UT_JUNIT_REPORTER .name ());
56
- utPLSQLMojo .reporters .add (junitReporter );
60
+ utPlsqlMojo .reporters .add (junitReporter );
57
61
58
- utPLSQLMojo .execute ();
62
+ utPlsqlMojo .execute ();
59
63
if (os .contains ("Windows" )) {
60
64
assertTrue (new File ("c:/tmp/junit-report.xml" ).exists ());
61
65
} else {
@@ -65,50 +69,58 @@ public void absolutPath() throws MojoExecutionException {
65
69
66
70
@ Test
67
71
public void parentDoesNotExist () throws MojoExecutionException {
72
+ UtPlsqlMojo utPlsqlMojo = createUtPlsqlMojo ();
73
+
68
74
ReporterParameter junitReporter = new ReporterParameter ();
69
75
junitReporter .setConsoleOutput (true );
70
76
junitReporter .setFileOutput ("not-exist/junit-report.xml" );
71
77
junitReporter .setName (CoreReporters .UT_JUNIT_REPORTER .name ());
72
- utPLSQLMojo .reporters .add (junitReporter );
78
+ utPlsqlMojo .reporters .add (junitReporter );
73
79
74
- utPLSQLMojo .execute ();
80
+ utPlsqlMojo .execute ();
75
81
76
82
assertTrue (new File ("target/not-exist/junit-report.xml" ).exists ());
77
83
}
78
84
79
85
@ Test
80
86
public void onlyConsoleOutput () throws MojoExecutionException {
87
+ UtPlsqlMojo utPlsqlMojo = createUtPlsqlMojo ();
88
+
81
89
ReporterParameter junitReporter = new ReporterParameter ();
82
90
junitReporter .setConsoleOutput (true );
83
91
junitReporter .setName (CoreReporters .UT_JUNIT_REPORTER .name ());
84
- utPLSQLMojo .reporters .add (junitReporter );
92
+ utPlsqlMojo .reporters .add (junitReporter );
85
93
86
- utPLSQLMojo .execute ();
94
+ utPlsqlMojo .execute ();
87
95
88
96
assertTrue (new File ("target/not-exist/junit-report.xml" ).exists ());
89
97
}
90
98
91
99
@ Test
92
100
public void onlyFileOutput () throws MojoExecutionException {
101
+ UtPlsqlMojo utPlsqlMojo = createUtPlsqlMojo ();
102
+
93
103
ReporterParameter junitReporter = new ReporterParameter ();
94
104
junitReporter .setConsoleOutput (false );
95
105
junitReporter .setFileOutput ("not-exist/junit-report.xml" );
96
106
junitReporter .setName (CoreReporters .UT_JUNIT_REPORTER .name ());
97
- utPLSQLMojo .reporters .add (junitReporter );
107
+ utPlsqlMojo .reporters .add (junitReporter );
98
108
99
- utPLSQLMojo .execute ();
109
+ utPlsqlMojo .execute ();
100
110
101
111
assertTrue (new File ("target/not-exist/junit-report.xml" ).exists ());
102
112
}
103
113
104
114
@ Test
105
115
public void skipUtplsqlTests () throws MojoExecutionException {
106
- utPLSQLMojo .skipUtplsqlTests = true ;
116
+ UtPlsqlMojo utPlsqlMojo = createUtPlsqlMojo ();
117
+
118
+ utPlsqlMojo .skipUtplsqlTests = true ;
107
119
108
120
final ByteArrayOutputStream console = new ByteArrayOutputStream ();
109
121
System .setOut (new PrintStream (console ));
110
122
111
- utPLSQLMojo .execute ();
123
+ utPlsqlMojo .execute ();
112
124
113
125
String standardOutput = console .toString ();
114
126
@@ -117,10 +129,12 @@ public void skipUtplsqlTests() throws MojoExecutionException {
117
129
118
130
@ Test
119
131
public void defaultReportAndExcludes () throws MojoExecutionException {
120
- utPLSQLMojo .excludeObject = "abc" ;
121
- utPLSQLMojo .includeObject = "xyz" ;
132
+ UtPlsqlMojo utPlsqlMojo = createUtPlsqlMojo ();
133
+
134
+ utPlsqlMojo .excludeObject = "abc" ;
135
+ utPlsqlMojo .includeObject = "xyz" ;
122
136
123
- utPLSQLMojo .execute ();
137
+ utPlsqlMojo .execute ();
124
138
}
125
139
126
140
}
0 commit comments