You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@carbondata.apache.org by gv...@apache.org on 2016/09/08 08:12:56 UTC
[1/2] incubator-carbondata git commit: [CARBONDATA-220]
TimeStampDirectDictionaryGenerator_UT.java is not running in the build
Refactored the class name and added boundary test cases
Repository: incubator-carbondata
Updated Branches:
refs/heads/master eb9806cd1 -> 66f6e62b6
[CARBONDATA-220] TimeStampDirectDictionaryGenerator_UT.java is not running in the build Refactored the class name and added boundary test cases
Project: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/commit/aa6a8bf5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/tree/aa6a8bf5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/diff/aa6a8bf5
Branch: refs/heads/master
Commit: aa6a8bf592317cabe91d50dce173777d98d0f14e
Parents: eb9806c
Author: mohammadshahidkhan <mo...@gmail.com>
Authored: Wed Sep 7 18:12:43 2016 +0530
Committer: Venkata Ramana G <ra...@huawei.com>
Committed: Thu Sep 8 13:33:00 2016 +0530
----------------------------------------------------------------------
.../TimeStampDirectDictionaryGeneratorTest.java | 110 +++++++++++++++++++
.../TimeStampDirectDictionaryGenerator_UT.java | 75 -------------
2 files changed, 110 insertions(+), 75 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/aa6a8bf5/processing/src/test/java/org/apache/carbondata/core/keygenerator/directdictionary/timestamp/TimeStampDirectDictionaryGeneratorTest.java
----------------------------------------------------------------------
diff --git a/processing/src/test/java/org/apache/carbondata/core/keygenerator/directdictionary/timestamp/TimeStampDirectDictionaryGeneratorTest.java b/processing/src/test/java/org/apache/carbondata/core/keygenerator/directdictionary/timestamp/TimeStampDirectDictionaryGeneratorTest.java
new file mode 100644
index 0000000..0e8d9dc
--- /dev/null
+++ b/processing/src/test/java/org/apache/carbondata/core/keygenerator/directdictionary/timestamp/TimeStampDirectDictionaryGeneratorTest.java
@@ -0,0 +1,110 @@
+/*
+ * 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.carbondata.core.keygenerator.directdictionary.timestamp;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.apache.carbondata.core.constants.CarbonCommonConstants;
+import org.apache.carbondata.core.util.CarbonProperties;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Unit test case for the TimeStampDirectDictionaryGenerator
+ */
+public class TimeStampDirectDictionaryGeneratorTest {
+ private String memberString = "2015-10-20 12:30:01";
+ private int surrogateKey = -1;
+
+ @Before public void setUp() throws Exception {
+ TimeStampDirectDictionaryGenerator generator = TimeStampDirectDictionaryGenerator.instance;
+ surrogateKey = generator.generateDirectSurrogateKey("2015-10-20 12:30:01");
+ }
+
+ /**
+ * The invalid input date format should return -1, if proper format then should return the ve integer value
+ *
+ * @throws Exception
+ */
+ @Test public void generateDirectSurrogateKey() throws Exception {
+ TimeStampDirectDictionaryGenerator generator = TimeStampDirectDictionaryGenerator.instance;
+ // default timestamp format is "yyyy-MM-dd HH:mm:ss" and the data being passed
+ // in "dd/MM/yyyy" so the parsing should fail and method should return 1.
+ int key = generator.generateDirectSurrogateKey("20/12/2014");
+ Assert.assertEquals(1, key);
+ key = generator.generateDirectSurrogateKey("2015-10-20 12:30:01");
+ Assert.assertEquals(surrogateKey, key);
+
+ }
+
+ /**
+ * The memberString should be retrieved from the actual surrogate key
+ *
+ * @throws Exception
+ */
+ @Test public void getValueFromSurrogate() throws Exception {
+ TimeStampDirectDictionaryGenerator generator = TimeStampDirectDictionaryGenerator.instance;
+ long valueFromSurrogate = (long) generator.getValueFromSurrogate(surrogateKey);
+ Date date = new Date(valueFromSurrogate / 1000);
+ SimpleDateFormat timeParser = new SimpleDateFormat(CarbonProperties.getInstance()
+ .getProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT,
+ CarbonCommonConstants.CARBON_TIMESTAMP_DEFAULT_FORMAT));
+ timeParser.setLenient(false);
+ String actualValue = timeParser.format(date);
+ Assert.assertEquals(memberString, actualValue);
+ }
+
+ /**
+ * The memberString should be retrieved from the actual surrogate key
+ *
+ * @throws Exception
+ */
+ @Test public void lowerBoundaryValueTest() throws Exception {
+ TimeStampDirectDictionaryGenerator generator = TimeStampDirectDictionaryGenerator.instance;
+ long valueFromSurrogate = (long) generator.getValueFromSurrogate(2);
+ Date date = new Date(valueFromSurrogate / 1000);
+ SimpleDateFormat timeParser = new SimpleDateFormat(CarbonProperties.getInstance()
+ .getProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT,
+ CarbonCommonConstants.CARBON_TIMESTAMP_DEFAULT_FORMAT));
+ timeParser.setLenient(false);
+ String actualValue = timeParser.format(date);
+ Assert.assertEquals("1970-01-01 05:30:00", actualValue);
+ }
+
+ /**
+ * The memberString should be retrieved from the actual surrogate key
+ *
+ * @throws Exception
+ */
+ @Test public void upperBoundaryValueTest() throws Exception {
+ TimeStampDirectDictionaryGenerator generator = TimeStampDirectDictionaryGenerator.instance;
+ int surrogateKey = generator.generateDirectSurrogateKey("2038-01-01 05:30:00");
+ long valueFromSurrogate = (long) generator.getValueFromSurrogate(surrogateKey);
+ Date date = new Date(valueFromSurrogate / 1000);
+ SimpleDateFormat timeParser = new SimpleDateFormat(CarbonProperties.getInstance()
+ .getProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT,
+ CarbonCommonConstants.CARBON_TIMESTAMP_DEFAULT_FORMAT));
+ timeParser.setLenient(false);
+ String actualValue = timeParser.format(date);
+ Assert.assertEquals("2038-01-01 05:30:00", actualValue);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/aa6a8bf5/processing/src/test/java/org/apache/carbondata/core/keygenerator/directdictionary/timestamp/TimeStampDirectDictionaryGenerator_UT.java
----------------------------------------------------------------------
diff --git a/processing/src/test/java/org/apache/carbondata/core/keygenerator/directdictionary/timestamp/TimeStampDirectDictionaryGenerator_UT.java b/processing/src/test/java/org/apache/carbondata/core/keygenerator/directdictionary/timestamp/TimeStampDirectDictionaryGenerator_UT.java
deleted file mode 100644
index 27710d7..0000000
--- a/processing/src/test/java/org/apache/carbondata/core/keygenerator/directdictionary/timestamp/TimeStampDirectDictionaryGenerator_UT.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 org.apache.carbondata.core.keygenerator.directdictionary.timestamp;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import org.apache.carbondata.core.constants.CarbonCommonConstants;
-import org.apache.carbondata.core.util.CarbonProperties;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Unit test case for the TimeStampDirectDictionaryGenerator
- */
-public class TimeStampDirectDictionaryGenerator_UT {
- private String memberString = "2015-10-20 12:30:01";
- private int surrogateKey = -1;
-
- @Before public void setUp() throws Exception {
- TimeStampDirectDictionaryGenerator generator = TimeStampDirectDictionaryGenerator.instance;
- surrogateKey = generator.generateDirectSurrogateKey("2015-10-20 12:30:01");
- }
-
- /**
- * The invalid input date format should return -1, if proper format then should return the ve integer value
- *
- * @throws Exception
- */
- @Test public void generateDirectSurrogateKey() throws Exception {
- TimeStampDirectDictionaryGenerator generator = TimeStampDirectDictionaryGenerator.instance;
- // default timestamp format is "yyyy-MM-dd HH:mm:ss" and the data being passed
- // in "dd/MM/yyyy" so the parsing should fail and method should return -1.
- int key = generator.generateDirectSurrogateKey("20/12/2014");
- Assert.assertEquals(-1, key);
- key = generator.generateDirectSurrogateKey("2015-10-20 12:30:01");
- Assert.assertEquals(surrogateKey, key);
-
- }
-
- /**
- * The memberString should be retrieved from the actual surrogate key
- *
- * @throws Exception
- */
- @Test public void getValueFromSurrogate() throws Exception {
- TimeStampDirectDictionaryGenerator generator = TimeStampDirectDictionaryGenerator.instance;
- long valueFromSurrogate = (long) generator.getValueFromSurrogate(surrogateKey);
- Date date = new Date(valueFromSurrogate / 1000);
- SimpleDateFormat timeParser = new SimpleDateFormat(CarbonProperties.getInstance()
- .getProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT,
- CarbonCommonConstants.CARBON_TIMESTAMP_DEFAULT_FORMAT));
- timeParser.setLenient(false);
- String actualValue = timeParser.format(date);
- Assert.assertEquals(memberString, actualValue);
- }
-}
[2/2] incubator-carbondata git commit: [CARBONDATA-220] UT
correction. This closes #134
Posted by gv...@apache.org.
[CARBONDATA-220] UT correction. This closes #134
Project: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/commit/66f6e62b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/tree/66f6e62b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/diff/66f6e62b
Branch: refs/heads/master
Commit: 66f6e62b68d0700b5b8ef5dddf1905d6e6fa132a
Parents: eb9806c aa6a8bf
Author: Venkata Ramana G <ra...@huawei.com>
Authored: Thu Sep 8 13:42:38 2016 +0530
Committer: Venkata Ramana G <ra...@huawei.com>
Committed: Thu Sep 8 13:42:38 2016 +0530
----------------------------------------------------------------------
.../TimeStampDirectDictionaryGeneratorTest.java | 110 +++++++++++++++++++
.../TimeStampDirectDictionaryGenerator_UT.java | 75 -------------
2 files changed, 110 insertions(+), 75 deletions(-)
----------------------------------------------------------------------