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_r321513178
 
 

 ##########
 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);
 
 Review comment:
   Consider using `Assert.fail()` instead: 
http://junit.sourceforge.net/javadoc/org/junit/Assert.html#fail(java.lang.String)

----------------------------------------------------------------
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