You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by sa...@apache.org on 2019/04/27 16:00:15 UTC

[pulsar] branch master updated: Added missing unittests for primitive schema types (#4147)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new d1d5aba  Added missing unittests for primitive schema types (#4147)
d1d5aba is described below

commit d1d5aba085490ce26f0c19873b87381677596258
Author: Sanjeev Kulkarni <sa...@gmail.com>
AuthorDate: Sat Apr 27 09:00:09 2019 -0700

    Added missing unittests for primitive schema types (#4147)
    
    * Added schema information and unittests for primitive schema types
    
    * Fixed unittest
    
    * For primitive types just check for schema type instead of the schema metadata
    
    * Address feedback
    
    * Revert changes to the schemas and only keep unittests
---
 .../client/impl/schema/BooleanSchemaTest.java      | 65 ++++++++++++++++++
 .../pulsar/client/impl/schema/DateSchemaTest.java  | 75 +++++++++++++++++++++
 .../client/impl/schema/DoubleSchemaTest.java       | 59 +++++++++++++++++
 .../pulsar/client/impl/schema/FloatSchemaTest.java | 53 +++++++++++++++
 .../pulsar/client/impl/schema/IntSchemaTest.java   | 69 +++++++++++++++++++
 .../pulsar/client/impl/schema/LongSchemaTest.java  | 77 ++++++++++++++++++++++
 .../pulsar/client/impl/schema/ShortSchemaTest.java | 65 ++++++++++++++++++
 .../pulsar/client/impl/schema/TimeSchemaTest.java  | 75 +++++++++++++++++++++
 .../client/impl/schema/TimestampSchemaTest.java    | 75 +++++++++++++++++++++
 9 files changed, 613 insertions(+)

diff --git a/pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/BooleanSchemaTest.java b/pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/BooleanSchemaTest.java
new file mode 100644
index 0000000..9f62d1a
--- /dev/null
+++ b/pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/BooleanSchemaTest.java
@@ -0,0 +1,65 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.client.impl.schema;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+public class BooleanSchemaTest {
+
+    @Test
+    public void testSchemaEncode() {
+        BooleanSchema schema = BooleanSchema.of();
+        byte[] expectedTrue = new byte[] {
+                1
+        };
+        byte[] expectedFalse = new byte[] {
+                0
+        };
+        Assert.assertEquals(expectedTrue, schema.encode(true));
+        Assert.assertEquals(expectedFalse, schema.encode(false));
+    }
+
+    @Test
+    public void testSchemaEncodeDecodeFidelity() {
+        BooleanSchema schema = BooleanSchema.of();
+        Assert.assertEquals(new Boolean(true), schema.decode(schema.encode(true)));
+        Assert.assertEquals(new Boolean(false), schema.decode(schema.encode(false)));
+    }
+
+    @Test
+    public void testSchemaDecode() {
+        byte[] trueBytes = new byte[] {
+                1
+        };
+        byte[] falseBytes = new byte[] {
+                0
+        };
+        BooleanSchema schema = BooleanSchema.of();
+        Assert.assertEquals(new Boolean(true), schema.decode(trueBytes));
+        Assert.assertEquals(new Boolean(false), schema.decode(falseBytes));
+    }
+
+    @Test
+    public void testNullEncodeDecode() {
+        Assert.assertNull(BooleanSchema.of().encode(null));
+        Assert.assertNull(BooleanSchema.of().decode(null));
+    }
+
+}
diff --git a/pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/DateSchemaTest.java b/pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/DateSchemaTest.java
new file mode 100644
index 0000000..0e707ed
--- /dev/null
+++ b/pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/DateSchemaTest.java
@@ -0,0 +1,75 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.client.impl.schema;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.util.Date;
+
+public class DateSchemaTest {
+
+    @Test
+    public void testSchemaEncode() {
+        DateSchema schema = DateSchema.of();
+        Date data = new Date();
+        byte[] expected = new byte[] {
+                (byte) (data.getTime() >>> 56),
+                (byte) (data.getTime() >>> 48),
+                (byte) (data.getTime() >>> 40),
+                (byte) (data.getTime() >>> 32),
+                (byte) (data.getTime() >>> 24),
+                (byte) (data.getTime() >>> 16),
+                (byte) (data.getTime() >>> 8),
+                ((Long)data.getTime()).byteValue()
+        };
+        Assert.assertEquals(expected, schema.encode(data));
+    }
+
+    @Test
+    public void testSchemaEncodeDecodeFidelity() {
+        DateSchema schema = DateSchema.of();
+        Date date = new Date();
+        Assert.assertEquals(date, schema.decode(schema.encode(date)));
+    }
+
+    @Test
+    public void testSchemaDecode() {
+        byte[] byteData = new byte[] {
+               0,
+               0,
+               0,
+               0,
+               0,
+               10,
+               24,
+               42
+        };
+        long expected = 10*65536 + 24*256 + 42;
+        DateSchema schema = DateSchema.of();
+        Assert.assertEquals(expected, schema.decode(byteData).getTime());
+    }
+
+    @Test
+    public void testNullEncodeDecode() {
+        Assert.assertNull(DateSchema.of().encode(null));
+        Assert.assertNull(DateSchema.of().decode(null));
+    }
+
+}
diff --git a/pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/DoubleSchemaTest.java b/pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/DoubleSchemaTest.java
new file mode 100644
index 0000000..0fbbca0
--- /dev/null
+++ b/pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/DoubleSchemaTest.java
@@ -0,0 +1,59 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.client.impl.schema;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.util.Date;
+
+public class DoubleSchemaTest {
+
+    @Test
+    public void testSchemaEncode() {
+        DoubleSchema schema = DoubleSchema.of();
+        Double data = new Double(12345678.1234);
+        long longData = Double.doubleToLongBits(data);
+        byte[] expected = new byte[] {
+                (byte) (longData >>> 56),
+                (byte) (longData >>> 48),
+                (byte) (longData >>> 40),
+                (byte) (longData >>> 32),
+                (byte) (longData >>> 24),
+                (byte) (longData >>> 16),
+                (byte) (longData >>> 8),
+                ((Long)longData).byteValue()
+        };
+        Assert.assertEquals(expected, schema.encode(data));
+    }
+
+    @Test
+    public void testSchemaEncodeDecodeFidelity() {
+        DoubleSchema schema = DoubleSchema.of();
+        Double dbl = new Double(1234578.8754321);
+        Assert.assertEquals(dbl, schema.decode(schema.encode(dbl)));
+    }
+
+    @Test
+    public void testNullEncodeDecode() {
+        Assert.assertNull(DoubleSchema.of().encode(null));
+        Assert.assertNull(DoubleSchema.of().decode(null));
+    }
+
+}
diff --git a/pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/FloatSchemaTest.java b/pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/FloatSchemaTest.java
new file mode 100644
index 0000000..b915582
--- /dev/null
+++ b/pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/FloatSchemaTest.java
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.client.impl.schema;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+public class FloatSchemaTest {
+
+    @Test
+    public void testSchemaEncode() {
+        FloatSchema schema = FloatSchema.of();
+        Float data = new Float(12345678.1234);
+        long longData = Float.floatToRawIntBits(data);
+        byte[] expected = new byte[] {
+                (byte) (longData >>> 24),
+                (byte) (longData >>> 16),
+                (byte) (longData >>> 8),
+                ((Long)longData).byteValue()
+        };
+        Assert.assertEquals(expected, schema.encode(data));
+    }
+
+    @Test
+    public void testSchemaEncodeDecodeFidelity() {
+        FloatSchema schema = FloatSchema.of();
+        Float dbl = new Float(1234578.8754321);
+        Assert.assertEquals(dbl, schema.decode(schema.encode(dbl)));
+    }
+
+    @Test
+    public void testNullEncodeDecode() {
+        Assert.assertNull(FloatSchema.of().encode(null));
+        Assert.assertNull(FloatSchema.of().decode(null));
+    }
+
+}
diff --git a/pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/IntSchemaTest.java b/pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/IntSchemaTest.java
new file mode 100644
index 0000000..fb17811
--- /dev/null
+++ b/pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/IntSchemaTest.java
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.client.impl.schema;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+public class IntSchemaTest {
+
+    @Test
+    public void testSchemaEncode() {
+        IntSchema schema = IntSchema.of();
+        Integer data = 1234578;
+        byte[] expected = new byte[] {
+                (byte) (data >>> 24),
+                (byte) (data >>> 16),
+                (byte) (data >>> 8),
+                data.byteValue()
+        };
+        Assert.assertEquals(expected, schema.encode(data));
+    }
+
+    @Test
+    public void testSchemaEncodeDecodeFidelity() {
+        IntSchema schema = IntSchema.of();
+        int start = 348592040;
+        for (int i = 0; i < 100; ++i) {
+            byte[] encode = schema.encode(start + i);
+            int decoded = schema.decode(encode);
+            Assert.assertEquals(decoded, start + i);
+        }
+    }
+
+    @Test
+    public void testSchemaDecode() {
+        byte[] byteData = new byte[] {
+               0,
+               10,
+               24,
+               42
+        };
+        Integer expected = 10*65536 + 24*256 + 42;
+        IntSchema schema = IntSchema.of();
+        Assert.assertEquals(expected, schema.decode(byteData));
+    }
+
+    @Test
+    public void testNullEncodeDecode() {
+        Assert.assertNull(IntSchema.of().encode(null));
+        Assert.assertNull(IntSchema.of().decode(null));
+    }
+
+}
diff --git a/pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/LongSchemaTest.java b/pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/LongSchemaTest.java
new file mode 100644
index 0000000..84c217c
--- /dev/null
+++ b/pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/LongSchemaTest.java
@@ -0,0 +1,77 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.client.impl.schema;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+public class LongSchemaTest {
+
+    @Test
+    public void testSchemaEncode() {
+        LongSchema longSchema = LongSchema.of();
+        Long data = 1234578l;
+        byte[] expected = new byte[] {
+                (byte) (data >>> 56),
+                (byte) (data >>> 48),
+                (byte) (data >>> 40),
+                (byte) (data >>> 32),
+                (byte) (data >>> 24),
+                (byte) (data >>> 16),
+                (byte) (data >>> 8),
+                data.byteValue()
+        };
+        Assert.assertEquals(expected, longSchema.encode(data));
+    }
+
+    @Test
+    public void testSchemaEncodeDecodeFidelity() {
+        LongSchema longSchema = LongSchema.of();
+        long start = 348592040;
+        for (int i = 0; i < 100; ++i) {
+            byte[] encode = longSchema.encode(start + i);
+            long decoded = longSchema.decode(encode);
+            Assert.assertEquals(decoded, start + i);
+        }
+    }
+
+    @Test
+    public void testSchemaDecode() {
+        byte[] byteData = new byte[] {
+               0,
+               0,
+               0,
+               0,
+               0,
+               10,
+               24,
+               42
+        };
+        Long expected = 10*65536l + 24*256 + 42;
+        LongSchema longSchema = LongSchema.of();
+        Assert.assertEquals(expected, longSchema.decode(byteData));
+    }
+
+    @Test
+    public void testNullEncodeDecode() {
+        Assert.assertNull(LongSchema.of().encode(null));
+        Assert.assertNull(LongSchema.of().decode(null));
+    }
+
+}
diff --git a/pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/ShortSchemaTest.java b/pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/ShortSchemaTest.java
new file mode 100644
index 0000000..1252dc9
--- /dev/null
+++ b/pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/ShortSchemaTest.java
@@ -0,0 +1,65 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.client.impl.schema;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+public class ShortSchemaTest {
+
+    @Test
+    public void testSchemaEncode() {
+        ShortSchema schema = ShortSchema.of();
+        Short data = 12345;
+        byte[] expected = new byte[] {
+                (byte) (data >>> 8),
+                data.byteValue()
+        };
+        Assert.assertEquals(expected, schema.encode(data));
+    }
+
+    @Test
+    public void testSchemaEncodeDecodeFidelity() {
+        ShortSchema schema = ShortSchema.of();
+        short start = 3440;
+        for (short i = 0; i < 100; ++i) {
+            byte[] encode = schema.encode((short)(start + i));
+            int decoded = schema.decode(encode);
+            Assert.assertEquals(decoded, start + i);
+        }
+    }
+
+    @Test
+    public void testSchemaDecode() {
+        byte[] byteData = new byte[] {
+               24,
+               42
+        };
+        Short expected = 24*256 + 42;
+        ShortSchema schema = ShortSchema.of();
+        Assert.assertEquals(expected, schema.decode(byteData));
+    }
+
+    @Test
+    public void testNullEncodeDecode() {
+        Assert.assertNull(ShortSchema.of().encode(null));
+        Assert.assertNull(ShortSchema.of().decode(null));
+    }
+
+}
diff --git a/pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/TimeSchemaTest.java b/pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/TimeSchemaTest.java
new file mode 100644
index 0000000..7b5cd56
--- /dev/null
+++ b/pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/TimeSchemaTest.java
@@ -0,0 +1,75 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.client.impl.schema;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.sql.Time;
+
+public class TimeSchemaTest {
+
+    @Test
+    public void testSchemaEncode() {
+        TimeSchema schema = TimeSchema.of();
+        Time data = new Time(System.currentTimeMillis());
+        byte[] expected = new byte[] {
+                (byte) (data.getTime() >>> 56),
+                (byte) (data.getTime() >>> 48),
+                (byte) (data.getTime() >>> 40),
+                (byte) (data.getTime() >>> 32),
+                (byte) (data.getTime() >>> 24),
+                (byte) (data.getTime() >>> 16),
+                (byte) (data.getTime() >>> 8),
+                ((Long)data.getTime()).byteValue()
+        };
+        Assert.assertEquals(expected, schema.encode(data));
+    }
+
+    @Test
+    public void testSchemaEncodeDecodeFidelity() {
+        TimeSchema schema = TimeSchema.of();
+        Time time = new Time(System.currentTimeMillis());
+        Assert.assertEquals(time, schema.decode(schema.encode(time)));
+    }
+
+    @Test
+    public void testSchemaDecode() {
+        byte[] byteData = new byte[] {
+               0,
+               0,
+               0,
+               0,
+               0,
+               10,
+               24,
+               42
+        };
+        long expected = 10*65536 + 24*256 + 42;
+        TimeSchema schema = TimeSchema.of();
+        Assert.assertEquals(expected, schema.decode(byteData).getTime());
+    }
+
+    @Test
+    public void testNullEncodeDecode() {
+        Assert.assertNull(TimeSchema.of().encode(null));
+        Assert.assertNull(TimeSchema.of().decode(null));
+    }
+
+}
diff --git a/pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/TimestampSchemaTest.java b/pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/TimestampSchemaTest.java
new file mode 100644
index 0000000..1d864b6
--- /dev/null
+++ b/pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/TimestampSchemaTest.java
@@ -0,0 +1,75 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.client.impl.schema;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.sql.Timestamp;
+
+public class TimestampSchemaTest {
+
+    @Test
+    public void testSchemaEncode() {
+        TimestampSchema schema = TimestampSchema.of();
+        Timestamp data = new Timestamp(System.currentTimeMillis());
+        byte[] expected = new byte[] {
+                (byte) (data.getTime() >>> 56),
+                (byte) (data.getTime() >>> 48),
+                (byte) (data.getTime() >>> 40),
+                (byte) (data.getTime() >>> 32),
+                (byte) (data.getTime() >>> 24),
+                (byte) (data.getTime() >>> 16),
+                (byte) (data.getTime() >>> 8),
+                ((Long)data.getTime()).byteValue()
+        };
+        Assert.assertEquals(expected, schema.encode(data));
+    }
+
+    @Test
+    public void testSchemaEncodeDecodeFidelity() {
+        TimestampSchema schema = TimestampSchema.of();
+        Timestamp timestamp = new Timestamp(System.currentTimeMillis());
+        Assert.assertEquals(timestamp, schema.decode(schema.encode(timestamp)));
+    }
+
+    @Test
+    public void testSchemaDecode() {
+        byte[] byteData = new byte[] {
+               0,
+               0,
+               0,
+               0,
+               0,
+               10,
+               24,
+               42
+        };
+        long expected = 10*65536 + 24*256 + 42;
+        TimestampSchema schema = TimestampSchema.of();
+        Assert.assertEquals(expected, schema.decode(byteData).getTime());
+    }
+
+    @Test
+    public void testNullEncodeDecode() {
+        Assert.assertNull(TimestampSchema.of().encode(null));
+        Assert.assertNull(TimestampSchema.of().decode(null));
+    }
+
+}