sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject sqoop git commit: SQOOP-2234: Sqoop2: Move DatasetURIValidator to Kite package as it's not generally usable validator
Date Thu, 19 Mar 2015 18:54:52 GMT
Repository: sqoop
Updated Branches:
  refs/heads/sqoop2 9e8636981 -> 251471ffb


SQOOP-2234: Sqoop2: Move DatasetURIValidator to Kite package as it's not generally usable
validator

(Jarek Jarcec Cecho via Abraham Elmahrek)


Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/251471ff
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/251471ff
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/251471ff

Branch: refs/heads/sqoop2
Commit: 251471ffb8038d55484286e1e71524b4348ca666
Parents: 9e86369
Author: Abraham Elmahrek <abe@apache.org>
Authored: Thu Mar 19 11:52:51 2015 -0700
Committer: Abraham Elmahrek <abe@apache.org>
Committed: Thu Mar 19 11:52:51 2015 -0700

----------------------------------------------------------------------
 .../validators/DatasetURIValidator.java         | 49 ------------
 .../kite/configuration/FromJobConfig.java       |  2 +-
 .../kite/configuration/ToJobConfig.java         |  2 +-
 .../kite/validators/DatasetURIValidator.java    | 49 ++++++++++++
 .../validators/TestDatasetURIValidator.java     | 79 ++++++++++++++++++++
 5 files changed, 130 insertions(+), 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/251471ff/common/src/main/java/org/apache/sqoop/validation/validators/DatasetURIValidator.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/validation/validators/DatasetURIValidator.java
b/common/src/main/java/org/apache/sqoop/validation/validators/DatasetURIValidator.java
deleted file mode 100644
index ad298ed..0000000
--- a/common/src/main/java/org/apache/sqoop/validation/validators/DatasetURIValidator.java
+++ /dev/null
@@ -1,49 +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.sqoop.validation.validators;
-
-import com.google.common.base.Strings;
-import org.apache.sqoop.classification.InterfaceAudience;
-import org.apache.sqoop.classification.InterfaceStability;
-import org.apache.sqoop.validation.Status;
-
-import java.util.regex.Pattern;
-
-/**
- * Ensure that given string represents a Kite dataset uri.
- */
-@InterfaceAudience.Public
-@InterfaceStability.Unstable
-public class DatasetURIValidator extends AbstractValidator<String> {
-
-  private static final Pattern DATASET_URI_PATTERN = Pattern
-      .compile("^dataset:(hive|hdfs|file):.*$");
-
-  @Override
-  public void validate(String uri) {
-    if (Strings.isNullOrEmpty(uri)) {
-      addMessage(Status.ERROR, "Cannot be null nor empty");
-      return;
-    }
-
-    if (!DATASET_URI_PATTERN.matcher(uri).matches()) {
-      addMessage(Status.ERROR, "Invalid dataset URI: " + uri);
-    }
-  }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/sqoop/blob/251471ff/connector/connector-kite/src/main/java/org/apache/sqoop/connector/kite/configuration/FromJobConfig.java
----------------------------------------------------------------------
diff --git a/connector/connector-kite/src/main/java/org/apache/sqoop/connector/kite/configuration/FromJobConfig.java
b/connector/connector-kite/src/main/java/org/apache/sqoop/connector/kite/configuration/FromJobConfig.java
index 68a1d7a..98d10a0 100644
--- a/connector/connector-kite/src/main/java/org/apache/sqoop/connector/kite/configuration/FromJobConfig.java
+++ b/connector/connector-kite/src/main/java/org/apache/sqoop/connector/kite/configuration/FromJobConfig.java
@@ -20,7 +20,7 @@ package org.apache.sqoop.connector.kite.configuration;
 import org.apache.sqoop.model.ConfigClass;
 import org.apache.sqoop.model.Input;
 import org.apache.sqoop.model.Validator;
-import org.apache.sqoop.validation.validators.DatasetURIValidator;
+import org.apache.sqoop.connector.kite.validators.DatasetURIValidator;
 
 @ConfigClass
 public class FromJobConfig {

http://git-wip-us.apache.org/repos/asf/sqoop/blob/251471ff/connector/connector-kite/src/main/java/org/apache/sqoop/connector/kite/configuration/ToJobConfig.java
----------------------------------------------------------------------
diff --git a/connector/connector-kite/src/main/java/org/apache/sqoop/connector/kite/configuration/ToJobConfig.java
b/connector/connector-kite/src/main/java/org/apache/sqoop/connector/kite/configuration/ToJobConfig.java
index 07ee8cf..8f00ce7 100644
--- a/connector/connector-kite/src/main/java/org/apache/sqoop/connector/kite/configuration/ToJobConfig.java
+++ b/connector/connector-kite/src/main/java/org/apache/sqoop/connector/kite/configuration/ToJobConfig.java
@@ -21,7 +21,7 @@ import org.apache.sqoop.connector.common.FileFormat;
 import org.apache.sqoop.model.ConfigClass;
 import org.apache.sqoop.model.Input;
 import org.apache.sqoop.model.Validator;
-import org.apache.sqoop.validation.validators.DatasetURIValidator;
+import org.apache.sqoop.connector.kite.validators.DatasetURIValidator;
 import org.apache.sqoop.validation.validators.NotNull;
 
 @ConfigClass

http://git-wip-us.apache.org/repos/asf/sqoop/blob/251471ff/connector/connector-kite/src/main/java/org/apache/sqoop/connector/kite/validators/DatasetURIValidator.java
----------------------------------------------------------------------
diff --git a/connector/connector-kite/src/main/java/org/apache/sqoop/connector/kite/validators/DatasetURIValidator.java
b/connector/connector-kite/src/main/java/org/apache/sqoop/connector/kite/validators/DatasetURIValidator.java
new file mode 100644
index 0000000..e9c26ed
--- /dev/null
+++ b/connector/connector-kite/src/main/java/org/apache/sqoop/connector/kite/validators/DatasetURIValidator.java
@@ -0,0 +1,49 @@
+/**
+ * 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.sqoop.connector.kite.validators;
+
+import com.google.common.base.Strings;
+import org.apache.sqoop.classification.InterfaceAudience;
+import org.apache.sqoop.classification.InterfaceStability;
+import org.apache.sqoop.validation.Status;
+import org.apache.sqoop.validation.validators.AbstractValidator;
+
+import java.util.regex.Pattern;
+
+/**
+ * Ensure that given string represents a Kite dataset uri.
+ */
+@InterfaceAudience.Public
+@InterfaceStability.Unstable
+public class DatasetURIValidator extends AbstractValidator<String> {
+
+  private static final Pattern DATASET_URI_PATTERN = Pattern.compile("^dataset:(hive|hdfs|file):.*$");
+
+  @Override
+  public void validate(String uri) {
+    if (Strings.isNullOrEmpty(uri)) {
+      addMessage(Status.ERROR, "Cannot be null nor empty");
+      return;
+    }
+
+    if (!DATASET_URI_PATTERN.matcher(uri).matches()) {
+      addMessage(Status.ERROR, "Invalid dataset URI: " + uri);
+    }
+  }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/sqoop/blob/251471ff/connector/connector-kite/src/test/java/org/apache/sqoop/connector/kite/validators/TestDatasetURIValidator.java
----------------------------------------------------------------------
diff --git a/connector/connector-kite/src/test/java/org/apache/sqoop/connector/kite/validators/TestDatasetURIValidator.java
b/connector/connector-kite/src/test/java/org/apache/sqoop/connector/kite/validators/TestDatasetURIValidator.java
new file mode 100644
index 0000000..920461e
--- /dev/null
+++ b/connector/connector-kite/src/test/java/org/apache/sqoop/connector/kite/validators/TestDatasetURIValidator.java
@@ -0,0 +1,79 @@
+/**
+ * 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.sqoop.connector.kite.validators;
+
+import org.apache.sqoop.validation.Status;
+import org.apache.sqoop.validation.validators.AbstractValidator;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ */
+public class TestDatasetURIValidator {
+
+  AbstractValidator validator = new DatasetURIValidator();
+
+  @BeforeMethod(alwaysRun = true)
+  public void resetValidator() {
+    validator.reset();
+  }
+
+  @Test
+  public void testNull() {
+    validator.validate(null);
+    assertEquals(validator.getStatus(), Status.ERROR);
+    assertEquals(validator.getMessages().size(), 1);
+  }
+
+  @Test
+  public void testEmpty() {
+    validator.validate("");
+    assertEquals(validator.getStatus(), Status.ERROR);
+    assertEquals(validator.getMessages().size(), 1);
+  }
+
+  @Test
+  public void testRandomString() {
+    validator.validate("!@#$%");
+    assertEquals(validator.getStatus(), Status.ERROR);
+    assertEquals(validator.getMessages().size(), 1);
+  }
+
+  @Test
+  public void testHdfsDataset() {
+    validator.validate("dataset:hive:");
+    assertEquals(validator.getStatus(), Status.OK);
+    assertEquals(validator.getMessages().size(), 0);
+  }
+
+  @Test
+  public void testHiveDataset() {
+    validator.validate("dataset:hive:");
+    assertEquals(validator.getStatus(), Status.OK);
+    assertEquals(validator.getMessages().size(), 0);
+  }
+
+  @Test
+  public void testFileDataset() {
+    validator.validate("dataset:file:");
+    assertEquals(validator.getStatus(), Status.OK);
+    assertEquals(validator.getMessages().size(), 0);
+  }
+}


Mime
View raw message