Repository: phoenix
Updated Branches:
  refs/heads/3.0 d6f70d25a -> cabb16f7d


http://git-wip-us.apache.org/repos/asf/phoenix/blob/cabb16f7/phoenix-pig/src/test/java/org/apache/phoenix/pig/PhoenixPigConfigurationTest.java
----------------------------------------------------------------------
diff --git 
a/phoenix-pig/src/test/java/org/apache/phoenix/pig/PhoenixPigConfigurationTest.java
 
b/phoenix-pig/src/test/java/org/apache/phoenix/pig/PhoenixPigConfigurationTest.java
deleted file mode 100644
index 0337563..0000000
--- 
a/phoenix-pig/src/test/java/org/apache/phoenix/pig/PhoenixPigConfigurationTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2010 The Apache Software Foundation
- *
- * 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 maynot 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 applicablelaw 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.phoenix.pig;
-
-import static org.junit.Assert.assertEquals;
-
-import java.sql.SQLException;
-
-import org.apache.hadoop.conf.Configuration;
-import org.junit.Test;
-
-
-/**
- * Tests for PhoenixPigConfiguration. 
- *
- */
-public class PhoenixPigConfigurationTest {
-
-  
-    @Test
-    public void testBasicConfiguration() throws SQLException {
-        Configuration conf = new Configuration();
-        final PhoenixPigConfiguration phoenixConfiguration = new 
PhoenixPigConfiguration(conf);
-        final String zkQuorum = "localhost";
-        final String tableName = "TABLE";
-        final long batchSize = 100;
-        phoenixConfiguration.configure(zkQuorum, tableName, batchSize);
-        assertEquals(zkQuorum,phoenixConfiguration.getServer());
-        assertEquals(tableName,phoenixConfiguration.getTableName());
-        assertEquals(batchSize,phoenixConfiguration.getBatchSize());
-     }
-}

http://git-wip-us.apache.org/repos/asf/phoenix/blob/cabb16f7/phoenix-pig/src/test/java/org/apache/phoenix/pig/util/ColumnInfoToStringEncoderDecoderTest.java
----------------------------------------------------------------------
diff --git 
a/phoenix-pig/src/test/java/org/apache/phoenix/pig/util/ColumnInfoToStringEncoderDecoderTest.java
 
b/phoenix-pig/src/test/java/org/apache/phoenix/pig/util/ColumnInfoToStringEncoderDecoderTest.java
deleted file mode 100644
index 9777bb5..0000000
--- 
a/phoenix-pig/src/test/java/org/apache/phoenix/pig/util/ColumnInfoToStringEncoderDecoderTest.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2010 The Apache Software Foundation
- *
- * 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 maynot 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 applicablelaw 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.phoenix.pig.util;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.List;
-
-import org.apache.phoenix.pig.util.ColumnInfoToStringEncoderDecoder;
-import org.apache.phoenix.schema.PDataType;
-import org.apache.phoenix.util.ColumnInfo;
-import org.junit.Test;
-
-import com.google.common.collect.Lists;
-
-/**
- * Tests methods on {@link ColumnInfoToStringEncoderDecoder}
- */
-public class ColumnInfoToStringEncoderDecoderTest {
-
-    @Test
-    public void testEncode() {
-        final ColumnInfo columnInfo = new ColumnInfo("col1", 
PDataType.VARCHAR.getSqlType());
-        final String encodedColumnInfo = 
ColumnInfoToStringEncoderDecoder.encode(Lists.newArrayList(columnInfo));
-        assertEquals(columnInfo.toString(),encodedColumnInfo);
-    }
-    
-    @Test
-    public void testDecode() {
-        final ColumnInfo columnInfo = new ColumnInfo("col1", 
PDataType.VARCHAR.getSqlType());
-        final String encodedColumnInfo = 
ColumnInfoToStringEncoderDecoder.encode(Lists.newArrayList(columnInfo));
-        assertEquals(columnInfo.toString(),encodedColumnInfo);
-    }
-    
-    @Test
-    public void testEncodeDecodeWithNulls() {
-        final ColumnInfo columnInfo1 = new ColumnInfo("col1", 
PDataType.VARCHAR.getSqlType());
-        final ColumnInfo columnInfo2 = null;
-        final String columnInfoStr = 
ColumnInfoToStringEncoderDecoder.encode(Lists.newArrayList(columnInfo1,columnInfo2));
-        final List<ColumnInfo> decodedColumnInfo = 
ColumnInfoToStringEncoderDecoder.decode(columnInfoStr);
-        assertEquals(1,decodedColumnInfo.size()); 
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/phoenix/blob/cabb16f7/phoenix-pig/src/test/java/org/apache/phoenix/pig/util/PhoenixPigSchemaUtilTest.java
----------------------------------------------------------------------
diff --git 
a/phoenix-pig/src/test/java/org/apache/phoenix/pig/util/PhoenixPigSchemaUtilTest.java
 
b/phoenix-pig/src/test/java/org/apache/phoenix/pig/util/PhoenixPigSchemaUtilTest.java
index 310128c..7a861b9 100644
--- 
a/phoenix-pig/src/test/java/org/apache/phoenix/pig/util/PhoenixPigSchemaUtilTest.java
+++ 
b/phoenix-pig/src/test/java/org/apache/phoenix/pig/util/PhoenixPigSchemaUtilTest.java
@@ -29,8 +29,10 @@ import java.sql.SQLException;
 import java.sql.Types;
 import java.util.List;
 
-import org.apache.phoenix.pig.PhoenixPigConfiguration;
-import org.apache.phoenix.pig.util.PhoenixPigSchemaUtil;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.phoenix.mapreduce.util.ColumnInfoToStringEncoderDecoder;
+import org.apache.phoenix.mapreduce.util.PhoenixConfigurationUtil;
+import org.apache.phoenix.mapreduce.util.PhoenixConfigurationUtil.SchemaType;
 import org.apache.phoenix.schema.IllegalDataException;
 import org.apache.phoenix.util.ColumnInfo;
 import org.apache.pig.ResourceSchema;
@@ -54,9 +56,11 @@ public class PhoenixPigSchemaUtilTest {
     @Test
     public void testSchema() throws SQLException, IOException {
         
-        final PhoenixPigConfiguration configuration = 
mock(PhoenixPigConfiguration.class);
+        final Configuration configuration = mock(Configuration.class);
         final List<ColumnInfo> columnInfos = 
ImmutableList.of(ID_COLUMN,NAME_COLUMN);
-        
when(configuration.getSelectColumnMetadataList()).thenReturn(columnInfos);
+        final String encodedColumnInfos = 
ColumnInfoToStringEncoderDecoder.encode(columnInfos);
+        
when(configuration.get(PhoenixConfigurationUtil.SELECT_COLUMN_INFO_KEY)).thenReturn(encodedColumnInfos);
+        
when(configuration.get(PhoenixConfigurationUtil.SCHEMA_TYPE)).thenReturn(SchemaType.TABLE.name());
         final ResourceSchema actual = 
PhoenixPigSchemaUtil.getResourceSchema(configuration);
         
         // expected schema.
@@ -75,9 +79,10 @@ public class PhoenixPigSchemaUtilTest {
     @Test(expected=IllegalDataException.class)
     public void testUnSupportedTypes() throws SQLException, IOException {
         
-        final PhoenixPigConfiguration configuration = 
mock(PhoenixPigConfiguration.class);
+        final Configuration configuration = mock(Configuration.class);
         final List<ColumnInfo> columnInfos = 
ImmutableList.of(ID_COLUMN,LOCATION_COLUMN);
-        
when(configuration.getSelectColumnMetadataList()).thenReturn(columnInfos);
+        final String encodedColumnInfos = 
ColumnInfoToStringEncoderDecoder.encode(columnInfos);
+        
when(configuration.get(PhoenixConfigurationUtil.SELECT_COLUMN_INFO_KEY)).thenReturn(encodedColumnInfos);
         PhoenixPigSchemaUtil.getResourceSchema(configuration);
         fail("We currently don't support Array type yet. WIP!!");
     }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/cabb16f7/phoenix-pig/src/test/java/org/apache/phoenix/pig/util/QuerySchemaParserFunctionTest.java
----------------------------------------------------------------------
diff --git 
a/phoenix-pig/src/test/java/org/apache/phoenix/pig/util/QuerySchemaParserFunctionTest.java
 
b/phoenix-pig/src/test/java/org/apache/phoenix/pig/util/QuerySchemaParserFunctionTest.java
index 3daf4e1..27fd879 100644
--- 
a/phoenix-pig/src/test/java/org/apache/phoenix/pig/util/QuerySchemaParserFunctionTest.java
+++ 
b/phoenix-pig/src/test/java/org/apache/phoenix/pig/util/QuerySchemaParserFunctionTest.java
@@ -22,15 +22,12 @@ package org.apache.phoenix.pig.util;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
-import java.sql.Connection;
-import java.sql.DriverManager;
 import java.sql.SQLException;
 
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.util.Pair;
-import org.apache.phoenix.pig.PhoenixPigConfiguration;
-import org.apache.phoenix.pig.util.QuerySchemaParserFunction;
 import org.apache.phoenix.query.BaseConnectionlessQueryTest;
-import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mockito;
@@ -44,16 +41,14 @@ import com.google.common.base.Joiner;
  */
 public class QuerySchemaParserFunctionTest extends BaseConnectionlessQueryTest 
{
 
-    private PhoenixPigConfiguration phoenixConfiguration;
-    private Connection conn;
+    private Configuration configuration;
     private QuerySchemaParserFunction function;
     
     @Before
     public void setUp() throws SQLException {
-        phoenixConfiguration = Mockito.mock(PhoenixPigConfiguration.class);
-        conn = DriverManager.getConnection(getUrl());
-        Mockito.when(phoenixConfiguration.getConnection()).thenReturn(conn);
-        function = new QuerySchemaParserFunction(phoenixConfiguration);
+        configuration = Mockito.mock(Configuration.class);
+        
Mockito.when(configuration.get(HConstants.ZOOKEEPER_QUORUM)).thenReturn(getUrl());
+        function = new QuerySchemaParserFunction(configuration);
     }
     
     @Test(expected=RuntimeException.class)
@@ -101,9 +96,4 @@ public class QuerySchemaParserFunctionTest extends 
BaseConnectionlessQueryTest {
         function.apply(selectQuery);
         fail(" Function call successful despite passing an aggreagate query");
     }
-
-    @After
-    public void tearDown() throws SQLException {
-        conn.close();
-    }
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/cabb16f7/phoenix-pig/src/test/java/org/apache/phoenix/pig/util/SqlQueryToColumnInfoFunctionTest.java
----------------------------------------------------------------------
diff --git 
a/phoenix-pig/src/test/java/org/apache/phoenix/pig/util/SqlQueryToColumnInfoFunctionTest.java
 
b/phoenix-pig/src/test/java/org/apache/phoenix/pig/util/SqlQueryToColumnInfoFunctionTest.java
index 1bd16e3..9897065 100644
--- 
a/phoenix-pig/src/test/java/org/apache/phoenix/pig/util/SqlQueryToColumnInfoFunctionTest.java
+++ 
b/phoenix-pig/src/test/java/org/apache/phoenix/pig/util/SqlQueryToColumnInfoFunctionTest.java
@@ -19,16 +19,14 @@
  */
 package org.apache.phoenix.pig.util;
 
-import java.sql.Connection;
-import java.sql.DriverManager;
 import java.sql.SQLException;
 import java.sql.Types;
 import java.util.List;
 
-import org.apache.phoenix.pig.PhoenixPigConfiguration;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.HConstants;
 import org.apache.phoenix.query.BaseConnectionlessQueryTest;
 import org.apache.phoenix.util.ColumnInfo;
-import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -38,16 +36,14 @@ import com.google.common.collect.ImmutableList;
 
 public class SqlQueryToColumnInfoFunctionTest  extends 
BaseConnectionlessQueryTest {
 
-    private PhoenixPigConfiguration phoenixConfiguration;
-    private Connection conn;
+    private Configuration configuration;
     private SqlQueryToColumnInfoFunction function;
     
     @Before
     public void setUp() throws SQLException {
-        phoenixConfiguration = Mockito.mock(PhoenixPigConfiguration.class);
-        conn = DriverManager.getConnection(getUrl());
-        Mockito.when(phoenixConfiguration.getConnection()).thenReturn(conn);
-        function = new SqlQueryToColumnInfoFunction(phoenixConfiguration);
+        configuration = Mockito.mock(Configuration.class);
+        
Mockito.when(configuration.get(HConstants.ZOOKEEPER_QUORUM)).thenReturn(getUrl());
+        function = new SqlQueryToColumnInfoFunction(configuration);
     }
     
     @Test
@@ -66,10 +62,5 @@ public class SqlQueryToColumnInfoFunctionTest  extends 
BaseConnectionlessQueryTe
         Assert.assertEquals(expectedColumnInfos, actualColumnInfos);
         
     }
-    
-    @After
-    public void tearDown() throws SQLException {
-        conn.close();
-    }
 
 }

Reply via email to