avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r776496 [2/2] - in /hadoop/avro/trunk: ./ lib/py/ src/doc/content/xdocs/ src/java/org/apache/avro/ src/java/org/apache/avro/generic/ src/java/org/apache/avro/reflect/ src/java/org/apache/avro/specific/ src/py/avro/ src/test/java/org/apache/...
Date Tue, 19 May 2009 23:35:40 GMT
Modified: hadoop/avro/trunk/src/test/java/org/apache/avro/TestProtocolSpecific.java
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/test/java/org/apache/avro/TestProtocolSpecific.java?rev=776496&r1=776495&r2=776496&view=diff
==============================================================================
--- hadoop/avro/trunk/src/test/java/org/apache/avro/TestProtocolSpecific.java (original)
+++ hadoop/avro/trunk/src/test/java/org/apache/avro/TestProtocolSpecific.java Tue May 19 23:35:39
2009
@@ -24,6 +24,7 @@
 import org.apache.avro.specific.SpecificRequestor;
 import org.apache.avro.specific.SpecificResponder;
 import org.apache.avro.test.Simple;
+import org.apache.avro.test.Simple.Kind;
 import org.apache.avro.test.Simple.TestError;
 import org.apache.avro.test.Simple.TestRecord;
 import org.apache.avro.util.Utf8;
@@ -91,6 +92,7 @@
   public void testEcho() throws IOException {
     TestRecord record = new TestRecord();
     record.name = new Utf8("foo");
+    record.kind = Kind.BAR;
     TestRecord echoed = proxy.echo(record);
     assertEquals(record.name, echoed.name);
   }

Modified: hadoop/avro/trunk/src/test/java/org/apache/avro/TestSchema.java
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/test/java/org/apache/avro/TestSchema.java?rev=776496&r1=776495&r2=776496&view=diff
==============================================================================
--- hadoop/avro/trunk/src/test/java/org/apache/avro/TestSchema.java (original)
+++ hadoop/avro/trunk/src/test/java/org/apache/avro/TestSchema.java Tue May 19 23:35:39 2009
@@ -108,6 +108,12 @@
   }
 
   @Test
+  public void testEnum() throws Exception {
+    check("{\"type\": \"enum\", \"symbols\": [\"A\", \"B\"]}", "\"B\"", "B",
+          false);
+  }
+
+  @Test
   public void testRecursive() throws Exception {
     check("{\"type\": \"record\", \"name\": \"Node\", \"fields\": ["
           +"{\"name\":\"label\", \"type\":\"string\"},"
@@ -134,7 +140,12 @@
 
   private static void check(String schemaJson, String defaultJson,
                             Object defaultValue) throws Exception {
-    check(schemaJson, true);
+    check(schemaJson, defaultJson, defaultValue, true);
+  }
+  private static void check(String schemaJson, String defaultJson,
+                            Object defaultValue, boolean induce)
+    throws Exception {
+    check(schemaJson, induce);
     checkDefault(schemaJson, defaultJson, defaultValue);
   }
 

Modified: hadoop/avro/trunk/src/test/py/testio.py
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/test/py/testio.py?rev=776496&r1=776495&r2=776496&view=diff
==============================================================================
--- hadoop/avro/trunk/src/test/py/testio.py (original)
+++ hadoop/avro/trunk/src/test/py/testio.py Tue May 19 23:35:39 2009
@@ -81,6 +81,12 @@
     elif schm.gettype() == schema.UNION:
       datum = self.nextdata(random.choice(schm.getelementtypes()), d)
       return datum
+    elif schm.gettype() == schema.ENUM:
+      symbols = schm.getenumsymbols()
+      len =  symbols.__len__()
+      if len == 0:
+        return None
+      return symbols[random.randint(0,len)-1]
 
 class TestSchema(unittest.TestCase):
 
@@ -129,6 +135,9 @@
     self.check("{\"type\":\"record\",\"fields\":[{\"name\":\"f\", \"type\":" +
                "\"string\"}, {\"name\":\"fb\", \"type\":\"bytes\"}]}")
 
+  def testEnum(self):
+    self.check("{\"type\": \"enum\", \"symbols\": [\"A\", \"B\"]}")
+
   def testRecursive(self):
     self.check("{\"type\": \"record\", \"name\": \"Node\", \"fields\": ["
           +"{\"name\":\"label\", \"type\":\"string\"},"

Modified: hadoop/avro/trunk/src/test/py/testipc.py
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/test/py/testipc.py?rev=776496&r1=776495&r2=776496&view=diff
==============================================================================
--- hadoop/avro/trunk/src/test/py/testipc.py (original)
+++ hadoop/avro/trunk/src/test/py/testipc.py Tue May 19 23:35:39 2009
@@ -76,6 +76,7 @@
   def checkecho(self):
     record = dict()
     record['name'] = unicode('foo')
+    record['kind'] = 'BAR'
     params = dict()
     params['record'] = record
     echoed = self.requestor.call('echo', params)

Modified: hadoop/avro/trunk/src/test/py/testipcreflect.py
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/test/py/testipcreflect.py?rev=776496&r1=776495&r2=776496&view=diff
==============================================================================
--- hadoop/avro/trunk/src/test/py/testipcreflect.py (original)
+++ hadoop/avro/trunk/src/test/py/testipcreflect.py Tue May 19 23:35:39 2009
@@ -58,6 +58,7 @@
   def checkecho(self):
     record = TestRecord()
     record.name = unicode('foo')
+    record.kind = 'BAR'
     echoed = self.proxy.echo(record)
     self.assertEquals(record.name, echoed.name)
 

Modified: hadoop/avro/trunk/src/test/schemata/interop.js
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/test/schemata/interop.js?rev=776496&r1=776495&r2=776496&view=diff
==============================================================================
--- hadoop/avro/trunk/src/test/schemata/interop.js (original)
+++ hadoop/avro/trunk/src/test/schemata/interop.js Tue May 19 23:35:39 2009
@@ -15,6 +15,8 @@
          "fields": [{"name": "label", "type": "string"}]}}},
       {"name": "unionField", "type":
        ["boolean", "double", {"type": "array", "items": "bytes"}]},
+      {"name": "enumField", "type":
+       {"type": "enum", "name": "Kind", "symbols": ["A","B","C"]}},
       {"name": "recordField", "type":
        {"type": "record", "name": "Node",
         "fields": [

Modified: hadoop/avro/trunk/src/test/schemata/simple.js
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/test/schemata/simple.js?rev=776496&r1=776495&r2=776496&view=diff
==============================================================================
--- hadoop/avro/trunk/src/test/schemata/simple.js (original)
+++ hadoop/avro/trunk/src/test/schemata/simple.js Tue May 19 23:35:39 2009
@@ -2,9 +2,12 @@
  "protocol": "Simple",
 
  "types": [
+     {"name": "Kind", "type": "enum", "symbols": ["FOO","BAR","BAZ"]},
+
      {"name": "TestRecord", "type": "record",
       "fields": [
-          {"name": "name", "type": "string"}
+          {"name": "name", "type": "string"},
+          {"name": "kind", "type": "Kind"}
       ]
      },
 



Mime
View raw message