package org.utplsql.cli;

import org.junit.jupiter.api.Test;
import org.utplsql.cli.datasource.TestedDataSourceProvider;

import javax.sql.DataSource;
import java.io.IOException;
import java.sql.SQLException;

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

public class DataSourceProviderIT {

    @Test
    public void connectToDatabase() throws IOException, SQLException {

        ConnectionConfig config = new ConnectionConfig(TestHelper.getConnectionString());

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

        assertNotNull(dataSource);
    }
}

@@ -192,22 +192,173 @@
 sql.
-SQLException;%0A
+Connection;%0Aimport java.sql.PreparedStatement;%0Aimport java.sql.ResultSet;%0Aimport java.sql.SQLException;%0A%0Aimport static org.junit.jupiter.api.Assertions.assertEquals;
 %0Aimp
@@ -754,11 +754,1528 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void initNlsLang() throws SQLException %7B%0A        ConnectionConfig config = new ConnectionConfig(TestHelper.getConnectionString());%0A        System.setProperty(%22NLS_LANG%22, %22BRAZILIAN PORTUGUESE_BRAZIL.WE8ISO8859P1%22);%0A%0A%0A        DataSource dataSource = new TestedDataSourceProvider(config).getDataSource();%0A%0A        assertNotNull(dataSource);%0A%0A        try ( Connection con = dataSource.getConnection() ) %7B%0A            try (PreparedStatement stmt = con.prepareStatement(%22select value from nls_session_parameters where parameter = 'NLS_LANGUAGE'%22)) %7B%0A                ResultSet rs = stmt.executeQuery();%0A                if ( rs.next() ) %7B%0A                    assertEquals(%22BRAZILIAN PORTUGUESE%22, rs.getString(1));%0A                %7D%0A            %7D%0A        %7D%0A    %7D%0A%0A    @Test%0A    public void initPartialNlsLang() throws SQLException %7B%0A        ConnectionConfig config = new ConnectionConfig(TestHelper.getConnectionString());%0A        System.setProperty(%22NLS_LANG%22, %22_SOMALIA%22);%0A%0A%0A        DataSource dataSource = new TestedDataSourceProvider(config).getDataSource();%0A%0A        assertNotNull(dataSource);%0A%0A        try ( Connection con = dataSource.getConnection() ) %7B%0A            try (PreparedStatement stmt = con.prepareStatement(%22select value from nls_session_parameters where parameter = 'NLS_TERRITORY'%22)) %7B%0A                ResultSet rs = stmt.executeQuery();%0A                if ( rs.next() ) %7B%0A                    assertEquals(%22SOMALIA%22, rs.getString(1));%0A                %7D%0A            %7D%0A        %7D%0A    %7D
 %0A%7D%0A

Test to parse/set NLS_LANG correctly