source: proiecte/HadoopJUnit/hadoop-0.20.1/src/test/org/apache/hadoop/fs/s3/TestINode.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: 2.1 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.fs.s3;
20
21import java.io.IOException;
22import java.io.InputStream;
23
24import junit.framework.TestCase;
25
26import org.apache.hadoop.fs.s3.INode.FileType;
27
28public class TestINode extends TestCase {
29
30  public void testSerializeFileWithSingleBlock() throws IOException {
31    Block[] blocks = { new Block(849282477840258181L, 128L) };
32    INode inode = new INode(FileType.FILE, blocks);
33
34    assertEquals("Length", 1L + 4 + 16, inode.getSerializedLength());
35    InputStream in = inode.serialize();
36
37    INode deserialized = INode.deserialize(in);
38
39    assertEquals("FileType", inode.getFileType(), deserialized.getFileType());
40    Block[] deserializedBlocks = deserialized.getBlocks();
41    assertEquals("Length", 1, deserializedBlocks.length);
42    assertEquals("Id", blocks[0].getId(), deserializedBlocks[0].getId());
43    assertEquals("Length", blocks[0].getLength(), deserializedBlocks[0]
44                 .getLength());
45
46  }
47 
48  public void testSerializeDirectory() throws IOException {
49    INode inode = INode.DIRECTORY_INODE;
50    assertEquals("Length", 1L, inode.getSerializedLength());
51    InputStream in = inode.serialize();
52    INode deserialized = INode.deserialize(in);   
53    assertSame(INode.DIRECTORY_INODE, deserialized);
54  }
55 
56  public void testDeserializeNull() throws IOException {
57    assertNull(INode.deserialize(null));
58  }
59
60}
Note: See TracBrowser for help on using the repository browser.