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';
5151ALTER SESSION SET NLS_TERRITORY= ' AMERICA' ;
5252```
5353
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+
5470## Usage
5571Currently, utPLSQL-cli supports the following sub-commands:
5672- run
Original file line number Diff line number Diff line change 2727 <scope >compile</scope >
2828 <exclusions >
2929 <exclusion >
30- <groupId >com.oracle.jdbc </groupId >
30+ <groupId >com.oracle.ojdbc </groupId >
3131 <artifactId >ucp</artifactId >
3232 </exclusion >
3333 <exclusion >
34- <groupId >com.oracle.jdbc </groupId >
34+ <groupId >com.oracle.ojdbc </groupId >
3535 <artifactId >ojdbc8</artifactId >
3636 </exclusion >
3737 <exclusion >
38- <groupId >com.oracle.jdbc </groupId >
38+ <groupId >com.oracle.ojdbc </groupId >
3939 <artifactId >orai18n</artifactId >
4040 </exclusion >
4141 </exclusions >
6767 </exclusion >
6868 </exclusions >
6969 </dependency >
70- <dependency >
70+ <dependency >
7171 <groupId >com.oracle.ojdbc</groupId >
7272 <artifactId >orai18n</artifactId >
7373 <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) {
1717
1818 static int runPicocliWithExitCode (String [] args ) {
1919
20- LoggerConfiguration .configure (LoggerConfiguration .ConfigLevel .NONE );
21- LocaleInitializer .initLocale ();
22-
2320 CommandLine commandLine = new CommandLine (UtplsqlPicocliCommand .class );
2421 commandLine .setTrimQuotes (true );
2522
Original file line number Diff line number Diff line change 11package org .utplsql .cli ;
22
3+ import org .slf4j .Logger ;
4+ import org .slf4j .LoggerFactory ;
35import org .utplsql .api .EnvironmentVariableUtil ;
46
57import java .util .Locale ;
1820 */
1921class LocaleInitializer {
2022
23+ private static final Logger logger = LoggerFactory .getLogger (RunAction .class );
24+
2125 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
2226
2327 /**
@@ -27,7 +31,10 @@ static void initLocale() {
2731
2832 boolean localeChanged = setDefaultLocale (EnvironmentVariableUtil .getEnvValue ("LC_ALL" ));
2933 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" );
3138 }
3239 }
3340
@@ -54,6 +61,7 @@ private static boolean setDefaultLocale(String localeString) {
5461 Locale l = new Locale .Builder ().setLanguageTag (sb .toString ()).build ();
5562 if (l != null ) {
5663 Locale .setDefault (l );
64+ logger .debug ("Java Locale changed to {}" , l );
5765 return true ;
5866 }
5967 }
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ public class ReportersCommand implements ICommand {
2828
2929 @ Override
3030 public int run () {
31+ LoggerConfiguration .configure (LoggerConfiguration .ConfigLevel .NONE );
3132
3233 try {
3334 DataSource ds = DataSourceProvider .getDataSource (connectionString , 1 );
Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ public RunAction(RunCommandConfig config) {
4848
4949 void init () {
5050 LoggerConfiguration .configure (config .getLogConfigLevel ());
51+ LocaleInitializer .initLocale ();
5152 }
5253
5354 public RunCommandConfig getConfig () {
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ public class VersionInfoCommand implements ICommand {
2323 boolean help ;
2424
2525 public int run () {
26+ LoggerConfiguration .configure (LoggerConfiguration .ConfigLevel .NONE );
2627
2728 System .out .println (CliVersionInfo .getInfo ());
2829 System .out .println (JavaApiVersionInfo .getInfo ());
Original file line number Diff line number Diff line change 11package org .utplsql .cli .config ;
22
3+ import org .utplsql .api .reporter .CoreReporters ;
4+
35import java .beans .ConstructorProperties ;
46
57public class ReporterConfig {
@@ -10,7 +12,11 @@ public class ReporterConfig {
1012
1113 @ ConstructorProperties ({"name" , "output" , "forceToScreen" })
1214 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+ }
1420 this .output = output ;
1521 if (forceToScreen != null ) this .forceToScreen = forceToScreen ;
1622 }
Original file line number Diff line number Diff line change @@ -163,6 +163,20 @@ void multipleReporters() throws Exception {
163163 assertTrue (reporterConfig .isForceToScreen ());
164164 }
165165
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+
166180 @ Test
167181 void sourceFileMapping () throws Exception {
168182 RunCommandConfig config = parseForConfig ("run" ,
Original file line number Diff line number Diff line change @@ -75,4 +75,18 @@ void run_withDbmsOutputEnabled() throws Exception {
7575
7676 assertValidReturnCode (result );
7777 }
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+ }
7892}
You can’t perform that action at this time.
0 commit comments