55
66import javax .sql .DataSource ;
77import java .io .IOException ;
8+ import java .sql .Connection ;
9+ import java .sql .PreparedStatement ;
10+ import java .sql .ResultSet ;
811import java .sql .SQLException ;
912
13+ import static org .junit .jupiter .api .Assertions .assertEquals ;
1014import static org .junit .jupiter .api .Assertions .assertNotNull ;
1115
1216public 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