Review Board 1.7.22


SQOOP-946 Sqoop2: Integration: Enhance the POC test case

Review Request #9896 - Created March 13, 2013 and submitted

Jarek Cecho
SQOOP-946
Reviewers
Sqoop
sqoop-sqoop2
I've changed a bit the temporary path generation logic by appending method name as another directory to the path. The reasoning is to support test cases with multiple tests (each test will have it's own sandbox). I've also extracted few easily reusable methods and added new test.
Integration tests seems to be passing.
test/src/test/java/org/apache/sqoop/integration/TomcatTestCase.java
Revision 5631144f8f0575d7507055f70b42e9edfc762904 New Change
[20] 20 lines
[+20]
21
import org.apache.commons.lang.StringUtils;
21
import org.apache.commons.lang.StringUtils;
22
import org.apache.sqoop.client.SqoopClient;
22
import org.apache.sqoop.client.SqoopClient;
23
import org.apache.sqoop.test.minicluster.TomcatSqoopMiniCluster;
23
import org.apache.sqoop.test.minicluster.TomcatSqoopMiniCluster;
24
import org.junit.After;
24
import org.junit.After;
25
import org.junit.Before;
25
import org.junit.Before;

    
   
26
import org.junit.Rule;

    
   
27
import org.junit.rules.TestName;
26

    
   
28

   
27
import java.io.BufferedReader;
29
import java.io.BufferedReader;
28
import java.io.File;
30
import java.io.File;
29
import java.io.FileReader;
31
import java.io.FileReader;
30
import java.io.FilenameFilter;
32
import java.io.FilenameFilter;
[+20] [20] 12 lines
[+20]
43
 */
45
 */
44
abstract public class TomcatTestCase {
46
abstract public class TomcatTestCase {
45

    
   
47

   
46
  private static final Logger LOG = Logger.getLogger(TomcatTestCase.class);
48
  private static final Logger LOG = Logger.getLogger(TomcatTestCase.class);
47

    
   
49

   

    
   
50
  @Rule public TestName name = new TestName();

    
   
51

   
48
  /**
52
  /**
49
   * Temporary path that will be used for this test.
53
   * Temporary base path that will be used for tests.
50
   *
54
   *
51
   * By default we will take look for sqoop.integration.tmpdir property that is
55
   * By default we will take a look for sqoop.integration.tmpdir property that is
52
   * filled up by maven. If the test is not started from maven (IDE) we will
56
   * filled up by maven. If the test is not started from maven (IDE) we will
53
   * pick up configured java.io.tmpdir value. The last results is /tmp/ directory
57
   * pick up configured java.io.tmpdir value. The last results is /tmp/ directory
54
   * in case that no property is set.
58
   * in case that no property is set.
55
   */
59
   */
56
  private final String TMP_PATH =
60
  private static final String TMP_PATH_BASE =
57
    System.getProperty("sqoop.integration.tmpdir", System.getProperty("java.io.tmpdir", "/tmp"))
61
    System.getProperty("sqoop.integration.tmpdir", System.getProperty("java.io.tmpdir", "/tmp")) + "/sqoop-cargo-tests/";
58
      + "/sqoop-cargo-tests/" + getClass().getName() + "/";
62

   

    
   
63
  /**

    
   
64
   * Temporary directory that will be used by the test.

    
   
65
   *

    
   
66
   * We will take TMP_PATH_BASE and append two subdirectories. First will be named

    
   
67
   * after fully qualified class name of current test class, second directory will

    
   
68
   * be named after current test method name. For example:

    
   
69
   *

    
   
70
   * TMP_PATH_BASE/org.apache.sqoop.TestClass/testMethod/

    
   
71
   */

    
   
72
  private String tmpPath;
59

    
   
73

   
60
  /**
74
  /**
61
   * Tomcat based Sqoop mini cluster
75
   * Tomcat based Sqoop mini cluster
62
   */
76
   */
63
  private TomcatSqoopMiniCluster cluster;
77
  private TomcatSqoopMiniCluster cluster;
64

    
   
78

   
65
  /**
79
  /**
66
   * Sqoop client API.
80
   * Sqoop client API.
67
   */
81
   */
68
  private SqoopClient client;
82
  private SqoopClient client;
69

    
   
83

   
70
  @Before
84
  @Before
71
  public void startServer() throws Exception {
85
  public void startServer() throws Exception {

    
   
86
    // Set up the temporary path

    
   
87
    tmpPath = TMP_PATH_BASE + getClass().getName() + "/" + name.getMethodName() + "/";

    
   
88

   

    
   
89
    // Set up and start server
72
    cluster = new TomcatSqoopMiniCluster(getTemporaryPath());
90
    cluster = new TomcatSqoopMiniCluster(getTemporaryPath());
73
    cluster.start();
91
    cluster.start();
74

    
   
92

   

    
   
93
    // Initialize Sqoop Client API
75
    client = new SqoopClient(getServerUrl());
94
    client = new SqoopClient(getServerUrl());
76
  }
95
  }
77

    
   
96

   
78
  @After
97
  @After
79
  public void stopServer() throws Exception {
98
  public void stopServer() throws Exception {
[+20] [20] 8 lines
[+20]
88
  public SqoopClient getClient() {
107
  public SqoopClient getClient() {
89
    return client;
108
    return client;
90
  }
109
  }
91

    
   
110

   
92
  public String getTemporaryPath() {
111
  public String getTemporaryPath() {
93
    return TMP_PATH;
112
    return tmpPath;
94
  }
113
  }
95

    
   
114

   
96
  /**
115
  /**
97
   * Return testing server URL
116
   * Return testing server URL
98
   *
117
   *
[+20] [20] 67 lines
test/src/test/java/org/apache/sqoop/integration/connector/ConnectorTestCase.java
Revision 14f7dc42f30d86a9e7c56fda9ea355c49fec07d5 New Change
 
test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/TableImportTest.java
Revision 05a799ce09757ca8ed5338a465fae4477adec744 New Change
 
  1. test/src/test/java/org/apache/sqoop/integration/TomcatTestCase.java: Loading...
  2. test/src/test/java/org/apache/sqoop/integration/connector/ConnectorTestCase.java: Loading...
  3. test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/TableImportTest.java: Loading...