// Path: src/main/java/com/savy3/hadoop/hive/serde2/cobol/CobolSerDe.java
// public final class CobolSerDe extends AbstractSerDe {
// 
// 	private ObjectInspector inspector;
// 	private int numCols;
// 	private List<TypeInfo> columnTypes;
// 	private List<Map<String, Integer>> columnProperties;
// 
// 	private CobolDeserializer cobolDeserializer = null;
// 	private CobolCopybook ccb;
// 
// 	@Override
// 	public void initialize(final Configuration conf, final Properties tbl)
// 			throws SerDeException {
// 
// 		// final int fixedRecordlLength =
// 		// Integer.parseInt(tbl.getProperty("fb.length"));
// 		// conf.setInt(FixedLengthInputFormat.FIXED_RECORD_LENGTH,
// 		// fixedRecordlLength);
// 		try {
// 			this.ccb = new CobolCopybook(
// 					CobolSerdeUtils.determineLayoutOrThrowException(conf, tbl));
// 		} catch (IOException e) {
// 			e.printStackTrace();
// 			return;
// 		}
// 
// 		numCols = ccb.getFieldNames().size();
// 		this.inspector = ObjectInspectorFactory
// 				.getStandardStructObjectInspector(ccb.getFieldNames(),
// 						ccb.getFieldOIs());
// 		this.columnTypes = ccb.getFieldTypeInfos();
// 		this.columnProperties = ccb.getFieldProperties();
// 
// 	}
// 
// 	@Override
// 	public Writable serialize(Object obj, ObjectInspector objInspector)
// 			throws SerDeException {
// 		// Serializing to cobol layout format is out-of-scope
// 		throw new SerDeException("Serializer not built");
// 		// return new Text("Out-of-scope");
// 	}
// 
// 	@Override
// 	public Object deserialize(final Writable blob) throws SerDeException {
// 		return getDeserializer().deserialize(ccb.getFieldNames(),
// 				this.columnTypes, this.columnProperties, this.numCols, blob);
// 	}
// 
// 	@Override
// 	public ObjectInspector getObjectInspector() throws SerDeException {
// 		return inspector;
// 	}
// 
// 	@Override
// 	public Class<? extends Writable> getSerializedClass() {
// 		return Text.class;
// 	}
// 
// 	public SerDeStats getSerDeStats() {
// 		return null;
// 	}
// 
// 	private CobolDeserializer getDeserializer() {
// 		if (cobolDeserializer == null) {
// 			cobolDeserializer = new CobolDeserializer();
// 		}
// 
// 		return cobolDeserializer;
// 	}
// 
// }


import com.savy3.hadoop.hive.serde2.cobol.CobolSerDe;
import junit.framework.TestCase;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hive.serde2.SerDeException;
import org.apache.hadoop.io.BytesWritable;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
package com.savy3.testcobolserde;


//import org.apache.hive.jdbc.HiveDriver;


public class TestCobolSerDe extends TestCase {

	Configuration conf = new Configuration();


	public static BytesWritable ConvertStringToEBCIDICBytes(String src) {
		Charset from = Charset.forName("ascii");
		Charset to = Charset.forName("ebcdic-cp-us");
		byte[] source = src.getBytes();
		byte[] result = new String(source, from).getBytes(to);
//		  System.out.println("source length"+source.length+"result length"+result.length);
		if (result.length != source.length) {
			throw new AssertionError("ASCII TO EBCIDIC conversion failed" + result.length + "!=" + source.length);
		}
		return new BytesWritable(result);
	}

	public void testDeserializeWritable() throws SerDeException {
// Path: src/main/java/com/savy3/hadoop/hive/serde2/cobol/CobolSerDe.java
// public final class CobolSerDe extends AbstractSerDe {
// 
// 	private ObjectInspector inspector;
// 	private int numCols;
// 	private List<TypeInfo> columnTypes;
// 	private List<Map<String, Integer>> columnProperties;
// 
// 	private CobolDeserializer cobolDeserializer = null;
// 	private CobolCopybook ccb;
// 
// 	@Override
// 	public void initialize(final Configuration conf, final Properties tbl)
// 			throws SerDeException {
// 
// 		// final int fixedRecordlLength =
// 		// Integer.parseInt(tbl.getProperty("fb.length"));
// 		// conf.setInt(FixedLengthInputFormat.FIXED_RECORD_LENGTH,
// 		// fixedRecordlLength);
// 		try {
// 			this.ccb = new CobolCopybook(
// 					CobolSerdeUtils.determineLayoutOrThrowException(conf, tbl));
// 		} catch (IOException e) {
// 			e.printStackTrace();
// 			return;
// 		}
// 
// 		numCols = ccb.getFieldNames().size();
// 		this.inspector = ObjectInspectorFactory
// 				.getStandardStructObjectInspector(ccb.getFieldNames(),
// 						ccb.getFieldOIs());
// 		this.columnTypes = ccb.getFieldTypeInfos();
// 		this.columnProperties = ccb.getFieldProperties();
// 
// 	}
// 
// 	@Override
// 	public Writable serialize(Object obj, ObjectInspector objInspector)
// 			throws SerDeException {
// 		// Serializing to cobol layout format is out-of-scope
// 		throw new SerDeException("Serializer not built");
// 		// return new Text("Out-of-scope");
// 	}
// 
// 	@Override
// 	public Object deserialize(final Writable blob) throws SerDeException {
// 		return getDeserializer().deserialize(ccb.getFieldNames(),
// 				this.columnTypes, this.columnProperties, this.numCols, blob);
// 	}
// 
// 	@Override
// 	public ObjectInspector getObjectInspector() throws SerDeException {
// 		return inspector;
// 	}
// 
// 	@Override
// 	public Class<? extends Writable> getSerializedClass() {
// 		return Text.class;
// 	}
// 
// 	public SerDeStats getSerDeStats() {
// 		return null;
// 	}
// 
// 	private CobolDeserializer getDeserializer() {
// 		if (cobolDeserializer == null) {
// 			cobolDeserializer = new CobolDeserializer();
// 		}
// 
// 		return cobolDeserializer;
// 	}
// 
// }


// Path: src/test/java/com/savy3/testcobolserde/TestCobolSerDe.java
import com.savy3.hadoop.hive.serde2.cobol.CobolSerDe;
import junit.framework.TestCase;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hive.serde2.SerDeException;
import org.apache.hadoop.io.BytesWritable;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

package com.savy3.testcobolserde;


//import org.apache.hive.jdbc.HiveDriver;


public class TestCobolSerDe extends TestCase {

	Configuration conf = new Configuration();


	public static BytesWritable ConvertStringToEBCIDICBytes(String src) {
		Charset from = Charset.forName("ascii");
		Charset to = Charset.forName("ebcdic-cp-us");
		byte[] source = src.getBytes();
		byte[] result = new String(source, from).getBytes(to);
//		  System.out.println("source length"+source.length+"result length"+result.length);
		if (result.length != source.length) {
			throw new AssertionError("ASCII TO EBCIDIC conversion failed" + result.length + "!=" + source.length);
		}
		return new BytesWritable(result);
	}

	public void testDeserializeWritable() throws SerDeException {
		CobolSerDe csd = new CobolSerDe();