@Test public void testChoppedStatementNoLineChange() { String example1 = "This is\na test"; String example2 = "This is\r\na test\nstring"; String expected1 = "This is a test"; String expected2 = "This is a test string"; Assert.assertEquals(HiveJdbcConnector.choppedStatementNoLineChange(example1), expected1); Assert.assertEquals(HiveJdbcConnector.choppedStatementNoLineChange(example2), expected2); int iter = 501; StringBuilder exampleExpected = new StringBuilder(); StringBuilder exampleResult = new StringBuilder(); while (iter > 0) { exampleExpected.append("a "); exampleResult.append("a\n"); iter -- ; } String expected = exampleExpected.toString().substring(0, 1000) + "...... (2 characters omitted)"; Assert.assertEquals(HiveJdbcConnector.choppedStatementNoLineChange(exampleResult.toString()), expected); }
static String choppedStatementNoLineChange(String statement) { statement = statement.replaceAll("\\r\\n|\\r|\\n", " "); if (statement.length() <= MAX_OUTPUT_STMT_LENGTH) { return statement; } return statement.substring(0, MAX_OUTPUT_STMT_LENGTH) + "...... (" + (statement.length() - MAX_OUTPUT_STMT_LENGTH) + " characters omitted)"; }
HiveJdbcConnector implements Closeable { static String choppedStatementNoLineChange(String statement) { statement = statement.replaceAll("\\r\\n|\\r|\\n", " "); if (statement.length() <= MAX_OUTPUT_STMT_LENGTH) { return statement; } return statement.substring(0, MAX_OUTPUT_STMT_LENGTH) + "...... (" + (statement.length() - MAX_OUTPUT_STMT_LENGTH) + " characters omitted)"; } }
HiveJdbcConnector implements Closeable { static String choppedStatementNoLineChange(String statement) { statement = statement.replaceAll("\\r\\n|\\r|\\n", " "); if (statement.length() <= MAX_OUTPUT_STMT_LENGTH) { return statement; } return statement.substring(0, MAX_OUTPUT_STMT_LENGTH) + "...... (" + (statement.length() - MAX_OUTPUT_STMT_LENGTH) + " characters omitted)"; } private  HiveJdbcConnector(); private  HiveJdbcConnector(boolean isSimulate); }
HiveJdbcConnector implements Closeable { static String choppedStatementNoLineChange(String statement) { statement = statement.replaceAll("\\r\\n|\\r|\\n", " "); if (statement.length() <= MAX_OUTPUT_STMT_LENGTH) { return statement; } return statement.substring(0, MAX_OUTPUT_STMT_LENGTH) + "...... (" + (statement.length() - MAX_OUTPUT_STMT_LENGTH) + " characters omitted)"; } private  HiveJdbcConnector(); private  HiveJdbcConnector(boolean isSimulate); @SuppressWarnings("resource") static HiveJdbcConnector newEmbeddedConnector(int hiveServerVersion); static HiveJdbcConnector newConnectorWithProps(Properties compactRunProps); void executeStatements(String... statements); Connection getConnection(); @Override void close(); }
HiveJdbcConnector implements Closeable { static String choppedStatementNoLineChange(String statement) { statement = statement.replaceAll("\\r\\n|\\r|\\n", " "); if (statement.length() <= MAX_OUTPUT_STMT_LENGTH) { return statement; } return statement.substring(0, MAX_OUTPUT_STMT_LENGTH) + "...... (" + (statement.length() - MAX_OUTPUT_STMT_LENGTH) + " characters omitted)"; } private  HiveJdbcConnector(); private  HiveJdbcConnector(boolean isSimulate); @SuppressWarnings("resource") static HiveJdbcConnector newEmbeddedConnector(int hiveServerVersion); static HiveJdbcConnector newConnectorWithProps(Properties compactRunProps); void executeStatements(String... statements); Connection getConnection(); @Override void close(); static final String HIVESERVER_VERSION; static final String DEFAULT_HIVESERVER_VERSION; static final String HIVESERVER_CONNECTION_STRING; static final String HIVESERVER_URL; static final String HIVESERVER_USER; static final String HIVESERVER_PASSWORD; static final String HIVESITE_DIR; static final String HIVE_EXECUTION_SIMULATE; }