File tree Expand file tree Collapse file tree 10 files changed +67
-9
lines changed
main/java/org/utplsql/cli
test/java/org/utplsql/cli Expand file tree Collapse file tree 10 files changed +67
-9
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,22 @@ ALTER SESSION SET NLS_LANGUAGE='AMERICAN';
51
51
ALTER SESSION SET NLS_TERRITORY= ' AMERICA' ;
52
52
```
53
53
54
+ ## Charset
55
+
56
+ Java will use the default charset of your system for any string output.
57
+ You can change this by passing the ` -Dfile.encoding ` property to the JVM when running a java-application.
58
+ To avoid changing the utPLSQL-cli shell- or batchscript, you can define ` -Dfile.encoding ` in the environment variable ` JAVA_TOOL_OPTIONS ` .
59
+ This environment variable will be picked up and interpreted by the JVM:
60
+
61
+ ```
62
+ export JAVA_TOOL_OPTIONS='-Dfile.encoding=utf8'
63
+ utplsql run user/pw@connecstring
64
+
65
+ > Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=utf8
66
+ ```
67
+
68
+ Make sure that the defined charset matches with the codepage your console is using.
69
+
54
70
## Usage
55
71
Currently, utPLSQL-cli supports the following sub-commands:
56
72
- run
Original file line number Diff line number Diff line change 27
27
<scope >compile</scope >
28
28
<exclusions >
29
29
<exclusion >
30
- <groupId >com.oracle.jdbc </groupId >
30
+ <groupId >com.oracle.ojdbc </groupId >
31
31
<artifactId >ucp</artifactId >
32
32
</exclusion >
33
33
<exclusion >
34
- <groupId >com.oracle.jdbc </groupId >
34
+ <groupId >com.oracle.ojdbc </groupId >
35
35
<artifactId >ojdbc8</artifactId >
36
36
</exclusion >
37
37
<exclusion >
38
- <groupId >com.oracle.jdbc </groupId >
38
+ <groupId >com.oracle.ojdbc </groupId >
39
39
<artifactId >orai18n</artifactId >
40
40
</exclusion >
41
41
</exclusions >
67
67
</exclusion >
68
68
</exclusions >
69
69
</dependency >
70
- <dependency >
70
+ <dependency >
71
71
<groupId >com.oracle.ojdbc</groupId >
72
72
<artifactId >orai18n</artifactId >
73
73
<version >${oracle.jdbc.version} </version >
Original file line number Diff line number Diff line change @@ -17,9 +17,6 @@ public static void main(String[] args) {
17
17
18
18
static int runPicocliWithExitCode (String [] args ) {
19
19
20
- LoggerConfiguration .configure (LoggerConfiguration .ConfigLevel .NONE );
21
- LocaleInitializer .initLocale ();
22
-
23
20
CommandLine commandLine = new CommandLine (UtplsqlPicocliCommand .class );
24
21
commandLine .setTrimQuotes (true );
25
22
Original file line number Diff line number Diff line change 1
1
package org .utplsql .cli ;
2
2
3
+ import org .slf4j .Logger ;
4
+ import org .slf4j .LoggerFactory ;
3
5
import org .utplsql .api .EnvironmentVariableUtil ;
4
6
5
7
import java .util .Locale ;
18
20
*/
19
21
class LocaleInitializer {
20
22
23
+ private static final Logger logger = LoggerFactory .getLogger (RunAction .class );
24
+
21
25
private static final Pattern REGEX_LOCALE = Pattern .compile ("^([a-zA-Z]+)[_-]([a-zA-Z]+)" ); // We only need the very first part and are pretty forgiving in parsing
22
26
23
27
/**
@@ -27,7 +31,10 @@ static void initLocale() {
27
31
28
32
boolean localeChanged = setDefaultLocale (EnvironmentVariableUtil .getEnvValue ("LC_ALL" ));
29
33
if (!localeChanged ) {
30
- setDefaultLocale (EnvironmentVariableUtil .getEnvValue ("LANG" ));
34
+ localeChanged = setDefaultLocale (EnvironmentVariableUtil .getEnvValue ("LANG" ));
35
+ }
36
+ if ( !localeChanged ) {
37
+ logger .debug ("Java Locale not changed from LC_ALL or LANG environment variable" );
31
38
}
32
39
}
33
40
@@ -54,6 +61,7 @@ private static boolean setDefaultLocale(String localeString) {
54
61
Locale l = new Locale .Builder ().setLanguageTag (sb .toString ()).build ();
55
62
if (l != null ) {
56
63
Locale .setDefault (l );
64
+ logger .debug ("Java Locale changed to {}" , l );
57
65
return true ;
58
66
}
59
67
}
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ public class ReportersCommand implements ICommand {
28
28
29
29
@ Override
30
30
public int run () {
31
+ LoggerConfiguration .configure (LoggerConfiguration .ConfigLevel .NONE );
31
32
32
33
try {
33
34
DataSource ds = DataSourceProvider .getDataSource (connectionString , 1 );
Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ public RunAction(RunCommandConfig config) {
48
48
49
49
void init () {
50
50
LoggerConfiguration .configure (config .getLogConfigLevel ());
51
+ LocaleInitializer .initLocale ();
51
52
}
52
53
53
54
public RunCommandConfig getConfig () {
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ public class VersionInfoCommand implements ICommand {
23
23
boolean help ;
24
24
25
25
public int run () {
26
+ LoggerConfiguration .configure (LoggerConfiguration .ConfigLevel .NONE );
26
27
27
28
System .out .println (CliVersionInfo .getInfo ());
28
29
System .out .println (JavaApiVersionInfo .getInfo ());
Original file line number Diff line number Diff line change 1
1
package org .utplsql .cli .config ;
2
2
3
+ import org .utplsql .api .reporter .CoreReporters ;
4
+
3
5
import java .beans .ConstructorProperties ;
4
6
5
7
public class ReporterConfig {
@@ -10,7 +12,11 @@ public class ReporterConfig {
10
12
11
13
@ ConstructorProperties ({"name" , "output" , "forceToScreen" })
12
14
public ReporterConfig (String name , String output , Boolean forceToScreen ) {
13
- this .name = name ;
15
+ if ( name != null ) {
16
+ this .name = name ;
17
+ } else {
18
+ this .name = CoreReporters .UT_DOCUMENTATION_REPORTER .name ();
19
+ }
14
20
this .output = output ;
15
21
if (forceToScreen != null ) this .forceToScreen = forceToScreen ;
16
22
}
Original file line number Diff line number Diff line change @@ -163,6 +163,20 @@ void multipleReporters() throws Exception {
163
163
assertTrue (reporterConfig .isForceToScreen ());
164
164
}
165
165
166
+ @ Test
167
+ void outputWithDefaultReporter () throws Exception {
168
+ RunCommandConfig config = parseForConfig ("run" ,
169
+ TestHelper .getConnectionString (),
170
+ "-o=output1.txt" );
171
+
172
+ assertNotNull ( config .getReporters () );
173
+
174
+ ReporterConfig reporterConfig = config .getReporters ()[0 ];
175
+ assertEquals ("ut_documentation_reporter" , reporterConfig .getName ().toLowerCase ());
176
+ assertEquals ("output1.txt" , reporterConfig .getOutput ());
177
+ assertFalse (reporterConfig .isForceToScreen ());
178
+ }
179
+
166
180
@ Test
167
181
void sourceFileMapping () throws Exception {
168
182
RunCommandConfig config = parseForConfig ("run" ,
Original file line number Diff line number Diff line change @@ -75,4 +75,18 @@ void run_withDbmsOutputEnabled() throws Exception {
75
75
76
76
assertValidReturnCode (result );
77
77
}
78
+
79
+ @ Test
80
+ void run_withOutputButNoReporterDefined () throws Exception {
81
+
82
+ String outputFileName = "output_" + System .currentTimeMillis () + ".xml" ;
83
+ addTempPath (Paths .get (outputFileName ));
84
+
85
+ int result = TestHelper .runApp ("run" ,
86
+ TestHelper .getConnectionString (),
87
+ "-o=" + outputFileName ,
88
+ "--failure-exit-code=2" );
89
+
90
+ assertValidReturnCode (result );
91
+ }
78
92
}
You can’t perform that action at this time.
0 commit comments