You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by dk...@apache.org on 2020/05/21 15:10:07 UTC

[avro] 03/03: AVRO-2608 Increase test cases

This is an automated email from the ASF dual-hosted git repository.

dkulp pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/avro.git

commit b0c09361fe985fe57858f19485b43e1deeec8d89
Author: zeshuai007 <51...@qq.com>
AuthorDate: Tue Nov 12 11:29:36 2019 +0800

    AVRO-2608 Increase test cases
---
 .../avro/compiler/specific/TestSpecificCompiler.java     | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/lang/java/ipc/src/test/java/org/apache/avro/compiler/specific/TestSpecificCompiler.java b/lang/java/ipc/src/test/java/org/apache/avro/compiler/specific/TestSpecificCompiler.java
index 32b2edc..7c42ca9 100644
--- a/lang/java/ipc/src/test/java/org/apache/avro/compiler/specific/TestSpecificCompiler.java
+++ b/lang/java/ipc/src/test/java/org/apache/avro/compiler/specific/TestSpecificCompiler.java
@@ -642,4 +642,20 @@ public class TestSpecificCompiler {
         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)"));
+  }
 }