Review Board 1.7.22


SQOOP-859 PostgreSQL: Test cases have hard coded username and password

Review Request #9582 - Created Feb. 25, 2013 and submitted

Jarek Cecho
SQOOP-859
Reviewers
Sqoop
sqoop-trunk
I've allowed the password, username and database to be overridden by system properties.
ant clean test -Dtestcase=PostgresqlImportTest -Dsqoop.test.postgresql.connectstring.host_url=jdbc:postgresql://postgresql/ -Dsqoop.test.postgresql.connectstring.username=sqoop -Dsqoop.test.postgresql.connectstring.database=sqoop -Dsqoop.test.postgresql.connectstring.password=sqoop

ant clean test -Dtestcase=PostgresqlExportTest -Dsqoop.test.postgresql.connectstring.host_url=jdbc:postgresql://postgresql/ -Dsqoop.test.postgresql.connectstring.username=sqoop -Dsqoop.test.postgresql.connectstring.database=sqoop -Dsqoop.test.postgresql.connectstring.password=sqoop
src/test/com/cloudera/sqoop/manager/PostgresqlExportTest.java
Revision e85e62adf3c6330df5388f89969684fdbaf9f628 New Change
[20] 43 lines
[+20] [+] public class PostgresqlExportTest extends ExportJobTestCase {
44
      PostgresqlExportTest.class.getName());
44
      PostgresqlExportTest.class.getName());
45

    
   
45

   
46
  static final String HOST_URL = System.getProperty(
46
  static final String HOST_URL = System.getProperty(
47
      "sqoop.test.postgresql.connectstring.host_url",
47
    "sqoop.test.postgresql.connectstring.host_url",
48
      "jdbc:postgresql://localhost/");
48
    "jdbc:postgresql://localhost/");

    
   
49
  static final String DATABASE_USER = System.getProperty(

    
   
50
    "sqoop.test.postgresql.connectstring.username",

    
   
51
    "sqooptest");

    
   
52
  static final String DATABASE_NAME = System.getProperty(

    
   
53
    "sqoop.test.postgresql.connectstring.database",

    
   
54
    "sqooptest");

    
   
55
  static final String PASSWORD = System.getProperty(

    
   
56
    "sqoop.test.postgresql.connectstring.password");
49

    
   
57

   
50
  static final String DATABASE_USER = "sqooptest";

   
51
  static final String DATABASE_NAME = "sqooptest";

   
52
  static final String TABLE_NAME = "EMPLOYEES_PG";
58
  static final String TABLE_NAME = "EMPLOYEES_PG";
53
  static final String PROCEDURE_NAME = "INSERT_AN_EMPLOYEE";
59
  static final String PROCEDURE_NAME = "INSERT_AN_EMPLOYEE";
54
  static final String STAGING_TABLE_NAME = "STAGING";
60
  static final String STAGING_TABLE_NAME = "STAGING";
55
  static final String SCHEMA_PUBLIC = "public";
61
  static final String SCHEMA_PUBLIC = "public";
56
  static final String SCHEMA_SPECIAL = "special";
62
  static final String SCHEMA_SPECIAL = "special";
[+20] [20] 11 lines
[+20] [+] protected boolean useHsqldbTestServer() {
68
    super.setUp();
74
    super.setUp();
69

    
   
75

   
70
    LOG.debug("Setting up postgresql test: " + CONNECT_STRING);
76
    LOG.debug("Setting up postgresql test: " + CONNECT_STRING);
71

    
   
77

   
72
    try {
78
    try {
73
      connection = DriverManager.getConnection(HOST_URL, DATABASE_USER, null);
79
      connection = DriverManager.getConnection(CONNECT_STRING, DATABASE_USER, PASSWORD);
74
      connection.setAutoCommit(false);
80
      connection.setAutoCommit(false);
75
    } catch (SQLException ex) {
81
    } catch (SQLException ex) {
76
      LOG.error("Can't create connection", ex);
82
      LOG.error("Can't create connection", ex);
77
      throw new RuntimeException(ex);
83
      throw new RuntimeException(ex);
78
    }
84
    }
[+20] [20] 378 lines
src/test/com/cloudera/sqoop/manager/PostgresqlImportTest.java
Revision 3fadff71a950daae63523a7e49e887a8ef848ba3 New Change
 
  1. src/test/com/cloudera/sqoop/manager/PostgresqlExportTest.java: Loading...
  2. src/test/com/cloudera/sqoop/manager/PostgresqlImportTest.java: Loading...