Skip to content

Commit

Permalink
Sanity test
Browse files Browse the repository at this point in the history
  • Loading branch information
li-ukumar committed Jan 19, 2024
1 parent 11cca1b commit 625f19d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ public static void main(String[] args) throws Exception {
.defaultsTo("false")
.describedAs("true/false");

OptionSpec<String> jsonPropsToIgnoreInCompareOpt = parser.accepts("jsonPropsToIgnoreInCompare", "json properties to ignore when comparing schemas on filesystem and classpath")
OptionSpec<String> jsonPropsToIgnoreInCompareOpt = parser.accepts("jsonPropsToIgnoreInCompare",
"json properties to ignore when comparing schemas on filesystem and classpath. Example : jsonOption1, jsonOption2")
.withOptionalArg()
.defaultsTo("")
.withValuesSeparatedBy(',');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,29 @@ public void testTopLevelUnionUsingOwnCodegen() throws Exception {
Assert.assertEquals(javaFiles.size(), 2);
}

@Test
public void testTopLevelUnionUsingOwnCodegenWithIngoreJsonPropOptipn() throws Exception {
File simpleProjectRoot = new File(locateTestProjectsRoot(), "union-schema-project");
File inputFolder = new File(simpleProjectRoot, "input");
File outputFolder = new File(simpleProjectRoot, "output");
if (outputFolder.exists()) { //clear output
FileUtils.deleteDirectory(outputFolder);
}
//run the builder
SchemaBuilder.main(new String[] {
"--input", inputFolder.getAbsolutePath(),
"--output", outputFolder.getAbsolutePath(),
"--generator", CodeGenerator.AVRO_UTIL.name(),
"enableUtf8EncodingInPutByIndex", "false",
"--jsonPropsToIgnoreInCompare", "option1, option2"
});
//see output was generated
List<Path> javaFiles = Files.find(outputFolder.toPath(), 5,
(path, basicFileAttributes) -> path.getFileName().toString().endsWith(".java")
).collect(Collectors.toList());
Assert.assertEquals(javaFiles.size(), 2);
}

private File locateTestProjectsRoot() {
//the current working directory for test execution varies across gradle and IDEs.
//as such, we need to get creative to locate the folder
Expand Down

0 comments on commit 625f19d

Please sign in to comment.