You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@falcon.apache.org by pa...@apache.org on 2016/03/01 09:26:19 UTC
[33/51] [partial] falcon git commit: FALCON-1830 Removed code source
directories and updated pom
http://git-wip-us.apache.org/repos/asf/falcon/blob/8e49379d/common/src/test/java/org/apache/falcon/entity/AbstractTestBase.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/falcon/entity/AbstractTestBase.java b/common/src/test/java/org/apache/falcon/entity/AbstractTestBase.java
deleted file mode 100644
index fd963e5..0000000
--- a/common/src/test/java/org/apache/falcon/entity/AbstractTestBase.java
+++ /dev/null
@@ -1,211 +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.falcon.entity;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.falcon.FalconException;
-import org.apache.falcon.cluster.util.EmbeddedCluster;
-import org.apache.falcon.entity.store.ConfigurationStore;
-import org.apache.falcon.entity.v0.Entity;
-import org.apache.falcon.entity.v0.EntityType;
-import org.apache.falcon.entity.v0.cluster.Cluster;
-import org.apache.falcon.entity.v0.cluster.Interfacetype;
-import org.apache.falcon.entity.v0.feed.Feed;
-import org.apache.falcon.entity.v0.process.Process;
-import org.apache.falcon.hadoop.HadoopClientFactory;
-import org.apache.falcon.security.CurrentUser;
-import org.apache.falcon.util.FalconTestUtil;
-import org.apache.falcon.util.StartupProperties;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.security.UserGroupInformation;
-import org.testng.annotations.BeforeClass;
-
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
-import javax.xml.bind.Unmarshaller;
-import java.io.File;
-import java.io.IOException;
-import java.io.StringWriter;
-import java.net.URI;
-import java.util.Collection;
-
-/**
- * Base class for config store test.
- */
-public class AbstractTestBase {
- protected static final String USER = System.getProperty("user.name");
-
- protected static final String PROCESS_XML = "/config/process/process-0.1.xml";
- protected static final String FEED_XML = "/config/feed/feed-0.1.xml";
- protected static final String FEED3_XML = "/config/feed/feed-0.3.xml";
- protected static final String FEED4_XML = "/config/feed/feed-0.4.xml";
- protected static final String CLUSTER_XML = "/config/cluster/cluster-0.1.xml";
- protected static final String DATASOURCE_XML = "/config/datasource/datasource-0.1.xml";
- protected EmbeddedCluster dfsCluster;
- protected Configuration conf = new Configuration();
- private ConfigurationStore store;
-
- public ConfigurationStore getStore() {
- return store;
- }
-
- @BeforeClass
- public void initConfigStore() throws Exception {
- String configPath = new URI(StartupProperties.get().getProperty("config.store.uri")).getPath();
- String location = configPath + "-" + getClass().getName();
- StartupProperties.get().setProperty("config.store.uri", location);
- FileUtils.deleteDirectory(new File(location));
-
- cleanupStore();
- String listeners = StartupProperties.get().getProperty("configstore.listeners");
- listeners = listeners.replace("org.apache.falcon.service.SharedLibraryHostingService", "");
- listeners = listeners.replace("org.apache.falcon.service.FeedSLAMonitoringService", "");
- StartupProperties.get().setProperty("configstore.listeners", listeners);
- store = ConfigurationStore.get();
- store.init();
-
- CurrentUser.authenticate(FalconTestUtil.TEST_USER_2);
- UserGroupInformation.createUserForTesting(FalconTestUtil.TEST_USER_2, new String[]{"testgroup"});
- }
-
- protected void cleanupStore() throws FalconException {
- store = ConfigurationStore.get();
- for (EntityType type : EntityType.values()) {
- Collection<String> entities = store.getEntities(type);
- for (String entity : entities) {
- store.remove(type, entity);
- }
- }
- }
-
- protected void storeEntity(EntityType type, String name) throws Exception {
- final String proxyUser = CurrentUser.getUser();
- final String defaultGroupName = CurrentUser.getPrimaryGroupName();
-
- Unmarshaller unmarshaller = type.getUnmarshaller();
- store = ConfigurationStore.get();
- store.remove(type, name);
- switch (type) {
- case CLUSTER:
- Cluster cluster = (Cluster) unmarshaller.unmarshal(this.getClass().getResource(CLUSTER_XML));
- cluster.setName(name);
- ClusterHelper.getInterface(cluster, Interfacetype.WRITE)
- .setEndpoint(conf.get(HadoopClientFactory.FS_DEFAULT_NAME_KEY));
- decorateACL(proxyUser, defaultGroupName, cluster);
-
- store.publish(type, cluster);
- break;
-
- case FEED:
- Feed feed = (Feed) unmarshaller.unmarshal(this.getClass().getResource(FEED_XML));
- feed.setName(name);
- decorateACL(proxyUser, defaultGroupName, feed);
-
- store.publish(type, feed);
- break;
-
- case PROCESS:
- Process process = (Process) unmarshaller.unmarshal(this.getClass().getResource(PROCESS_XML));
- process.setName(name);
- FileSystem fs = dfsCluster.getFileSystem();
- fs.mkdirs(new Path(process.getWorkflow().getPath()));
- if (!fs.exists(new Path(process.getWorkflow() + "/lib"))) {
- fs.mkdirs(new Path(process.getWorkflow() + "/lib"));
- }
-
- decorateACL(proxyUser, defaultGroupName, process);
-
- store.publish(type, process);
- break;
- default:
- }
- }
-
- protected void deleteEntity(EntityType type, String name) throws FalconException {
- store.remove(type, name);
- }
-
-
-
- private void decorateACL(String proxyUser, String defaultGroupName, Cluster cluster) {
- if (cluster.getACL() != null) {
- return;
- }
-
- org.apache.falcon.entity.v0.cluster.ACL clusterACL =
- new org.apache.falcon.entity.v0.cluster.ACL();
- clusterACL.setOwner(proxyUser);
- clusterACL.setGroup(defaultGroupName);
- cluster.setACL(clusterACL);
- }
-
- private void decorateACL(String proxyUser, String defaultGroupName, Feed feed) {
- if (feed.getACL() != null) {
- return;
- }
-
- org.apache.falcon.entity.v0.feed.ACL feedACL =
- new org.apache.falcon.entity.v0.feed.ACL();
- feedACL.setOwner(proxyUser);
- feedACL.setGroup(defaultGroupName);
- feed.setACL(feedACL);
- }
-
- private void decorateACL(String proxyUser, String defaultGroupName,
- Process process) {
- if (process.getACL() != null) {
- return;
- }
-
- org.apache.falcon.entity.v0.process.ACL processACL =
- new org.apache.falcon.entity.v0.process.ACL();
- processACL.setOwner(proxyUser);
- processACL.setGroup(defaultGroupName);
- process.setACL(processACL);
- }
-
- public void setup() throws Exception {
- store = ConfigurationStore.get();
- for (EntityType type : EntityType.values()) {
- for (String name : store.getEntities(type)) {
- store.remove(type, name);
- }
- }
- storeEntity(EntityType.CLUSTER, "corp");
- storeEntity(EntityType.FEED, "clicks");
- storeEntity(EntityType.FEED, "impressions");
- storeEntity(EntityType.FEED, "clicksummary");
- storeEntity(EntityType.PROCESS, "clicksummary");
- }
-
- public String marshallEntity(final Entity entity) throws FalconException,
- JAXBException {
- Marshaller marshaller = entity.getEntityType().getMarshaller();
- StringWriter stringWriter = new StringWriter();
- marshaller.marshal(entity, stringWriter);
- return stringWriter.toString();
- }
-
- // assumes there will always be at least one group for a logged in user
- protected String getPrimaryGroupName() throws IOException {
- return CurrentUser.getPrimaryGroupName();
- }
-}
http://git-wip-us.apache.org/repos/asf/falcon/blob/8e49379d/common/src/test/java/org/apache/falcon/entity/CatalogStorageTest.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/falcon/entity/CatalogStorageTest.java b/common/src/test/java/org/apache/falcon/entity/CatalogStorageTest.java
deleted file mode 100644
index 5d06431..0000000
--- a/common/src/test/java/org/apache/falcon/entity/CatalogStorageTest.java
+++ /dev/null
@@ -1,213 +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.falcon.entity;
-
-import org.apache.falcon.entity.v0.feed.LocationType;
-import org.testng.Assert;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-import java.net.URISyntaxException;
-
-/**
- * Test class for Catalog Table Storage.
- * Exists will be covered in integration tests as it actually checks if the table exists.
- */
-public class CatalogStorageTest {
-
- @Test
- public void testGetType() throws Exception {
- String table = "catalog:clicksdb:clicks#ds=${YEAR}-${MONTH}-${DAY};region=us";
- CatalogStorage storage = new CatalogStorage(CatalogStorage.CATALOG_URL, table);
- Assert.assertEquals(Storage.TYPE.TABLE, storage.getType());
- }
-
- @Test
- public void testParseFeedUriValid() throws URISyntaxException {
- String table = "catalog:clicksdb:clicks#ds=${YEAR}-${MONTH}-${DAY};region=us";
- CatalogStorage storage = new CatalogStorage(CatalogStorage.CATALOG_URL, table);
- Assert.assertEquals("${hcatNode}", storage.getCatalogUrl());
- Assert.assertEquals("clicksdb", storage.getDatabase());
- Assert.assertEquals("clicks", storage.getTable());
- Assert.assertEquals(Storage.TYPE.TABLE, storage.getType());
- Assert.assertEquals(2, storage.getPartitions().size());
- Assert.assertEquals("us", storage.getPartitionValue("region"));
- Assert.assertTrue(storage.hasPartition("region"));
- Assert.assertNull(storage.getPartitionValue("unknown"));
- Assert.assertFalse(storage.hasPartition("unknown"));
- Assert.assertEquals(storage.getDatedPartitionKeys().get(0), "ds");
- }
-
- @Test
- public void testParseFeedUriValid2() throws URISyntaxException {
- String table = "catalog:clicksdb:clicks#ds=${YEAR}${MONTH}${DAY};region=us";
- CatalogStorage storage = new CatalogStorage(CatalogStorage.CATALOG_URL, table);
- Assert.assertEquals("${hcatNode}", storage.getCatalogUrl());
- Assert.assertEquals("clicksdb", storage.getDatabase());
- Assert.assertEquals("clicks", storage.getTable());
- Assert.assertEquals(Storage.TYPE.TABLE, storage.getType());
- Assert.assertEquals(2, storage.getPartitions().size());
- Assert.assertEquals("us", storage.getPartitionValue("region"));
- Assert.assertTrue(storage.hasPartition("region"));
- Assert.assertNull(storage.getPartitionValue("unknown"));
- Assert.assertFalse(storage.hasPartition("unknown"));
- Assert.assertEquals(storage.getDatedPartitionKeys().get(0), "ds");
- }
-
- @Test
- public void testCreateFromUriTemplate() throws Exception {
- String uriTemplate = "thrift://localhost:49083/clicksdb/clicks/region=us;ds=${YEAR}-${MONTH}-${DAY}";
- CatalogStorage storage = new CatalogStorage(uriTemplate);
- Assert.assertEquals("thrift://localhost:49083", storage.getCatalogUrl());
- Assert.assertEquals("clicksdb", storage.getDatabase());
- Assert.assertEquals("clicks", storage.getTable());
- Assert.assertEquals(Storage.TYPE.TABLE, storage.getType());
- Assert.assertEquals(2, storage.getPartitions().size());
- Assert.assertEquals("us", storage.getPartitionValue("region"));
- Assert.assertTrue(storage.hasPartition("region"));
- Assert.assertNull(storage.getPartitionValue("unknown"));
- Assert.assertFalse(storage.hasPartition("unknown"));
- }
-
- @DataProvider(name = "invalidFeedURITemplates")
- public Object[][] createInValidFeedUriTemplates() {
- return new Object[][] {
- {"thrift://localhost:49083/clicksdb/clicks/region=us;ds=${YEAR}/${MONTH}/${DAY}"},
- {"thrift://localhost:49083/clicksdb/clicks/region=us;ds=${YEAR}/${MONTH}-${DAY}"},
- };
- }
-
- @Test(dataProvider = "invalidFeedURITemplates", expectedExceptions = URISyntaxException.class)
- public void testParseInvalidFeedUriTemplate(String uriTemplate) throws URISyntaxException {
- new CatalogStorage(uriTemplate);
- Assert.fail("Exception must have been thrown");
- }
-
- @DataProvider(name = "invalidFeedURIs")
- public Object[][] createFeedUriInvalid() {
- return new Object[][] {
- {"catalog:default:clicks:ds=${YEAR}-${MONTH}-${DAY}#region=us"},
- {"default:clicks:ds=${YEAR}-${MONTH}-${DAY}#region=us"},
- {"catalog:default#ds=${YEAR}-${MONTH}-${DAY};region=us"},
- {"catalog://default/clicks#ds=${YEAR}-${MONTH}-${DAY}:region=us"},
- };
- }
-
- @Test(dataProvider = "invalidFeedURIs", expectedExceptions = URISyntaxException.class)
- public void testParseFeedUriInvalid(String tableUri) throws URISyntaxException {
- new CatalogStorage(CatalogStorage.CATALOG_URL, tableUri);
- Assert.fail("Exception must have been thrown");
- }
-
- @Test
- public void testIsIdenticalPositive() throws Exception {
- CatalogStorage table1 = new CatalogStorage(CatalogStorage.CATALOG_URL,
- "catalog:clicksdb:clicks#ds=${YEAR}-${MONTH}-${DAY};region=us");
- CatalogStorage table2 = new CatalogStorage(CatalogStorage.CATALOG_URL,
- "catalog:clicksdb:clicks#ds=${YEAR}-${MONTH}-${DAY};region=us");
- Assert.assertTrue(table1.isIdentical(table2));
-
- final String catalogUrl = "thrift://localhost:49083";
- CatalogStorage table3 = new CatalogStorage(catalogUrl,
- "catalog:clicksdb:clicks#ds=${YEAR}-${MONTH}-${DAY};region=us");
- CatalogStorage table4 = new CatalogStorage(catalogUrl,
- "catalog:clicksdb:clicks#ds=${YEAR}-${MONTH}-${DAY};region=us");
- Assert.assertTrue(table3.isIdentical(table4));
- }
-
- @Test
- public void testIsIdenticalNegative() throws Exception {
- CatalogStorage table1 = new CatalogStorage(CatalogStorage.CATALOG_URL,
- "catalog:clicksdb:clicks#ds=${YEAR}-${MONTH}-${DAY};region=us");
- CatalogStorage table2 = new CatalogStorage(CatalogStorage.CATALOG_URL,
- "catalog:clicksdb:impressions#ds=${YEAR}-${MONTH}-${DAY};region=us");
- Assert.assertFalse(table1.isIdentical(table2));
-
- final String catalogUrl = "thrift://localhost:49083";
- CatalogStorage table3 = new CatalogStorage(catalogUrl,
- "catalog:clicksdb:clicks#ds=${YEAR}-${MONTH}-${DAY};region=us");
- CatalogStorage table4 = new CatalogStorage(catalogUrl,
- "catalog:clicksdb:impressions#ds=${YEAR}-${MONTH}-${DAY};region=us");
- Assert.assertFalse(table3.isIdentical(table4));
-
- CatalogStorage table5 = new CatalogStorage("thrift://localhost:49084",
- "catalog:clicksdb:clicks#ds=${YEAR}-${MONTH}-${DAY};region=us");
- CatalogStorage table6 = new CatalogStorage("thrift://localhost:49083",
- "catalog:clicksdb:clicks#ds=${YEAR}-${MONTH}-${DAY};region=us");
- Assert.assertFalse(table5.isIdentical(table6));
- }
-
- @Test
- public void testGetUriTemplateWithCatalogUrl() throws Exception {
- final String catalogUrl = "thrift://localhost:49083";
- String tableUri = "catalog:clicksdb:clicks#ds=${YEAR}-${MONTH}-${DAY};region=us";
- String uriTemplate = "thrift://localhost:49083/clicksdb/clicks/ds=${YEAR}-${MONTH}-${DAY};region=us";
-
- CatalogStorage table = new CatalogStorage(catalogUrl, tableUri);
-
- Assert.assertEquals(uriTemplate, table.getUriTemplate());
- Assert.assertEquals(uriTemplate, table.getUriTemplate(LocationType.DATA));
- Assert.assertEquals(table.getUriTemplate(), table.getUriTemplate(LocationType.DATA));
- }
-
- @Test
- public void testGetUriTemplateWithOutCatalogUrl() throws Exception {
- String tableUri = "catalog:clicksdb:clicks#ds=${YEAR}-${MONTH}-${DAY};region=us";
- String uriTemplate = "${hcatNode}/clicksdb/clicks/ds=${YEAR}-${MONTH}-${DAY};region=us";
-
- CatalogStorage table = new CatalogStorage(CatalogStorage.CATALOG_URL, tableUri);
-
- Assert.assertEquals(uriTemplate, table.getUriTemplate());
- Assert.assertEquals(uriTemplate, table.getUriTemplate(LocationType.DATA));
- Assert.assertEquals(table.getUriTemplate(), table.getUriTemplate(LocationType.DATA));
- }
-
- @Test
- public void testToPartitionFilter() throws Exception {
- final String catalogUrl = "thrift://localhost:49083";
- String tableUri = "catalog:clicksdb:clicks#ds=20130918;region=us";
- String partitionFilter = "(ds='20130918';region='us')";
-
- CatalogStorage table = new CatalogStorage(catalogUrl, tableUri);
- Assert.assertEquals(table.toPartitionFilter(), partitionFilter);
- }
-
- @Test
- public void testToPartitionAsPath() throws Exception {
- final String catalogUrl = "thrift://localhost:49083";
- String tableUri = "catalog:clicksdb:clicks#ds=20130918;region=us";
- String partitionPath = "ds=20130918/region=us";
-
- CatalogStorage table = new CatalogStorage(catalogUrl, tableUri);
- Assert.assertEquals(table.toPartitionAsPath(), partitionPath);
- }
-
- @Test
- public void testCreateFromURL() throws Exception {
- String url = "thrift://localhost:29083/falcon_db/output_table/ds=2012-04-21-00";
- CatalogStorage storage = new CatalogStorage(url);
- Assert.assertEquals("thrift://localhost:29083", storage.getCatalogUrl());
- Assert.assertEquals("falcon_db", storage.getDatabase());
- Assert.assertEquals("output_table", storage.getTable());
- Assert.assertEquals(Storage.TYPE.TABLE, storage.getType());
- Assert.assertEquals(1, storage.getPartitions().size());
- Assert.assertEquals("2012-04-21-00", storage.getPartitionValue("ds"));
- Assert.assertTrue(storage.hasPartition("ds"));
- }
-}
http://git-wip-us.apache.org/repos/asf/falcon/blob/8e49379d/common/src/test/java/org/apache/falcon/entity/ColoClusterRelationTest.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/falcon/entity/ColoClusterRelationTest.java b/common/src/test/java/org/apache/falcon/entity/ColoClusterRelationTest.java
deleted file mode 100644
index 0d6e754..0000000
--- a/common/src/test/java/org/apache/falcon/entity/ColoClusterRelationTest.java
+++ /dev/null
@@ -1,73 +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.falcon.entity;
-
-import org.apache.falcon.entity.v0.EntityType;
-import org.apache.falcon.entity.v0.cluster.Cluster;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import java.util.Set;
-
-/**
- * Tests for validating relationship between cluster to data center/co-location.
- */
-@Test
-public class ColoClusterRelationTest extends AbstractTestBase {
-
- private Cluster newCluster(String name, String colo) {
- Cluster cluster = new Cluster();
- cluster.setName(name);
- cluster.setColo(colo);
- return cluster;
- }
-
- @Test
- public void testMapping() throws Exception {
- Cluster cluster1 = newCluster("cluster1", "colo1");
- Cluster cluster2 = newCluster("cluster2", "colo1");
- Cluster cluster3 = newCluster("cluster3", "colo2");
- getStore().publish(EntityType.CLUSTER, cluster1);
- getStore().publish(EntityType.CLUSTER, cluster2);
- getStore().publish(EntityType.CLUSTER, cluster3);
-
- ColoClusterRelation relation = ColoClusterRelation.get();
- Set<String> clusters = relation.getClusters("colo1");
- Assert.assertNotNull(clusters);
- Assert.assertEquals(2, clusters.size());
- Assert.assertTrue(clusters.contains(cluster1.getName()));
- Assert.assertTrue(clusters.contains(cluster2.getName()));
-
- clusters = relation.getClusters("colo2");
- Assert.assertNotNull(clusters);
- Assert.assertEquals(1, clusters.size());
- Assert.assertTrue(clusters.contains(cluster3.getName()));
-
- getStore().remove(EntityType.CLUSTER, cluster1.getName());
- clusters = relation.getClusters("colo1");
- Assert.assertNotNull(clusters);
- Assert.assertEquals(1, clusters.size());
- Assert.assertTrue(clusters.contains(cluster2.getName()));
-
- getStore().remove(EntityType.CLUSTER, cluster2.getName());
- clusters = relation.getClusters("colo1");
- Assert.assertNotNull(clusters);
- Assert.assertEquals(0, clusters.size());
- }
-}
http://git-wip-us.apache.org/repos/asf/falcon/blob/8e49379d/common/src/test/java/org/apache/falcon/entity/EntityTypeTest.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/falcon/entity/EntityTypeTest.java b/common/src/test/java/org/apache/falcon/entity/EntityTypeTest.java
deleted file mode 100644
index 5a4d6ec..0000000
--- a/common/src/test/java/org/apache/falcon/entity/EntityTypeTest.java
+++ /dev/null
@@ -1,60 +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.falcon.entity;
-
-import org.apache.falcon.entity.v0.EntityType;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-/**
- * Test for validating entity types.
- */
-public class EntityTypeTest {
-
- @Test
- public void testGetEntityClass() {
- Assert.assertEquals(EntityType.PROCESS.getEntityClass().getName(),
- "org.apache.falcon.entity.v0.process.Process");
- }
-
- @Test
- public void testIsSchedulable() {
- Assert.assertTrue(EntityType.PROCESS.isSchedulable());
- Assert.assertTrue(EntityType.FEED.isSchedulable());
- Assert.assertFalse(EntityType.CLUSTER.isSchedulable());
- Assert.assertFalse(EntityType.DATASOURCE.isSchedulable());
- }
-
- @Test
- public void testValidEntityTypes() {
- Assert.assertEquals(EntityType.FEED, EntityType.getEnum("feed"));
- Assert.assertEquals(EntityType.FEED, EntityType.getEnum("FeEd"));
- Assert.assertEquals(EntityType.CLUSTER, EntityType.getEnum("cluster"));
- Assert.assertEquals(EntityType.CLUSTER, EntityType.getEnum("cluSTER"));
- Assert.assertEquals(EntityType.PROCESS, EntityType.getEnum("process"));
- Assert.assertEquals(EntityType.PROCESS, EntityType.getEnum("pRocess"));
- Assert.assertEquals(EntityType.DATASOURCE, EntityType.getEnum("datasource"));
- Assert.assertEquals(EntityType.DATASOURCE, EntityType.getEnum("dataSource"));
- }
-
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void testInvalidEntityTypes() throws Exception {
- EntityType.getEnum("invalid");
- }
-}
http://git-wip-us.apache.org/repos/asf/falcon/blob/8e49379d/common/src/test/java/org/apache/falcon/entity/EntityUtilTest.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/falcon/entity/EntityUtilTest.java b/common/src/test/java/org/apache/falcon/entity/EntityUtilTest.java
deleted file mode 100644
index c87449c..0000000
--- a/common/src/test/java/org/apache/falcon/entity/EntityUtilTest.java
+++ /dev/null
@@ -1,453 +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.falcon.entity;
-
-import org.apache.falcon.Pair;
-import org.apache.falcon.FalconException;
-import org.apache.falcon.entity.parser.ClusterEntityParser;
-import org.apache.falcon.entity.parser.EntityParserFactory;
-import org.apache.falcon.entity.parser.ProcessEntityParser;
-import org.apache.falcon.entity.v0.EntityType;
-import org.apache.falcon.entity.v0.Frequency;
-import org.apache.falcon.entity.v0.SchemaHelper;
-import org.apache.falcon.entity.v0.feed.Feed;
-import org.apache.falcon.entity.v0.feed.LateArrival;
-import org.apache.falcon.entity.v0.feed.Property;
-import org.apache.falcon.entity.v0.process.Cluster;
-import org.apache.falcon.entity.v0.process.Process;
-import org.apache.falcon.hadoop.HadoopClientFactory;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.Path;
-import org.testng.Assert;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Map;
-import java.util.Properties;
-import java.util.TimeZone;
-
-/**
- * Test for validating Entity util helper methods.
- */
-public class EntityUtilTest extends AbstractTestBase {
- private static TimeZone tz = TimeZone.getTimeZone("UTC");
-
- @Test
- public void testProcessView() throws Exception {
- Process process = (Process) EntityType.PROCESS.getUnmarshaller().unmarshal(
- getClass().getResourceAsStream(PROCESS_XML));
- Cluster cluster = new Cluster();
- cluster.setName("newCluster");
- cluster.setValidity(process.getClusters().getClusters().get(0).getValidity());
- process.getClusters().getClusters().add(cluster);
- Assert.assertEquals(process.getClusters().getClusters().size(), 2);
- String currentCluster = process.getClusters().getClusters().get(0).getName();
- Process newProcess = EntityUtil.getClusterView(process, currentCluster);
- Assert.assertFalse(EntityUtil.equals(process, newProcess));
- Assert.assertEquals(newProcess.getClusters().getClusters().size(), 1);
- Assert.assertEquals(newProcess.getClusters().getClusters().get(0).getName(), currentCluster);
- }
-
- @Test
- public void testFeedView() throws Exception {
- Feed feed = (Feed) EntityType.FEED.getUnmarshaller().unmarshal(
- getClass().getResourceAsStream(FEED_XML));
- Feed view = EntityUtil.getClusterView(feed, "testCluster");
- Assert.assertEquals(view.getClusters().getClusters().size(), 1);
- Assert.assertEquals(view.getClusters().getClusters().get(0).getName(), "testCluster");
-
- view = EntityUtil.getClusterView(feed, "backupCluster");
- Assert.assertEquals(view.getClusters().getClusters().size(), 2);
- }
-
- @Test
- public void testEquals() throws Exception {
- Process process1 = (Process) EntityType.PROCESS.getUnmarshaller().unmarshal(
- getClass().getResourceAsStream(PROCESS_XML));
- Process process2 = (Process) EntityType.PROCESS.getUnmarshaller().unmarshal(
- getClass().getResourceAsStream(PROCESS_XML));
- Assert.assertTrue(EntityUtil.equals(process1, process2));
- Assert.assertTrue(EntityUtil.md5(process1).equals(EntityUtil.md5(process2)));
-
- process2.getClusters().getClusters().get(0).getValidity().setEnd(
- SchemaHelper.parseDateUTC("2013-04-21T00:00Z"));
- Assert.assertFalse(EntityUtil.equals(process1, process2));
- Assert.assertFalse(EntityUtil.md5(process1).equals(EntityUtil.md5(process2)));
- Assert.assertTrue(EntityUtil.equals(process1, process2, new String[]{"clusters.clusters[\\d+].validity.end"}));
- }
-
- private static Date getDate(String date) throws Exception {
- DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm Z");
- return format.parse(date);
- }
-
- @Test
- public void testGetNextStartTime() throws Exception {
- Date now = getDate("2012-04-03 02:45 UTC");
- Date start = getDate("2012-04-02 03:00 UTC");
- Date newStart = getDate("2012-04-03 03:00 UTC");
-
- Frequency frequency = new Frequency("hours(1)");
- Assert.assertEquals(newStart, EntityUtil.getNextStartTime(start,
- frequency, tz, now));
- }
-
- @Test
- public void testgetNextStartTimeOld() throws Exception {
- Date now = getDate("2012-05-02 02:45 UTC");
- Date start = getDate("2012-02-01 03:00 UTC");
- Date newStart = getDate("2012-05-02 03:00 UTC");
-
- Frequency frequency = new Frequency("days(7)");
- Assert.assertEquals(newStart, EntityUtil.getNextStartTime(start,
- frequency, tz, now));
- }
-
- @Test
- public void testGetNextStartTime2() throws Exception {
- Date now = getDate("2010-05-02 04:45 UTC");
- Date start = getDate("2010-02-01 03:00 UTC");
- Date newStart = getDate("2010-05-03 03:00 UTC");
-
- Frequency frequency = new Frequency("days(7)");
- Assert.assertEquals(newStart, EntityUtil.getNextStartTime(start,
- frequency, tz, now));
- }
-
- @Test
- public void testGetNextStartTime3() throws Exception {
- Date now = getDate("2010-05-02 04:45 UTC");
- Date start = getDate("1980-02-01 03:00 UTC");
- Date newStart = getDate("2010-05-07 03:00 UTC");
-
- Frequency frequency = new Frequency("days(7)");
- Assert.assertEquals(newStart, EntityUtil.getNextStartTime(start,
- frequency, tz, now));
- }
-
-
- @Test
- public void testGetInstanceSequence() throws Exception {
- Date instance = getDate("2012-05-22 13:40 UTC");
- Date start = getDate("2012-05-14 07:40 UTC");
-
- Frequency frequency = new Frequency("hours(1)");
- Assert.assertEquals(199, EntityUtil.getInstanceSequence(start,
- frequency, tz, instance));
- }
-
- @Test
- public void testGetInstanceSequence1() throws Exception {
- Date instance = getDate("2012-05-22 12:40 UTC");
- Date start = getDate("2012-05-14 07:40 UTC");
-
- Frequency frequency = Frequency.fromString("hours(1)");
- Assert.assertEquals(198, EntityUtil.getInstanceSequence(start,
- frequency, tz, instance));
- }
-
- @Test
- public void testGetInstanceSequence2() throws Exception {
- Date instance = getDate("2012-05-22 12:41 UTC");
- Date start = getDate("2012-05-14 07:40 UTC");
-
- Frequency frequency = Frequency.fromString("hours(1)");
- Assert.assertEquals(199, EntityUtil.getInstanceSequence(start,
- frequency, tz, instance));
- }
-
- @Test
- public void testGetInstanceSequence3() throws Exception {
- Date instance = getDate("2010-01-02 01:01 UTC");
- Date start = getDate("2010-01-02 01:00 UTC");
-
- Frequency frequency = Frequency.fromString("minutes(1)");
- Assert.assertEquals(2, EntityUtil.getInstanceSequence(start,
- frequency, tz, instance));
- }
-
- @Test
- public void testGetInstanceSequence4() throws Exception {
- Date instance = getDate("2010-01-01 01:03 UTC");
- Date start = getDate("2010-01-01 01:01 UTC");
-
- Frequency frequency = Frequency.fromString("minutes(2)");
- Assert.assertEquals(2, EntityUtil.getInstanceSequence(start,
- frequency, tz, instance));
- }
-
- @Test
- public void testGetInstanceSequence5() throws Exception {
- Date instance = getDate("2010-01-01 02:01 UTC");
- Date start = getDate("2010-01-01 01:01 UTC");
-
- Frequency frequency = Frequency.fromString("hours(1)");
- Assert.assertEquals(2, EntityUtil.getInstanceSequence(start,
- frequency, tz, instance));
- }
-
- @Test
- public void testGetInstanceSequence6() throws Exception {
- Date instance = getDate("2010-01-01 01:04 UTC");
- Date start = getDate("2010-01-01 01:01 UTC");
-
- Frequency frequency = Frequency.fromString("minutes(3)");
- Assert.assertEquals(2, EntityUtil.getInstanceSequence(start,
- frequency, tz, instance));
- }
-
- @Test
- public void testGetInstanceSequence7() throws Exception {
- Date instance = getDate("2010-01-01 01:03 UTC");
- Date start = getDate("2010-01-01 01:01 UTC");
-
- Frequency frequency = Frequency.fromString("minutes(1)");
- Assert.assertEquals(3, EntityUtil.getInstanceSequence(start,
- frequency, tz, instance));
- }
-
- @Test
- public void testGetNextStartTimeMonthly() throws Exception {
- Date startDate = getDate("2012-06-02 10:00 UTC");
- Date nextAfter = getDate("2136-06-02 10:00 UTC");
- Frequency frequency = Frequency.fromString("months(1)");
- Date expectedResult = nextAfter;
- Date result = EntityUtil.getNextStartTime(startDate, frequency, tz, nextAfter);
- Assert.assertEquals(result, expectedResult);
- }
-
- @Test
- public void testGetEntityStartEndDates() throws Exception {
- Process process = (Process) EntityType.PROCESS.getUnmarshaller().unmarshal(
- getClass().getResourceAsStream(PROCESS_XML));
-
- Cluster cluster = new Cluster();
- cluster.setName("testCluster");
- cluster.setValidity(process.getClusters().getClusters().get(0).getValidity());
-
- process.getClusters().getClusters().add(cluster);
-
- Date expectedStartDate = new SimpleDateFormat("yyyy-MM-dd z").parse("2011-11-02 UTC");
- Date expectedEndDate = new SimpleDateFormat("yyyy-MM-dd z").parse("2091-12-30 UTC");
-
- Pair<Date, Date> startEndDates = EntityUtil.getEntityStartEndDates(process);
- Assert.assertEquals(startEndDates.first, expectedStartDate);
- Assert.assertEquals(startEndDates.second, expectedEndDate);
- }
-
- @Test
- public void testGetFeedProperties() {
- Feed feed = new Feed();
- org.apache.falcon.entity.v0.feed.Properties props = new org.apache.falcon.entity.v0.feed.Properties();
- Property queue = new Property();
- String name = "Q";
- String value = "head of Q division!";
- queue.setName(name);
- queue.setValue(value);
- props.getProperties().add(queue);
- feed.setProperties(props);
- Properties actual = EntityUtil.getEntityProperties(feed);
- Assert.assertEquals(actual.size(), 1);
- Assert.assertEquals(actual.getProperty(name), value);
- }
-
- @Test
- public void testGetProcessProperties() {
- org.apache.falcon.entity.v0.cluster.Cluster cluster = new org.apache.falcon.entity.v0.cluster.Cluster();
- org.apache.falcon.entity.v0.cluster.Properties props = new org.apache.falcon.entity.v0.cluster.Properties();
- org.apache.falcon.entity.v0.cluster.Property priority = new org.apache.falcon.entity.v0.cluster.Property();
- String name = "priority";
- String value = "Sister of Moriarity!";
- priority.setName(name);
- priority.setValue(value);
- props.getProperties().add(priority);
- cluster.setProperties(props);
- Properties actual = EntityUtil.getEntityProperties(cluster);
- Assert.assertEquals(actual.size(), 1);
- Assert.assertEquals(actual.getProperty(name), value);
- }
-
- @Test
- public void testGetClusterProperties() {
- Process process = new Process();
- org.apache.falcon.entity.v0.process.Properties props = new org.apache.falcon.entity.v0.process.Properties();
- org.apache.falcon.entity.v0.process.Property priority = new org.apache.falcon.entity.v0.process.Property();
- String name = "M";
- String value = "Minions!";
- priority.setName(name);
- priority.setValue(value);
- props.getProperties().add(priority);
- process.setProperties(props);
- Properties actual = EntityUtil.getEntityProperties(process);
- Assert.assertEquals(actual.size(), 1);
- Assert.assertEquals(actual.getProperty(name), value);
-
- }
-
- @Test
- public void testGetLateProcessFeed() throws FalconException {
- Feed feed = new Feed();
-
- Assert.assertNull(EntityUtil.getLateProcess(feed));
- LateArrival lateArrival = new LateArrival();
- lateArrival.setCutOff(Frequency.fromString("days(1)"));
- feed.setLateArrival(lateArrival);
- Assert.assertNotNull(EntityUtil.getLateProcess(feed));
- }
-
- @Test(dataProvider = "NextInstanceExpressions")
- public void testGetNextInstances(String instanceTimeStr, String frequencyStr, int instanceIncrementCount,
- String expectedInstanceTimeStr) throws Exception {
-
- Date instanceTime = getDate(instanceTimeStr);
- Frequency frequency = Frequency.fromString(frequencyStr);
-
- Date nextInstanceTime = EntityUtil.getNextInstanceTime(instanceTime, frequency, tz, instanceIncrementCount);
-
- Assert.assertEquals(nextInstanceTime, getDate(expectedInstanceTimeStr));
-
- }
-
- @DataProvider(name = "NextInstanceExpressions")
- public Object[][] nextInstanceExpressions() throws ParseException {
- String instanceTimeStr = "2014-01-01 00:00 UTC";
- return new Object[][] {
- {instanceTimeStr, "minutes(1)", 1, "2014-01-01 00:01 UTC"},
- {instanceTimeStr, "minutes(1)", 25, "2014-01-01 00:25 UTC"},
-
- {instanceTimeStr, "hours(1)", 1, "2014-01-01 01:00 UTC"},
- {instanceTimeStr, "hours(1)", 5, "2014-01-01 05:00 UTC"},
-
- {instanceTimeStr, "days(1)", 1, "2014-01-02 00:00 UTC"},
- {instanceTimeStr, "days(1)", 10, "2014-01-11 00:00 UTC"},
-
- {instanceTimeStr, "months(1)", 1, "2014-02-01 00:00 UTC"},
- {instanceTimeStr, "months(1)", 7, "2014-08-01 00:00 UTC"},
- };
- }
-
- @Test(dataProvider = "bundlePaths")
- public void testIsStagingPath(Path path, boolean createPath, boolean expected) throws Exception {
- ClusterEntityParser parser = (ClusterEntityParser) EntityParserFactory.getParser(EntityType.CLUSTER);
- InputStream stream = this.getClass().getResourceAsStream(CLUSTER_XML);
- org.apache.falcon.entity.v0.cluster.Cluster cluster = parser.parse(stream);
-
- ProcessEntityParser processParser = (ProcessEntityParser) EntityParserFactory.getParser(EntityType.PROCESS);
- stream = this.getClass().getResourceAsStream(PROCESS_XML);
- Process process = processParser.parse(stream);
-
- FileSystem fs = HadoopClientFactory.get().
- createFalconFileSystem(ClusterHelper.getConfiguration(cluster));
- if (createPath && !fs.exists(path)) {
- fs.create(path);
- }
-
- Assert.assertEquals(EntityUtil.isStagingPath(cluster, process, path), expected);
- }
-
- @DataProvider(name = "bundlePaths")
- public Object[][] getBundlePaths() {
- return new Object[][] {
- {new Path("/projects/falcon/staging/ivory/workflows/process/sample/"), true, true},
- {new Path("/projects/falcon/staging/falcon/workflows/process/sample/"), true, true},
- {new Path("/projects/abc/falcon/workflows/process/sample/"), true, false},
- {new Path("/projects/falcon/staging/falcon/workflows/process/test-process/"), false, false},
- {new Path("/projects/falcon/staging/falcon/workflows/process/test-process/"), true, false},
- };
- }
-
- @Test
- public void testStringToProps() {
- String testPropsString = "key1:value1,key2 : value2 , key3: value3, key4:value4:test";
- Map<String, String> props = EntityUtil.getPropertyMap(testPropsString);
- Assert.assertEquals(props.size(), 4);
- for (int i = 1; i <= 3; i++) {
- Assert.assertEquals(props.get("key" + i), "value" + i);
- }
- Assert.assertEquals(props.get("key4"), "value4:test");
- }
-
- @Test (expectedExceptions = IllegalArgumentException.class,
- expectedExceptionsMessageRegExp = "Found invalid property .*",
- dataProvider = "InvalidProps")
- public void testInvalidStringToProps(String propString) {
- String[] invalidProps = {"key1", "key1=value1", "key1:value1,key2=value2, :value"};
- EntityUtil.getPropertyMap(propString);
- }
-
- @DataProvider(name = "InvalidProps")
- public Object[][] getInvalidProps() {
- return new Object[][]{
- {"key1"},
- {"key1=value1"},
- {"key1:value1,key2=value2"},
- {":value"},
- };
- }
-
- @Test
- public void testGetLatestStagingPath() throws FalconException, IOException {
- ClusterEntityParser parser = (ClusterEntityParser) EntityParserFactory.getParser(EntityType.CLUSTER);
- InputStream stream = this.getClass().getResourceAsStream(CLUSTER_XML);
- org.apache.falcon.entity.v0.cluster.Cluster cluster = parser.parse(stream);
-
- ProcessEntityParser processParser = (ProcessEntityParser) EntityParserFactory.getParser(EntityType.PROCESS);
- stream = this.getClass().getResourceAsStream(PROCESS_XML);
- Process process = processParser.parse(stream);
- process.setName("staging-test");
-
- String md5 = EntityUtil.md5(EntityUtil.getClusterView(process, "testCluster"));
- FileSystem fs = HadoopClientFactory.get().
- createFalconFileSystem(ClusterHelper.getConfiguration(cluster));
-
- String basePath = "/projects/falcon/staging/falcon/workflows/process/staging-test/";
- Path[] paths = {
- new Path(basePath + "5a8100dc460b44db2e7bfab84b24cb92_1436441045003"),
- new Path(basePath + "6b3a1b6c7cf9de62c78b125415ffb70c_1436504488677"),
- new Path(basePath + md5 + "_1436344303117"),
- new Path(basePath + md5 + "_1436347924846"),
- new Path(basePath + md5 + "_1436357052992"),
- new Path(basePath + "logs"),
- new Path(basePath + "random_dir"),
- };
-
- // Ensure exception is thrown when there are no staging dirs.
- fs.delete(new Path(basePath), true);
- try {
- EntityUtil.getLatestStagingPath(cluster, process);
- Assert.fail("Exception expected");
- } catch (FalconException e) {
- // Do nothing
- }
-
- // Now create paths
- for (Path path : paths) {
- fs.create(path);
- }
-
- // Ensure latest is returned.
- Assert.assertEquals(EntityUtil.getLatestStagingPath(cluster, process).getName(), md5 + "_1436357052992");
- }
-}
http://git-wip-us.apache.org/repos/asf/falcon/blob/8e49379d/common/src/test/java/org/apache/falcon/entity/FeedDataPathTest.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/falcon/entity/FeedDataPathTest.java b/common/src/test/java/org/apache/falcon/entity/FeedDataPathTest.java
deleted file mode 100644
index 4c293bb..0000000
--- a/common/src/test/java/org/apache/falcon/entity/FeedDataPathTest.java
+++ /dev/null
@@ -1,124 +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.falcon.entity;
-
-import org.apache.falcon.entity.common.FeedDataPath;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-/**
- *
- */
-public class FeedDataPathTest {
-
- @Test
- public void testMinutesRegularExpression() {
- String monthPattern = FeedDataPath.VARS.MINUTE.getValuePattern();
- Assert.assertFalse("0".matches(monthPattern));
- Assert.assertFalse("1".matches(monthPattern));
- Assert.assertFalse("61".matches(monthPattern));
- Assert.assertFalse("010".matches(monthPattern));
- Assert.assertFalse("10 ".matches(monthPattern));
- Assert.assertFalse(" 10".matches(monthPattern));
-
-
- Assert.assertTrue("00".matches(monthPattern));
- Assert.assertTrue("01".matches(monthPattern));
- Assert.assertTrue("60".matches(monthPattern));
- }
-
- @Test
- public void testHourRegularExpression() {
- String hourPattern = FeedDataPath.VARS.HOUR.getValuePattern();
- Assert.assertFalse("0".matches(hourPattern));
- Assert.assertFalse("1".matches(hourPattern));
- Assert.assertFalse("2".matches(hourPattern));
- Assert.assertFalse("25".matches(hourPattern));
- Assert.assertFalse("29".matches(hourPattern));
- Assert.assertFalse("010".matches(hourPattern));
- Assert.assertFalse("10 ".matches(hourPattern));
- Assert.assertFalse(" 10".matches(hourPattern));
-
-
- Assert.assertTrue("00".matches(hourPattern));
- Assert.assertTrue("01".matches(hourPattern));
- Assert.assertTrue("24".matches(hourPattern));
- Assert.assertTrue("10".matches(hourPattern));
- Assert.assertTrue("19".matches(hourPattern));
- Assert.assertTrue("12".matches(hourPattern));
- }
-
-
- @Test
- public void testDayRegularExpression() {
- String dayPattern = FeedDataPath.VARS.DAY.getValuePattern();
- Assert.assertFalse("0".matches(dayPattern));
- Assert.assertFalse("1".matches(dayPattern));
- Assert.assertFalse("32".matches(dayPattern));
- Assert.assertFalse("00".matches(dayPattern));
- Assert.assertFalse("010".matches(dayPattern));
- Assert.assertFalse("10 ".matches(dayPattern));
- Assert.assertFalse(" 10".matches(dayPattern));
-
-
- Assert.assertTrue("01".matches(dayPattern));
- Assert.assertTrue("10".matches(dayPattern));
- Assert.assertTrue("29".matches(dayPattern));
- Assert.assertTrue("30".matches(dayPattern));
- Assert.assertTrue("31".matches(dayPattern));
- }
-
- @Test
- public void testMonthRegularExpression() {
- String monthPattern = FeedDataPath.VARS.MONTH.getValuePattern();
- Assert.assertFalse("0".matches(monthPattern));
- Assert.assertFalse("1".matches(monthPattern));
- Assert.assertFalse("13".matches(monthPattern));
- Assert.assertFalse("19".matches(monthPattern));
- Assert.assertFalse("00".matches(monthPattern));
- Assert.assertFalse("010".matches(monthPattern));
- Assert.assertFalse("10 ".matches(monthPattern));
- Assert.assertFalse(" 10".matches(monthPattern));
-
-
- Assert.assertTrue("01".matches(monthPattern));
- Assert.assertTrue("02".matches(monthPattern));
- Assert.assertTrue("10".matches(monthPattern));
- Assert.assertTrue("12".matches(monthPattern));
- }
-
- @Test
- public void testYearRegularExpression() {
- String monthPattern = FeedDataPath.VARS.YEAR.getValuePattern();
- Assert.assertFalse("0".matches(monthPattern));
- Assert.assertFalse("1".matches(monthPattern));
- Assert.assertFalse("13".matches(monthPattern));
- Assert.assertFalse("19".matches(monthPattern));
- Assert.assertFalse("00".matches(monthPattern));
- Assert.assertFalse("010".matches(monthPattern));
- Assert.assertFalse("10 ".matches(monthPattern));
- Assert.assertFalse(" 10".matches(monthPattern));
-
-
- Assert.assertTrue("0001".matches(monthPattern));
- Assert.assertTrue("2014".matches(monthPattern));
- }
-
-
-}