incubator-hcatalog-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tra...@apache.org
Subject svn commit: r1383152 [17/27] - in /incubator/hcatalog/trunk: ./ hcatalog-pig-adapter/src/main/java/org/apache/hcatalog/pig/ hcatalog-pig-adapter/src/main/java/org/apache/hcatalog/pig/drivers/ hcatalog-pig-adapter/src/test/java/org/apache/hcatalog/pig/ ...
Date Mon, 10 Sep 2012 23:29:03 GMT
Modified: incubator/hcatalog/trunk/src/test/org/apache/hcatalog/data/TestDefaultHCatRecord.java
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/src/test/org/apache/hcatalog/data/TestDefaultHCatRecord.java?rev=1383152&r1=1383151&r2=1383152&view=diff
==============================================================================
--- incubator/hcatalog/trunk/src/test/org/apache/hcatalog/data/TestDefaultHCatRecord.java (original)
+++ incubator/hcatalog/trunk/src/test/org/apache/hcatalog/data/TestDefaultHCatRecord.java Mon Sep 10 23:28:55 2012
@@ -39,221 +39,221 @@ import org.apache.hcatalog.data.schema.H
 import junit.framework.Assert;
 import junit.framework.TestCase;
 
-public class TestDefaultHCatRecord extends TestCase{
+public class TestDefaultHCatRecord extends TestCase {
 
-  public void testRYW() throws IOException{
+    public void testRYW() throws IOException {
 
-    File f = new File("binary.dat");
-    f.delete();
-    f.createNewFile();
-    f.deleteOnExit();
-
-    OutputStream fileOutStream = new FileOutputStream(f);
-    DataOutput outStream = new DataOutputStream(fileOutStream);
-
-    HCatRecord[]  recs = getHCatRecords();
-    for(int i =0; i < recs.length; i++){
-      recs[i].write(outStream);
-    }
-    fileOutStream.flush();
-    fileOutStream.close();
-
-    InputStream fInStream = new FileInputStream(f);
-    DataInput inpStream = new DataInputStream(fInStream);
-
-    for(int i =0; i < recs.length; i++){
-      HCatRecord rec = new DefaultHCatRecord();
-      rec.readFields(inpStream);
-      Assert.assertTrue(HCatDataCheckUtil.recordsEqual(recs[i],rec));
-    }
-
-    Assert.assertEquals(fInStream.available(), 0);
-    fInStream.close();
-
-  }
-
-  public void testCompareTo() {
-    HCatRecord[] recs = getHCatRecords();
-    Assert.assertTrue(HCatDataCheckUtil.compareRecords(recs[0],recs[1]) == 0);
-    Assert.assertTrue(HCatDataCheckUtil.compareRecords(recs[4],recs[5]) == 0);
-  }
-
-  public void testEqualsObject() {
-
-    HCatRecord[] recs = getHCatRecords();
-    Assert.assertTrue(HCatDataCheckUtil.recordsEqual(recs[0],recs[1]));
-    Assert.assertTrue(HCatDataCheckUtil.recordsEqual(recs[4],recs[5]));
-  }
-
-  /**
-   * Test get and set calls with type
-   * @throws HCatException
-   */
-  public void testGetSetByType1() throws HCatException{
-    HCatRecord inpRec = getHCatRecords()[0];
-    HCatRecord newRec = new DefaultHCatRecord(inpRec.size());
-    HCatSchema hsch = 
-        HCatSchemaUtils.getHCatSchema(
-            "a:tinyint,b:smallint,c:int,d:bigint,e:float,f:double,g:boolean,h:string,i:binary,j:string");
-    
-
-    newRec.setByte("a", hsch, inpRec.getByte("a", hsch) );
-    newRec.setShort("b", hsch, inpRec.getShort("b", hsch) );
-    newRec.setInteger("c", hsch, inpRec.getInteger("c", hsch) );
-    newRec.setLong("d", hsch, inpRec.getLong("d", hsch) );
-    newRec.setFloat("e", hsch, inpRec.getFloat("e", hsch) );
-    newRec.setDouble("f", hsch, inpRec.getDouble("f", hsch) );
-    newRec.setBoolean("g", hsch, inpRec.getBoolean("g", hsch) );
-    newRec.setString("h", hsch, inpRec.getString("h", hsch) );
-    newRec.setByteArray("i", hsch, inpRec.getByteArray("i", hsch) );
-    newRec.setString("j", hsch, inpRec.getString("j", hsch) );
-    
-    Assert.assertTrue(HCatDataCheckUtil.recordsEqual(newRec,inpRec));
-    
-    
-  }
-  
-  /**
-   * Test get and set calls with type
-   * @throws HCatException
-   */
-  public void testGetSetByType2() throws HCatException{
-    HCatRecord inpRec = getGetSet2InpRec();
-    
-    HCatRecord newRec = new DefaultHCatRecord(inpRec.size());
-    HCatSchema hsch = 
-        HCatSchemaUtils.getHCatSchema("a:binary,b:map<string,string>,c:array<int>,d:struct<i:int>");
-    
-
-    newRec.setByteArray("a", hsch, inpRec.getByteArray("a", hsch) );
-    newRec.setMap("b", hsch, inpRec.getMap("b", hsch) );
-    newRec.setList("c", hsch, inpRec.getList("c", hsch) );
-    newRec.setStruct("d", hsch, inpRec.getStruct("d", hsch) );
-
-    Assert.assertTrue(HCatDataCheckUtil.recordsEqual(newRec,inpRec));
-  }
-  
-  
-  private HCatRecord getGetSet2InpRec() {
-    List<Object> rlist = new ArrayList<Object>();
-    
-    rlist.add(new byte[]{1,2,3});
-    
-    Map<Short, String> mapcol = new HashMap<Short, String>(3);
-    mapcol.put(new Short("2"), "hcat is cool");
-    mapcol.put(new Short("3"), "is it?");
-    mapcol.put(new Short("4"), "or is it not?");
-    rlist.add(mapcol);
-
-    List<Integer> listcol = new ArrayList<Integer>();
-    listcol.add(314);
-    listcol.add(007);
-    rlist.add( listcol);//list
-    rlist.add( listcol);//struct
-    return new DefaultHCatRecord(rlist);
-  }
-
-  private HCatRecord[] getHCatRecords(){
-
-    List<Object> rec_1 = new ArrayList<Object>(8);
-    rec_1.add(new Byte("123"));
-    rec_1.add(new Short("456"));
-    rec_1.add( new Integer(789));
-    rec_1.add( new Long(1000L));
-    rec_1.add( new Float(5.3F));
-    rec_1.add( new Double(5.3D));
-    rec_1.add( new Boolean(true));
-    rec_1.add( new String("hcat and hadoop"));
-    rec_1.add( null);
-    rec_1.add( "null");
-
-    HCatRecord tup_1 = new DefaultHCatRecord(rec_1);
-
-    List<Object> rec_2 = new ArrayList<Object>(8);
-    rec_2.add( new Byte("123"));
-    rec_2.add( new Short("456"));
-    rec_2.add( new Integer(789));
-    rec_2.add( new Long(1000L));
-    rec_2.add( new Float(5.3F));
-    rec_2.add( new Double(5.3D));
-    rec_2.add( new Boolean(true));
-    rec_2.add( new String("hcat and hadoop"));
-    rec_2.add( null);
-    rec_2.add( "null");
-    HCatRecord tup_2 = new DefaultHCatRecord(rec_2);
-
-    List<Object> rec_3 = new ArrayList<Object>(10);
-    rec_3.add(new Byte("123"));
-    rec_3.add(new Short("456"));
-    rec_3.add( new Integer(789));
-    rec_3.add( new Long(1000L));
-    rec_3.add( new Double(5.3D));
-    rec_3.add( new String("hcat and hadoop"));
-    rec_3.add( null);
-    List<Integer> innerList = new ArrayList<Integer>();
-    innerList.add(314);
-    innerList.add(007);
-    rec_3.add( innerList);
-    Map<Short, String> map = new HashMap<Short, String>(3);
-    map.put(new Short("2"), "hcat is cool");
-    map.put(new Short("3"), "is it?");
-    map.put(new Short("4"), "or is it not?");
-    rec_3.add(map);
-
-    HCatRecord tup_3 = new DefaultHCatRecord(rec_3);
-
-    List<Object> rec_4 = new ArrayList<Object>(8);
-    rec_4.add( new Byte("123"));
-    rec_4.add( new Short("456"));
-    rec_4.add( new Integer(789));
-    rec_4.add( new Long(1000L));
-    rec_4.add( new Double(5.3D));
-    rec_4.add( new String("hcat and hadoop"));
-    rec_4.add( null);
-    rec_4.add( "null");
-
-    Map<Short, String> map2 = new HashMap<Short, String>(3);
-    map2.put(new Short("2"), "hcat is cool");
-    map2.put(new Short("3"), "is it?");
-    map2.put(new Short("4"), "or is it not?");
-    rec_4.add(map2);
-    List<Integer> innerList2 = new ArrayList<Integer>();
-    innerList2.add(314);
-    innerList2.add(007);
-    rec_4.add( innerList2);
-    HCatRecord tup_4 = new DefaultHCatRecord(rec_4);
-
-    
-    List<Object> rec_5 = new ArrayList<Object>(3);
-    rec_5.add( getByteArray());
-    rec_5.add( getStruct());
-    rec_5.add( getList());
-    HCatRecord tup_5 = new DefaultHCatRecord(rec_5);
-    
-
-    List<Object> rec_6 = new ArrayList<Object>(3);
-    rec_6.add( getByteArray());
-    rec_6.add( getStruct());
-    rec_6.add( getList());
-    HCatRecord tup_6 = new DefaultHCatRecord(rec_6);
-
-    
-    return  new HCatRecord[]{tup_1,tup_2,tup_3,tup_4,tup_5,tup_6};
-
-  }
-
-  private Object getList() {
-    return getStruct();
-  }
-
-  private Object getByteArray() {
-    return new byte[]{1,2,3,4};
-  }
-
-  private List<?> getStruct() {
-    List<Object> struct = new ArrayList<Object>();
-    struct.add(new Integer(1));
-    struct.add(new String("x"));
-    return struct;
-  }
+        File f = new File("binary.dat");
+        f.delete();
+        f.createNewFile();
+        f.deleteOnExit();
+
+        OutputStream fileOutStream = new FileOutputStream(f);
+        DataOutput outStream = new DataOutputStream(fileOutStream);
+
+        HCatRecord[] recs = getHCatRecords();
+        for (int i = 0; i < recs.length; i++) {
+            recs[i].write(outStream);
+        }
+        fileOutStream.flush();
+        fileOutStream.close();
+
+        InputStream fInStream = new FileInputStream(f);
+        DataInput inpStream = new DataInputStream(fInStream);
+
+        for (int i = 0; i < recs.length; i++) {
+            HCatRecord rec = new DefaultHCatRecord();
+            rec.readFields(inpStream);
+            Assert.assertTrue(HCatDataCheckUtil.recordsEqual(recs[i], rec));
+        }
+
+        Assert.assertEquals(fInStream.available(), 0);
+        fInStream.close();
+
+    }
+
+    public void testCompareTo() {
+        HCatRecord[] recs = getHCatRecords();
+        Assert.assertTrue(HCatDataCheckUtil.compareRecords(recs[0], recs[1]) == 0);
+        Assert.assertTrue(HCatDataCheckUtil.compareRecords(recs[4], recs[5]) == 0);
+    }
+
+    public void testEqualsObject() {
+
+        HCatRecord[] recs = getHCatRecords();
+        Assert.assertTrue(HCatDataCheckUtil.recordsEqual(recs[0], recs[1]));
+        Assert.assertTrue(HCatDataCheckUtil.recordsEqual(recs[4], recs[5]));
+    }
+
+    /**
+     * Test get and set calls with type
+     * @throws HCatException
+     */
+    public void testGetSetByType1() throws HCatException {
+        HCatRecord inpRec = getHCatRecords()[0];
+        HCatRecord newRec = new DefaultHCatRecord(inpRec.size());
+        HCatSchema hsch =
+                HCatSchemaUtils.getHCatSchema(
+                        "a:tinyint,b:smallint,c:int,d:bigint,e:float,f:double,g:boolean,h:string,i:binary,j:string");
+
+
+        newRec.setByte("a", hsch, inpRec.getByte("a", hsch));
+        newRec.setShort("b", hsch, inpRec.getShort("b", hsch));
+        newRec.setInteger("c", hsch, inpRec.getInteger("c", hsch));
+        newRec.setLong("d", hsch, inpRec.getLong("d", hsch));
+        newRec.setFloat("e", hsch, inpRec.getFloat("e", hsch));
+        newRec.setDouble("f", hsch, inpRec.getDouble("f", hsch));
+        newRec.setBoolean("g", hsch, inpRec.getBoolean("g", hsch));
+        newRec.setString("h", hsch, inpRec.getString("h", hsch));
+        newRec.setByteArray("i", hsch, inpRec.getByteArray("i", hsch));
+        newRec.setString("j", hsch, inpRec.getString("j", hsch));
+
+        Assert.assertTrue(HCatDataCheckUtil.recordsEqual(newRec, inpRec));
+
+
+    }
+
+    /**
+     * Test get and set calls with type
+     * @throws HCatException
+     */
+    public void testGetSetByType2() throws HCatException {
+        HCatRecord inpRec = getGetSet2InpRec();
+
+        HCatRecord newRec = new DefaultHCatRecord(inpRec.size());
+        HCatSchema hsch =
+                HCatSchemaUtils.getHCatSchema("a:binary,b:map<string,string>,c:array<int>,d:struct<i:int>");
+
+
+        newRec.setByteArray("a", hsch, inpRec.getByteArray("a", hsch));
+        newRec.setMap("b", hsch, inpRec.getMap("b", hsch));
+        newRec.setList("c", hsch, inpRec.getList("c", hsch));
+        newRec.setStruct("d", hsch, inpRec.getStruct("d", hsch));
+
+        Assert.assertTrue(HCatDataCheckUtil.recordsEqual(newRec, inpRec));
+    }
+
+
+    private HCatRecord getGetSet2InpRec() {
+        List<Object> rlist = new ArrayList<Object>();
+
+        rlist.add(new byte[]{1, 2, 3});
+
+        Map<Short, String> mapcol = new HashMap<Short, String>(3);
+        mapcol.put(new Short("2"), "hcat is cool");
+        mapcol.put(new Short("3"), "is it?");
+        mapcol.put(new Short("4"), "or is it not?");
+        rlist.add(mapcol);
+
+        List<Integer> listcol = new ArrayList<Integer>();
+        listcol.add(314);
+        listcol.add(007);
+        rlist.add(listcol);//list
+        rlist.add(listcol);//struct
+        return new DefaultHCatRecord(rlist);
+    }
+
+    private HCatRecord[] getHCatRecords() {
+
+        List<Object> rec_1 = new ArrayList<Object>(8);
+        rec_1.add(new Byte("123"));
+        rec_1.add(new Short("456"));
+        rec_1.add(new Integer(789));
+        rec_1.add(new Long(1000L));
+        rec_1.add(new Float(5.3F));
+        rec_1.add(new Double(5.3D));
+        rec_1.add(new Boolean(true));
+        rec_1.add(new String("hcat and hadoop"));
+        rec_1.add(null);
+        rec_1.add("null");
+
+        HCatRecord tup_1 = new DefaultHCatRecord(rec_1);
+
+        List<Object> rec_2 = new ArrayList<Object>(8);
+        rec_2.add(new Byte("123"));
+        rec_2.add(new Short("456"));
+        rec_2.add(new Integer(789));
+        rec_2.add(new Long(1000L));
+        rec_2.add(new Float(5.3F));
+        rec_2.add(new Double(5.3D));
+        rec_2.add(new Boolean(true));
+        rec_2.add(new String("hcat and hadoop"));
+        rec_2.add(null);
+        rec_2.add("null");
+        HCatRecord tup_2 = new DefaultHCatRecord(rec_2);
+
+        List<Object> rec_3 = new ArrayList<Object>(10);
+        rec_3.add(new Byte("123"));
+        rec_3.add(new Short("456"));
+        rec_3.add(new Integer(789));
+        rec_3.add(new Long(1000L));
+        rec_3.add(new Double(5.3D));
+        rec_3.add(new String("hcat and hadoop"));
+        rec_3.add(null);
+        List<Integer> innerList = new ArrayList<Integer>();
+        innerList.add(314);
+        innerList.add(007);
+        rec_3.add(innerList);
+        Map<Short, String> map = new HashMap<Short, String>(3);
+        map.put(new Short("2"), "hcat is cool");
+        map.put(new Short("3"), "is it?");
+        map.put(new Short("4"), "or is it not?");
+        rec_3.add(map);
+
+        HCatRecord tup_3 = new DefaultHCatRecord(rec_3);
+
+        List<Object> rec_4 = new ArrayList<Object>(8);
+        rec_4.add(new Byte("123"));
+        rec_4.add(new Short("456"));
+        rec_4.add(new Integer(789));
+        rec_4.add(new Long(1000L));
+        rec_4.add(new Double(5.3D));
+        rec_4.add(new String("hcat and hadoop"));
+        rec_4.add(null);
+        rec_4.add("null");
+
+        Map<Short, String> map2 = new HashMap<Short, String>(3);
+        map2.put(new Short("2"), "hcat is cool");
+        map2.put(new Short("3"), "is it?");
+        map2.put(new Short("4"), "or is it not?");
+        rec_4.add(map2);
+        List<Integer> innerList2 = new ArrayList<Integer>();
+        innerList2.add(314);
+        innerList2.add(007);
+        rec_4.add(innerList2);
+        HCatRecord tup_4 = new DefaultHCatRecord(rec_4);
+
+
+        List<Object> rec_5 = new ArrayList<Object>(3);
+        rec_5.add(getByteArray());
+        rec_5.add(getStruct());
+        rec_5.add(getList());
+        HCatRecord tup_5 = new DefaultHCatRecord(rec_5);
+
+
+        List<Object> rec_6 = new ArrayList<Object>(3);
+        rec_6.add(getByteArray());
+        rec_6.add(getStruct());
+        rec_6.add(getList());
+        HCatRecord tup_6 = new DefaultHCatRecord(rec_6);
+
+
+        return new HCatRecord[]{tup_1, tup_2, tup_3, tup_4, tup_5, tup_6};
+
+    }
+
+    private Object getList() {
+        return getStruct();
+    }
+
+    private Object getByteArray() {
+        return new byte[]{1, 2, 3, 4};
+    }
+
+    private List<?> getStruct() {
+        List<Object> struct = new ArrayList<Object>();
+        struct.add(new Integer(1));
+        struct.add(new String("x"));
+        return struct;
+    }
 }

Modified: incubator/hcatalog/trunk/src/test/org/apache/hcatalog/data/TestHCatRecordSerDe.java
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/src/test/org/apache/hcatalog/data/TestHCatRecordSerDe.java?rev=1383152&r1=1383151&r2=1383152&view=diff
==============================================================================
--- incubator/hcatalog/trunk/src/test/org/apache/hcatalog/data/TestHCatRecordSerDe.java (original)
+++ incubator/hcatalog/trunk/src/test/org/apache/hcatalog/data/TestHCatRecordSerDe.java Mon Sep 10 23:28:55 2012
@@ -34,135 +34,135 @@ import org.apache.hadoop.io.Writable;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class TestHCatRecordSerDe extends TestCase{
+public class TestHCatRecordSerDe extends TestCase {
 
     private static final Logger LOG = LoggerFactory.getLogger(TestHCatRecordSerDe.class);
 
-  public Map<Properties,HCatRecord> getData(){
-    Map<Properties,HCatRecord> data = new HashMap<Properties,HCatRecord>();
+    public Map<Properties, HCatRecord> getData() {
+        Map<Properties, HCatRecord> data = new HashMap<Properties, HCatRecord>();
 
-    List<Object> rlist = new ArrayList<Object>(11);
-    rlist.add(new Byte("123"));
-    rlist.add(new Short("456"));
-    rlist.add(new Integer(789));
-    rlist.add(new Long(1000L));
-    rlist.add(new Double(5.3D));
-    rlist.add(new Float(2.39F));
-    rlist.add(new String("hcat and hadoop"));
-    rlist.add(null);
-
-    List<Object> innerStruct = new ArrayList<Object>(2);
-    innerStruct.add(new String("abc"));
-    innerStruct.add(new String("def"));
-    rlist.add(innerStruct);
-
-    List<Integer> innerList = new ArrayList<Integer>();
-    innerList.add(314);
-    innerList.add(007);
-    rlist.add(innerList);
-
-    Map<Short, String> map = new HashMap<Short, String>(3);
-    map.put(new Short("2"), "hcat is cool");
-    map.put(new Short("3"), "is it?");
-    map.put(new Short("4"), "or is it not?");
-    rlist.add(map);
-
-    rlist.add(new Boolean(true));
-
-    List<Object> c1 = new ArrayList<Object>();
-      List<Object> c1_1 = new ArrayList<Object>();
-      c1_1.add(new Integer(12));
+        List<Object> rlist = new ArrayList<Object>(11);
+        rlist.add(new Byte("123"));
+        rlist.add(new Short("456"));
+        rlist.add(new Integer(789));
+        rlist.add(new Long(1000L));
+        rlist.add(new Double(5.3D));
+        rlist.add(new Float(2.39F));
+        rlist.add(new String("hcat and hadoop"));
+        rlist.add(null);
+
+        List<Object> innerStruct = new ArrayList<Object>(2);
+        innerStruct.add(new String("abc"));
+        innerStruct.add(new String("def"));
+        rlist.add(innerStruct);
+
+        List<Integer> innerList = new ArrayList<Integer>();
+        innerList.add(314);
+        innerList.add(007);
+        rlist.add(innerList);
+
+        Map<Short, String> map = new HashMap<Short, String>(3);
+        map.put(new Short("2"), "hcat is cool");
+        map.put(new Short("3"), "is it?");
+        map.put(new Short("4"), "or is it not?");
+        rlist.add(map);
+
+        rlist.add(new Boolean(true));
+
+        List<Object> c1 = new ArrayList<Object>();
+        List<Object> c1_1 = new ArrayList<Object>();
+        c1_1.add(new Integer(12));
         List<Object> i2 = new ArrayList<Object>();
-          List<Integer> ii1 = new ArrayList<Integer>();
-            ii1.add(new Integer(13));
-            ii1.add(new Integer(14));
-          i2.add(ii1);
-          Map<String,List<?>> ii2 = new HashMap<String,List<?>>();
-            List<Integer> iii1 = new ArrayList<Integer>();
-              iii1.add(new Integer(15));
-            ii2.put("phew", iii1);
-          i2.add(ii2);
-      c1_1.add(i2);
-      c1.add(c1_1);
-    rlist.add(c1);
-    List<Object> am = new ArrayList<Object>();
-      Map<String,String> am_1 = new HashMap<String,String>();
-        am_1.put("noo","haha");
-      am.add(am_1);
-    rlist.add(am);
-    List<Object> aa = new ArrayList<Object>();
-      List<String> aa_1 = new ArrayList<String>();
+        List<Integer> ii1 = new ArrayList<Integer>();
+        ii1.add(new Integer(13));
+        ii1.add(new Integer(14));
+        i2.add(ii1);
+        Map<String, List<?>> ii2 = new HashMap<String, List<?>>();
+        List<Integer> iii1 = new ArrayList<Integer>();
+        iii1.add(new Integer(15));
+        ii2.put("phew", iii1);
+        i2.add(ii2);
+        c1_1.add(i2);
+        c1.add(c1_1);
+        rlist.add(c1);
+        List<Object> am = new ArrayList<Object>();
+        Map<String, String> am_1 = new HashMap<String, String>();
+        am_1.put("noo", "haha");
+        am.add(am_1);
+        rlist.add(am);
+        List<Object> aa = new ArrayList<Object>();
+        List<String> aa_1 = new ArrayList<String>();
         aa_1.add("bloo");
         aa_1.add("bwahaha");
-      aa.add(aa_1);
-    rlist.add(aa);
+        aa.add(aa_1);
+        rlist.add(aa);
 
-    String typeString =
-        "tinyint,smallint,int,bigint,double,float,string,string,"
-        + "struct<a:string,b:string>,array<int>,map<smallint,string>,boolean,"
-        + "array<struct<i1:int,i2:struct<ii1:array<int>,ii2:map<string,struct<iii1:int>>>>>,"
-        + "array<map<string,string>>,array<array<string>>";
-    Properties props = new Properties();
+        String typeString =
+                "tinyint,smallint,int,bigint,double,float,string,string,"
+                        + "struct<a:string,b:string>,array<int>,map<smallint,string>,boolean,"
+                        + "array<struct<i1:int,i2:struct<ii1:array<int>,ii2:map<string,struct<iii1:int>>>>>,"
+                        + "array<map<string,string>>,array<array<string>>";
+        Properties props = new Properties();
 
-    props.put(Constants.LIST_COLUMNS, "ti,si,i,bi,d,f,s,n,r,l,m,b,c1,am,aa");
-    props.put(Constants.LIST_COLUMN_TYPES, typeString);
+        props.put(Constants.LIST_COLUMNS, "ti,si,i,bi,d,f,s,n,r,l,m,b,c1,am,aa");
+        props.put(Constants.LIST_COLUMN_TYPES, typeString);
 //    props.put(Constants.SERIALIZATION_NULL_FORMAT, "\\N");
 //    props.put(Constants.SERIALIZATION_FORMAT, "1");
 
-    data.put(props, new DefaultHCatRecord(rlist));
-    return data;
-  }
+        data.put(props, new DefaultHCatRecord(rlist));
+        return data;
+    }
 
-  public void testRW() throws Exception {
+    public void testRW() throws Exception {
 
-    Configuration conf = new Configuration();
+        Configuration conf = new Configuration();
 
-    for (Entry<Properties,HCatRecord> e : getData().entrySet()){
-      Properties tblProps = e.getKey();
-      HCatRecord r = e.getValue();
+        for (Entry<Properties, HCatRecord> e : getData().entrySet()) {
+            Properties tblProps = e.getKey();
+            HCatRecord r = e.getValue();
 
-      HCatRecordSerDe hrsd = new HCatRecordSerDe();
-      hrsd.initialize(conf, tblProps);
+            HCatRecordSerDe hrsd = new HCatRecordSerDe();
+            hrsd.initialize(conf, tblProps);
 
-      LOG.info("ORIG: {}", r);
+            LOG.info("ORIG: {}", r);
 
-      Writable s = hrsd.serialize(r,hrsd.getObjectInspector());
-      LOG.info("ONE: {}", s);
+            Writable s = hrsd.serialize(r, hrsd.getObjectInspector());
+            LOG.info("ONE: {}", s);
 
-      HCatRecord r2 = (HCatRecord) hrsd.deserialize(s);
-      Assert.assertTrue(HCatDataCheckUtil.recordsEqual(r,r2));
+            HCatRecord r2 = (HCatRecord) hrsd.deserialize(s);
+            Assert.assertTrue(HCatDataCheckUtil.recordsEqual(r, r2));
 
-      // If it went through correctly, then s is also a HCatRecord,
-      // and also equal to the above, and a deepcopy, and this holds
-      // through for multiple levels more of serialization as well.
+            // If it went through correctly, then s is also a HCatRecord,
+            // and also equal to the above, and a deepcopy, and this holds
+            // through for multiple levels more of serialization as well.
 
-      Writable s2 = hrsd.serialize(s, hrsd.getObjectInspector());
-      LOG.info("TWO: {}", s2);
-      Assert.assertTrue(HCatDataCheckUtil.recordsEqual(r,(HCatRecord)s));
-      Assert.assertTrue(HCatDataCheckUtil.recordsEqual(r,(HCatRecord)s2));
+            Writable s2 = hrsd.serialize(s, hrsd.getObjectInspector());
+            LOG.info("TWO: {}", s2);
+            Assert.assertTrue(HCatDataCheckUtil.recordsEqual(r, (HCatRecord) s));
+            Assert.assertTrue(HCatDataCheckUtil.recordsEqual(r, (HCatRecord) s2));
 
-      // serialize using another serde, and read out that object repr.
-      LazySimpleSerDe testSD = new LazySimpleSerDe();
-      testSD.initialize(conf, tblProps);
+            // serialize using another serde, and read out that object repr.
+            LazySimpleSerDe testSD = new LazySimpleSerDe();
+            testSD.initialize(conf, tblProps);
 
-      Writable s3 = testSD.serialize(s, hrsd.getObjectInspector());
-      LOG.info("THREE: {}",s3);
-      Object o3 = testSD.deserialize(s3);
-      Assert.assertFalse(r.getClass().equals(o3.getClass()));
+            Writable s3 = testSD.serialize(s, hrsd.getObjectInspector());
+            LOG.info("THREE: {}", s3);
+            Object o3 = testSD.deserialize(s3);
+            Assert.assertFalse(r.getClass().equals(o3.getClass()));
 
-      // then serialize again using hrsd, and compare results
-      HCatRecord s4 = (HCatRecord) hrsd.serialize(o3, testSD.getObjectInspector());
-      LOG.info("FOUR: {}", s4);
+            // then serialize again using hrsd, and compare results
+            HCatRecord s4 = (HCatRecord) hrsd.serialize(o3, testSD.getObjectInspector());
+            LOG.info("FOUR: {}", s4);
 
-      // Test LazyHCatRecord init and read
-      LazyHCatRecord s5 = new LazyHCatRecord(o3,testSD.getObjectInspector());
-      LOG.info("FIVE: {}",s5);
+            // Test LazyHCatRecord init and read
+            LazyHCatRecord s5 = new LazyHCatRecord(o3, testSD.getObjectInspector());
+            LOG.info("FIVE: {}", s5);
 
-      LazyHCatRecord s6 = new LazyHCatRecord(s4,hrsd.getObjectInspector());
-      LOG.info("SIX: {}", s6);
+            LazyHCatRecord s6 = new LazyHCatRecord(s4, hrsd.getObjectInspector());
+            LOG.info("SIX: {}", s6);
 
-    }
+        }
 
-  }
+    }
 
 }

Modified: incubator/hcatalog/trunk/src/test/org/apache/hcatalog/data/TestJsonSerDe.java
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/src/test/org/apache/hcatalog/data/TestJsonSerDe.java?rev=1383152&r1=1383151&r2=1383152&view=diff
==============================================================================
--- incubator/hcatalog/trunk/src/test/org/apache/hcatalog/data/TestJsonSerDe.java (original)
+++ incubator/hcatalog/trunk/src/test/org/apache/hcatalog/data/TestJsonSerDe.java Mon Sep 10 23:28:55 2012
@@ -32,182 +32,182 @@ import org.apache.hadoop.io.Writable;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class TestJsonSerDe extends TestCase{
+public class TestJsonSerDe extends TestCase {
 
-  private static final Logger LOG = LoggerFactory.getLogger(TestJsonSerDe.class);
+    private static final Logger LOG = LoggerFactory.getLogger(TestJsonSerDe.class);
 
-  public List<Pair<Properties,HCatRecord>> getData(){
-    List<Pair<Properties,HCatRecord>> data = new ArrayList<Pair<Properties,HCatRecord>>();
+    public List<Pair<Properties, HCatRecord>> getData() {
+        List<Pair<Properties, HCatRecord>> data = new ArrayList<Pair<Properties, HCatRecord>>();
 
-    List<Object> rlist = new ArrayList<Object>(13);
-    rlist.add(new Byte("123"));
-    rlist.add(new Short("456"));
-    rlist.add(new Integer(789));
-    rlist.add(new Long(1000L));
-    rlist.add(new Double(5.3D));
-    rlist.add(new Float(2.39F));
-    rlist.add(new String("hcat and hadoop"));
-    rlist.add(null);
-
-    List<Object> innerStruct = new ArrayList<Object>(2);
-    innerStruct.add(new String("abc"));
-    innerStruct.add(new String("def"));
-    rlist.add(innerStruct);
-
-    List<Integer> innerList = new ArrayList<Integer>();
-    innerList.add(314);
-    innerList.add(007);
-    rlist.add(innerList);
-
-    Map<Short, String> map = new HashMap<Short, String>(3);
-    map.put(new Short("2"), "hcat is cool");
-    map.put(new Short("3"), "is it?");
-    map.put(new Short("4"), "or is it not?");
-    rlist.add(map);
-
-    rlist.add(new Boolean(true));
-
-    List<Object> c1 = new ArrayList<Object>();
-      List<Object> c1_1 = new ArrayList<Object>();
-      c1_1.add(new Integer(12));
+        List<Object> rlist = new ArrayList<Object>(13);
+        rlist.add(new Byte("123"));
+        rlist.add(new Short("456"));
+        rlist.add(new Integer(789));
+        rlist.add(new Long(1000L));
+        rlist.add(new Double(5.3D));
+        rlist.add(new Float(2.39F));
+        rlist.add(new String("hcat and hadoop"));
+        rlist.add(null);
+
+        List<Object> innerStruct = new ArrayList<Object>(2);
+        innerStruct.add(new String("abc"));
+        innerStruct.add(new String("def"));
+        rlist.add(innerStruct);
+
+        List<Integer> innerList = new ArrayList<Integer>();
+        innerList.add(314);
+        innerList.add(007);
+        rlist.add(innerList);
+
+        Map<Short, String> map = new HashMap<Short, String>(3);
+        map.put(new Short("2"), "hcat is cool");
+        map.put(new Short("3"), "is it?");
+        map.put(new Short("4"), "or is it not?");
+        rlist.add(map);
+
+        rlist.add(new Boolean(true));
+
+        List<Object> c1 = new ArrayList<Object>();
+        List<Object> c1_1 = new ArrayList<Object>();
+        c1_1.add(new Integer(12));
         List<Object> i2 = new ArrayList<Object>();
-          List<Integer> ii1 = new ArrayList<Integer>();
-            ii1.add(new Integer(13));
-            ii1.add(new Integer(14));
-          i2.add(ii1);
-          Map<String,List<?>> ii2 = new HashMap<String,List<?>>();
-            List<Integer> iii1 = new ArrayList<Integer>();
-              iii1.add(new Integer(15));
-            ii2.put("phew", iii1);
-          i2.add(ii2);
-      c1_1.add(i2);
-      c1.add(c1_1);
-    rlist.add(c1);
-
-    List<Object> nlist = new ArrayList<Object>(13);
-    nlist.add(null); // tinyint
-    nlist.add(null); // smallint
-    nlist.add(null); // int
-    nlist.add(null); // bigint
-    nlist.add(null); // double
-    nlist.add(null); // float
-    nlist.add(null); // string
-    nlist.add(null); // string
-    nlist.add(null); // struct
-    nlist.add(null); // array
-    nlist.add(null); // map
-    nlist.add(null); // bool
-    nlist.add(null); // complex
-
-    String typeString =
-        "tinyint,smallint,int,bigint,double,float,string,string,"
-        + "struct<a:string,b:string>,array<int>,map<smallint,string>,boolean,"
-        + "array<struct<i1:int,i2:struct<ii1:array<int>,ii2:map<string,struct<iii1:int>>>>>";
-    Properties props = new Properties();
+        List<Integer> ii1 = new ArrayList<Integer>();
+        ii1.add(new Integer(13));
+        ii1.add(new Integer(14));
+        i2.add(ii1);
+        Map<String, List<?>> ii2 = new HashMap<String, List<?>>();
+        List<Integer> iii1 = new ArrayList<Integer>();
+        iii1.add(new Integer(15));
+        ii2.put("phew", iii1);
+        i2.add(ii2);
+        c1_1.add(i2);
+        c1.add(c1_1);
+        rlist.add(c1);
+
+        List<Object> nlist = new ArrayList<Object>(13);
+        nlist.add(null); // tinyint
+        nlist.add(null); // smallint
+        nlist.add(null); // int
+        nlist.add(null); // bigint
+        nlist.add(null); // double
+        nlist.add(null); // float
+        nlist.add(null); // string
+        nlist.add(null); // string
+        nlist.add(null); // struct
+        nlist.add(null); // array
+        nlist.add(null); // map
+        nlist.add(null); // bool
+        nlist.add(null); // complex
+
+        String typeString =
+                "tinyint,smallint,int,bigint,double,float,string,string,"
+                        + "struct<a:string,b:string>,array<int>,map<smallint,string>,boolean,"
+                        + "array<struct<i1:int,i2:struct<ii1:array<int>,ii2:map<string,struct<iii1:int>>>>>";
+        Properties props = new Properties();
 
-    props.put(Constants.LIST_COLUMNS, "ti,si,i,bi,d,f,s,n,r,l,m,b,c1");
-    props.put(Constants.LIST_COLUMN_TYPES, typeString);
+        props.put(Constants.LIST_COLUMNS, "ti,si,i,bi,d,f,s,n,r,l,m,b,c1");
+        props.put(Constants.LIST_COLUMN_TYPES, typeString);
 //    props.put(Constants.SERIALIZATION_NULL_FORMAT, "\\N");
 //    props.put(Constants.SERIALIZATION_FORMAT, "1");
 
-    data.add(new Pair(props, new DefaultHCatRecord(rlist)));
-    data.add(new Pair(props, new DefaultHCatRecord(nlist)));
-    return data;
-  }
-
-  public void testRW() throws Exception {
-
-    Configuration conf = new Configuration();
+        data.add(new Pair(props, new DefaultHCatRecord(rlist)));
+        data.add(new Pair(props, new DefaultHCatRecord(nlist)));
+        return data;
+    }
 
-    for (Pair<Properties,HCatRecord> e : getData()){
-      Properties tblProps = e.first;
-      HCatRecord r = e.second;
+    public void testRW() throws Exception {
 
-      HCatRecordSerDe hrsd = new HCatRecordSerDe();
-      hrsd.initialize(conf, tblProps);
+        Configuration conf = new Configuration();
 
-      JsonSerDe jsde = new JsonSerDe();
-      jsde.initialize(conf, tblProps);
+        for (Pair<Properties, HCatRecord> e : getData()) {
+            Properties tblProps = e.first;
+            HCatRecord r = e.second;
 
-      LOG.info("ORIG:{}",r);
+            HCatRecordSerDe hrsd = new HCatRecordSerDe();
+            hrsd.initialize(conf, tblProps);
 
-      Writable s = hrsd.serialize(r,hrsd.getObjectInspector());
-      LOG.info("ONE:{}",s);
+            JsonSerDe jsde = new JsonSerDe();
+            jsde.initialize(conf, tblProps);
 
-      Object o1 = hrsd.deserialize(s);
-      assertTrue(HCatDataCheckUtil.recordsEqual(r, (HCatRecord) o1));
+            LOG.info("ORIG:{}", r);
 
-      Writable s2 = jsde.serialize(o1, hrsd.getObjectInspector());
-      LOG.info("TWO:{}",s2);
-      Object o2 = jsde.deserialize(s2);
-      LOG.info("deserialized TWO : {} ", o2);
+            Writable s = hrsd.serialize(r, hrsd.getObjectInspector());
+            LOG.info("ONE:{}", s);
 
-      assertTrue(HCatDataCheckUtil.recordsEqual(r, (HCatRecord) o2));
-    }
+            Object o1 = hrsd.deserialize(s);
+            assertTrue(HCatDataCheckUtil.recordsEqual(r, (HCatRecord) o1));
 
-  }
+            Writable s2 = jsde.serialize(o1, hrsd.getObjectInspector());
+            LOG.info("TWO:{}", s2);
+            Object o2 = jsde.deserialize(s2);
+            LOG.info("deserialized TWO : {} ", o2);
 
-  public void testRobustRead() throws Exception {
-    /**
-     *  This test has been added to account for HCATALOG-436
-     *  We write out columns with "internal column names" such
-     *  as "_col0", but try to read with retular column names.
-     */
-    
-    Configuration conf = new Configuration();
-
-    for (Pair<Properties,HCatRecord> e : getData()){
-      Properties tblProps = e.first;
-      HCatRecord r = e.second;
-      
-      Properties internalTblProps = new Properties();
-      for (Map.Entry pe : tblProps.entrySet()){
-        if (!pe.getKey().equals(Constants.LIST_COLUMNS)){
-          internalTblProps.put(pe.getKey(), pe.getValue());
-        } else {
-          internalTblProps.put(pe.getKey(),getInternalNames((String) pe.getValue()));
+            assertTrue(HCatDataCheckUtil.recordsEqual(r, (HCatRecord) o2));
         }
-      }
-      
-      LOG.info("orig tbl props:{}",tblProps);
-      LOG.info("modif tbl props:{}",internalTblProps);
 
-      JsonSerDe wjsd = new JsonSerDe();
-      wjsd.initialize(conf, internalTblProps);
-
-      JsonSerDe rjsd = new JsonSerDe();
-      rjsd.initialize(conf, tblProps);
+    }
 
-      LOG.info("ORIG:{}",r);
+    public void testRobustRead() throws Exception {
+        /**
+         *  This test has been added to account for HCATALOG-436
+         *  We write out columns with "internal column names" such
+         *  as "_col0", but try to read with retular column names.
+         */
+
+        Configuration conf = new Configuration();
+
+        for (Pair<Properties, HCatRecord> e : getData()) {
+            Properties tblProps = e.first;
+            HCatRecord r = e.second;
+
+            Properties internalTblProps = new Properties();
+            for (Map.Entry pe : tblProps.entrySet()) {
+                if (!pe.getKey().equals(Constants.LIST_COLUMNS)) {
+                    internalTblProps.put(pe.getKey(), pe.getValue());
+                } else {
+                    internalTblProps.put(pe.getKey(), getInternalNames((String) pe.getValue()));
+                }
+            }
+
+            LOG.info("orig tbl props:{}", tblProps);
+            LOG.info("modif tbl props:{}", internalTblProps);
+
+            JsonSerDe wjsd = new JsonSerDe();
+            wjsd.initialize(conf, internalTblProps);
+
+            JsonSerDe rjsd = new JsonSerDe();
+            rjsd.initialize(conf, tblProps);
+
+            LOG.info("ORIG:{}", r);
+
+            Writable s = wjsd.serialize(r, wjsd.getObjectInspector());
+            LOG.info("ONE:{}", s);
+
+            Object o1 = wjsd.deserialize(s);
+            LOG.info("deserialized ONE : {} ", o1);
+
+            Object o2 = rjsd.deserialize(s);
+            LOG.info("deserialized TWO : {} ", o2);
+            assertTrue(HCatDataCheckUtil.recordsEqual(r, (HCatRecord) o2));
+        }
 
-      Writable s = wjsd.serialize(r,wjsd.getObjectInspector());
-      LOG.info("ONE:{}",s);
+    }
 
-      Object o1 = wjsd.deserialize(s);
-      LOG.info("deserialized ONE : {} ", o1);
+    String getInternalNames(String columnNames) {
+        if (columnNames == null) {
+            return null;
+        }
+        if (columnNames.isEmpty()) {
+            return "";
+        }
 
-      Object o2 = rjsd.deserialize(s);
-      LOG.info("deserialized TWO : {} ", o2);
-      assertTrue(HCatDataCheckUtil.recordsEqual(r, (HCatRecord) o2));
-    }
-    
-  }
-  
-  String getInternalNames(String columnNames){
-    if (columnNames == null) { 
-      return null; 
-    }
-    if (columnNames.isEmpty()) { 
-      return ""; 
-    }
-    
-    StringBuffer sb = new StringBuffer();
-    int numStrings = columnNames.split(",").length;
-    sb.append("_col0");
-    for (int i = 1; i < numStrings ; i++ ){
-      sb.append(",");
-      sb.append(HiveConf.getColumnInternalName(i));
+        StringBuffer sb = new StringBuffer();
+        int numStrings = columnNames.split(",").length;
+        sb.append("_col0");
+        for (int i = 1; i < numStrings; i++) {
+            sb.append(",");
+            sb.append(HiveConf.getColumnInternalName(i));
+        }
+        return sb.toString();
     }
-    return sb.toString();
-  }
 }

Modified: incubator/hcatalog/trunk/src/test/org/apache/hcatalog/data/TestLazyHCatRecord.java
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/src/test/org/apache/hcatalog/data/TestLazyHCatRecord.java?rev=1383152&r1=1383151&r2=1383152&view=diff
==============================================================================
--- incubator/hcatalog/trunk/src/test/org/apache/hcatalog/data/TestLazyHCatRecord.java (original)
+++ incubator/hcatalog/trunk/src/test/org/apache/hcatalog/data/TestLazyHCatRecord.java Mon Sep 10 23:28:55 2012
@@ -31,165 +31,162 @@ import org.junit.Test;
 
 public class TestLazyHCatRecord {
 
-  private final int INT_CONST = 789;
-  private final long LONG_CONST = 5000000000L;
-  private final double DOUBLE_CONST = 3.141592654;
-  private final String STRING_CONST = "hello world";
-
-  @Test
-  public void testGet() throws Exception {
-    HCatRecord r = new LazyHCatRecord(getHCatRecord(), getObjectInspector());
-    Assert.assertEquals(INT_CONST, ((Integer) r.get(0)).intValue());
-    Assert.assertEquals(LONG_CONST, ((Long) r.get(1)).longValue());
-    Assert.assertEquals(DOUBLE_CONST, ((Double) r.get(2)).doubleValue(), 0);
-    Assert.assertEquals(STRING_CONST, (String) r.get(3));
-  }
-
-  @Test
-  public void testGetWithName() throws Exception {
-    TypeInfo ti = getTypeInfo();
-    HCatRecord r = new LazyHCatRecord(getHCatRecord(), getObjectInspector(ti));
-    HCatSchema schema = HCatSchemaUtils.getHCatSchema(ti)
-                                          .get(0).getStructSubSchema();
-    Assert.assertEquals(INT_CONST, ((Integer) r.get("an_int", schema)).intValue());
-    Assert.assertEquals(LONG_CONST, ((Long) r.get("a_long", schema)).longValue());
-    Assert.assertEquals(DOUBLE_CONST, ((Double) r.get("a_double", schema)).doubleValue(), 0);
-    Assert.assertEquals(STRING_CONST, (String) r.get("a_string", schema));
-  }
-
-  @Test
-  public void testGetAll() throws Exception {
-    HCatRecord r = new LazyHCatRecord(getHCatRecord(), getObjectInspector());
-    List<Object> list = r.getAll();
-    Assert.assertEquals(INT_CONST, ((Integer) list.get(0)).intValue());
-    Assert.assertEquals(LONG_CONST, ((Long) list.get(1)).longValue());
-    Assert.assertEquals(DOUBLE_CONST, ((Double) list.get(2)).doubleValue(), 0);
-    Assert.assertEquals(STRING_CONST, (String) list.get(3));
-  }
-
-  @Test
-  public void testSet() throws Exception {
-    HCatRecord r = new LazyHCatRecord(getHCatRecord(), getObjectInspector());
-    boolean sawException = false;
-    try {
-      r.set(3, "Mary had a little lamb");
-    } catch (UnsupportedOperationException uoe) {
-      sawException = true;
-    }
-    Assert.assertTrue(sawException);
-  }
-
-  @Test
-  public void testSize() throws Exception {
-    HCatRecord r = new LazyHCatRecord(getHCatRecord(), getObjectInspector());
-    Assert.assertEquals(4, r.size());
-  }
-
-  @Test
-  public void testReadFields() throws Exception {
-    HCatRecord r = new LazyHCatRecord(getHCatRecord(), getObjectInspector());
-    boolean sawException = false;
-    try {
-      r.readFields(null);
-    } catch (UnsupportedOperationException uoe) {
-      sawException = true;
-    }
-    Assert.assertTrue(sawException);
-  }
-
-  @Test
-  public void testWrite() throws Exception {
-    HCatRecord r = new LazyHCatRecord(getHCatRecord(), getObjectInspector());
-    boolean sawException = false;
-    try {
-      r.write(null);
-    } catch (UnsupportedOperationException uoe) {
-      sawException = true;
-    }
-    Assert.assertTrue(sawException);
-  }
-
-  @Test
-  public void testSetWithName() throws Exception {
-    HCatRecord r = new LazyHCatRecord(getHCatRecord(), getObjectInspector());
-    boolean sawException = false;
-    try {
-      r.set("fred", null, "bob");
-    } catch (UnsupportedOperationException uoe) {
-      sawException = true;
-    }
-    Assert.assertTrue(sawException);
-  }
-
-  @Test
-  public void testRemove() throws Exception {
-    HCatRecord r = new LazyHCatRecord(getHCatRecord(), getObjectInspector());
-    boolean sawException = false;
-    try {
-      r.remove(0);
-    } catch (UnsupportedOperationException uoe) {
-      sawException = true;
-    }
-    Assert.assertTrue(sawException);
-  }
-
-  @Test
-  public void testCopy() throws Exception {
-    HCatRecord r = new LazyHCatRecord(getHCatRecord(), getObjectInspector());
-    boolean sawException = false;
-    try {
-      r.copy(null);
-    } catch (UnsupportedOperationException uoe) {
-      sawException = true;
-    }
-    Assert.assertTrue(sawException);
-  }
-
-  @Test
-  public void testGetWritable() throws Exception {
-    HCatRecord r = new LazyHCatRecord(getHCatRecord(), getObjectInspector()).getWritable();
-    Assert.assertEquals(INT_CONST, ((Integer) r.get(0)).intValue());
-    Assert.assertEquals(LONG_CONST, ((Long) r.get(1)).longValue());
-    Assert.assertEquals(DOUBLE_CONST, ((Double) r.get(2)).doubleValue(), 0);
-    Assert.assertEquals(STRING_CONST, (String) r.get(3));
-    Assert.assertEquals("org.apache.hcatalog.data.DefaultHCatRecord", r.getClass().getName());
-  }
-
-  private HCatRecord getHCatRecord() throws Exception {
-
-    List<Object> rec_1 = new ArrayList<Object>(4);
-    rec_1.add( new Integer(INT_CONST));
-    rec_1.add( new Long(LONG_CONST));
-    rec_1.add( new Double(DOUBLE_CONST));
-    rec_1.add( new String(STRING_CONST));
-
-    return new DefaultHCatRecord(rec_1);
-  }
-
-  private TypeInfo getTypeInfo() throws Exception {
-    List<String> names = new ArrayList<String>(4);
-    names.add("an_int");
-    names.add("a_long");
-    names.add("a_double");
-    names.add("a_string");
-
-    List<TypeInfo> tis = new ArrayList<TypeInfo>(4);
-    tis.add(TypeInfoFactory.getPrimitiveTypeInfo("int"));
-    tis.add(TypeInfoFactory.getPrimitiveTypeInfo("bigint"));
-    tis.add(TypeInfoFactory.getPrimitiveTypeInfo("double"));
-    tis.add(TypeInfoFactory.getPrimitiveTypeInfo("string"));
-
-    return TypeInfoFactory.getStructTypeInfo(names, tis);
-
-  }
-
-  private ObjectInspector getObjectInspector(TypeInfo ti) throws Exception {
-    return HCatRecordObjectInspectorFactory.getHCatRecordObjectInspector(
-        (StructTypeInfo)ti);
-  }
-
-  private ObjectInspector getObjectInspector() throws Exception {
-    return HCatRecordObjectInspectorFactory.getHCatRecordObjectInspector(
-          (StructTypeInfo)getTypeInfo());
-  }
+    private final int INT_CONST = 789;
+    private final long LONG_CONST = 5000000000L;
+    private final double DOUBLE_CONST = 3.141592654;
+    private final String STRING_CONST = "hello world";
+
+    @Test
+    public void testGet() throws Exception {
+        HCatRecord r = new LazyHCatRecord(getHCatRecord(), getObjectInspector());
+        Assert.assertEquals(INT_CONST, ((Integer) r.get(0)).intValue());
+        Assert.assertEquals(LONG_CONST, ((Long) r.get(1)).longValue());
+        Assert.assertEquals(DOUBLE_CONST, ((Double) r.get(2)).doubleValue(), 0);
+        Assert.assertEquals(STRING_CONST, (String) r.get(3));
+    }
+
+    @Test
+    public void testGetWithName() throws Exception {
+        TypeInfo ti = getTypeInfo();
+        HCatRecord r = new LazyHCatRecord(getHCatRecord(), getObjectInspector(ti));
+        HCatSchema schema = HCatSchemaUtils.getHCatSchema(ti)
+                                              .get(0).getStructSubSchema();
+        Assert.assertEquals(INT_CONST, ((Integer) r.get("an_int", schema)).intValue());
+        Assert.assertEquals(LONG_CONST, ((Long) r.get("a_long", schema)).longValue());
+        Assert.assertEquals(DOUBLE_CONST, ((Double) r.get("a_double", schema)).doubleValue(), 0);
+        Assert.assertEquals(STRING_CONST, (String) r.get("a_string", schema));
+    }
+
+    @Test
+    public void testGetAll() throws Exception {
+        HCatRecord r = new LazyHCatRecord(getHCatRecord(), getObjectInspector());
+        List<Object> list = r.getAll();
+        Assert.assertEquals(INT_CONST, ((Integer) list.get(0)).intValue());
+        Assert.assertEquals(LONG_CONST, ((Long) list.get(1)).longValue());
+        Assert.assertEquals(DOUBLE_CONST, ((Double) list.get(2)).doubleValue(), 0);
+        Assert.assertEquals(STRING_CONST, (String) list.get(3));
+    }
+
+    @Test
+    public void testSet() throws Exception {
+        HCatRecord r = new LazyHCatRecord(getHCatRecord(), getObjectInspector());
+        boolean sawException = false;
+        try {
+            r.set(3, "Mary had a little lamb");
+        } catch (UnsupportedOperationException uoe) {
+            sawException = true;
+        }
+        Assert.assertTrue(sawException);
+    }
+
+    @Test
+    public void testSize() throws Exception {
+        HCatRecord r = new LazyHCatRecord(getHCatRecord(), getObjectInspector());
+        Assert.assertEquals(4, r.size());
+    }
+
+    @Test
+    public void testReadFields() throws Exception {
+        HCatRecord r = new LazyHCatRecord(getHCatRecord(), getObjectInspector());
+        boolean sawException = false;
+        try {
+            r.readFields(null);
+        } catch (UnsupportedOperationException uoe) {
+            sawException = true;
+        }
+        Assert.assertTrue(sawException);
+    }
+
+    @Test
+    public void testWrite() throws Exception {
+        HCatRecord r = new LazyHCatRecord(getHCatRecord(), getObjectInspector());
+        boolean sawException = false;
+        try {
+            r.write(null);
+        } catch (UnsupportedOperationException uoe) {
+            sawException = true;
+        }
+        Assert.assertTrue(sawException);
+    }
+
+    @Test
+    public void testSetWithName() throws Exception {
+        HCatRecord r = new LazyHCatRecord(getHCatRecord(), getObjectInspector());
+        boolean sawException = false;
+        try {
+            r.set("fred", null, "bob");
+        } catch (UnsupportedOperationException uoe) {
+            sawException = true;
+        }
+        Assert.assertTrue(sawException);
+    }
+
+    @Test
+    public void testRemove() throws Exception {
+        HCatRecord r = new LazyHCatRecord(getHCatRecord(), getObjectInspector());
+        boolean sawException = false;
+        try {
+            r.remove(0);
+        } catch (UnsupportedOperationException uoe) {
+            sawException = true;
+        }
+        Assert.assertTrue(sawException);
+    }
+
+    @Test
+    public void testCopy() throws Exception {
+        HCatRecord r = new LazyHCatRecord(getHCatRecord(), getObjectInspector());
+        boolean sawException = false;
+        try {
+            r.copy(null);
+        } catch (UnsupportedOperationException uoe) {
+            sawException = true;
+        }
+        Assert.assertTrue(sawException);
+    }
+
+    @Test
+    public void testGetWritable() throws Exception {
+        HCatRecord r = new LazyHCatRecord(getHCatRecord(), getObjectInspector()).getWritable();
+        Assert.assertEquals(INT_CONST, ((Integer) r.get(0)).intValue());
+        Assert.assertEquals(LONG_CONST, ((Long) r.get(1)).longValue());
+        Assert.assertEquals(DOUBLE_CONST, ((Double) r.get(2)).doubleValue(), 0);
+        Assert.assertEquals(STRING_CONST, (String) r.get(3));
+        Assert.assertEquals("org.apache.hcatalog.data.DefaultHCatRecord", r.getClass().getName());
+    }
+
+    private HCatRecord getHCatRecord() throws Exception {
+        List<Object> rec_1 = new ArrayList<Object>(4);
+        rec_1.add( new Integer(INT_CONST));
+        rec_1.add( new Long(LONG_CONST));
+        rec_1.add( new Double(DOUBLE_CONST));
+        rec_1.add( new String(STRING_CONST));
+
+        return new DefaultHCatRecord(rec_1);
+    }
+
+    private TypeInfo getTypeInfo() throws Exception {
+        List<String> names = new ArrayList<String>(4);
+        names.add("an_int");
+        names.add("a_long");
+        names.add("a_double");
+        names.add("a_string");
+
+        List<TypeInfo> tis = new ArrayList<TypeInfo>(4);
+        tis.add(TypeInfoFactory.getPrimitiveTypeInfo("int"));
+        tis.add(TypeInfoFactory.getPrimitiveTypeInfo("bigint"));
+        tis.add(TypeInfoFactory.getPrimitiveTypeInfo("double"));
+        tis.add(TypeInfoFactory.getPrimitiveTypeInfo("string"));
+
+        return TypeInfoFactory.getStructTypeInfo(names, tis);
+    }
+
+    private ObjectInspector getObjectInspector(TypeInfo ti) throws Exception {
+        return HCatRecordObjectInspectorFactory.getHCatRecordObjectInspector((StructTypeInfo)ti);
+    }
+
+    private ObjectInspector getObjectInspector() throws Exception {
+        return HCatRecordObjectInspectorFactory.getHCatRecordObjectInspector(
+            (StructTypeInfo)getTypeInfo());
+    }
 }

Modified: incubator/hcatalog/trunk/src/test/org/apache/hcatalog/data/TestReaderWriter.java
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/src/test/org/apache/hcatalog/data/TestReaderWriter.java?rev=1383152&r1=1383151&r2=1383152&view=diff
==============================================================================
--- incubator/hcatalog/trunk/src/test/org/apache/hcatalog/data/TestReaderWriter.java (original)
+++ incubator/hcatalog/trunk/src/test/org/apache/hcatalog/data/TestReaderWriter.java Mon Sep 10 23:28:55 2012
@@ -49,140 +49,136 @@ import org.junit.Test;
 
 public class TestReaderWriter extends HCatBaseTest {
 
-  @Test
-  public void test() throws MetaException, CommandNeedRetryException,
-      IOException, ClassNotFoundException {
-
-    driver.run("drop table mytbl");
-    driver.run("create table mytbl (a string, b int)");
-    Iterator<Entry<String, String>> itr = hiveConf.iterator();
-    Map<String, String> map = new HashMap<String, String>();
-    while (itr.hasNext()) {
-      Entry<String, String> kv = itr.next();
-      map.put(kv.getKey(), kv.getValue());
-    }
-
-    WriterContext cntxt = runsInMaster(map);
-
-    File writeCntxtFile = File.createTempFile("hcat-write", "temp");
-    writeCntxtFile.deleteOnExit();
-
-    // Serialize context.
-    ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(
-        writeCntxtFile));
-    oos.writeObject(cntxt);
-    oos.flush();
-    oos.close();
-
-    // Now, deserialize it.
-    ObjectInputStream ois = new ObjectInputStream(new FileInputStream(
-        writeCntxtFile));
-    cntxt = (WriterContext) ois.readObject();
-    ois.close();
-
-    runsInSlave(cntxt);
-    commit(map, true, cntxt);
-
-    ReaderContext readCntxt = runsInMaster(map, false);
-
-    File readCntxtFile = File.createTempFile("hcat-read", "temp");
-    readCntxtFile.deleteOnExit();
-    oos = new ObjectOutputStream(new FileOutputStream(readCntxtFile));
-    oos.writeObject(readCntxt);
-    oos.flush();
-    oos.close();
-
-    ois = new ObjectInputStream(new FileInputStream(readCntxtFile));
-    readCntxt = (ReaderContext) ois.readObject();
-    ois.close();
-
-    for (InputSplit split : readCntxt.getSplits()) {
-      runsInSlave(split, readCntxt.getConf());
-    }
-  }
-
-  private WriterContext runsInMaster(Map<String, String> config)
-      throws HCatException {
-
-    WriteEntity.Builder builder = new WriteEntity.Builder();
-    WriteEntity entity = builder.withTable("mytbl").build();
-    HCatWriter writer = DataTransferFactory.getHCatWriter(entity, config);
-    WriterContext info = writer.prepareWrite();
-    return info;
-  }
-
-  private ReaderContext runsInMaster(Map<String, String> config, boolean bogus)
-      throws HCatException {
-
-    ReadEntity.Builder builder = new ReadEntity.Builder();
-    ReadEntity entity = builder.withTable("mytbl").build();
-    HCatReader reader = DataTransferFactory.getHCatReader(entity, config);
-    ReaderContext cntxt = reader.prepareRead();
-    return cntxt;
-  }
-
-  private void runsInSlave(InputSplit split, Configuration config)
-      throws HCatException {
-
-    HCatReader reader = DataTransferFactory.getHCatReader(split, config);
-    Iterator<HCatRecord> itr = reader.read();
-    int i = 1;
-    while (itr.hasNext()) {
-      HCatRecord read = itr.next();
-      HCatRecord written = getRecord(i++);
-      // Argh, HCatRecord doesnt implement equals()
-      Assert.assertTrue("Read: " + read.get(0) + "Written: " + written.get(0),
-          written.get(0).equals(read.get(0)));
-      Assert.assertTrue("Read: " + read.get(1) + "Written: " + written.get(1),
-          written.get(1).equals(read.get(1)));
-      Assert.assertEquals(2, read.size());
-    }
-    //Assert.assertFalse(itr.hasNext());
-  }
-
-  private void runsInSlave(WriterContext context) throws HCatException {
-
-    HCatWriter writer = DataTransferFactory.getHCatWriter(context);
-    writer.write(new HCatRecordItr());
-  }
-
-  private void commit(Map<String, String> config, boolean status,
-      WriterContext context) throws IOException {
-
-    WriteEntity.Builder builder = new WriteEntity.Builder();
-    WriteEntity entity = builder.withTable("mytbl").build();
-    HCatWriter writer = DataTransferFactory.getHCatWriter(entity, config);
-    if (status) {
-      writer.commit(context);
-    } else {
-      writer.abort(context);
-    }
-  }
-
-  private static HCatRecord getRecord(int i) {
-    List<Object> list = new ArrayList<Object>(2);
-    list.add("Row #: " + i);
-    list.add(i);
-    return new DefaultHCatRecord(list);
-  }
-
-  private static class HCatRecordItr implements Iterator<HCatRecord> {
-
-    int i = 0;
-
-    @Override
-    public boolean hasNext() {
-      return i++ < 100 ? true : false;
-    }
-
-    @Override
-    public HCatRecord next() {
-      return getRecord(i);
-    }
-
-    @Override
-    public void remove() {
-      throw new RuntimeException();
+    @Test
+    public void test() throws MetaException, CommandNeedRetryException,
+            IOException, ClassNotFoundException {
+
+        driver.run("drop table mytbl");
+        driver.run("create table mytbl (a string, b int)");
+        Iterator<Entry<String, String>> itr = hiveConf.iterator();
+        Map<String, String> map = new HashMap<String, String>();
+        while (itr.hasNext()) {
+            Entry<String, String> kv = itr.next();
+            map.put(kv.getKey(), kv.getValue());
+        }
+
+        WriterContext cntxt = runsInMaster(map);
+
+        File writeCntxtFile = File.createTempFile("hcat-write", "temp");
+        writeCntxtFile.deleteOnExit();
+
+        // Serialize context.
+        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(writeCntxtFile));
+        oos.writeObject(cntxt);
+        oos.flush();
+        oos.close();
+
+        // Now, deserialize it.
+        ObjectInputStream ois = new ObjectInputStream(new FileInputStream(writeCntxtFile));
+        cntxt = (WriterContext) ois.readObject();
+        ois.close();
+
+        runsInSlave(cntxt);
+        commit(map, true, cntxt);
+
+        ReaderContext readCntxt = runsInMaster(map, false);
+
+        File readCntxtFile = File.createTempFile("hcat-read", "temp");
+        readCntxtFile.deleteOnExit();
+        oos = new ObjectOutputStream(new FileOutputStream(readCntxtFile));
+        oos.writeObject(readCntxt);
+        oos.flush();
+        oos.close();
+
+        ois = new ObjectInputStream(new FileInputStream(readCntxtFile));
+        readCntxt = (ReaderContext) ois.readObject();
+        ois.close();
+
+        for (InputSplit split : readCntxt.getSplits()) {
+            runsInSlave(split, readCntxt.getConf());
+        }
+    }
+
+    private WriterContext runsInMaster(Map<String, String> config) throws HCatException {
+
+        WriteEntity.Builder builder = new WriteEntity.Builder();
+        WriteEntity entity = builder.withTable("mytbl").build();
+        HCatWriter writer = DataTransferFactory.getHCatWriter(entity, config);
+        WriterContext info = writer.prepareWrite();
+        return info;
+    }
+
+    private ReaderContext runsInMaster(Map<String, String> config, boolean bogus)
+        throws HCatException {
+
+        ReadEntity.Builder builder = new ReadEntity.Builder();
+        ReadEntity entity = builder.withTable("mytbl").build();
+        HCatReader reader = DataTransferFactory.getHCatReader(entity, config);
+        ReaderContext cntxt = reader.prepareRead();
+        return cntxt;
+    }
+
+    private void runsInSlave(InputSplit split, Configuration config) throws HCatException {
+
+        HCatReader reader = DataTransferFactory.getHCatReader(split, config);
+        Iterator<HCatRecord> itr = reader.read();
+        int i = 1;
+        while (itr.hasNext()) {
+            HCatRecord read = itr.next();
+            HCatRecord written = getRecord(i++);
+            // Argh, HCatRecord doesnt implement equals()
+            Assert.assertTrue("Read: " + read.get(0) + "Written: " + written.get(0),
+                written.get(0).equals(read.get(0)));
+            Assert.assertTrue("Read: " + read.get(1) + "Written: " + written.get(1),
+                written.get(1).equals(read.get(1)));
+            Assert.assertEquals(2, read.size());
+        }
+        //Assert.assertFalse(itr.hasNext());
+    }
+
+    private void runsInSlave(WriterContext context) throws HCatException {
+
+        HCatWriter writer = DataTransferFactory.getHCatWriter(context);
+        writer.write(new HCatRecordItr());
+    }
+
+    private void commit(Map<String, String> config, boolean status,
+            WriterContext context) throws IOException {
+
+        WriteEntity.Builder builder = new WriteEntity.Builder();
+        WriteEntity entity = builder.withTable("mytbl").build();
+        HCatWriter writer = DataTransferFactory.getHCatWriter(entity, config);
+        if (status) {
+            writer.commit(context);
+        } else {
+            writer.abort(context);
+        }
+    }
+
+    private static HCatRecord getRecord(int i) {
+        List<Object> list = new ArrayList<Object>(2);
+        list.add("Row #: " + i);
+        list.add(i);
+        return new DefaultHCatRecord(list);
+    }
+
+    private static class HCatRecordItr implements Iterator<HCatRecord> {
+
+        int i = 0;
+
+        @Override
+        public boolean hasNext() {
+            return i++ < 100 ? true : false;
+        }
+
+        @Override
+        public HCatRecord next() {
+            return getRecord(i);
+        }
+
+        @Override
+        public void remove() {
+            throw new RuntimeException();
+        }
     }
-  }
 }

Modified: incubator/hcatalog/trunk/src/test/org/apache/hcatalog/data/schema/TestHCatSchema.java
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/src/test/org/apache/hcatalog/data/schema/TestHCatSchema.java?rev=1383152&r1=1383151&r2=1383152&view=diff
==============================================================================
--- incubator/hcatalog/trunk/src/test/org/apache/hcatalog/data/schema/TestHCatSchema.java (original)
+++ incubator/hcatalog/trunk/src/test/org/apache/hcatalog/data/schema/TestHCatSchema.java Mon Sep 10 23:28:55 2012
@@ -24,55 +24,55 @@ import java.util.ArrayList;
 import java.util.List;
 
 public class TestHCatSchema extends TestCase {
-  public void testCannotAddFieldMoreThanOnce() throws HCatException {
-    List<HCatFieldSchema> fieldSchemaList = new ArrayList<HCatFieldSchema>();
-    fieldSchemaList.add(new HCatFieldSchema("name", HCatFieldSchema.Type.STRING, "What's your handle?"));
-    fieldSchemaList.add(new HCatFieldSchema("age", HCatFieldSchema.Type.INT, "So very old"));
-
-    HCatSchema schema = new HCatSchema(fieldSchemaList);
-
-    assertTrue(schema.getFieldNames().contains("age"));
-    assertEquals(2, schema.getFields().size());
-
-    try {
-      schema.append(new HCatFieldSchema("age", HCatFieldSchema.Type.INT, "So very old"));
-      fail("Was able to append field schema with same name");
-    } catch(HCatException he) {
-      assertTrue(he.getMessage().contains("Attempt to append HCatFieldSchema with already existing name: age."));
+    public void testCannotAddFieldMoreThanOnce() throws HCatException {
+        List<HCatFieldSchema> fieldSchemaList = new ArrayList<HCatFieldSchema>();
+        fieldSchemaList.add(new HCatFieldSchema("name", HCatFieldSchema.Type.STRING, "What's your handle?"));
+        fieldSchemaList.add(new HCatFieldSchema("age", HCatFieldSchema.Type.INT, "So very old"));
+
+        HCatSchema schema = new HCatSchema(fieldSchemaList);
+
+        assertTrue(schema.getFieldNames().contains("age"));
+        assertEquals(2, schema.getFields().size());
+
+        try {
+            schema.append(new HCatFieldSchema("age", HCatFieldSchema.Type.INT, "So very old"));
+            fail("Was able to append field schema with same name");
+        } catch (HCatException he) {
+            assertTrue(he.getMessage().contains("Attempt to append HCatFieldSchema with already existing name: age."));
+        }
+
+        assertTrue(schema.getFieldNames().contains("age"));
+        assertEquals(2, schema.getFields().size());
+
+        // Should also not be able to add fields of different types with same name
+        try {
+            schema.append(new HCatFieldSchema("age", HCatFieldSchema.Type.STRING, "Maybe spelled out?"));
+            fail("Was able to append field schema with same name");
+        } catch (HCatException he) {
+            assertTrue(he.getMessage().contains("Attempt to append HCatFieldSchema with already existing name: age."));
+        }
+
+        assertTrue(schema.getFieldNames().contains("age"));
+        assertEquals(2, schema.getFields().size());
     }
 
-    assertTrue(schema.getFieldNames().contains("age"));
-    assertEquals(2, schema.getFields().size());
+    public void testCannotInstantiateSchemaWithRepeatedFieldNames() throws HCatException {
+        List<HCatFieldSchema> fieldSchemaList = new ArrayList<HCatFieldSchema>();
 
-    // Should also not be able to add fields of different types with same name
-    try {
-      schema.append(new HCatFieldSchema("age", HCatFieldSchema.Type.STRING, "Maybe spelled out?"));
-      fail("Was able to append field schema with same name");
-    } catch(HCatException he) {
-      assertTrue(he.getMessage().contains("Attempt to append HCatFieldSchema with already existing name: age."));
-    }
+        fieldSchemaList.add(new HCatFieldSchema("memberID", HCatFieldSchema.Type.INT, "as a number"));
+        fieldSchemaList.add(new HCatFieldSchema("location", HCatFieldSchema.Type.STRING, "there's Waldo"));
 
-    assertTrue(schema.getFieldNames().contains("age"));
-    assertEquals(2, schema.getFields().size());
-  }
-
-  public void testCannotInstantiateSchemaWithRepeatedFieldNames() throws HCatException {
-      List<HCatFieldSchema> fieldSchemaList = new ArrayList<HCatFieldSchema>();
-
-      fieldSchemaList.add(new HCatFieldSchema("memberID", HCatFieldSchema.Type.INT, "as a number"));
-      fieldSchemaList.add(new HCatFieldSchema("location", HCatFieldSchema.Type.STRING, "there's Waldo"));
-
-      // No duplicate names.  This should be ok
-      HCatSchema schema = new HCatSchema(fieldSchemaList);
-
-      fieldSchemaList.add(new HCatFieldSchema("memberID", HCatFieldSchema.Type.STRING, "as a String"));
-
-      // Now a duplicated field name.  Should fail
-      try {
-        HCatSchema schema2 = new HCatSchema(fieldSchemaList);
-        fail("Able to add duplicate field name");
-      } catch (IllegalArgumentException iae) {
-        assertTrue(iae.getMessage().contains("Field named memberID already exists"));
-      }
-  }
+        // No duplicate names.  This should be ok
+        HCatSchema schema = new HCatSchema(fieldSchemaList);
+
+        fieldSchemaList.add(new HCatFieldSchema("memberID", HCatFieldSchema.Type.STRING, "as a String"));
+
+        // Now a duplicated field name.  Should fail
+        try {
+            HCatSchema schema2 = new HCatSchema(fieldSchemaList);
+            fail("Able to add duplicate field name");
+        } catch (IllegalArgumentException iae) {
+            assertTrue(iae.getMessage().contains("Field named memberID already exists"));
+        }
+    }
 }

Modified: incubator/hcatalog/trunk/src/test/org/apache/hcatalog/data/schema/TestHCatSchemaUtils.java
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/src/test/org/apache/hcatalog/data/schema/TestHCatSchemaUtils.java?rev=1383152&r1=1383151&r2=1383152&view=diff
==============================================================================
--- incubator/hcatalog/trunk/src/test/org/apache/hcatalog/data/schema/TestHCatSchemaUtils.java (original)
+++ incubator/hcatalog/trunk/src/test/org/apache/hcatalog/data/schema/TestHCatSchemaUtils.java Mon Sep 10 23:28:55 2012
@@ -31,47 +31,49 @@ import org.slf4j.LoggerFactory;
 public class TestHCatSchemaUtils extends TestCase {
 
     private static final Logger LOG = LoggerFactory.getLogger(TestHCatSchemaUtils.class);
-    public void testSimpleOperation() throws Exception{
+
+    public void testSimpleOperation() throws Exception {
         String typeString = "struct<name:string,studentid:int,"
-            + "contact:struct<phno:string,email:string>,"
-            + "currently_registered_courses:array<string>,"
-            + "current_grades:map<string,string>,"
-            + "phnos:array<struct<phno:string,type:string>>,blah:array<int>>";
+                + "contact:struct<phno:string,email:string>,"
+                + "currently_registered_courses:array<string>,"
+                + "current_grades:map<string,string>,"
+                + "phnos:array<struct<phno:string,type:string>>,blah:array<int>>";
 
         TypeInfo ti = TypeInfoUtils.getTypeInfoFromTypeString(typeString);
 
         HCatSchema hsch = HCatSchemaUtils.getHCatSchemaFromTypeString(typeString);
-        LOG.info("Type name : {}",ti.getTypeName());
-        LOG.info("HCatSchema : {}",hsch);
+        LOG.info("Type name : {}", ti.getTypeName());
+        LOG.info("HCatSchema : {}", hsch);
         assertEquals(hsch.size(), 1);
-        assertEquals(ti.getTypeName(),hsch.get(0).getTypeString());
-        assertEquals(hsch.get(0).getTypeString(),typeString);
+        assertEquals(ti.getTypeName(), hsch.get(0).getTypeString());
+        assertEquals(hsch.get(0).getTypeString(), typeString);
     }
 
     @SuppressWarnings("unused")
     private void pretty_print(PrintStream pout, HCatSchema hsch) throws HCatException {
-        pretty_print(pout,hsch,"");
+        pretty_print(pout, hsch, "");
     }
 
 
     private void pretty_print(PrintStream pout, HCatSchema hsch, String prefix) throws HCatException {
         int i = 0;
-        for (HCatFieldSchema field : hsch.getFields()){
-            pretty_print(pout,field,prefix+"."+(field.getName()==null?i:field.getName()));
+        for (HCatFieldSchema field : hsch.getFields()) {
+            pretty_print(pout, field, prefix + "." + (field.getName() == null ? i : field.getName()));
             i++;
         }
     }
+
     private void pretty_print(PrintStream pout, HCatFieldSchema hfsch, String prefix) throws HCatException {
 
         Category tcat = hfsch.getCategory();
-        if (Category.STRUCT == tcat){
-            pretty_print(pout,hfsch.getStructSubSchema(),prefix);
-        }else if (Category.ARRAY == tcat){
-            pretty_print(pout,hfsch.getArrayElementSchema(),prefix);
-        }else if (Category.MAP == tcat){
+        if (Category.STRUCT == tcat) {
+            pretty_print(pout, hfsch.getStructSubSchema(), prefix);
+        } else if (Category.ARRAY == tcat) {
+            pretty_print(pout, hfsch.getArrayElementSchema(), prefix);
+        } else if (Category.MAP == tcat) {
             pout.println(prefix + ".mapkey:\t" + hfsch.getMapKeyType().toString());
-            pretty_print(pout,hfsch.getMapValueSchema(),prefix+".mapvalue:");
-        }else{
+            pretty_print(pout, hfsch.getMapValueSchema(), prefix + ".mapvalue:");
+        } else {
             pout.println(prefix + "\t" + hfsch.getType().toString());
         }
     }

Modified: incubator/hcatalog/trunk/src/test/org/apache/hcatalog/listener/TestMsgBusConnection.java
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/src/test/org/apache/hcatalog/listener/TestMsgBusConnection.java?rev=1383152&r1=1383151&r2=1383152&view=diff
==============================================================================
--- incubator/hcatalog/trunk/src/test/org/apache/hcatalog/listener/TestMsgBusConnection.java (original)
+++ incubator/hcatalog/trunk/src/test/org/apache/hcatalog/listener/TestMsgBusConnection.java Mon Sep 10 23:28:55 2012
@@ -43,80 +43,80 @@ import org.apache.hcatalog.common.HCatCo
 
 public class TestMsgBusConnection extends TestCase {
 
-  private Driver driver;
-  private BrokerService broker;
-  private MessageConsumer consumer;
-
-  @Override
-  protected void setUp() throws Exception {
-
-    super.setUp();
-    broker = new BrokerService();
-    // configure the broker
-    broker.addConnector("tcp://localhost:61616?broker.persistent=false");
-
-    broker.start();
-
-    System.setProperty("java.naming.factory.initial",
-        "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
-    System.setProperty("java.naming.provider.url", "tcp://localhost:61616");
-    connectClient();
-    HiveConf hiveConf = new HiveConf(this.getClass());
-    hiveConf.set(ConfVars.METASTORE_EVENT_LISTENERS.varname,
-        NotificationListener.class.getName());
-    hiveConf.set("hive.metastore.local", "true");
-    hiveConf.set(HiveConf.ConfVars.PREEXECHOOKS.varname, "");
-    hiveConf.set(HiveConf.ConfVars.POSTEXECHOOKS.varname, "");
-    hiveConf.set(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY.varname, "false");
-    hiveConf.set(HCatConstants.HCAT_MSGBUS_TOPIC_PREFIX, "planetlab.hcat");
-    SessionState.start(new CliSessionState(hiveConf));
-    driver = new Driver(hiveConf);
-  }
-
-  private void connectClient() throws JMSException {
-    ConnectionFactory connFac = new ActiveMQConnectionFactory(
-        "tcp://localhost:61616");
-    Connection conn = connFac.createConnection();
-    conn.start();
-    Session session = conn.createSession(true, Session.SESSION_TRANSACTED);
-    Destination hcatTopic = session.createTopic("planetlab.hcat");
-    consumer = session.createConsumer(hcatTopic);
-  }
-
-  public void testConnection() throws Exception {
-
-    try {
-      driver.run("create database testconndb");
-      Message msg = consumer.receive();
-      assertEquals(HCatConstants.HCAT_ADD_DATABASE_EVENT,
-          msg.getStringProperty(HCatConstants.HCAT_EVENT));
-      assertEquals("topic://planetlab.hcat", msg.getJMSDestination().toString());
-      assertEquals("testconndb",
-          ((Database) ((ObjectMessage) msg).getObject()).getName());
-      broker.stop();
-      driver.run("drop database testconndb cascade");
-      broker.start(true);
-      connectClient();
-      driver.run("create database testconndb");
-      msg = consumer.receive();
-      assertEquals(HCatConstants.HCAT_ADD_DATABASE_EVENT,
-          msg.getStringProperty(HCatConstants.HCAT_EVENT));
-      assertEquals("topic://planetlab.hcat", msg.getJMSDestination().toString());
-      assertEquals("testconndb",
-          ((Database) ((ObjectMessage) msg).getObject()).getName());
-      driver.run("drop database testconndb cascade");
-      msg = consumer.receive();
-      assertEquals(HCatConstants.HCAT_DROP_DATABASE_EVENT,
-          msg.getStringProperty(HCatConstants.HCAT_EVENT));
-      assertEquals("topic://planetlab.hcat", msg.getJMSDestination().toString());
-      assertEquals("testconndb",
-          ((Database) ((ObjectMessage) msg).getObject()).getName());
-    } catch (NoSuchObjectException nsoe) {
-      nsoe.printStackTrace(System.err);
-      assert false;
-    } catch (AlreadyExistsException aee) {
-      aee.printStackTrace(System.err);
-      assert false;
+    private Driver driver;
+    private BrokerService broker;
+    private MessageConsumer consumer;
+
+    @Override
+    protected void setUp() throws Exception {
+
+        super.setUp();
+        broker = new BrokerService();
+        // configure the broker
+        broker.addConnector("tcp://localhost:61616?broker.persistent=false");
+
+        broker.start();
+
+        System.setProperty("java.naming.factory.initial",
+                "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
+        System.setProperty("java.naming.provider.url", "tcp://localhost:61616");
+        connectClient();
+        HiveConf hiveConf = new HiveConf(this.getClass());
+        hiveConf.set(ConfVars.METASTORE_EVENT_LISTENERS.varname,
+                NotificationListener.class.getName());
+        hiveConf.set("hive.metastore.local", "true");
+        hiveConf.set(HiveConf.ConfVars.PREEXECHOOKS.varname, "");
+        hiveConf.set(HiveConf.ConfVars.POSTEXECHOOKS.varname, "");
+        hiveConf.set(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY.varname, "false");
+        hiveConf.set(HCatConstants.HCAT_MSGBUS_TOPIC_PREFIX, "planetlab.hcat");
+        SessionState.start(new CliSessionState(hiveConf));
+        driver = new Driver(hiveConf);
+    }
+
+    private void connectClient() throws JMSException {
+        ConnectionFactory connFac = new ActiveMQConnectionFactory(
+                "tcp://localhost:61616");
+        Connection conn = connFac.createConnection();
+        conn.start();
+        Session session = conn.createSession(true, Session.SESSION_TRANSACTED);
+        Destination hcatTopic = session.createTopic("planetlab.hcat");
+        consumer = session.createConsumer(hcatTopic);
+    }
+
+    public void testConnection() throws Exception {
+
+        try {
+            driver.run("create database testconndb");
+            Message msg = consumer.receive();
+            assertEquals(HCatConstants.HCAT_ADD_DATABASE_EVENT,
+                    msg.getStringProperty(HCatConstants.HCAT_EVENT));
+            assertEquals("topic://planetlab.hcat", msg.getJMSDestination().toString());
+            assertEquals("testconndb",
+                    ((Database) ((ObjectMessage) msg).getObject()).getName());
+            broker.stop();
+            driver.run("drop database testconndb cascade");
+            broker.start(true);
+            connectClient();
+            driver.run("create database testconndb");
+            msg = consumer.receive();
+            assertEquals(HCatConstants.HCAT_ADD_DATABASE_EVENT,
+                    msg.getStringProperty(HCatConstants.HCAT_EVENT));
+            assertEquals("topic://planetlab.hcat", msg.getJMSDestination().toString());
+            assertEquals("testconndb",
+                    ((Database) ((ObjectMessage) msg).getObject()).getName());
+            driver.run("drop database testconndb cascade");
+            msg = consumer.receive();
+            assertEquals(HCatConstants.HCAT_DROP_DATABASE_EVENT,
+                    msg.getStringProperty(HCatConstants.HCAT_EVENT));
+            assertEquals("topic://planetlab.hcat", msg.getJMSDestination().toString());
+            assertEquals("testconndb",
+                    ((Database) ((ObjectMessage) msg).getObject()).getName());
+        } catch (NoSuchObjectException nsoe) {
+            nsoe.printStackTrace(System.err);
+            assert false;
+        } catch (AlreadyExistsException aee) {
+            aee.printStackTrace(System.err);
+            assert false;
+        }
     }
-  }
 }



Mime
View raw message