Search in sources :

Example 56 with TestDir

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

the class TestServer method invalidSservice.

@Test
@TestException(exception = ServerException.class, msgRegExp = "S08.*")
@TestDir
public void invalidSservice() throws Exception {
    String dir = TestDirHelper.getTestDir().getAbsolutePath();
    Configuration conf = new Configuration(false);
    conf.set("server.services", "foo");
    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)

Example 57 with TestDir

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

the class TestServer method loadingSysPropConfig.

@Test
@TestDir
public void loadingSysPropConfig() throws Exception {
    try {
        System.setProperty("testserver.a", "sysprop");
        String dir = TestDirHelper.getTestDir().getAbsolutePath();
        File configFile = new File(dir, "testserver-site.xml");
        Writer w = new FileWriter(configFile);
        w.write("<configuration><property><name>testserver.a</name><value>site</value></property></configuration>");
        w.close();
        Server server = new Server("testserver", dir, dir, dir, dir);
        server.init();
        assertEquals(server.getConfig().get("testserver.a"), "sysprop");
    } finally {
        System.getProperties().remove("testserver.a");
    }
}
Also used : FileWriter(java.io.FileWriter) File(java.io.File) FileWriter(java.io.FileWriter) Writer(java.io.Writer) TestDir(org.apache.hadoop.test.TestDir) Test(org.junit.Test)

Example 58 with TestDir

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

the class TestServer method initHomeDirNotDir.

@Test
@TestException(exception = ServerException.class, msgRegExp = "S02.*")
@TestDir
public void initHomeDirNotDir() throws Exception {
    File homeDir = new File(TestDirHelper.getTestDir(), "home");
    new FileOutputStream(homeDir).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 59 with TestDir

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

the class TestServer method startWithStatusNotNormal.

@Test
@TestDir
public void startWithStatusNotNormal() throws Exception {
    Configuration conf = new Configuration(false);
    conf.set("server.startup.status", "ADMIN");
    Server server = createServer(conf);
    server.init();
    assertEquals(server.getStatus(), Server.Status.ADMIN);
    server.destroy();
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) TestDir(org.apache.hadoop.test.TestDir) Test(org.junit.Test)

Example 60 with TestDir

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

the class TestServer method initNoHomeDir.

@Test
@TestException(exception = ServerException.class, msgRegExp = "S01.*")
@TestDir
public void initNoHomeDir() throws Exception {
    File homeDir = new File(TestDirHelper.getTestDir(), "home");
    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)

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