当前位置: 首页>>代码示例>>Java>>正文


Java TestDirHelper类代码示例

本文整理汇总了Java中org.apache.hadoop.test.TestDirHelper的典型用法代码示例。如果您正苦于以下问题:Java TestDirHelper类的具体用法?Java TestDirHelper怎么用?Java TestDirHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TestDirHelper类属于org.apache.hadoop.test包,在下文中一共展示了TestDirHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: lifecycle

import org.apache.hadoop.test.TestDirHelper; //导入依赖的package包/类
@Test
@TestDir
public void lifecycle() throws Exception {
  String dir = TestDirHelper.getTestDir().getAbsolutePath();
  System.setProperty("TestServerWebApp1.home.dir", dir);
  System.setProperty("TestServerWebApp1.config.dir", dir);
  System.setProperty("TestServerWebApp1.log.dir", dir);
  System.setProperty("TestServerWebApp1.temp.dir", dir);
  ServerWebApp server = new ServerWebApp("TestServerWebApp1") {
  };

  assertEquals(server.getStatus(), Server.Status.UNDEF);
  server.contextInitialized(null);
  assertEquals(server.getStatus(), Server.Status.NORMAL);
  server.contextDestroyed(null);
  assertEquals(server.getStatus(), Server.Status.SHUTDOWN);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:TestServerWebApp.java

示例2: testResolveAuthority

import org.apache.hadoop.test.TestDirHelper; //导入依赖的package包/类
@Test
@TestDir
public void testResolveAuthority() throws Exception {
  String dir = TestDirHelper.getTestDir().getAbsolutePath();
  System.setProperty("TestServerWebApp3.home.dir", dir);
  System.setProperty("TestServerWebApp3.config.dir", dir);
  System.setProperty("TestServerWebApp3.log.dir", dir);
  System.setProperty("TestServerWebApp3.temp.dir", dir);
  System.setProperty("testserverwebapp3.http.hostname", "localhost");
  System.setProperty("testserverwebapp3.http.port", "14000");
  ServerWebApp server = new ServerWebApp("TestServerWebApp3") {
  };

  InetSocketAddress address = server.resolveAuthority();
  Assert.assertEquals("localhost", address.getHostName());
  Assert.assertEquals(14000, address.getPort());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:TestServerWebApp.java

示例3: noKerberosKeytabProperty

import org.apache.hadoop.test.TestDirHelper; //导入依赖的package包/类
@Test
@TestException(exception = ServiceException.class, msgRegExp = "H01.*")
@TestDir
public void noKerberosKeytabProperty() throws Exception {
  String dir = TestDirHelper.getTestDir().getAbsolutePath();
  String services = StringUtils.join(",",
  Arrays.asList(InstrumentationService.class.getName(),
                SchedulerService.class.getName(),
                FileSystemAccessService.class.getName()));
  Configuration conf = new Configuration(false);
  conf.set("server.services", services);
  conf.set("server.hadoop.authentication.type", "kerberos");
  conf.set("server.hadoop.authentication.kerberos.keytab", " ");
  Server server = new Server("server", dir, dir, dir, dir, conf);
  server.init();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:TestFileSystemAccessService.java

示例4: noKerberosPrincipalProperty

import org.apache.hadoop.test.TestDirHelper; //导入依赖的package包/类
@Test
@TestException(exception = ServiceException.class, msgRegExp = "H01.*")
@TestDir
public void noKerberosPrincipalProperty() throws Exception {
  String dir = TestDirHelper.getTestDir().getAbsolutePath();
  String services = StringUtils.join(",",
    Arrays.asList(InstrumentationService.class.getName(),
                  SchedulerService.class.getName(),
                  FileSystemAccessService.class.getName()));
  Configuration conf = new Configuration(false);
  conf.set("server.services", services);
  conf.set("server.hadoop.authentication.type", "kerberos");
  conf.set("server.hadoop.authentication.kerberos.keytab", "/tmp/foo");
  conf.set("server.hadoop.authentication.kerberos.principal", " ");
  Server server = new Server("server", dir, dir, dir, dir, conf);
  server.init();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:TestFileSystemAccessService.java

示例5: kerberosInitializationFailure

import org.apache.hadoop.test.TestDirHelper; //导入依赖的package包/类
@Test
@TestException(exception = ServiceException.class, msgRegExp = "H02.*")
@TestDir
public void kerberosInitializationFailure() throws Exception {
  String dir = TestDirHelper.getTestDir().getAbsolutePath();
  String services = StringUtils.join(",",
    Arrays.asList(InstrumentationService.class.getName(),
                  SchedulerService.class.getName(),
                  FileSystemAccessService.class.getName()));
  Configuration conf = new Configuration(false);
  conf.set("server.services", services);
  conf.set("server.hadoop.authentication.type", "kerberos");
  conf.set("server.hadoop.authentication.kerberos.keytab", "/tmp/foo");
  conf.set("server.hadoop.authentication.kerberos.principal", "[email protected]");
  Server server = new Server("server", dir, dir, dir, dir, conf);
  server.init();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:TestFileSystemAccessService.java

示例6: serviceHadoopConf

import org.apache.hadoop.test.TestDirHelper; //导入依赖的package包/类
@Test
@TestDir
public void serviceHadoopConf() throws Exception {
  String dir = TestDirHelper.getTestDir().getAbsolutePath();
  String services = StringUtils.join(",",
    Arrays.asList(InstrumentationService.class.getName(),
                  SchedulerService.class.getName(),
                  FileSystemAccessService.class.getName()));
  Configuration conf = new Configuration(false);
  conf.set("server.services", services);

  Server server = new Server("server", dir, dir, dir, dir, conf);
  server.init();
  FileSystemAccessService fsAccess = (FileSystemAccessService) server.get(FileSystemAccess.class);
  Assert.assertEquals(fsAccess.serviceHadoopConf.get("foo"), "FOO");
  server.destroy();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:TestFileSystemAccessService.java

示例7: NameNodeNotinWhitelists

import org.apache.hadoop.test.TestDirHelper; //导入依赖的package包/类
@Test
@TestException(exception = FileSystemAccessException.class, msgRegExp = "H05.*")
@TestDir
public void NameNodeNotinWhitelists() throws Exception {
  String dir = TestDirHelper.getTestDir().getAbsolutePath();
  String services = StringUtils.join(",",
    Arrays.asList(InstrumentationService.class.getName(),
                  SchedulerService.class.getName(),
                  FileSystemAccessService.class.getName()));
  Configuration conf = new Configuration(false);
  conf.set("server.services", services);
  conf.set("server.hadoop.name.node.whitelist", "NN");
  Server server = new Server("server", dir, dir, dir, dir, conf);
  server.init();
  FileSystemAccessService fsAccess = (FileSystemAccessService) server.get(FileSystemAccess.class);
  fsAccess.validateNamenode("NNx");
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:TestFileSystemAccessService.java

示例8: loadingSysPropConfig

import org.apache.hadoop.test.TestDirHelper; //导入依赖的package包/类
@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");
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:TestServer.java

示例9: startMiniDFS

import org.apache.hadoop.test.TestDirHelper; //导入依赖的package包/类
/**
 * Fire up our own hand-rolled MiniDFSCluster.  We do this here instead
 * of relying on TestHdfsHelper because we don't want to turn on ACL
 * support.
 *
 * @throws Exception
 */
private void startMiniDFS() throws Exception {

  File testDirRoot = TestDirHelper.getTestDir();

  if (System.getProperty("hadoop.log.dir") == null) {
    System.setProperty("hadoop.log.dir",
            new File(testDirRoot, "hadoop-log").getAbsolutePath());
  }
  if (System.getProperty("test.build.data") == null) {
    System.setProperty("test.build.data",
            new File(testDirRoot, "hadoop-data").getAbsolutePath());
  }

  Configuration conf = HadoopUsersConfTestHelper.getBaseConf();
  HadoopUsersConfTestHelper.addUserConf(conf);
  conf.set("fs.hdfs.impl.disable.cache", "true");
  conf.set("dfs.block.access.token.enable", "false");
  conf.set("dfs.permissions", "true");
  conf.set("hadoop.security.authentication", "simple");

  // Explicitly turn off ACL support
  conf.setBoolean(DFSConfigKeys.DFS_NAMENODE_ACLS_ENABLED_KEY, false);

  MiniDFSCluster.Builder builder = new MiniDFSCluster.Builder(conf);
  builder.numDataNodes(2);
  miniDfs = builder.build();
  nnConf = miniDfs.getConfiguration(0);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:36,代码来源:TestHttpFSServerNoACLs.java

示例10: startMiniDFS

import org.apache.hadoop.test.TestDirHelper; //导入依赖的package包/类
/**
 * Fire up our own hand-rolled MiniDFSCluster.  We do this here instead
 * of relying on TestHdfsHelper because we don't want to turn on XAttr
 * support.
 *
 * @throws Exception
 */
private void startMiniDFS() throws Exception {

  File testDirRoot = TestDirHelper.getTestDir();

  if (System.getProperty("hadoop.log.dir") == null) {
    System.setProperty("hadoop.log.dir",
            new File(testDirRoot, "hadoop-log").getAbsolutePath());
  }
  if (System.getProperty("test.build.data") == null) {
    System.setProperty("test.build.data",
            new File(testDirRoot, "hadoop-data").getAbsolutePath());
  }

  Configuration conf = HadoopUsersConfTestHelper.getBaseConf();
  HadoopUsersConfTestHelper.addUserConf(conf);
  conf.set("fs.hdfs.impl.disable.cache", "true");
  conf.set("dfs.block.access.token.enable", "false");
  conf.set("dfs.permissions", "true");
  conf.set("hadoop.security.authentication", "simple");

  // Explicitly turn off XAttr support
  conf.setBoolean(DFSConfigKeys.DFS_NAMENODE_XATTRS_ENABLED_KEY, false);

  MiniDFSCluster.Builder builder = new MiniDFSCluster.Builder(conf);
  builder.numDataNodes(2);
  miniDfs = builder.build();
  nnConf = miniDfs.getConfiguration(0);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:36,代码来源:TestHttpFSServerNoXAttrs.java

示例11: failedInit

import org.apache.hadoop.test.TestDirHelper; //导入依赖的package包/类
@Test(expected = RuntimeException.class)
@TestDir
public void failedInit() throws Exception {
  String dir = TestDirHelper.getTestDir().getAbsolutePath();
  System.setProperty("TestServerWebApp2.home.dir", dir);
  System.setProperty("TestServerWebApp2.config.dir", dir);
  System.setProperty("TestServerWebApp2.log.dir", dir);
  System.setProperty("TestServerWebApp2.temp.dir", dir);
  System.setProperty("testserverwebapp2.services", "FOO");
  ServerWebApp server = new ServerWebApp("TestServerWebApp2") {
  };

  server.contextInitialized(null);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:TestServerWebApp.java

示例12: createHadoopConf

import org.apache.hadoop.test.TestDirHelper; //导入依赖的package包/类
private void createHadoopConf(Configuration hadoopConf) throws Exception {
  String dir = TestDirHelper.getTestDir().getAbsolutePath();
  File hdfsSite = new File(dir, "hdfs-site.xml");
  OutputStream os = new FileOutputStream(hdfsSite);
  hadoopConf.writeXml(os);
  os.close();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:8,代码来源:TestFileSystemAccessService.java

示例13: simpleSecurity

import org.apache.hadoop.test.TestDirHelper; //导入依赖的package包/类
@Test
@TestDir
public void simpleSecurity() throws Exception {
  String dir = TestDirHelper.getTestDir().getAbsolutePath();
  String services = StringUtils.join(",",
    Arrays.asList(InstrumentationService.class.getName(),
                  SchedulerService.class.getName(),
                  FileSystemAccessService.class.getName()));
  Configuration conf = new Configuration(false);
  conf.set("server.services", services);
  Server server = new Server("server", dir, dir, dir, dir, conf);
  server.init();
  Assert.assertNotNull(server.get(FileSystemAccess.class));
  server.destroy();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:16,代码来源:TestFileSystemAccessService.java

示例14: invalidSecurity

import org.apache.hadoop.test.TestDirHelper; //导入依赖的package包/类
@Test
@TestException(exception = ServiceException.class, msgRegExp = "H09.*")
@TestDir
public void invalidSecurity() throws Exception {
  String dir = TestDirHelper.getTestDir().getAbsolutePath();
  String services = StringUtils.join(",",
    Arrays.asList(InstrumentationService.class.getName(),
                  SchedulerService.class.getName(),
                  FileSystemAccessService.class.getName()));
  Configuration conf = new Configuration(false);
  conf.set("server.services", services);
  conf.set("server.hadoop.authentication.type", "foo");
  Server server = new Server("server", dir, dir, dir, dir, conf);
  server.init();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:16,代码来源:TestFileSystemAccessService.java

示例15: serviceHadoopConfCustomDir

import org.apache.hadoop.test.TestDirHelper; //导入依赖的package包/类
@Test
@TestDir
public void serviceHadoopConfCustomDir() throws Exception {
  String dir = TestDirHelper.getTestDir().getAbsolutePath();
  String hadoopConfDir = new File(dir, "confx").getAbsolutePath();
  new File(hadoopConfDir).mkdirs();
  String services = StringUtils.join(",",
    Arrays.asList(InstrumentationService.class.getName(),
                  SchedulerService.class.getName(),
                  FileSystemAccessService.class.getName()));
  Configuration conf = new Configuration(false);
  conf.set("server.services", services);
  conf.set("server.hadoop.config.dir", hadoopConfDir);

  File hdfsSite = new File(hadoopConfDir, "hdfs-site.xml");
  OutputStream os = new FileOutputStream(hdfsSite);
  Configuration hadoopConf = new Configuration(false);
  hadoopConf.set("foo", "BAR");
  hadoopConf.writeXml(os);
  os.close();

  Server server = new Server("server", dir, dir, dir, dir, conf);
  server.init();
  FileSystemAccessService fsAccess = (FileSystemAccessService) server.get(FileSystemAccess.class);
  Assert.assertEquals(fsAccess.serviceHadoopConf.get("foo"), "BAR");
  server.destroy();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:28,代码来源:TestFileSystemAccessService.java


注:本文中的org.apache.hadoop.test.TestDirHelper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。