ccaominh commented on a change in pull request #8465: disallow whitespace 
characters in data source names
URL: https://github.com/apache/incubator-druid/pull/8465#discussion_r321514260
 
 

 ##########
 File path: 
server/src/test/java/org/apache/druid/segment/indexing/DataSchemaTest.java
 ##########
 @@ -324,6 +325,38 @@ public void testEmptyDatasource()
     );
   }
 
+
+  @Test
+  public void testWhitespaceDatasource()
+  {
+    String[] dataSource = {"\tab\t", "\rcarriage\return\r", "\nnew\nline\n"};
+    String[] invalidChars = {"\\t", "\\r", "\\n"};
+    for (int i = 0; i < dataSource.length; ++i) {
+      testWhitespaceDatasourceHelper(dataSource[i], invalidChars[i]);
+    }
+  }
+
+  private void testWhitespaceDatasourceHelper(String dataSource, String 
invalidChar)
+  {
+    String testFailMsg = "dataSource contain invalid character: " + 
invalidChar;
+    try {
+      DataSchema schema = new DataSchema(
+          dataSource,
+          Collections.emptyMap(),
+          null,
+          null,
+          null,
+          jsonMapper
+      );
+      Assert.assertTrue(testFailMsg, false);
+    }
+    catch (IllegalArgumentException errorMsg) {
+      String expectedMsg = "dataSource cannot contain whitespace character.";
+      Assert.assertEquals(testFailMsg, errorMsg.getMessage(), expectedMsg);
 
 Review comment:
   The JUnit assert apis take the expected value as the second argument and the 
actual value as the third argument: 
http://junit.sourceforge.net/javadoc/org/junit/Assert.html#assertEquals(java.lang.String,%20java.lang.Object,%20java.lang.Object)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to