You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tajo.apache.org by hy...@apache.org on 2013/07/02 16:16:30 UTC
[36/51] [partial] TAJO-22: The package prefix should be
org.apache.tajo. (DaeMyung Kang via hyunsik)
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-common/src/test/java/org/apache/tajo/datum/TestDatum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/org/apache/tajo/datum/TestDatum.java b/tajo-common/src/test/java/org/apache/tajo/datum/TestDatum.java
new file mode 100644
index 0000000..9a0b654
--- /dev/null
+++ b/tajo-common/src/test/java/org/apache/tajo/datum/TestDatum.java
@@ -0,0 +1,314 @@
+/**
+ * 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.tajo.datum;
+
+import org.junit.Test;
+import org.apache.tajo.common.TajoDataTypes.Type;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class TestDatum {
+
+ @Test
+ public final void testPlusDatumDatum() {
+ Datum x;
+ Datum y;
+ Datum z;
+
+ x = DatumFactory.createInt4(1);
+ y = DatumFactory.createInt4(2);
+ z = x.plus(y);
+ assertEquals(z.type(), Type.INT4);
+ assertEquals(z.asInt4(),3);
+ z = y.plus(x);
+ assertEquals(z.type(),Type.INT4);
+ assertEquals(z.asInt4(),3);
+
+ x = DatumFactory.createInt4(1);
+ y = DatumFactory.createInt8(2l);
+ z = x.plus(y);
+ assertEquals(z.type(),Type.INT8);
+ assertEquals(z.asInt8(),3l);
+ z = y.plus(x);
+ assertEquals(z.type(),Type.INT8);
+ assertEquals(z.asInt8(),3l);
+
+ y = DatumFactory.createFloat4(2.5f);
+ z = x.plus(y);
+ assertEquals(z.type(),Type.FLOAT4);
+ assertTrue(z.asFloat4() == 3.5f);
+ z = y.plus(x);
+ assertEquals(z.type(),Type.FLOAT4);
+ assertEquals(z.asInt4(),3);
+
+ y = DatumFactory.createFloat8(4.5d);
+ z = x.plus(y);
+ assertEquals(z.type(),Type.FLOAT8);
+ assertTrue(z.asFloat8() == 5.5d);
+ z = y.plus(x);
+ assertEquals(z.type(),Type.FLOAT8);
+ assertTrue(z.asFloat8() == 5.5d);
+ }
+
+ @Test
+ public final void testMinusDatumDatum() {
+ Datum x;
+ Datum y;
+ Datum z;
+
+ x = DatumFactory.createInt4(5);
+ y = DatumFactory.createInt4(2);
+ z = x.minus(y);
+ assertEquals(z.type(),Type.INT4);
+ assertEquals(z.asInt4(),3);
+ z = y.minus(x);
+ assertEquals(z.type(),Type.INT4);
+ assertEquals(z.asInt4(),-3);
+
+ y = DatumFactory.createInt8(2l);
+ z = x.minus(y);
+ assertEquals(z.type(),Type.INT8);
+ assertEquals(z.asInt8(),3l);
+ z = y.minus(x);
+ assertEquals(z.type(),Type.INT8);
+ assertEquals(z.asInt8(),-3l);
+
+ y = DatumFactory.createFloat4(2.5f);
+ z = x.minus(y);
+ assertEquals(z.type(),Type.FLOAT4);
+ assertTrue(z.asFloat4() == 2.5f);
+ z = y.minus(x);
+ assertEquals(z.type(),Type.FLOAT4);
+ assertTrue(z.asFloat4() == -2.5f);
+
+ y = DatumFactory.createFloat8(4.5d);
+ z = x.minus(y);
+ assertEquals(z.type(),Type.FLOAT8);
+ assertTrue(z.asFloat8() == 0.5d);
+ z = y.minus(x);
+ assertEquals(z.type(),Type.FLOAT8);
+ assertTrue(z.asFloat8() == -0.5d);
+ }
+
+ @Test
+ public final void testMultiplyDatumDatum() {
+ Datum x;
+ Datum y;
+ Datum z;
+
+ x = DatumFactory.createInt4(5);
+ y = DatumFactory.createInt4(2);
+ z = x.multiply(y);
+ assertEquals(z.type(),Type.INT4);
+ assertEquals(z.asInt4(),10);
+ z = y.multiply(x);
+ assertEquals(z.type(),Type.INT4);
+ assertEquals(z.asInt4(),10);
+
+ y = DatumFactory.createInt8(2l);
+ z = x.multiply(y);
+ assertEquals(z.type(),Type.INT8);
+ assertEquals(z.asInt8(),10l);
+ z = y.multiply(x);
+ assertEquals(z.type(),Type.INT8);
+ assertEquals(z.asInt8(),10l);
+
+ y = DatumFactory.createFloat4(2.5f);
+ z = x.multiply(y);
+ assertEquals(z.type(),Type.FLOAT4);
+ assertTrue(z.asFloat4() == 12.5f);
+ z = y.multiply(x);
+ assertEquals(z.type(),Type.FLOAT4);
+ assertTrue(z.asFloat4() == 12.5f);
+
+ y = DatumFactory.createFloat8(4.5d);
+ z = x.multiply(y);
+ assertEquals(z.type(),Type.FLOAT8);
+ assertTrue(z.asFloat8() == 22.5d);
+ z = y.multiply(x);
+ assertEquals(z.type(),Type.FLOAT8);
+ assertTrue(z.asFloat8() == 22.5d);
+ }
+
+ @Test
+ public final void testDivideDatumDatum() {
+ Datum x;
+ Datum y;
+ Datum z;
+
+ x = DatumFactory.createInt4(6);
+ y = DatumFactory.createInt4(3);
+ z = x.divide(y);
+ assertEquals(z.type(), Type.INT4);
+ assertEquals(z.asInt4(),2);
+ z = y.divide(x);
+ assertEquals(z.type(),Type.INT4);
+ assertTrue(z.asInt4() == 0);
+
+ y = DatumFactory.createInt8(3l);
+ z = x.divide(y);
+ assertEquals(z.type(),Type.INT8);
+ assertEquals(z.asInt8(),2l);
+ z = y.divide(x);
+ assertEquals(z.type(),Type.INT8);
+ assertEquals(z.asInt8(),0l);
+
+ y = DatumFactory.createFloat4(3f);
+ z = x.divide(y);
+ assertEquals(z.type(),Type.FLOAT4);
+ assertTrue(z.asFloat4() == 2.0f);
+ z = y.divide(x);
+ assertEquals(z.type(),Type.FLOAT4);
+ assertTrue(z.asFloat4() == 0.5f);
+
+ y = DatumFactory.createFloat8(3d);
+ z = x.divide(y);
+ assertEquals(z.type(),Type.FLOAT8);
+ assertTrue(z.asFloat8() == 2.0d);
+ z = y.divide(x);
+ assertEquals(z.type(),Type.FLOAT8);
+ assertTrue(z.asFloat8() == 0.5d);
+ }
+
+ @Test
+ public final void testEqualToDatum() {
+ Datum x;
+ Datum y;
+ Datum z;
+
+ x = DatumFactory.createInt4(6);
+ y = DatumFactory.createInt4(3);
+ z = x.equalsTo(y);
+ assertEquals(z.type(),Type.BOOLEAN);
+ assertEquals(z.asBool(),false);
+ z = y.equalsTo(x);
+ assertEquals(z.type(),Type.BOOLEAN);
+ assertEquals(z.asBool(), false);
+
+ x = DatumFactory.createFloat4(3.27f);
+ y = DatumFactory.createFloat4(3.27f);
+ z = x.equalsTo(y);
+ assertEquals(z.type(),Type.BOOLEAN);
+ assertEquals(z.asBool(),true);
+ z = y.equalsTo(x);
+ assertEquals(z.type(),Type.BOOLEAN);
+ assertEquals(z.asBool(), true);
+
+ x = DatumFactory.createInt8(123456789012345l);
+ y = DatumFactory.createInt8(123456789012345l);
+ z = x.equalsTo(y);
+ assertEquals(z.type(),Type.BOOLEAN);
+ assertEquals(z.asBool(),true);
+ z = y.equalsTo(x);
+ assertEquals(z.type(),Type.BOOLEAN);
+ assertEquals(z.asBool(), true);
+ }
+
+ @Test
+ public final void testLessThanDatum() {
+ Datum x;
+ Datum y;
+ Datum z;
+
+ x = DatumFactory.createInt4(6);
+ y = DatumFactory.createInt4(3);
+ z = x.lessThan(y);
+ assertEquals(z.type(),Type.BOOLEAN);
+ assertEquals(z.asBool(),false);
+ z = y.lessThan(x);
+ assertEquals(z.type(),Type.BOOLEAN);
+ assertEquals(z.asBool(), true);
+ }
+
+ @Test
+ public final void testLessThanEqualsDatum() {
+ Datum x;
+ Datum y;
+ Datum z;
+
+ x = DatumFactory.createInt4(6);
+ y = DatumFactory.createInt4(3);
+ z = x.lessThanEqual(y);
+ assertEquals(z.type(),Type.BOOLEAN);
+ assertEquals(z.asBool(),false);
+ z = y.lessThanEqual(x);
+ assertEquals(z.type(),Type.BOOLEAN);
+ assertEquals(z.asBool(), true);
+
+ x = DatumFactory.createInt4(6);
+ y = DatumFactory.createInt4(6);
+ z = x.lessThanEqual(y);
+ assertEquals(z.type(),Type.BOOLEAN);
+ assertEquals(z.asBool(),true);
+ z = y.lessThanEqual(x);
+ assertEquals(z.type(),Type.BOOLEAN);
+ assertEquals(z.asBool(), true);
+ }
+
+ @Test
+ public final void testgreaterThanDatum() {
+ Datum x;
+ Datum y;
+ Datum z;
+
+ x = DatumFactory.createInt4(6);
+ y = DatumFactory.createInt4(3);
+ z = x.greaterThan(y);
+ assertEquals(z.type(),Type.BOOLEAN);
+ assertEquals(z.asBool(),true);
+ z = y.greaterThan(x);
+ assertEquals(z.type(),Type.BOOLEAN);
+ assertEquals(z.asBool(), false);
+
+ x = DatumFactory.createInt4(6);
+ y = DatumFactory.createInt4(6);
+ z = x.greaterThan(y);
+ assertEquals(z.type(),Type.BOOLEAN);
+ assertEquals(z.asBool(),false);
+ z = y.greaterThan(x);
+ assertEquals(z.type(),Type.BOOLEAN);
+ assertEquals(z.asBool(), false);
+ }
+
+ @Test
+ public final void testgreaterThanEqualsDatum() {
+ Datum x;
+ Datum y;
+ Datum z;
+
+ x = DatumFactory.createInt4(6);
+ y = DatumFactory.createInt4(3);
+ z = x.greaterThanEqual(y);
+ assertEquals(z.type(),Type.BOOLEAN);
+ assertEquals(z.asBool(),true);
+ z = y.greaterThanEqual(x);
+ assertEquals(z.type(),Type.BOOLEAN);
+ assertEquals(z.asBool(), false);
+
+ x = DatumFactory.createInt4(6);
+ y = DatumFactory.createInt4(6);
+ z = x.greaterThanEqual(y);
+ assertEquals(z.type(),Type.BOOLEAN);
+ assertEquals(z.asBool(),true);
+ z = y.greaterThanEqual(x);
+ assertEquals(z.type(),Type.BOOLEAN);
+ assertEquals(z.asBool(), true);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-common/src/test/java/org/apache/tajo/datum/TestDatumFactory.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/org/apache/tajo/datum/TestDatumFactory.java b/tajo-common/src/test/java/org/apache/tajo/datum/TestDatumFactory.java
new file mode 100644
index 0000000..ffb3a30
--- /dev/null
+++ b/tajo-common/src/test/java/org/apache/tajo/datum/TestDatumFactory.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.tajo.datum;
+
+import org.junit.Test;
+import org.apache.tajo.common.TajoDataTypes.Type;
+
+import static org.junit.Assert.assertEquals;
+
+public class TestDatumFactory {
+
+ @Test
+ public final void testCreateBit() {
+ Datum d = DatumFactory.createBit((byte) 5);
+ assertEquals(Type.BIT, d.type());
+ }
+
+ @Test
+ public final void testCreateInt2() {
+ Datum d = DatumFactory.createInt2((short) 5);
+ assertEquals(Type.INT2, d.type());
+ }
+
+ @Test
+ public final void testCreateInt4() {
+ Datum d = DatumFactory.createInt4(5);
+ assertEquals(Type.INT4, d.type());
+ }
+
+ @Test
+ public final void testCreateInt8() {
+ Datum d = DatumFactory.createInt8((long) 5);
+ assertEquals(Type.INT8, d.type());
+ }
+
+ @Test
+ public final void testCreateFloat4() {
+ Datum d = DatumFactory.createFloat4(5.0f);
+ assertEquals(Type.FLOAT4, d.type());
+ }
+
+ @Test
+ public final void testCreateFloat8() {
+ Datum d = DatumFactory.createFloat8(5.0d);
+ assertEquals(Type.FLOAT8, d.type());
+ }
+
+ @Test
+ public final void testCreateBoolean() {
+ Datum d = DatumFactory.createBool(true);
+ assertEquals(Type.BOOLEAN, d.type());
+ }
+
+ @Test
+ public final void testCreateString() {
+ Datum d = DatumFactory.createText("12345a");
+ assertEquals(Type.TEXT, d.type());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-common/src/test/java/org/apache/tajo/datum/TestFloat8Datum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/org/apache/tajo/datum/TestFloat8Datum.java b/tajo-common/src/test/java/org/apache/tajo/datum/TestFloat8Datum.java
new file mode 100644
index 0000000..1aed558
--- /dev/null
+++ b/tajo-common/src/test/java/org/apache/tajo/datum/TestFloat8Datum.java
@@ -0,0 +1,70 @@
+/**
+ * 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.tajo.datum;
+
+import org.junit.Test;
+import org.apache.tajo.common.TajoDataTypes.Type;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class TestFloat8Datum {
+
+ @Test
+ public final void testType() {
+ Datum d = DatumFactory.createFloat8(1d);
+ assertEquals(Type.FLOAT8, d.type());
+ }
+
+ @Test
+ public final void testAsInt4() {
+ Datum d = DatumFactory.createFloat8(5d);
+ assertEquals(5,d.asInt4());
+ }
+
+ @Test
+ public final void testAsInt8() {
+ Datum d = DatumFactory.createFloat8(5d);
+ assertEquals(5l,d.asInt8());
+ }
+
+ @Test
+ public final void testAsFloat4() {
+ Datum d = DatumFactory.createFloat8(5d);
+ assertTrue(5.0f == d.asFloat4());
+ }
+
+ @Test
+ public final void testAsFloat8() {
+ Datum d = DatumFactory.createFloat8(5d);
+ assertTrue(5.0d == d.asFloat8());
+ }
+
+ @Test
+ public final void testAsText() {
+ Datum d = DatumFactory.createFloat8(5d);
+ assertEquals("5.0", d.asChars());
+ }
+
+ @Test
+ public final void testSize() {
+ Datum d = DatumFactory.createFloat8(5d);
+ assertEquals(8, d.size());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-common/src/test/java/org/apache/tajo/datum/TestFloatDatum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/org/apache/tajo/datum/TestFloatDatum.java b/tajo-common/src/test/java/org/apache/tajo/datum/TestFloatDatum.java
new file mode 100644
index 0000000..185ba55
--- /dev/null
+++ b/tajo-common/src/test/java/org/apache/tajo/datum/TestFloatDatum.java
@@ -0,0 +1,70 @@
+/**
+ * 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.tajo.datum;
+
+import org.junit.Test;
+import org.apache.tajo.common.TajoDataTypes.Type;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class TestFloatDatum {
+
+ @Test
+ public final void testType() {
+ Datum d = DatumFactory.createFloat4(1f);
+ assertEquals(Type.FLOAT4, d.type());
+ }
+
+ @Test
+ public final void testAsInt() {
+ Datum d = DatumFactory.createFloat4(5f);
+ assertEquals(5,d.asInt4());
+ }
+
+ @Test
+ public final void testAsLong() {
+ Datum d = DatumFactory.createFloat4(5f);
+ assertEquals(5l,d.asInt8());
+ }
+
+ @Test
+ public final void testAsFloat() {
+ Datum d = DatumFactory.createFloat4(5f);
+ assertTrue(5.0f == d.asFloat4());
+ }
+
+ @Test
+ public final void testAsDouble() {
+ Datum d = DatumFactory.createFloat4(5f);
+ assertTrue(5.0d == d.asFloat8());
+ }
+
+ @Test
+ public final void testAsChars() {
+ Datum d = DatumFactory.createFloat4(5f);
+ assertEquals("5.0", d.asChars());
+ }
+
+ @Test
+ public final void testSize() {
+ Datum d = DatumFactory.createFloat4(5f);
+ assertEquals(4, d.size());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-common/src/test/java/org/apache/tajo/datum/TestInet4Datum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/org/apache/tajo/datum/TestInet4Datum.java b/tajo-common/src/test/java/org/apache/tajo/datum/TestInet4Datum.java
new file mode 100644
index 0000000..77b3363
--- /dev/null
+++ b/tajo-common/src/test/java/org/apache/tajo/datum/TestInet4Datum.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.tajo.datum;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.apache.tajo.datum.json.GsonCreator;
+
+import java.util.Arrays;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class TestInet4Datum {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @Test
+ public final void testEquals() {
+ Inet4Datum ip1 = new Inet4Datum("192.168.0.1");
+ Inet4Datum ip2 = new Inet4Datum("192.168.0.1");
+
+ assertEquals(ip1, ip2);
+
+ Inet4Datum ip3 = new Inet4Datum(ip1.asByteArray());
+ assertEquals(ip1, ip3);
+ Inet4Datum ip4 = DatumFactory.createInet4(ip1.asByteArray());
+ assertEquals(ip1, ip4);
+ }
+
+ @Test
+ public final void testAsByteArray() {
+ byte[] bytes = {(byte) 0xA3, (byte) 0x98, 0x17, (byte) 0xDE};
+ Inet4Datum ip = new Inet4Datum(bytes);
+ assertTrue(Arrays.equals(bytes, ip.asByteArray()));
+ }
+
+ @Test
+ public final void testAsChars() {
+ Inet4Datum ip = new Inet4Datum("163.152.23.222");
+ assertEquals("163.152.23.222", ip.asChars());
+ }
+
+ @Test
+ public final void testSize() {
+ Datum d = DatumFactory.createInet4("163.152.23.222");
+ assertEquals(4, d.size());
+ }
+
+ @Test
+ public final void testJson() {
+ Datum d = DatumFactory.createInet4("163.152.163.152");
+ String json = d.toJSON();
+ Datum fromJson = GsonCreator.getInstance().fromJson(json, Datum.class);
+ assertTrue(d.equalsTo(fromJson).asBool());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-common/src/test/java/org/apache/tajo/datum/TestInt2Datum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/org/apache/tajo/datum/TestInt2Datum.java b/tajo-common/src/test/java/org/apache/tajo/datum/TestInt2Datum.java
new file mode 100644
index 0000000..8a04a91
--- /dev/null
+++ b/tajo-common/src/test/java/org/apache/tajo/datum/TestInt2Datum.java
@@ -0,0 +1,70 @@
+/**
+ * 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.tajo.datum;
+
+import org.junit.Test;
+import org.apache.tajo.common.TajoDataTypes.Type;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class TestInt2Datum {
+
+ @Test
+ public final void testType() {
+ Datum d = DatumFactory.createInt2((short) 1);
+ assertEquals(d.type(), Type.INT2);
+ }
+
+ @Test
+ public final void testAsInt4() {
+ Datum d = DatumFactory.createInt2((short) 5);
+ assertEquals(5,d.asInt4());
+ }
+
+ @Test
+ public final void testAsInt8() {
+ Datum d = DatumFactory.createInt2((short) 5);
+ assertEquals(5,d.asInt8());
+ }
+
+ @Test
+ public final void testAsFloat4() {
+ Datum d = DatumFactory.createInt2((short) 5);
+ assertTrue(5.0f == d.asFloat4());
+ }
+
+ @Test
+ public final void testAsFloat8() {
+ Datum d = DatumFactory.createInt2((short) 5);
+ assertTrue(5.0d == d.asFloat8());
+ }
+
+ @Test
+ public final void testAsText() {
+ Datum d = DatumFactory.createInt2((short) 5);
+ assertEquals("5", d.asChars());
+ }
+
+ @Test
+ public final void testSize() {
+ Datum d = DatumFactory.createInt2((short) 5);
+ assertEquals(2, d.size());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-common/src/test/java/org/apache/tajo/datum/TestInt4Datum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/org/apache/tajo/datum/TestInt4Datum.java b/tajo-common/src/test/java/org/apache/tajo/datum/TestInt4Datum.java
new file mode 100644
index 0000000..223fdd9
--- /dev/null
+++ b/tajo-common/src/test/java/org/apache/tajo/datum/TestInt4Datum.java
@@ -0,0 +1,70 @@
+/**
+ * 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.tajo.datum;
+
+import org.junit.Test;
+import org.apache.tajo.common.TajoDataTypes;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class TestInt4Datum {
+
+ @Test
+ public final void testType() {
+ Datum d = DatumFactory.createInt4(1);
+ assertEquals(TajoDataTypes.Type.INT4, d.type());
+ }
+
+ @Test
+ public final void testAsInt() {
+ Datum d = DatumFactory.createInt4(5);
+ assertEquals(5, d.asInt4());
+ }
+
+ @Test
+ public final void testAsLong() {
+ Datum d = DatumFactory.createInt4(5);
+ assertEquals(5, d.asInt8());
+ }
+
+ @Test
+ public final void testAsFloat() {
+ Datum d = DatumFactory.createInt4(5);
+ assertTrue(5.0f == d.asFloat4());
+ }
+
+ @Test
+ public final void testAsDouble() {
+ Datum d = DatumFactory.createInt4(5);
+ assertTrue(5.0d == d.asFloat8());
+ }
+
+ @Test
+ public final void testAsChars() {
+ Datum d = DatumFactory.createInt4(5);
+ assertEquals("5", d.asChars());
+ }
+
+ @Test
+ public final void testSize() {
+ Datum d = DatumFactory.createInt4(5);
+ assertEquals(4, d.size());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-common/src/test/java/org/apache/tajo/datum/TestInt8Datum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/org/apache/tajo/datum/TestInt8Datum.java b/tajo-common/src/test/java/org/apache/tajo/datum/TestInt8Datum.java
new file mode 100644
index 0000000..a8e6acf
--- /dev/null
+++ b/tajo-common/src/test/java/org/apache/tajo/datum/TestInt8Datum.java
@@ -0,0 +1,70 @@
+/**
+ * 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.tajo.datum;
+
+import org.junit.Test;
+import org.apache.tajo.common.TajoDataTypes.Type;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class TestInt8Datum {
+
+ @Test
+ public final void testType() {
+ Datum d = DatumFactory.createInt8(1l);
+ assertEquals(d.type(), Type.INT8);
+ }
+
+ @Test
+ public final void testAsInt() {
+ Datum d = DatumFactory.createInt8(5l);
+ assertEquals(5,d.asInt4());
+ }
+
+ @Test
+ public final void testAsLong() {
+ Datum d = DatumFactory.createInt8(5l);
+ assertEquals(5l,d.asInt8());
+ }
+
+ @Test
+ public final void testAsFloat() {
+ Datum d = DatumFactory.createInt8(5l);
+ assertTrue(5.0f == d.asFloat4());
+ }
+
+ @Test
+ public final void testAsDouble() {
+ Datum d = DatumFactory.createInt8(5l);
+ assertTrue(5.0d == d.asFloat8());
+ }
+
+ @Test
+ public final void testAsChars() {
+ Datum d = DatumFactory.createInt8(5l);
+ assertEquals("5", d.asChars());
+ }
+
+ @Test
+ public final void testSize() {
+ Datum d = DatumFactory.createInt8(5l);
+ assertEquals(8, d.size());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-common/src/test/java/org/apache/tajo/datum/TestTextDatum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/org/apache/tajo/datum/TestTextDatum.java b/tajo-common/src/test/java/org/apache/tajo/datum/TestTextDatum.java
new file mode 100644
index 0000000..07ce3ad
--- /dev/null
+++ b/tajo-common/src/test/java/org/apache/tajo/datum/TestTextDatum.java
@@ -0,0 +1,70 @@
+/**
+ * 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.tajo.datum;
+
+import org.junit.Test;
+import org.apache.tajo.common.TajoDataTypes.Type;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class TestTextDatum {
+
+ @Test
+ public final void testType() {
+ Datum d = DatumFactory.createText("12345");
+ assertEquals(d.type(), Type.TEXT);
+ }
+
+ @Test
+ public final void testAsInt4() {
+ Datum d = DatumFactory.createText("12345");
+ assertEquals(12345,d.asInt4());
+ }
+
+ @Test
+ public final void testAsInt8() {
+ Datum d = DatumFactory.createText("12345");
+ assertEquals(12345l,d.asInt8());
+ }
+
+ @Test
+ public final void testAsFloat4() {
+ Datum d = DatumFactory.createText("12345");
+ assertTrue(12345.0f == d.asFloat4());
+ }
+
+ @Test
+ public final void testAsFloat8() {
+ Datum d = DatumFactory.createText("12345");
+ assertTrue(12345.0d == d.asFloat8());
+ }
+
+ @Test
+ public final void testAsText() {
+ Datum d = DatumFactory.createText("12345");
+ assertEquals("12345", d.asChars());
+ }
+
+ @Test
+ public final void testSize() {
+ Datum d = DatumFactory.createText("12345");
+ assertEquals(5, d.size());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-common/src/test/java/org/apache/tajo/util/TestBitArrayTest.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/org/apache/tajo/util/TestBitArrayTest.java b/tajo-common/src/test/java/org/apache/tajo/util/TestBitArrayTest.java
new file mode 100644
index 0000000..9c82c8e
--- /dev/null
+++ b/tajo-common/src/test/java/org/apache/tajo/util/TestBitArrayTest.java
@@ -0,0 +1,39 @@
+/**
+ * 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.tajo.util;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class TestBitArrayTest {
+
+ @Test
+ public void test() {
+ int num = 80;
+ BitArray bitArray = new BitArray(num);
+
+ for (int i = 0; i < num; i++) {
+ assertFalse(bitArray.get(i));
+ bitArray.set(i);
+ assertTrue(bitArray.get(i));
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-common/src/test/java/org/apache/tajo/util/TestFileUtils.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/org/apache/tajo/util/TestFileUtils.java b/tajo-common/src/test/java/org/apache/tajo/util/TestFileUtils.java
new file mode 100644
index 0000000..1e7d3c3
--- /dev/null
+++ b/tajo-common/src/test/java/org/apache/tajo/util/TestFileUtils.java
@@ -0,0 +1,107 @@
+/**
+ * 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.tajo.util;
+
+import com.google.protobuf.Message;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.apache.tajo.util.TestProtos.TestMessageProto;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import static org.junit.Assert.assertEquals;
+
+public class TestFileUtils {
+ private static final String TEST_PATH = "target/test-data/TestFileUTils";
+ TestMessageProto proto = null;
+
+ @Before
+ public void setUp() throws Exception {
+ TestMessageProto.Builder builder = TestMessageProto.newBuilder();
+ builder.setName("TestFileUtils");
+ builder.setAge(30);
+ builder.setAddr(TestFileUtils.class.getName());
+
+ proto = builder.build();
+
+ File testDir = new File(TEST_PATH);
+ if(testDir.exists()) {
+ testDir.delete();
+ }
+ testDir.mkdirs();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ File testDir = new File(TEST_PATH);
+ if(testDir.exists()) {
+ testDir.delete();
+ }
+ }
+
+ @Test
+ public final void testWriteLoadProtoFromFile() throws IOException {
+ File file = new File(TEST_PATH+"/file.bin");
+ file.createNewFile();
+ FileUtil.writeProto(file, proto);
+
+ Message defaultInstance = TestMessageProto.getDefaultInstance();
+ TestMessageProto message = (TestMessageProto)
+ FileUtil.loadProto(new File(TEST_PATH+"/file.bin"), defaultInstance);
+
+ assertEquals(proto, message);
+ }
+
+ @Test
+ public final void testWriteLoadProtoFromStream() throws IOException {
+ FileOutputStream out = new FileOutputStream(new File(TEST_PATH+"/file.bin"));
+ FileUtil.writeProto(out, proto);
+
+
+ FileInputStream in = new FileInputStream(new File(TEST_PATH+"/file.bin"));
+ Message defaultInstance = TestMessageProto.getDefaultInstance();
+ TestMessageProto message = (TestMessageProto)
+ FileUtil.loadProto(in, defaultInstance);
+
+ assertEquals(proto, message);
+ }
+
+ @Test
+ public final void testWriteLoadProtoFromPath() throws IOException {
+ Path path = new Path(TEST_PATH+"/file.bin");
+ Configuration conf = new Configuration();
+ FileSystem localFS = FileSystem.getLocal(conf);
+ FileUtil.writeProto(localFS, path, proto);
+
+ Message defaultInstance = TestMessageProto.getDefaultInstance();
+ TestMessageProto message = (TestMessageProto)
+ FileUtil.loadProto(localFS, new Path(TEST_PATH+"/file.bin"),
+ defaultInstance);
+
+ assertEquals(proto, message);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-common/src/test/java/tajo/common/type/TestIPv4.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/tajo/common/type/TestIPv4.java b/tajo-common/src/test/java/tajo/common/type/TestIPv4.java
deleted file mode 100644
index 8d4bf68..0000000
--- a/tajo-common/src/test/java/tajo/common/type/TestIPv4.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/**
- * 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 tajo.common.type;
-
-import org.junit.Test;
-import tajo.common.exception.InvalidAddressException;
-
-import static org.junit.Assert.*;
-
-public class TestIPv4 {
-
- @Test
- public final void testSet() {
- IPv4 ip = null;
- try {
- ip = new IPv4("255.255.255.255");
- } catch (InvalidAddressException e) {
- System.out.println("InvalidAddressException is catched");
- }
- byte[] b = new byte[4];
- for (int i = 0; i < 4; i++) {
- b[i] = (byte)0xFF;
- }
- IPv4 ip2 = new IPv4(b);
- assertEquals(ip, ip2);
- }
-
- @Test
- public final void testEqual() throws InvalidAddressException {
- IPv4 ip1 = new IPv4("163.152.23.1");
- IPv4 ip2 = new IPv4("163.152.23.2");
- IPv4 ip3 = new IPv4("163.152.23.1");
- assertTrue(ip1.equals(ip3));
- assertFalse(ip1.equals(ip2));
- IPv4 ip4 = new IPv4("255.255.0.0");
- assertFalse(ip1.equals(ip4));
- }
-
- @Test
- public final void testAnd() throws InvalidAddressException {
- IPv4 ip1 = new IPv4("163.152.23.223");
- IPv4 ip2 = new IPv4("255.255.255.0");
- IPv4 ip3 = new IPv4("255.0.0.0");
- assertEquals(new IPv4("163.152.23.0"), ip1.and(ip2));
- assertFalse(ip1.and(ip2).equals(new IPv4("163.152.0.0")));
- assertTrue(ip1.and(ip3).equals(new IPv4("163.0.0.0")));
- }
-
- @Test
- public final void testMatchSubnet() throws InvalidAddressException {
- IPv4 ip1 = new IPv4("163.152.23.223");
- assertTrue(ip1.matchSubnet("163.152.23.0/1"));
- assertFalse(ip1.matchSubnet("163.152.23.0/28"));
- }
-
- @Test
- public final void testCompareTo() throws InvalidAddressException {
- IPv4 ip1 = new IPv4("163.152.23.1");
- IPv4 ip2 = new IPv4("163.152.23.2");
- IPv4 ip3 = new IPv4("177.234.123.12");
- IPv4 ip4 = new IPv4("177.234.123.12");
- assertTrue(ip1.compareTo(ip2) == -1);
- assertTrue(ip2.compareTo(ip1) == 1);
- assertTrue(ip3.compareTo(ip1) == 1);
- assertFalse(ip3.compareTo(ip2) != 1);
- assertTrue(ip4.compareTo(ip3) == 0);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-common/src/test/java/tajo/common/type/TestTimeRange.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/tajo/common/type/TestTimeRange.java b/tajo-common/src/test/java/tajo/common/type/TestTimeRange.java
deleted file mode 100644
index be74f4a..0000000
--- a/tajo-common/src/test/java/tajo/common/type/TestTimeRange.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * 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 tajo.common.type;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-public class TestTimeRange {
- TimeRange test1;
- TimeRange test2;
-
- @Before
- public void testSet() {
- test1 = new TimeRange(1321421413036l, 1321421442057l);
- test2 = new TimeRange(1321421580408l, 1321421592193l);
- }
-
- @Test
- public void testGet() {
- assertEquals(test1.getBegin(), 1321421413036l);
- assertEquals(test2.getEnd(), 1321421592193l);
- }
-
- @Test
- public void testCompare() {
- assertEquals(test2.compareTo(test1), 1321421580408l-1321421413036l);
- }
-
- @Test
- public void testEquals() {
- assertTrue(test1.equals(test1));
- assertFalse(test1.equals(100));
- }
-
-// @Test
-// public void testToString() {
-// assertEquals(test1.toString(), "(1321421413036l, 1321421442057l)");
-// }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-common/src/test/java/tajo/datum/TestBitDatum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/tajo/datum/TestBitDatum.java b/tajo-common/src/test/java/tajo/datum/TestBitDatum.java
deleted file mode 100644
index 9225a0d..0000000
--- a/tajo-common/src/test/java/tajo/datum/TestBitDatum.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * 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 tajo.datum;
-
-import org.junit.Test;
-import tajo.common.TajoDataTypes.Type;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-public class TestBitDatum {
-
- @Test
- public final void testType() {
- Datum d = DatumFactory.createBit((byte) 1);
- assertEquals(Type.BIT, d.type());
- }
-
- @Test
- public final void testAsInt() {
- Datum d = DatumFactory.createBit((byte) 5);
- assertEquals(5,d.asInt4());
- }
-
- @Test
- public final void testAsLong() {
- Datum d = DatumFactory.createBit((byte) 5);
- assertEquals(5l,d.asInt8());
- }
-
- @Test
- public final void testAsByte() {
- Datum d = DatumFactory.createBit((byte) 5);
- assertEquals(5,d.asInt8());
- }
-
- @Test
- public final void testAsFloat() {
- Datum d = DatumFactory.createBit((byte) 5);
- assertTrue(5.0f == d.asFloat4());
- }
-
- @Test
- public final void testAsDouble() {
- Datum d = DatumFactory.createBit((byte) 5);
- assertTrue(5.0d == d.asFloat8());
- }
-
- @Test
- public final void testAsChars() {
- Datum d = DatumFactory.createBit((byte) 5);
- System.out.println(d.asChars());
- }
-
- @Test
- public final void testSize() {
- Datum d = DatumFactory.createBit((byte) 1);
- assertEquals(1, d.size());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-common/src/test/java/tajo/datum/TestBoolDatum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/tajo/datum/TestBoolDatum.java b/tajo-common/src/test/java/tajo/datum/TestBoolDatum.java
deleted file mode 100644
index f7cfaaf..0000000
--- a/tajo-common/src/test/java/tajo/datum/TestBoolDatum.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * 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 tajo.datum;
-
-import org.junit.Test;
-import tajo.common.TajoDataTypes.Type;
-
-import static org.junit.Assert.assertEquals;
-
-public class TestBoolDatum {
-
- @Test
- public final void testType() {
- Datum d = DatumFactory.createBool(true);
- assertEquals(Type.BOOLEAN, d.type());
- }
-
- @Test
- public final void testAsBool() {
- Datum d = DatumFactory.createBool(false);
- assertEquals(false, d.asBool());
- }
-
- @Test
- public final void testAsShort() {
- Datum d = DatumFactory.createBool(true);
- assertEquals(1, d.asInt2());
- }
-
- @Test
- public final void testAsInt() {
- Datum d = DatumFactory.createBool(true);
- assertEquals(1, d.asInt4());
- }
-
- @Test
- public final void testAsLong() {
- Datum d = DatumFactory.createBool(false);
- assertEquals(0, d.asInt8());
- }
-
- @Test
- public final void testAsByte() {
- Datum d = DatumFactory.createBool(true);
- assertEquals(0x01, d.asByte());
- }
-
- @Test
- public final void testAsChars() {
- Datum d = DatumFactory.createBool(true);
- assertEquals("true", d.asChars());
- }
-
- @Test
- public final void testSize() {
- Datum d = DatumFactory.createBool(true);
- assertEquals(1, d.size());
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-common/src/test/java/tajo/datum/TestBytesDatum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/tajo/datum/TestBytesDatum.java b/tajo-common/src/test/java/tajo/datum/TestBytesDatum.java
deleted file mode 100644
index b718f23..0000000
--- a/tajo-common/src/test/java/tajo/datum/TestBytesDatum.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * 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 tajo.datum;
-
-import org.junit.Test;
-import tajo.common.TajoDataTypes.Type;
-import tajo.datum.json.GsonCreator;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-public class TestBytesDatum {
-
- @Test
- public final void testType() {
- Datum d = DatumFactory.createBlob("12345".getBytes());
- assertEquals(Type.BLOB, d.type());
- }
-
- @Test
- public final void testAsChars() {
- Datum d = DatumFactory.createBlob("12345".getBytes());
- assertEquals("12345", d.asChars());
- }
-
- @Test
- public final void testSize() {
- Datum d = DatumFactory.createBlob("12345".getBytes());
- assertEquals(5, d.size());
- }
-
- @Test
- public final void testJson() {
- Datum d = DatumFactory.createBlob("12345".getBytes());
- String json = d.toJSON();
- Datum fromJson = GsonCreator.getInstance().fromJson(json, Datum.class);
- assertTrue(d.equalsTo(fromJson).asBool());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-common/src/test/java/tajo/datum/TestCharDatum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/tajo/datum/TestCharDatum.java b/tajo-common/src/test/java/tajo/datum/TestCharDatum.java
deleted file mode 100644
index c193142..0000000
--- a/tajo-common/src/test/java/tajo/datum/TestCharDatum.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- * 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 tajo.datum;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static tajo.common.TajoDataTypes.Type;
-
-public class TestCharDatum {
-
- @Test
- public final void testType() {
- Datum d = DatumFactory.createChar((char) 1);
- assertEquals(Type.CHAR, d.type());
- }
-
- @Test
- public final void testAsInt() {
- Datum d = DatumFactory.createChar((char)5);
- assertEquals(5,d.asInt4());
- }
-
- @Test
- public final void testAsLong() {
- Datum d = DatumFactory.createChar((char)5);
- assertEquals(5l,d.asInt8());
- }
-
- @Test
- public final void testAsByte() {
- Datum d = DatumFactory.createChar((char)5);
- assertEquals(5,d.asInt8());
- }
-
- @Test
- public final void testAsFloat() {
- Datum d = DatumFactory.createChar((char)5);
- assertTrue(5.0f == d.asFloat4());
- }
-
- @Test
- public final void testAsDouble() {
- Datum d = DatumFactory.createChar((char)5);
- assertTrue(5.0d == d.asFloat8());
- }
-
- @Test
- public final void testAsChars() {
- Datum d = DatumFactory.createChar((char)5);
- System.out.println(d.asChars());
- }
-
- @Test
- public final void testSize() {
- Datum d = DatumFactory.createChar((char) 1);
- assertEquals(1, d.size());
- }
-
- @Test
- public final void testCompare() {
- Datum a = DatumFactory.createChar('a');
- Datum b = DatumFactory.createChar('b');
- Datum c = DatumFactory.createChar('c');
-
- assertTrue(a.compareTo(b) < 0);
- assertTrue(b.compareTo(a) > 0);
- assertTrue(c.compareTo(c) == 0);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-common/src/test/java/tajo/datum/TestDatum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/tajo/datum/TestDatum.java b/tajo-common/src/test/java/tajo/datum/TestDatum.java
deleted file mode 100644
index 73776e8..0000000
--- a/tajo-common/src/test/java/tajo/datum/TestDatum.java
+++ /dev/null
@@ -1,314 +0,0 @@
-/**
- * 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 tajo.datum;
-
-import org.junit.Test;
-import tajo.common.TajoDataTypes.Type;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-public class TestDatum {
-
- @Test
- public final void testPlusDatumDatum() {
- Datum x;
- Datum y;
- Datum z;
-
- x = DatumFactory.createInt4(1);
- y = DatumFactory.createInt4(2);
- z = x.plus(y);
- assertEquals(z.type(), Type.INT4);
- assertEquals(z.asInt4(),3);
- z = y.plus(x);
- assertEquals(z.type(),Type.INT4);
- assertEquals(z.asInt4(),3);
-
- x = DatumFactory.createInt4(1);
- y = DatumFactory.createInt8(2l);
- z = x.plus(y);
- assertEquals(z.type(),Type.INT8);
- assertEquals(z.asInt8(),3l);
- z = y.plus(x);
- assertEquals(z.type(),Type.INT8);
- assertEquals(z.asInt8(),3l);
-
- y = DatumFactory.createFloat4(2.5f);
- z = x.plus(y);
- assertEquals(z.type(),Type.FLOAT4);
- assertTrue(z.asFloat4() == 3.5f);
- z = y.plus(x);
- assertEquals(z.type(),Type.FLOAT4);
- assertEquals(z.asInt4(),3);
-
- y = DatumFactory.createFloat8(4.5d);
- z = x.plus(y);
- assertEquals(z.type(),Type.FLOAT8);
- assertTrue(z.asFloat8() == 5.5d);
- z = y.plus(x);
- assertEquals(z.type(),Type.FLOAT8);
- assertTrue(z.asFloat8() == 5.5d);
- }
-
- @Test
- public final void testMinusDatumDatum() {
- Datum x;
- Datum y;
- Datum z;
-
- x = DatumFactory.createInt4(5);
- y = DatumFactory.createInt4(2);
- z = x.minus(y);
- assertEquals(z.type(),Type.INT4);
- assertEquals(z.asInt4(),3);
- z = y.minus(x);
- assertEquals(z.type(),Type.INT4);
- assertEquals(z.asInt4(),-3);
-
- y = DatumFactory.createInt8(2l);
- z = x.minus(y);
- assertEquals(z.type(),Type.INT8);
- assertEquals(z.asInt8(),3l);
- z = y.minus(x);
- assertEquals(z.type(),Type.INT8);
- assertEquals(z.asInt8(),-3l);
-
- y = DatumFactory.createFloat4(2.5f);
- z = x.minus(y);
- assertEquals(z.type(),Type.FLOAT4);
- assertTrue(z.asFloat4() == 2.5f);
- z = y.minus(x);
- assertEquals(z.type(),Type.FLOAT4);
- assertTrue(z.asFloat4() == -2.5f);
-
- y = DatumFactory.createFloat8(4.5d);
- z = x.minus(y);
- assertEquals(z.type(),Type.FLOAT8);
- assertTrue(z.asFloat8() == 0.5d);
- z = y.minus(x);
- assertEquals(z.type(),Type.FLOAT8);
- assertTrue(z.asFloat8() == -0.5d);
- }
-
- @Test
- public final void testMultiplyDatumDatum() {
- Datum x;
- Datum y;
- Datum z;
-
- x = DatumFactory.createInt4(5);
- y = DatumFactory.createInt4(2);
- z = x.multiply(y);
- assertEquals(z.type(),Type.INT4);
- assertEquals(z.asInt4(),10);
- z = y.multiply(x);
- assertEquals(z.type(),Type.INT4);
- assertEquals(z.asInt4(),10);
-
- y = DatumFactory.createInt8(2l);
- z = x.multiply(y);
- assertEquals(z.type(),Type.INT8);
- assertEquals(z.asInt8(),10l);
- z = y.multiply(x);
- assertEquals(z.type(),Type.INT8);
- assertEquals(z.asInt8(),10l);
-
- y = DatumFactory.createFloat4(2.5f);
- z = x.multiply(y);
- assertEquals(z.type(),Type.FLOAT4);
- assertTrue(z.asFloat4() == 12.5f);
- z = y.multiply(x);
- assertEquals(z.type(),Type.FLOAT4);
- assertTrue(z.asFloat4() == 12.5f);
-
- y = DatumFactory.createFloat8(4.5d);
- z = x.multiply(y);
- assertEquals(z.type(),Type.FLOAT8);
- assertTrue(z.asFloat8() == 22.5d);
- z = y.multiply(x);
- assertEquals(z.type(),Type.FLOAT8);
- assertTrue(z.asFloat8() == 22.5d);
- }
-
- @Test
- public final void testDivideDatumDatum() {
- Datum x;
- Datum y;
- Datum z;
-
- x = DatumFactory.createInt4(6);
- y = DatumFactory.createInt4(3);
- z = x.divide(y);
- assertEquals(z.type(), Type.INT4);
- assertEquals(z.asInt4(),2);
- z = y.divide(x);
- assertEquals(z.type(),Type.INT4);
- assertTrue(z.asInt4() == 0);
-
- y = DatumFactory.createInt8(3l);
- z = x.divide(y);
- assertEquals(z.type(),Type.INT8);
- assertEquals(z.asInt8(),2l);
- z = y.divide(x);
- assertEquals(z.type(),Type.INT8);
- assertEquals(z.asInt8(),0l);
-
- y = DatumFactory.createFloat4(3f);
- z = x.divide(y);
- assertEquals(z.type(),Type.FLOAT4);
- assertTrue(z.asFloat4() == 2.0f);
- z = y.divide(x);
- assertEquals(z.type(),Type.FLOAT4);
- assertTrue(z.asFloat4() == 0.5f);
-
- y = DatumFactory.createFloat8(3d);
- z = x.divide(y);
- assertEquals(z.type(),Type.FLOAT8);
- assertTrue(z.asFloat8() == 2.0d);
- z = y.divide(x);
- assertEquals(z.type(),Type.FLOAT8);
- assertTrue(z.asFloat8() == 0.5d);
- }
-
- @Test
- public final void testEqualToDatum() {
- Datum x;
- Datum y;
- Datum z;
-
- x = DatumFactory.createInt4(6);
- y = DatumFactory.createInt4(3);
- z = x.equalsTo(y);
- assertEquals(z.type(),Type.BOOLEAN);
- assertEquals(z.asBool(),false);
- z = y.equalsTo(x);
- assertEquals(z.type(),Type.BOOLEAN);
- assertEquals(z.asBool(), false);
-
- x = DatumFactory.createFloat4(3.27f);
- y = DatumFactory.createFloat4(3.27f);
- z = x.equalsTo(y);
- assertEquals(z.type(),Type.BOOLEAN);
- assertEquals(z.asBool(),true);
- z = y.equalsTo(x);
- assertEquals(z.type(),Type.BOOLEAN);
- assertEquals(z.asBool(), true);
-
- x = DatumFactory.createInt8(123456789012345l);
- y = DatumFactory.createInt8(123456789012345l);
- z = x.equalsTo(y);
- assertEquals(z.type(),Type.BOOLEAN);
- assertEquals(z.asBool(),true);
- z = y.equalsTo(x);
- assertEquals(z.type(),Type.BOOLEAN);
- assertEquals(z.asBool(), true);
- }
-
- @Test
- public final void testLessThanDatum() {
- Datum x;
- Datum y;
- Datum z;
-
- x = DatumFactory.createInt4(6);
- y = DatumFactory.createInt4(3);
- z = x.lessThan(y);
- assertEquals(z.type(),Type.BOOLEAN);
- assertEquals(z.asBool(),false);
- z = y.lessThan(x);
- assertEquals(z.type(),Type.BOOLEAN);
- assertEquals(z.asBool(), true);
- }
-
- @Test
- public final void testLessThanEqualsDatum() {
- Datum x;
- Datum y;
- Datum z;
-
- x = DatumFactory.createInt4(6);
- y = DatumFactory.createInt4(3);
- z = x.lessThanEqual(y);
- assertEquals(z.type(),Type.BOOLEAN);
- assertEquals(z.asBool(),false);
- z = y.lessThanEqual(x);
- assertEquals(z.type(),Type.BOOLEAN);
- assertEquals(z.asBool(), true);
-
- x = DatumFactory.createInt4(6);
- y = DatumFactory.createInt4(6);
- z = x.lessThanEqual(y);
- assertEquals(z.type(),Type.BOOLEAN);
- assertEquals(z.asBool(),true);
- z = y.lessThanEqual(x);
- assertEquals(z.type(),Type.BOOLEAN);
- assertEquals(z.asBool(), true);
- }
-
- @Test
- public final void testgreaterThanDatum() {
- Datum x;
- Datum y;
- Datum z;
-
- x = DatumFactory.createInt4(6);
- y = DatumFactory.createInt4(3);
- z = x.greaterThan(y);
- assertEquals(z.type(),Type.BOOLEAN);
- assertEquals(z.asBool(),true);
- z = y.greaterThan(x);
- assertEquals(z.type(),Type.BOOLEAN);
- assertEquals(z.asBool(), false);
-
- x = DatumFactory.createInt4(6);
- y = DatumFactory.createInt4(6);
- z = x.greaterThan(y);
- assertEquals(z.type(),Type.BOOLEAN);
- assertEquals(z.asBool(),false);
- z = y.greaterThan(x);
- assertEquals(z.type(),Type.BOOLEAN);
- assertEquals(z.asBool(), false);
- }
-
- @Test
- public final void testgreaterThanEqualsDatum() {
- Datum x;
- Datum y;
- Datum z;
-
- x = DatumFactory.createInt4(6);
- y = DatumFactory.createInt4(3);
- z = x.greaterThanEqual(y);
- assertEquals(z.type(),Type.BOOLEAN);
- assertEquals(z.asBool(),true);
- z = y.greaterThanEqual(x);
- assertEquals(z.type(),Type.BOOLEAN);
- assertEquals(z.asBool(), false);
-
- x = DatumFactory.createInt4(6);
- y = DatumFactory.createInt4(6);
- z = x.greaterThanEqual(y);
- assertEquals(z.type(),Type.BOOLEAN);
- assertEquals(z.asBool(),true);
- z = y.greaterThanEqual(x);
- assertEquals(z.type(),Type.BOOLEAN);
- assertEquals(z.asBool(), true);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-common/src/test/java/tajo/datum/TestDatumFactory.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/tajo/datum/TestDatumFactory.java b/tajo-common/src/test/java/tajo/datum/TestDatumFactory.java
deleted file mode 100644
index 2b59f46..0000000
--- a/tajo-common/src/test/java/tajo/datum/TestDatumFactory.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * 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 tajo.datum;
-
-import org.junit.Test;
-import tajo.common.TajoDataTypes.Type;
-
-import static org.junit.Assert.assertEquals;
-
-public class TestDatumFactory {
-
- @Test
- public final void testCreateBit() {
- Datum d = DatumFactory.createBit((byte) 5);
- assertEquals(Type.BIT, d.type());
- }
-
- @Test
- public final void testCreateInt2() {
- Datum d = DatumFactory.createInt2((short) 5);
- assertEquals(Type.INT2, d.type());
- }
-
- @Test
- public final void testCreateInt4() {
- Datum d = DatumFactory.createInt4(5);
- assertEquals(Type.INT4, d.type());
- }
-
- @Test
- public final void testCreateInt8() {
- Datum d = DatumFactory.createInt8((long) 5);
- assertEquals(Type.INT8, d.type());
- }
-
- @Test
- public final void testCreateFloat4() {
- Datum d = DatumFactory.createFloat4(5.0f);
- assertEquals(Type.FLOAT4, d.type());
- }
-
- @Test
- public final void testCreateFloat8() {
- Datum d = DatumFactory.createFloat8(5.0d);
- assertEquals(Type.FLOAT8, d.type());
- }
-
- @Test
- public final void testCreateBoolean() {
- Datum d = DatumFactory.createBool(true);
- assertEquals(Type.BOOLEAN, d.type());
- }
-
- @Test
- public final void testCreateString() {
- Datum d = DatumFactory.createText("12345a");
- assertEquals(Type.TEXT, d.type());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-common/src/test/java/tajo/datum/TestFloat8Datum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/tajo/datum/TestFloat8Datum.java b/tajo-common/src/test/java/tajo/datum/TestFloat8Datum.java
deleted file mode 100644
index 6558fd2..0000000
--- a/tajo-common/src/test/java/tajo/datum/TestFloat8Datum.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * 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 tajo.datum;
-
-import org.junit.Test;
-import tajo.common.TajoDataTypes.Type;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-public class TestFloat8Datum {
-
- @Test
- public final void testType() {
- Datum d = DatumFactory.createFloat8(1d);
- assertEquals(Type.FLOAT8, d.type());
- }
-
- @Test
- public final void testAsInt4() {
- Datum d = DatumFactory.createFloat8(5d);
- assertEquals(5,d.asInt4());
- }
-
- @Test
- public final void testAsInt8() {
- Datum d = DatumFactory.createFloat8(5d);
- assertEquals(5l,d.asInt8());
- }
-
- @Test
- public final void testAsFloat4() {
- Datum d = DatumFactory.createFloat8(5d);
- assertTrue(5.0f == d.asFloat4());
- }
-
- @Test
- public final void testAsFloat8() {
- Datum d = DatumFactory.createFloat8(5d);
- assertTrue(5.0d == d.asFloat8());
- }
-
- @Test
- public final void testAsText() {
- Datum d = DatumFactory.createFloat8(5d);
- assertEquals("5.0", d.asChars());
- }
-
- @Test
- public final void testSize() {
- Datum d = DatumFactory.createFloat8(5d);
- assertEquals(8, d.size());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-common/src/test/java/tajo/datum/TestFloatDatum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/tajo/datum/TestFloatDatum.java b/tajo-common/src/test/java/tajo/datum/TestFloatDatum.java
deleted file mode 100644
index b207666..0000000
--- a/tajo-common/src/test/java/tajo/datum/TestFloatDatum.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * 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 tajo.datum;
-
-import org.junit.Test;
-import tajo.common.TajoDataTypes.Type;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-public class TestFloatDatum {
-
- @Test
- public final void testType() {
- Datum d = DatumFactory.createFloat4(1f);
- assertEquals(Type.FLOAT4, d.type());
- }
-
- @Test
- public final void testAsInt() {
- Datum d = DatumFactory.createFloat4(5f);
- assertEquals(5,d.asInt4());
- }
-
- @Test
- public final void testAsLong() {
- Datum d = DatumFactory.createFloat4(5f);
- assertEquals(5l,d.asInt8());
- }
-
- @Test
- public final void testAsFloat() {
- Datum d = DatumFactory.createFloat4(5f);
- assertTrue(5.0f == d.asFloat4());
- }
-
- @Test
- public final void testAsDouble() {
- Datum d = DatumFactory.createFloat4(5f);
- assertTrue(5.0d == d.asFloat8());
- }
-
- @Test
- public final void testAsChars() {
- Datum d = DatumFactory.createFloat4(5f);
- assertEquals("5.0", d.asChars());
- }
-
- @Test
- public final void testSize() {
- Datum d = DatumFactory.createFloat4(5f);
- assertEquals(4, d.size());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-common/src/test/java/tajo/datum/TestInet4Datum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/tajo/datum/TestInet4Datum.java b/tajo-common/src/test/java/tajo/datum/TestInet4Datum.java
deleted file mode 100644
index 8df9506..0000000
--- a/tajo-common/src/test/java/tajo/datum/TestInet4Datum.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * 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 tajo.datum;
-
-import org.junit.Before;
-import org.junit.Test;
-import tajo.datum.json.GsonCreator;
-
-import java.util.Arrays;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-public class TestInet4Datum {
-
- @Before
- public void setUp() throws Exception {
- }
-
- @Test
- public final void testEquals() {
- Inet4Datum ip1 = new Inet4Datum("192.168.0.1");
- Inet4Datum ip2 = new Inet4Datum("192.168.0.1");
-
- assertEquals(ip1, ip2);
-
- Inet4Datum ip3 = new Inet4Datum(ip1.asByteArray());
- assertEquals(ip1, ip3);
- Inet4Datum ip4 = DatumFactory.createInet4(ip1.asByteArray());
- assertEquals(ip1, ip4);
- }
-
- @Test
- public final void testAsByteArray() {
- byte[] bytes = {(byte) 0xA3, (byte) 0x98, 0x17, (byte) 0xDE};
- Inet4Datum ip = new Inet4Datum(bytes);
- assertTrue(Arrays.equals(bytes, ip.asByteArray()));
- }
-
- @Test
- public final void testAsChars() {
- Inet4Datum ip = new Inet4Datum("163.152.23.222");
- assertEquals("163.152.23.222", ip.asChars());
- }
-
- @Test
- public final void testSize() {
- Datum d = DatumFactory.createInet4("163.152.23.222");
- assertEquals(4, d.size());
- }
-
- @Test
- public final void testJson() {
- Datum d = DatumFactory.createInet4("163.152.163.152");
- String json = d.toJSON();
- Datum fromJson = GsonCreator.getInstance().fromJson(json, Datum.class);
- assertTrue(d.equalsTo(fromJson).asBool());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-common/src/test/java/tajo/datum/TestInt2Datum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/tajo/datum/TestInt2Datum.java b/tajo-common/src/test/java/tajo/datum/TestInt2Datum.java
deleted file mode 100644
index cef991b..0000000
--- a/tajo-common/src/test/java/tajo/datum/TestInt2Datum.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * 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 tajo.datum;
-
-import org.junit.Test;
-import tajo.common.TajoDataTypes.Type;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-public class TestInt2Datum {
-
- @Test
- public final void testType() {
- Datum d = DatumFactory.createInt2((short) 1);
- assertEquals(d.type(), Type.INT2);
- }
-
- @Test
- public final void testAsInt4() {
- Datum d = DatumFactory.createInt2((short) 5);
- assertEquals(5,d.asInt4());
- }
-
- @Test
- public final void testAsInt8() {
- Datum d = DatumFactory.createInt2((short) 5);
- assertEquals(5,d.asInt8());
- }
-
- @Test
- public final void testAsFloat4() {
- Datum d = DatumFactory.createInt2((short) 5);
- assertTrue(5.0f == d.asFloat4());
- }
-
- @Test
- public final void testAsFloat8() {
- Datum d = DatumFactory.createInt2((short) 5);
- assertTrue(5.0d == d.asFloat8());
- }
-
- @Test
- public final void testAsText() {
- Datum d = DatumFactory.createInt2((short) 5);
- assertEquals("5", d.asChars());
- }
-
- @Test
- public final void testSize() {
- Datum d = DatumFactory.createInt2((short) 5);
- assertEquals(2, d.size());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-common/src/test/java/tajo/datum/TestInt4Datum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/tajo/datum/TestInt4Datum.java b/tajo-common/src/test/java/tajo/datum/TestInt4Datum.java
deleted file mode 100644
index 5fc9e2d..0000000
--- a/tajo-common/src/test/java/tajo/datum/TestInt4Datum.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * 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 tajo.datum;
-
-import org.junit.Test;
-import tajo.common.TajoDataTypes;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-public class TestInt4Datum {
-
- @Test
- public final void testType() {
- Datum d = DatumFactory.createInt4(1);
- assertEquals(TajoDataTypes.Type.INT4, d.type());
- }
-
- @Test
- public final void testAsInt() {
- Datum d = DatumFactory.createInt4(5);
- assertEquals(5, d.asInt4());
- }
-
- @Test
- public final void testAsLong() {
- Datum d = DatumFactory.createInt4(5);
- assertEquals(5, d.asInt8());
- }
-
- @Test
- public final void testAsFloat() {
- Datum d = DatumFactory.createInt4(5);
- assertTrue(5.0f == d.asFloat4());
- }
-
- @Test
- public final void testAsDouble() {
- Datum d = DatumFactory.createInt4(5);
- assertTrue(5.0d == d.asFloat8());
- }
-
- @Test
- public final void testAsChars() {
- Datum d = DatumFactory.createInt4(5);
- assertEquals("5", d.asChars());
- }
-
- @Test
- public final void testSize() {
- Datum d = DatumFactory.createInt4(5);
- assertEquals(4, d.size());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-common/src/test/java/tajo/datum/TestInt8Datum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/tajo/datum/TestInt8Datum.java b/tajo-common/src/test/java/tajo/datum/TestInt8Datum.java
deleted file mode 100644
index 6e8042b..0000000
--- a/tajo-common/src/test/java/tajo/datum/TestInt8Datum.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * 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 tajo.datum;
-
-import org.junit.Test;
-import tajo.common.TajoDataTypes.Type;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-public class TestInt8Datum {
-
- @Test
- public final void testType() {
- Datum d = DatumFactory.createInt8(1l);
- assertEquals(d.type(), Type.INT8);
- }
-
- @Test
- public final void testAsInt() {
- Datum d = DatumFactory.createInt8(5l);
- assertEquals(5,d.asInt4());
- }
-
- @Test
- public final void testAsLong() {
- Datum d = DatumFactory.createInt8(5l);
- assertEquals(5l,d.asInt8());
- }
-
- @Test
- public final void testAsFloat() {
- Datum d = DatumFactory.createInt8(5l);
- assertTrue(5.0f == d.asFloat4());
- }
-
- @Test
- public final void testAsDouble() {
- Datum d = DatumFactory.createInt8(5l);
- assertTrue(5.0d == d.asFloat8());
- }
-
- @Test
- public final void testAsChars() {
- Datum d = DatumFactory.createInt8(5l);
- assertEquals("5", d.asChars());
- }
-
- @Test
- public final void testSize() {
- Datum d = DatumFactory.createInt8(5l);
- assertEquals(8, d.size());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-common/src/test/java/tajo/datum/TestTextDatum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/tajo/datum/TestTextDatum.java b/tajo-common/src/test/java/tajo/datum/TestTextDatum.java
deleted file mode 100644
index af87bde..0000000
--- a/tajo-common/src/test/java/tajo/datum/TestTextDatum.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * 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 tajo.datum;
-
-import org.junit.Test;
-import tajo.common.TajoDataTypes.Type;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-public class TestTextDatum {
-
- @Test
- public final void testType() {
- Datum d = DatumFactory.createText("12345");
- assertEquals(d.type(), Type.TEXT);
- }
-
- @Test
- public final void testAsInt4() {
- Datum d = DatumFactory.createText("12345");
- assertEquals(12345,d.asInt4());
- }
-
- @Test
- public final void testAsInt8() {
- Datum d = DatumFactory.createText("12345");
- assertEquals(12345l,d.asInt8());
- }
-
- @Test
- public final void testAsFloat4() {
- Datum d = DatumFactory.createText("12345");
- assertTrue(12345.0f == d.asFloat4());
- }
-
- @Test
- public final void testAsFloat8() {
- Datum d = DatumFactory.createText("12345");
- assertTrue(12345.0d == d.asFloat8());
- }
-
- @Test
- public final void testAsText() {
- Datum d = DatumFactory.createText("12345");
- assertEquals("12345", d.asChars());
- }
-
- @Test
- public final void testSize() {
- Datum d = DatumFactory.createText("12345");
- assertEquals(5, d.size());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-common/src/test/java/tajo/util/TestBitArrayTest.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/tajo/util/TestBitArrayTest.java b/tajo-common/src/test/java/tajo/util/TestBitArrayTest.java
deleted file mode 100644
index 3839409..0000000
--- a/tajo-common/src/test/java/tajo/util/TestBitArrayTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * 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 tajo.util;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-public class TestBitArrayTest {
-
- @Test
- public void test() {
- int num = 80;
- BitArray bitArray = new BitArray(num);
-
- for (int i = 0; i < num; i++) {
- assertFalse(bitArray.get(i));
- bitArray.set(i);
- assertTrue(bitArray.get(i));
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-common/src/test/java/tajo/util/TestFileUtils.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/tajo/util/TestFileUtils.java b/tajo-common/src/test/java/tajo/util/TestFileUtils.java
deleted file mode 100644
index d0e84b7..0000000
--- a/tajo-common/src/test/java/tajo/util/TestFileUtils.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/**
- * 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 tajo.util;
-
-import com.google.protobuf.Message;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.Path;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import tajo.util.TestProtos.TestMessageProto;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-
-import static org.junit.Assert.assertEquals;
-
-public class TestFileUtils {
- private static final String TEST_PATH = "target/test-data/TestFileUTils";
- TestMessageProto proto = null;
-
- @Before
- public void setUp() throws Exception {
- TestMessageProto.Builder builder = TestMessageProto.newBuilder();
- builder.setName("TestFileUtils");
- builder.setAge(30);
- builder.setAddr(TestFileUtils.class.getName());
-
- proto = builder.build();
-
- File testDir = new File(TEST_PATH);
- if(testDir.exists()) {
- testDir.delete();
- }
- testDir.mkdirs();
- }
-
- @After
- public void tearDown() throws Exception {
- File testDir = new File(TEST_PATH);
- if(testDir.exists()) {
- testDir.delete();
- }
- }
-
- @Test
- public final void testWriteLoadProtoFromFile() throws IOException {
- File file = new File(TEST_PATH+"/file.bin");
- file.createNewFile();
- FileUtil.writeProto(file, proto);
-
- Message defaultInstance = TestMessageProto.getDefaultInstance();
- TestMessageProto message = (TestMessageProto)
- FileUtil.loadProto(new File(TEST_PATH+"/file.bin"), defaultInstance);
-
- assertEquals(proto, message);
- }
-
- @Test
- public final void testWriteLoadProtoFromStream() throws IOException {
- FileOutputStream out = new FileOutputStream(new File(TEST_PATH+"/file.bin"));
- FileUtil.writeProto(out, proto);
-
-
- FileInputStream in = new FileInputStream(new File(TEST_PATH+"/file.bin"));
- Message defaultInstance = TestMessageProto.getDefaultInstance();
- TestMessageProto message = (TestMessageProto)
- FileUtil.loadProto(in, defaultInstance);
-
- assertEquals(proto, message);
- }
-
- @Test
- public final void testWriteLoadProtoFromPath() throws IOException {
- Path path = new Path(TEST_PATH+"/file.bin");
- Configuration conf = new Configuration();
- FileSystem localFS = FileSystem.getLocal(conf);
- FileUtil.writeProto(localFS, path, proto);
-
- Message defaultInstance = TestMessageProto.getDefaultInstance();
- TestMessageProto message = (TestMessageProto)
- FileUtil.loadProto(localFS, new Path(TEST_PATH+"/file.bin"),
- defaultInstance);
-
- assertEquals(proto, message);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-core/tajo-core-backend/pom.xml
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/pom.xml b/tajo-core/tajo-core-backend/pom.xml
index 88d804f..83af62a 100644
--- a/tajo-core/tajo-core-backend/pom.xml
+++ b/tajo-core/tajo-core-backend/pom.xml
@@ -69,7 +69,7 @@
</dependency>
</dependencies>
<configuration>
- <excludedGroups>tajo.IntegrationTest</excludedGroups>
+ <excludedGroups>org.apache.tajo.IntegrationTest</excludedGroups>
</configuration>
</plugin>
<plugin>
@@ -95,7 +95,7 @@
<includes>
<include>**/*.class</include>
</includes>
- <groups>tajo.IntegrationTest</groups>
+ <groups>org.apache.tajo.IntegrationTest</groups>
<!--
<environmentVariables>
<TAJO_CLASSPATH>${project.basedir}/../../tajo-dist/target/tajo-${project.version}/*:${project.basedir}/../../tajo-dist/target/tajo-${project.version}/lib/*</TAJO_CLASSPATH>