1212import org .junit .*;
1313
1414import java .io .*;
15- import java .net .URI ;
1615import java .net .URL ;
1716
17+ import static com .google .common .base .Preconditions .checkNotNull ;
18+
1819/**
1920 * Licensed to the Apache Software Foundation (ASF) under one or more
2021 * contributor license agreements. See the NOTICE file distributed with
@@ -35,9 +36,8 @@ public class TestPseudoHadoop {
3536
3637 private static final String DST = "/user/" + System .getProperty ("user.name" );
3738 private static final String HOME = System .getProperty ("user.home" );
38- private static final String DST_FILE = "/dir /test" ;
39+ private static final String DST_FILE = DST + " /test" ;
3940 private static final String HOME_FILE = HOME + "/test" ;
40- private Configuration conf ;
4141 private MiniDFSCluster cluster ;
4242 private FileSystem fs ;
4343
@@ -50,27 +50,28 @@ public static void setUpClass() throws IOException {
5050 } finally {
5151 IOUtils .closeStream (f );
5252 }
53- URL . setURLStreamHandlerFactory ( new FsUrlStreamHandlerFactory ());
53+
5454 }
5555
5656 @ Before
5757 public void setUp () throws IOException {
58- conf = new Configuration ();
58+ Configuration configuration = new Configuration ();
5959 if (System .getProperty ("test.build.data" ) == null ) {
6060 System .setProperty ("test.build.data" , "/tmp" );
6161 }
62- cluster = new MiniDFSCluster (conf , 1 , true , null );
62+ cluster = new MiniDFSCluster (configuration , 1 , true , null );
6363 fs = cluster .getFileSystem ();
6464 copyFileWithProgress ();
6565 }
6666
6767 @ After
6868 public void tearDown () throws IOException {
69- if (fs != null ) fs .close ();
70- if (cluster != null ) cluster .shutdown ();
69+ checkNotNull (fs );
70+ fs .close ();
71+ checkNotNull (cluster );
72+ cluster .shutdown ();
7173 }
7274
73- @ Ignore
7475 public void copyFileWithProgress () throws IOException {
7576 InputStream in = null ;
7677 OutputStream out = null ;
@@ -92,8 +93,10 @@ public void progress() {
9293 }
9394
9495 @ Test
96+ @ Ignore ("StackOverflowError with *-site.xml" )
9597 public void readWithURLHandler () throws IOException {
96- printStream (new URL (DST_FILE ).openStream ());
98+ URL .setURLStreamHandlerFactory (new FsUrlStreamHandlerFactory ());
99+ printStream (new URL (fs .getUri () + DST_FILE ).openStream ());
97100 }
98101
99102 @ Test
0 commit comments