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_r321453690
########## File path: server/src/test/java/org/apache/druid/segment/indexing/DataSchemaTest.java ########## @@ -324,109 +326,34 @@ public void testEmptyDatasource() ); } - @Test - public void testNewlineDatasource() - { - Map<String, Object> parser = jsonMapper.convertValue( - new StringInputRowParser( - new JSONParseSpec( - new TimestampSpec("time", "auto", null), - new DimensionsSpec( - DimensionsSpec.getDefaultSchemas(ImmutableList.of("time", "dimA", "dimB", "col2")), - ImmutableList.of("dimC"), - null - ), - null, - null - ), - null - ), JacksonUtils.TYPE_REFERENCE_MAP_STRING_OBJECT - ); - - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage( - "dataSource cannot contain whitespace character." - ); - - DataSchema schema = new DataSchema( - "new\nline\ncharacter", - parser, - null, - null, - null, - jsonMapper - ); - } - @Test - public void testCarriageReturnDatasource() + public void testWhitespaceDatasource() { - Map<String, Object> parser = jsonMapper.convertValue( - new StringInputRowParser( - new JSONParseSpec( - new TimestampSpec("time", "auto", null), - new DimensionsSpec( - DimensionsSpec.getDefaultSchemas(ImmutableList.of("time", "dimA", "dimB", "col2")), - ImmutableList.of("dimC"), - null - ), - null, - null - ), - null - ), JacksonUtils.TYPE_REFERENCE_MAP_STRING_OBJECT - ); - - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage( - "dataSource cannot contain whitespace character." - ); - - DataSchema schema = new DataSchema( - "carriage\return\rcharacter", - parser, - null, - null, - null, - jsonMapper - ); + List<String> dataSource = Arrays.asList("\tab\t", "\rcarriage\return\r", "\nnew\nline\n"); + for (String name : dataSource) { + testDatasource(name); Review comment: It's useful to have a message describing the input in case the test fails so that it is easier to understand why the test failed ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org For additional commands, e-mail: commits-h...@druid.apache.org