Skip to content

Commit

Permalink
AVRO-2608 Increase test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
zeshuai007 authored and dkulp committed May 21, 2020
1 parent 192cd3b commit b0c0936
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -642,4 +642,20 @@ static void assertCompilesWithJavaCompiler(File dstDir, Collection<OutputFile> o
fileManager.getJavaFileObjects(javaFiles.toArray(new File[0])));
assertTrue(cTask.call());
}

private static String SCHEMA1 = "{ \"name\": \"volatile\", \"type\": \"record\", "
+ " \"fields\": [{\"name\": \"ownerAddress\", \"type\": [\"null\",{ \"type\": \"string\",\"java-class\": \"java.net.URI\"}], \"default\": null},"
+ " {\"name\": \"ownerURL\", \"type\": [\"null\",{ \"type\": \"string\",\"java-class\": \"java.net.URL\"}], \"default\": null}]}";

@Test
public void testGenerateExceptionCodeBlock() throws IOException {
Collection<OutputFile> outputs = new SpecificCompiler(new Schema.Parser().parse(SCHEMA1)).compile();
assertEquals(1, outputs.size());
String contents = outputs.iterator().next().contents;

assertTrue(contents.contains("private java.net.URI"));
assertTrue(contents.contains("catch (java.net.URISyntaxException e)"));
assertTrue(contents.contains("private java.net.URL"));
assertTrue(contents.contains("catch (java.net.MalformedURLException e)"));
}
}

0 comments on commit b0c0936

Please sign in to comment.