Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Test to parse/set NLS_LANG correctly
  • Loading branch information
pesse committed Oct 11, 2018
commit 3513f49df275866ecf71be8defd581707cf67dc0
44 changes: 44 additions & 0 deletions src/test/java/org/utplsql/cli/DataSourceProviderIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@

import javax.sql.DataSource;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

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

assertNotNull(dataSource);
}

@Test
public void initNlsLang() throws SQLException {
ConnectionConfig config = new ConnectionConfig(TestHelper.getConnectionString());
System.setProperty("NLS_LANG", "BRAZILIAN PORTUGUESE_BRAZIL.WE8ISO8859P1");


DataSource dataSource = new TestedDataSourceProvider(config).getDataSource();

assertNotNull(dataSource);

try ( Connection con = dataSource.getConnection() ) {
try (PreparedStatement stmt = con.prepareStatement("select value from nls_session_parameters where parameter = 'NLS_LANGUAGE'")) {
ResultSet rs = stmt.executeQuery();
if ( rs.next() ) {
assertEquals("BRAZILIAN PORTUGUESE", rs.getString(1));
}
}
}
}

@Test
public void initPartialNlsLang() throws SQLException {
ConnectionConfig config = new ConnectionConfig(TestHelper.getConnectionString());
System.setProperty("NLS_LANG", "_SOMALIA");


DataSource dataSource = new TestedDataSourceProvider(config).getDataSource();

assertNotNull(dataSource);

try ( Connection con = dataSource.getConnection() ) {
try (PreparedStatement stmt = con.prepareStatement("select value from nls_session_parameters where parameter = 'NLS_TERRITORY'")) {
ResultSet rs = stmt.executeQuery();
if ( rs.next() ) {
assertEquals("SOMALIA", rs.getString(1));
}
}
}
}
}