|
1 | 1 | package org.gluster.test;
|
2 | 2 |
|
3 | 3 | import java.io.File;
|
4 |
| -import java.io.IOException; |
5 |
| -import java.util.TreeMap; |
6 | 4 |
|
7 |
| -import org.apache.hadoop.fs.glusterfs.GlusterFSBrickClass; |
| 5 | +import junit.framework.Assert; |
| 6 | + |
8 | 7 | import org.apache.hadoop.fs.glusterfs.GlusterFUSEInputStream;
|
| 8 | +import org.apache.hadoop.fs.glusterfs.GlusterFUSEOutputStream; |
| 9 | +import org.junit.After; |
| 10 | +import org.junit.Before; |
9 | 11 | import org.junit.Test;
|
10 | 12 |
|
11 | 13 | public class TestGlusterFuseInputStream{
|
| 14 | + String infile ; |
12 | 15 |
|
| 16 | + @Before |
| 17 | + public void create() throws Exception{ |
| 18 | + //setup: no need for gluster specific path, since its just reading from local path |
| 19 | + infile=File.createTempFile("TestGlusterFuseInputStream"+System.currentTimeMillis(),"txt").getAbsolutePath(); |
| 20 | + new File(infile).deleteOnExit(); |
| 21 | + final GlusterFUSEOutputStream stream = new GlusterFUSEOutputStream(infile,true); |
| 22 | + stream.write("hello there, certainly, there is some data in this stream".getBytes()); |
| 23 | + stream.close(); |
| 24 | + } |
| 25 | + |
13 | 26 | @Test
|
14 |
| - public void testDoubleClose() throws IOException{ |
15 |
| - /** |
16 |
| - * GlusterFUSEInputStream gfi= new GlusterFUSEInputStream ( new |
17 |
| - * File(""), null, "localhost") ; gfi.close(); gfi.close(); |
18 |
| - **/ |
19 |
| - } |
| 27 | + public void testDoubleClose() throws Exception{ |
| 28 | + //test |
| 29 | + GlusterFUSEInputStream gfi= new GlusterFUSEInputStream (new File(infile), null, "localhost") ; |
| 30 | + |
| 31 | + //assert that Position is updated (necessary for hbase to function properly) |
| 32 | + gfi.seek(2); |
| 33 | + Assert.assertEquals(2,gfi.getPos()); |
20 | 34 |
|
21 |
| - @Test |
22 |
| - public void testDoubleClose2() throws IOException{ |
23 |
| - /** |
24 |
| - * GlusterFUSEInputStream gfi= new GlusterFUSEInputStream ( new |
25 |
| - * File(""), null, "localhost") ; gfi.close(); gfi.close(); |
26 |
| - **/ |
| 35 | + gfi.close(); |
| 36 | + |
| 37 | + //cleanup |
| 38 | + new File(infile).delete(); |
27 | 39 | }
|
28 | 40 | }
|
0 commit comments