Skip to content

Commit 3513f49

Browse files
committed
Test to parse/set NLS_LANG correctly
1 parent f87c61e commit 3513f49

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

src/test/java/org/utplsql/cli/DataSourceProviderIT.java

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@
55

66
import javax.sql.DataSource;
77
import java.io.IOException;
8+
import java.sql.Connection;
9+
import java.sql.PreparedStatement;
10+
import java.sql.ResultSet;
811
import java.sql.SQLException;
912

13+
import static org.junit.jupiter.api.Assertions.assertEquals;
1014
import static org.junit.jupiter.api.Assertions.assertNotNull;
1115

1216
public class DataSourceProviderIT {
@@ -20,4 +24,44 @@ public void connectToDatabase() throws IOException, SQLException {
2024

2125
assertNotNull(dataSource);
2226
}
27+
28+
@Test
29+
public void initNlsLang() throws SQLException {
30+
ConnectionConfig config = new ConnectionConfig(TestHelper.getConnectionString());
31+
System.setProperty("NLS_LANG", "BRAZILIAN PORTUGUESE_BRAZIL.WE8ISO8859P1");
32+
33+
34+
DataSource dataSource = new TestedDataSourceProvider(config).getDataSource();
35+
36+
assertNotNull(dataSource);
37+
38+
try ( Connection con = dataSource.getConnection() ) {
39+
try (PreparedStatement stmt = con.prepareStatement("select value from nls_session_parameters where parameter = 'NLS_LANGUAGE'")) {
40+
ResultSet rs = stmt.executeQuery();
41+
if ( rs.next() ) {
42+
assertEquals("BRAZILIAN PORTUGUESE", rs.getString(1));
43+
}
44+
}
45+
}
46+
}
47+
48+
@Test
49+
public void initPartialNlsLang() throws SQLException {
50+
ConnectionConfig config = new ConnectionConfig(TestHelper.getConnectionString());
51+
System.setProperty("NLS_LANG", "_SOMALIA");
52+
53+
54+
DataSource dataSource = new TestedDataSourceProvider(config).getDataSource();
55+
56+
assertNotNull(dataSource);
57+
58+
try ( Connection con = dataSource.getConnection() ) {
59+
try (PreparedStatement stmt = con.prepareStatement("select value from nls_session_parameters where parameter = 'NLS_TERRITORY'")) {
60+
ResultSet rs = stmt.executeQuery();
61+
if ( rs.next() ) {
62+
assertEquals("SOMALIA", rs.getString(1));
63+
}
64+
}
65+
}
66+
}
2367
}

0 commit comments

Comments
 (0)