Search in sources :

Example 41 with TestDir

use of org.apache.hadoop.test.TestDir in project hadoop by apache.

the class TestHttpFSWithKerberos method testValidHttpFSAccess.

@Test
@TestDir
@TestJetty
@TestHdfs
public void testValidHttpFSAccess() throws Exception {
    createHttpFSServer();
    KerberosTestUtils.doAsClient(new Callable<Void>() {

        @Override
        public Void call() throws Exception {
            URL url = new URL(TestJettyHelper.getJettyURL(), "/webhdfs/v1/?op=GETHOMEDIRECTORY");
            AuthenticatedURL aUrl = new AuthenticatedURL();
            AuthenticatedURL.Token aToken = new AuthenticatedURL.Token();
            HttpURLConnection conn = aUrl.openConnection(url, aToken);
            Assert.assertEquals(conn.getResponseCode(), HttpURLConnection.HTTP_OK);
            return null;
        }
    });
}
Also used : HttpURLConnection(java.net.HttpURLConnection) Token(org.apache.hadoop.security.token.Token) URL(java.net.URL) AuthenticatedURL(org.apache.hadoop.security.authentication.client.AuthenticatedURL) AuthenticatedURL(org.apache.hadoop.security.authentication.client.AuthenticatedURL) TestJetty(org.apache.hadoop.test.TestJetty) TestHdfs(org.apache.hadoop.test.TestHdfs) TestDir(org.apache.hadoop.test.TestDir) Test(org.junit.Test)

Example 42 with TestDir

use of org.apache.hadoop.test.TestDir in project hadoop by apache.

the class TestServer method initNoConfigDir.

@Test
@TestException(exception = ServerException.class, msgRegExp = "S01.*")
@TestDir
public void initNoConfigDir() throws Exception {
    File homeDir = new File(TestDirHelper.getTestDir(), "home");
    assertTrue(homeDir.mkdir());
    assertTrue(new File(homeDir, "log").mkdir());
    assertTrue(new File(homeDir, "temp").mkdir());
    Configuration conf = new Configuration(false);
    conf.set("server.services", TestService.class.getName());
    Server server = new Server("server", homeDir.getAbsolutePath(), conf);
    server.init();
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) File(java.io.File) TestException(org.apache.hadoop.test.TestException) TestDir(org.apache.hadoop.test.TestDir) Test(org.junit.Test)

Example 43 with TestDir

use of org.apache.hadoop.test.TestDir in project hadoop by apache.

the class TestServer method initConfigDirNotDir.

@Test
@TestException(exception = ServerException.class, msgRegExp = "S02.*")
@TestDir
public void initConfigDirNotDir() throws Exception {
    File homeDir = new File(TestDirHelper.getTestDir(), "home");
    assertTrue(homeDir.mkdir());
    assertTrue(new File(homeDir, "log").mkdir());
    assertTrue(new File(homeDir, "temp").mkdir());
    File configDir = new File(homeDir, "conf");
    new FileOutputStream(configDir).close();
    Configuration conf = new Configuration(false);
    conf.set("server.services", TestService.class.getName());
    Server server = new Server("server", homeDir.getAbsolutePath(), conf);
    server.init();
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) FileOutputStream(java.io.FileOutputStream) File(java.io.File) TestException(org.apache.hadoop.test.TestException) TestDir(org.apache.hadoop.test.TestDir) Test(org.junit.Test)

Example 44 with TestDir

use of org.apache.hadoop.test.TestDir in project hadoop by apache.

the class TestServer method initNoLogDir.

@Test
@TestException(exception = ServerException.class, msgRegExp = "S01.*")
@TestDir
public void initNoLogDir() throws Exception {
    File homeDir = new File(TestDirHelper.getTestDir(), "home");
    assertTrue(homeDir.mkdir());
    assertTrue(new File(homeDir, "conf").mkdir());
    assertTrue(new File(homeDir, "temp").mkdir());
    Configuration conf = new Configuration(false);
    conf.set("server.services", TestService.class.getName());
    Server server = new Server("server", homeDir.getAbsolutePath(), conf);
    server.init();
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) File(java.io.File) TestException(org.apache.hadoop.test.TestException) TestDir(org.apache.hadoop.test.TestDir) Test(org.junit.Test)

Example 45 with TestDir

use of org.apache.hadoop.test.TestDir in project hadoop by apache.

the class TestServer method serviceWithMissingDependency.

@Test
@TestException(exception = ServerException.class, msgRegExp = "S10.*")
@TestDir
public void serviceWithMissingDependency() throws Exception {
    String dir = TestDirHelper.getTestDir().getAbsolutePath();
    Configuration conf = new Configuration(false);
    String services = StringUtils.join(",", Arrays.asList(MyService3.class.getName(), MyService6.class.getName()));
    conf.set("server.services", services);
    Server server = new Server("server", dir, dir, dir, dir, conf);
    server.init();
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) TestException(org.apache.hadoop.test.TestException) TestDir(org.apache.hadoop.test.TestDir) Test(org.junit.Test)

Aggregations

TestDir (org.apache.hadoop.test.TestDir)67 Test (org.junit.Test)67 Configuration (org.apache.hadoop.conf.Configuration)46 TestException (org.apache.hadoop.test.TestException)25 TestHdfs (org.apache.hadoop.test.TestHdfs)21 Server (org.apache.hadoop.lib.server.Server)19 TestJetty (org.apache.hadoop.test.TestJetty)18 FileSystem (org.apache.hadoop.fs.FileSystem)14 File (java.io.File)13 Path (org.apache.hadoop.fs.Path)13 FileOutputStream (java.io.FileOutputStream)10 FileSystemAccess (org.apache.hadoop.lib.service.FileSystemAccess)10 HttpURLConnection (java.net.HttpURLConnection)9 URL (java.net.URL)9 AuthenticatedURL (org.apache.hadoop.security.authentication.client.AuthenticatedURL)9 IOException (java.io.IOException)6 OutputStream (java.io.OutputStream)6 InputStreamReader (java.io.InputStreamReader)5 ServiceException (org.apache.hadoop.lib.server.ServiceException)4 FileSystemAccessException (org.apache.hadoop.lib.service.FileSystemAccessException)4