Repository: hive
Updated Branches:
  refs/heads/master 42581930e -> 2218bd279


http://git-wip-us.apache.org/repos/asf/hive/blob/3681b859/ql/src/test/org/apache/hadoop/hive/ql/exec/repl/bootstrap/load/TestTaskTracker.java
----------------------------------------------------------------------
diff --git 
a/ql/src/test/org/apache/hadoop/hive/ql/exec/repl/bootstrap/load/TestTaskTracker.java
 
b/ql/src/test/org/apache/hadoop/hive/ql/exec/repl/bootstrap/load/TestTaskTracker.java
new file mode 100644
index 0000000..ac2db80
--- /dev/null
+++ 
b/ql/src/test/org/apache/hadoop/hive/ql/exec/repl/bootstrap/load/TestTaskTracker.java
@@ -0,0 +1,46 @@
+/**
+ * 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.hadoop.hive.ql.exec.repl.bootstrap.load;
+
+import org.apache.hadoop.hive.ql.exec.Task;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import java.io.Serializable;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+@RunWith(PowerMockRunner.class)
+  public class TestTaskTracker {
+  @Mock
+  private Task<? extends Serializable> task;
+
+  @Test
+  public void taskTrackerCompositionInitializesTheMaxTasksCorrectly() {
+    TaskTracker taskTracker = new TaskTracker(1);
+    assertTrue(taskTracker.canAddMoreTasks());
+    taskTracker.addTask(task);
+    assertFalse(taskTracker.canAddMoreTasks());
+
+    TaskTracker taskTracker2 = new TaskTracker(taskTracker);
+    assertFalse(taskTracker2.canAddMoreTasks());
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/hive/blob/3681b859/ql/src/test/org/apache/hadoop/hive/ql/exec/tez/InputSplitComparatorTest.java
----------------------------------------------------------------------
diff --git 
a/ql/src/test/org/apache/hadoop/hive/ql/exec/tez/InputSplitComparatorTest.java 
b/ql/src/test/org/apache/hadoop/hive/ql/exec/tez/InputSplitComparatorTest.java
deleted file mode 100644
index add65ae..0000000
--- 
a/ql/src/test/org/apache/hadoop/hive/ql/exec/tez/InputSplitComparatorTest.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 org.apache.hadoop.hive.ql.exec.tez;
-
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.mapred.FileSplit;
-import org.junit.Test;
-
-import static 
org.apache.hadoop.hive.ql.exec.tez.HiveSplitGenerator.InputSplitComparator;
-import static org.junit.Assert.assertEquals;
-
-public class InputSplitComparatorTest {
-
-  private static final String[] EMPTY = new String[]{};
-
-  @Test
-  public void testCompare1() throws Exception {
-    FileSplit split1 = new FileSplit(new Path("/abc/def"), 2000L, 500L, EMPTY);
-    FileSplit split2 = new FileSplit(new Path("/abc/def"), 1000L, 500L, EMPTY);
-    InputSplitComparator comparator = new InputSplitComparator();
-    assertEquals(1, comparator.compare(split1, split2));
-  }
-}

http://git-wip-us.apache.org/repos/asf/hive/blob/3681b859/ql/src/test/org/apache/hadoop/hive/ql/exec/tez/TestInputSplitComparator.java
----------------------------------------------------------------------
diff --git 
a/ql/src/test/org/apache/hadoop/hive/ql/exec/tez/TestInputSplitComparator.java 
b/ql/src/test/org/apache/hadoop/hive/ql/exec/tez/TestInputSplitComparator.java
new file mode 100644
index 0000000..f1c1885
--- /dev/null
+++ 
b/ql/src/test/org/apache/hadoop/hive/ql/exec/tez/TestInputSplitComparator.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.hadoop.hive.ql.exec.tez;
+
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.mapred.FileSplit;
+import org.junit.Test;
+
+import static 
org.apache.hadoop.hive.ql.exec.tez.HiveSplitGenerator.InputSplitComparator;
+import static org.junit.Assert.assertEquals;
+
+public class TestInputSplitComparator {
+
+  private static final String[] EMPTY = new String[]{};
+
+  @Test
+  public void testCompare1() throws Exception {
+    FileSplit split1 = new FileSplit(new Path("/abc/def"), 2000L, 500L, EMPTY);
+    FileSplit split2 = new FileSplit(new Path("/abc/def"), 1000L, 500L, EMPTY);
+    InputSplitComparator comparator = new InputSplitComparator();
+    assertEquals(1, comparator.compare(split1, split2));
+  }
+}

http://git-wip-us.apache.org/repos/asf/hive/blob/3681b859/ql/src/test/org/apache/hadoop/hive/ql/parse/repl/CopyUtilsTest.java
----------------------------------------------------------------------
diff --git 
a/ql/src/test/org/apache/hadoop/hive/ql/parse/repl/CopyUtilsTest.java 
b/ql/src/test/org/apache/hadoop/hive/ql/parse/repl/CopyUtilsTest.java
deleted file mode 100644
index e643d8f..0000000
--- a/ql/src/test/org/apache/hadoop/hive/ql/parse/repl/CopyUtilsTest.java
+++ /dev/null
@@ -1,47 +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.hadoop.hive.ql.parse.repl;
-
-import org.apache.hadoop.hive.conf.HiveConf;
-import org.junit.Test;
-
-import static org.junit.Assert.assertFalse;
-
-public class CopyUtilsTest {
-  /*
-  Distcp currently does not copy a single file in a distributed manner hence 
we dont care about
-  the size of file, if there is only file, we dont want to launch distcp.
-   */
-  @Test
-  public void distcpShouldNotBeCalledOnlyForOneFile() {
-    HiveConf conf = new HiveConf();
-    conf.setLongVar(HiveConf.ConfVars.HIVE_EXEC_COPYFILE_MAXSIZE, 1);
-    CopyUtils copyUtils = new CopyUtils("", conf);
-    long MB_128 = 128 * 1024 * 1024;
-    assertFalse(copyUtils.limitReachedForLocalCopy(MB_128, 1L));
-  }
-
-  @Test
-  public void distcpShouldNotBeCalledForSmallerFileSize() {
-    HiveConf conf = new HiveConf();
-    CopyUtils copyUtils = new CopyUtils("", conf);
-    long MB_16 = 16 * 1024 * 1024;
-    assertFalse(copyUtils.limitReachedForLocalCopy(MB_16, 100L));
-  }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/hive/blob/3681b859/ql/src/test/org/apache/hadoop/hive/ql/parse/repl/TestCopyUtils.java
----------------------------------------------------------------------
diff --git 
a/ql/src/test/org/apache/hadoop/hive/ql/parse/repl/TestCopyUtils.java 
b/ql/src/test/org/apache/hadoop/hive/ql/parse/repl/TestCopyUtils.java
new file mode 100644
index 0000000..a203afc
--- /dev/null
+++ b/ql/src/test/org/apache/hadoop/hive/ql/parse/repl/TestCopyUtils.java
@@ -0,0 +1,47 @@
+/**
+ * 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.hadoop.hive.ql.parse.repl;
+
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+
+public class TestCopyUtils {
+  /*
+  Distcp currently does not copy a single file in a distributed manner hence 
we dont care about
+  the size of file, if there is only file, we dont want to launch distcp.
+   */
+  @Test
+  public void distcpShouldNotBeCalledOnlyForOneFile() {
+    HiveConf conf = new HiveConf();
+    conf.setLongVar(HiveConf.ConfVars.HIVE_EXEC_COPYFILE_MAXSIZE, 1);
+    CopyUtils copyUtils = new CopyUtils("", conf);
+    long MB_128 = 128 * 1024 * 1024;
+    assertFalse(copyUtils.limitReachedForLocalCopy(MB_128, 1L));
+  }
+
+  @Test
+  public void distcpShouldNotBeCalledForSmallerFileSize() {
+    HiveConf conf = new HiveConf();
+    CopyUtils copyUtils = new CopyUtils("", conf);
+    long MB_16 = 16 * 1024 * 1024;
+    assertFalse(copyUtils.limitReachedForLocalCopy(MB_16, 100L));
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/hive/blob/3681b859/ql/src/test/org/apache/hadoop/hive/ql/parse/repl/dump/HiveWrapperTest.java
----------------------------------------------------------------------
diff --git 
a/ql/src/test/org/apache/hadoop/hive/ql/parse/repl/dump/HiveWrapperTest.java 
b/ql/src/test/org/apache/hadoop/hive/ql/parse/repl/dump/HiveWrapperTest.java
deleted file mode 100644
index fab9327..0000000
--- a/ql/src/test/org/apache/hadoop/hive/ql/parse/repl/dump/HiveWrapperTest.java
+++ /dev/null
@@ -1,45 +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.hadoop.hive.ql.parse.repl.dump;
-
-import org.apache.hadoop.hive.metastore.api.Table;
-import org.apache.hadoop.hive.ql.metadata.HiveException;
-import org.apache.hadoop.hive.ql.parse.ReplicationSpec;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.InOrder;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.runners.MockitoJUnitRunner;
-
-@RunWith(MockitoJUnitRunner.class)
-public class HiveWrapperTest {
-  @Mock
-  private HiveWrapper.Tuple.Function<ReplicationSpec> specFunction;
-  @Mock
-  private HiveWrapper.Tuple.Function<Table> tableFunction;
-
-  @Test
-  public void replicationIdIsRequestedBeforeObjectDefinition() throws 
HiveException {
-    new HiveWrapper.Tuple<>(specFunction, tableFunction);
-    InOrder inOrder = Mockito.inOrder(specFunction, tableFunction);
-    inOrder.verify(specFunction).fromMetaStore();
-    inOrder.verify(tableFunction).fromMetaStore();
-  }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/hive/blob/3681b859/ql/src/test/org/apache/hadoop/hive/ql/parse/repl/dump/TestHiveWrapper.java
----------------------------------------------------------------------
diff --git 
a/ql/src/test/org/apache/hadoop/hive/ql/parse/repl/dump/TestHiveWrapper.java 
b/ql/src/test/org/apache/hadoop/hive/ql/parse/repl/dump/TestHiveWrapper.java
new file mode 100644
index 0000000..5a1e60b
--- /dev/null
+++ b/ql/src/test/org/apache/hadoop/hive/ql/parse/repl/dump/TestHiveWrapper.java
@@ -0,0 +1,45 @@
+/**
+ * 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.hadoop.hive.ql.parse.repl.dump;
+
+import org.apache.hadoop.hive.metastore.api.Table;
+import org.apache.hadoop.hive.ql.metadata.HiveException;
+import org.apache.hadoop.hive.ql.parse.ReplicationSpec;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InOrder;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+
+@RunWith(MockitoJUnitRunner.class)
+public class TestHiveWrapper {
+  @Mock
+  private HiveWrapper.Tuple.Function<ReplicationSpec> specFunction;
+  @Mock
+  private HiveWrapper.Tuple.Function<Table> tableFunction;
+
+  @Test
+  public void replicationIdIsRequestedBeforeObjectDefinition() throws 
HiveException {
+    new HiveWrapper.Tuple<>(specFunction, tableFunction);
+    InOrder inOrder = Mockito.inOrder(specFunction, tableFunction);
+    inOrder.verify(specFunction).fromMetaStore();
+    inOrder.verify(tableFunction).fromMetaStore();
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/hive/blob/3681b859/ql/src/test/org/apache/hadoop/hive/ql/parse/repl/load/message/PrimaryToReplicaResourceFunctionTest.java
----------------------------------------------------------------------
diff --git 
a/ql/src/test/org/apache/hadoop/hive/ql/parse/repl/load/message/PrimaryToReplicaResourceFunctionTest.java
 
b/ql/src/test/org/apache/hadoop/hive/ql/parse/repl/load/message/PrimaryToReplicaResourceFunctionTest.java
deleted file mode 100644
index 1859dba..0000000
--- 
a/ql/src/test/org/apache/hadoop/hive/ql/parse/repl/load/message/PrimaryToReplicaResourceFunctionTest.java
+++ /dev/null
@@ -1,105 +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.hadoop.hive.ql.parse.repl.load.message;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hive.conf.HiveConf;
-import org.apache.hadoop.hive.metastore.api.Function;
-import org.apache.hadoop.hive.metastore.api.ResourceType;
-import org.apache.hadoop.hive.metastore.api.ResourceUri;
-import org.apache.hadoop.hive.ql.exec.ReplCopyTask;
-import org.apache.hadoop.hive.ql.exec.Task;
-import org.apache.hadoop.hive.ql.parse.ReplicationSpec;
-import org.apache.hadoop.hive.ql.parse.SemanticException;
-import org.apache.hadoop.hive.ql.parse.repl.load.MetaData;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import org.mockito.Mock;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import static 
org.apache.hadoop.hive.ql.parse.repl.load.message.CreateFunctionHandler.PrimaryToReplicaResourceFunction;
-import static 
org.apache.hadoop.hive.ql.parse.repl.load.message.MessageHandler.Context;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.powermock.api.mockito.PowerMockito.mockStatic;
-import static org.powermock.api.mockito.PowerMockito.when;
-import static org.mockito.Matchers.any;
-
-@RunWith(PowerMockRunner.class)
-@PrepareForTest({ PrimaryToReplicaResourceFunction.class, FileSystem.class, 
ReplCopyTask.class,
-                    System.class })
-public class PrimaryToReplicaResourceFunctionTest {
-
-  private PrimaryToReplicaResourceFunction function;
-  @Mock
-  private HiveConf hiveConf;
-  @Mock
-
-  private Function functionObj;
-  @Mock
-  private FileSystem mockFs;
-  private static Logger logger =
-      LoggerFactory.getLogger(PrimaryToReplicaResourceFunctionTest.class);
-
-  @Before
-  public void setup() {
-    MetaData metadata = new MetaData(null, null, null, null, functionObj);
-    Context context =
-        new Context("primaryDb", null, null, null, null, hiveConf, null, null, 
logger);
-    when(hiveConf.getVar(HiveConf.ConfVars.REPL_FUNCTIONS_ROOT_DIR))
-        .thenReturn("/someBasePath/withADir/");
-    function = new PrimaryToReplicaResourceFunction(context, metadata, 
"replicaDbName");
-  }
-
-  @Test
-  public void createDestinationPath() throws IOException, SemanticException, 
URISyntaxException {
-    mockStatic(FileSystem.class);
-    when(FileSystem.get(any(Configuration.class))).thenReturn(mockFs);
-    when(mockFs.getScheme()).thenReturn("hdfs");
-    when(mockFs.getUri()).thenReturn(new URI("hdfs", "somehost:9000", null, 
null, null));
-    mockStatic(System.class);
-    when(System.currentTimeMillis()).thenReturn(Long.MAX_VALUE);
-    when(functionObj.getFunctionName()).thenReturn("someFunctionName");
-    mockStatic(ReplCopyTask.class);
-    Task mock = mock(Task.class);
-    when(ReplCopyTask.getLoadCopyTask(any(ReplicationSpec.class), 
any(Path.class), any(Path.class),
-        any(HiveConf.class))).thenReturn(mock);
-
-    ResourceUri resourceUri = function.destinationResourceUri(new 
ResourceUri(ResourceType.JAR,
-        "hdfs://localhost:9000/user/someplace/ab.jar#e094828883"));
-
-    assertThat(resourceUri.getUri(),
-        is(equalTo(
-            
"hdfs://somehost:9000/someBasePath/withADir/replicaDbName/somefunctionname/" + 
String
-                .valueOf(Long.MAX_VALUE) + "/ab.jar")));
-  }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/hive/blob/3681b859/ql/src/test/org/apache/hadoop/hive/ql/parse/repl/load/message/TestPrimaryToReplicaResourceFunction.java
----------------------------------------------------------------------
diff --git 
a/ql/src/test/org/apache/hadoop/hive/ql/parse/repl/load/message/TestPrimaryToReplicaResourceFunction.java
 
b/ql/src/test/org/apache/hadoop/hive/ql/parse/repl/load/message/TestPrimaryToReplicaResourceFunction.java
new file mode 100644
index 0000000..ba3f598
--- /dev/null
+++ 
b/ql/src/test/org/apache/hadoop/hive/ql/parse/repl/load/message/TestPrimaryToReplicaResourceFunction.java
@@ -0,0 +1,104 @@
+/**
+ * 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.hadoop.hive.ql.parse.repl.load.message;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.metastore.api.Function;
+import org.apache.hadoop.hive.metastore.api.ResourceType;
+import org.apache.hadoop.hive.metastore.api.ResourceUri;
+import org.apache.hadoop.hive.ql.exec.ReplCopyTask;
+import org.apache.hadoop.hive.ql.exec.Task;
+import org.apache.hadoop.hive.ql.parse.ReplicationSpec;
+import org.apache.hadoop.hive.ql.parse.SemanticException;
+import org.apache.hadoop.hive.ql.parse.repl.load.MetaData;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import static 
org.apache.hadoop.hive.ql.parse.repl.load.message.CreateFunctionHandler.PrimaryToReplicaResourceFunction;
+import static 
org.apache.hadoop.hive.ql.parse.repl.load.message.MessageHandler.Context;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.powermock.api.mockito.PowerMockito.mockStatic;
+import static org.powermock.api.mockito.PowerMockito.when;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({ PrimaryToReplicaResourceFunction.class, FileSystem.class, 
ReplCopyTask.class,
+                    System.class })
+public class TestPrimaryToReplicaResourceFunction {
+
+  private PrimaryToReplicaResourceFunction function;
+  @Mock
+  private HiveConf hiveConf;
+  @Mock
+
+  private Function functionObj;
+  @Mock
+  private FileSystem mockFs;
+  private static Logger logger =
+      LoggerFactory.getLogger(TestPrimaryToReplicaResourceFunction.class);
+
+  @Before
+  public void setup() {
+    MetaData metadata = new MetaData(null, null, null, null, functionObj);
+    Context context =
+        new Context("primaryDb", null, null, null, null, hiveConf, null, null, 
logger);
+    when(hiveConf.getVar(HiveConf.ConfVars.REPL_FUNCTIONS_ROOT_DIR))
+        .thenReturn("/someBasePath/withADir/");
+    function = new PrimaryToReplicaResourceFunction(context, metadata, 
"replicaDbName");
+  }
+
+  @Test
+  public void createDestinationPath() throws IOException, SemanticException, 
URISyntaxException {
+    mockStatic(FileSystem.class);
+    when(FileSystem.get(any(Configuration.class))).thenReturn(mockFs);
+    when(mockFs.getScheme()).thenReturn("hdfs");
+    when(mockFs.getUri()).thenReturn(new URI("hdfs", "somehost:9000", null, 
null, null));
+    mockStatic(System.class);
+    when(System.nanoTime()).thenReturn(Long.MAX_VALUE);
+    when(functionObj.getFunctionName()).thenReturn("someFunctionName");
+    mockStatic(ReplCopyTask.class);
+    Task mock = mock(Task.class);
+    when(ReplCopyTask.getLoadCopyTask(any(ReplicationSpec.class), 
any(Path.class), any(Path.class),
+        any(HiveConf.class))).thenReturn(mock);
+
+    ResourceUri resourceUri = function.destinationResourceUri(new 
ResourceUri(ResourceType.JAR,
+        "hdfs://localhost:9000/user/someplace/ab.jar#e094828883"));
+
+    assertThat(resourceUri.getUri(),
+        is(equalTo(
+            
"hdfs://somehost:9000/someBasePath/withADir/replicadbname/somefunctionname/" + 
String
+                .valueOf(Long.MAX_VALUE) + "/ab.jar")));
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/hive/blob/3681b859/service/src/test/org/apache/hive/service/cli/CLIServiceRestoreTest.java
----------------------------------------------------------------------
diff --git 
a/service/src/test/org/apache/hive/service/cli/CLIServiceRestoreTest.java 
b/service/src/test/org/apache/hive/service/cli/CLIServiceRestoreTest.java
deleted file mode 100644
index a049440..0000000
--- a/service/src/test/org/apache/hive/service/cli/CLIServiceRestoreTest.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 org.apache.hive.service.cli;
-
-
-import org.apache.hadoop.hive.conf.HiveConf;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class CLIServiceRestoreTest {
-
-  CLIService service = getService();
-
-  @Test
-  public void testRestore() throws HiveSQLException {
-    SessionHandle session = service.openSession("foo", "bar", null);
-    service.stop();
-    service = getService();
-    try {
-      service.getSessionManager().getSession(session);
-      Assert.fail("session already exists before restore");
-    } catch (HiveSQLException e) {
-      Assert.assertTrue(e.getMessage().contains("Invalid SessionHandle"));
-    }
-    service.createSessionWithSessionHandle(session, "foo", "bar", null);
-    Assert.assertNotNull(service.getSessionManager().getSession(session));
-    service.stop();
-  }
-
-  public CLIService getService() {
-    HiveConf conf = new HiveConf();
-    conf.setVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER,
-      
"org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLStdHiveAuthorizerFactory");
-    CLIService service = new CLIService(null);
-    service.init(conf);
-    service.start();
-    return service;
-  }
-}

http://git-wip-us.apache.org/repos/asf/hive/blob/3681b859/service/src/test/org/apache/hive/service/cli/TestCLIServiceRestore.java
----------------------------------------------------------------------
diff --git 
a/service/src/test/org/apache/hive/service/cli/TestCLIServiceRestore.java 
b/service/src/test/org/apache/hive/service/cli/TestCLIServiceRestore.java
new file mode 100644
index 0000000..a4f0be0
--- /dev/null
+++ b/service/src/test/org/apache/hive/service/cli/TestCLIServiceRestore.java
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hive.service.cli;
+
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestCLIServiceRestore {
+
+  CLIService service = getService();
+
+  @Test
+  public void testRestore() throws HiveSQLException {
+    SessionHandle session = service.openSession("foo", "bar", null);
+    service.stop();
+    service = getService();
+    try {
+      service.getSessionManager().getSession(session);
+      Assert.fail("session already exists before restore");
+    } catch (HiveSQLException e) {
+      Assert.assertTrue(e.getMessage().contains("Invalid SessionHandle"));
+    }
+    service.createSessionWithSessionHandle(session, "foo", "bar", null);
+    Assert.assertNotNull(service.getSessionManager().getSession(session));
+    service.stop();
+  }
+
+  public CLIService getService() {
+    HiveConf conf = new HiveConf();
+    conf.setVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER,
+      
"org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLStdHiveAuthorizerFactory");
+    CLIService service = new CLIService(null);
+    service.init(conf);
+    service.start();
+    return service;
+  }
+}

http://git-wip-us.apache.org/repos/asf/hive/blob/3681b859/storage-api/src/test/org/apache/hadoop/hive/ql/util/JavaDataModelTest.java
----------------------------------------------------------------------
diff --git 
a/storage-api/src/test/org/apache/hadoop/hive/ql/util/JavaDataModelTest.java 
b/storage-api/src/test/org/apache/hadoop/hive/ql/util/JavaDataModelTest.java
deleted file mode 100644
index 7cd2e12..0000000
--- a/storage-api/src/test/org/apache/hadoop/hive/ql/util/JavaDataModelTest.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 org.apache.hadoop.hive.ql.util;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
-
-public final class JavaDataModelTest {
-
-  private static final String DATA_MODEL_PROPERTY = "sun.arch.data.model";
-
-  private String previousModelSetting;
-
-  @Before
-  public void setUp() throws Exception {
-    previousModelSetting = System.getProperty(DATA_MODEL_PROPERTY);
-  }
-
-  @After
-  public void tearDown() throws Exception {
-    if (previousModelSetting != null) {
-      System.setProperty(DATA_MODEL_PROPERTY, previousModelSetting);
-    } else {
-      System.clearProperty(DATA_MODEL_PROPERTY);
-    }
-  }
-
-  @Test
-  public void testGetDoesNotReturnNull() throws Exception {
-    JavaDataModel model = JavaDataModel.get();
-    assertNotNull(model);
-  }
-
-  @Test
-  public void testGetModelForSystemWhenSetTo32() throws Exception {
-    System.setProperty(DATA_MODEL_PROPERTY, "32");
-    assertSame(JavaDataModel.JAVA32, JavaDataModel.getModelForSystem());
-  }
-
-  @Test
-  public void testGetModelForSystemWhenSetTo64() throws Exception {
-    System.setProperty(DATA_MODEL_PROPERTY, "64");
-    assertSame(JavaDataModel.JAVA64, JavaDataModel.getModelForSystem());
-  }
-
-  @Test
-  public void testGetModelForSystemWhenSetToUnknown() throws Exception {
-    System.setProperty(DATA_MODEL_PROPERTY, "unknown");
-    assertSame(JavaDataModel.JAVA64, JavaDataModel.getModelForSystem());
-  }
-
-  @Test
-  public void testGetModelForSystemWhenUndefined() throws Exception {
-    System.clearProperty(DATA_MODEL_PROPERTY);
-    assertSame(JavaDataModel.JAVA64, JavaDataModel.getModelForSystem());
-  }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/hive/blob/3681b859/storage-api/src/test/org/apache/hadoop/hive/ql/util/TestJavaDataModel.java
----------------------------------------------------------------------
diff --git 
a/storage-api/src/test/org/apache/hadoop/hive/ql/util/TestJavaDataModel.java 
b/storage-api/src/test/org/apache/hadoop/hive/ql/util/TestJavaDataModel.java
new file mode 100644
index 0000000..9295b89
--- /dev/null
+++ b/storage-api/src/test/org/apache/hadoop/hive/ql/util/TestJavaDataModel.java
@@ -0,0 +1,76 @@
+/**
+ * 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.hadoop.hive.ql.util;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
+
+public final class TestJavaDataModel {
+
+  private static final String DATA_MODEL_PROPERTY = "sun.arch.data.model";
+
+  private String previousModelSetting;
+
+  @Before
+  public void setUp() throws Exception {
+    previousModelSetting = System.getProperty(DATA_MODEL_PROPERTY);
+  }
+
+  @After
+  public void tearDown() throws Exception {
+    if (previousModelSetting != null) {
+      System.setProperty(DATA_MODEL_PROPERTY, previousModelSetting);
+    } else {
+      System.clearProperty(DATA_MODEL_PROPERTY);
+    }
+  }
+
+  @Test
+  public void testGetDoesNotReturnNull() throws Exception {
+    JavaDataModel model = JavaDataModel.get();
+    assertNotNull(model);
+  }
+
+  @Test
+  public void testGetModelForSystemWhenSetTo32() throws Exception {
+    System.setProperty(DATA_MODEL_PROPERTY, "32");
+    assertSame(JavaDataModel.JAVA32, JavaDataModel.getModelForSystem());
+  }
+
+  @Test
+  public void testGetModelForSystemWhenSetTo64() throws Exception {
+    System.setProperty(DATA_MODEL_PROPERTY, "64");
+    assertSame(JavaDataModel.JAVA64, JavaDataModel.getModelForSystem());
+  }
+
+  @Test
+  public void testGetModelForSystemWhenSetToUnknown() throws Exception {
+    System.setProperty(DATA_MODEL_PROPERTY, "unknown");
+    assertSame(JavaDataModel.JAVA64, JavaDataModel.getModelForSystem());
+  }
+
+  @Test
+  public void testGetModelForSystemWhenUndefined() throws Exception {
+    System.clearProperty(DATA_MODEL_PROPERTY);
+    assertSame(JavaDataModel.JAVA64, JavaDataModel.getModelForSystem());
+  }
+}
\ No newline at end of file

Reply via email to