source: proiecte/HadoopJUnit/hadoop-0.20.1/src/test/org/apache/hadoop/record/ToCpp.java @ 120

Last change on this file since 120 was 120, checked in by (none), 14 years ago

Added the mail files for the Hadoop JUNit Project

  • Property svn:executable set to *
File size: 3.4 KB
Line 
1/**
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements.  See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership.  The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License.  You may obtain a copy of the License at
9 *
10 *     http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19package org.apache.hadoop.record;
20
21import java.io.IOException;
22import junit.framework.*;
23import java.io.File;
24import java.io.FileOutputStream;
25import java.util.ArrayList;
26import java.util.TreeMap;
27
28/**
29 */
30public class ToCpp extends TestCase {
31   
32  public ToCpp(String testName) {
33    super(testName);
34  }
35
36  protected void setUp() throws Exception {
37  }
38
39  protected void tearDown() throws Exception {
40  }
41   
42  public void testBinary() {
43    File tmpfile;
44    try {
45      tmpfile = new File("/tmp/hadooptemp.dat");
46      FileOutputStream ostream = new FileOutputStream(tmpfile);
47      BinaryRecordOutput out = new BinaryRecordOutput(ostream);
48      RecRecord1 r1 = new RecRecord1();
49      r1.setBoolVal(true);
50      r1.setByteVal((byte)0x66);
51      r1.setFloatVal(3.145F);
52      r1.setDoubleVal(1.5234);
53      r1.setIntVal(4567);
54      r1.setLongVal(0x5a5a5a5a5a5aL);
55      r1.setStringVal("random text");
56      r1.setBufferVal(new Buffer());
57      r1.setVectorVal(new ArrayList<String>());
58      r1.setMapVal(new TreeMap<String,String>());
59      r1.serialize(out, "");
60      ostream.close();
61    } catch (IOException ex) {
62      ex.printStackTrace();
63    } 
64  }
65   
66  public void testCsv() {
67    File tmpfile;
68    try {
69      tmpfile = new File("/tmp/hadooptemp.txt");
70      FileOutputStream ostream = new FileOutputStream(tmpfile);
71      CsvRecordOutput out = new CsvRecordOutput(ostream);
72      RecRecord1 r1 = new RecRecord1();
73      r1.setBoolVal(true);
74      r1.setByteVal((byte)0x66);
75      r1.setFloatVal(3.145F);
76      r1.setDoubleVal(1.5234);
77      r1.setIntVal(4567);
78      r1.setLongVal(0x5a5a5a5a5a5aL);
79      r1.setStringVal("random text");
80      r1.setBufferVal(new Buffer());
81      r1.setVectorVal(new ArrayList<String>());
82      r1.setMapVal(new TreeMap<String,String>());
83      r1.serialize(out, "");
84      ostream.close();
85    } catch (IOException ex) {
86      ex.printStackTrace();
87    } 
88  }
89
90  public void testXml() {
91    File tmpfile;
92    try {
93      tmpfile = new File("/tmp/hadooptemp.xml");
94      FileOutputStream ostream = new FileOutputStream(tmpfile);
95      XmlRecordOutput out = new XmlRecordOutput(ostream);
96      RecRecord1 r1 = new RecRecord1();
97      r1.setBoolVal(true);
98      r1.setByteVal((byte)0x66);
99      r1.setFloatVal(3.145F);
100      r1.setDoubleVal(1.5234);
101      r1.setIntVal(4567);
102      r1.setLongVal(0x5a5a5a5a5a5aL);
103      r1.setStringVal("random text");
104      r1.setBufferVal(new Buffer());
105      r1.setVectorVal(new ArrayList<String>());
106      r1.setMapVal(new TreeMap<String,String>());
107      r1.serialize(out, "");
108      ostream.close();
109    } catch (IOException ex) {
110      ex.printStackTrace();
111    } 
112  }
113}
Note: See TracBrowser for help on using the repository browser.