Exemplo n.º 1
0
  /**
   * Setup to do for each unit test.
   *
   * @throws IOException if there's an error accessing the local file system
   */
  @Before
  public void setUp() throws IOException {
    srcMetastore = new MockHiveMetastoreClient();
    destMetastore = new MockHiveMetastoreClient();

    srcLocalTmp.create();
    destLocalTmp.create();

    final Path srcFsRoot = new Path("file://" + srcLocalTmp.getRoot().getAbsolutePath());
    final Path destFsRoot = new Path("file://" + destLocalTmp.getRoot().getAbsolutePath());

    srcWarehouseRoot = new Path(makeFileUri(srcLocalTmp), "warehouse");
    destWarehouseRoot = new Path(makeFileUri(destLocalTmp), "warehouse");

    srcWarehouseRoot.getFileSystem(conf).mkdirs(srcWarehouseRoot);
    destWarehouseRoot.getFileSystem(conf).mkdirs(destWarehouseRoot);

    LOG.info(String.format("src root: %s, dest root: %s", srcWarehouseRoot, destWarehouseRoot));

    final Path srcTmp = new Path(makeFileUri(this.srcLocalTmp), "tmp");
    final Path destTmp = new Path(makeFileUri(this.destLocalTmp), "tmp");

    srcCluster = new MockCluster("src_cluster", srcMetastore, srcFsRoot, srcTmp);
    destCluster = new MockCluster("dest_cluster", destMetastore, destFsRoot, destTmp);

    // Disable checking of modified times as the local filesystem does not
    // support this
    directoryCopier = new DirectoryCopier(conf, destCluster.getTmpDir(), false);
  }
Exemplo n.º 2
0
  @Before
  public void setup() throws Exception {

    vfs = getVFS();

    folder1.create();
    folder2.create();

    FileUtils.copyURLToFile(
        this.getClass().getResource("/HelloWorld.jar"), folder1.newFile("HelloWorld.jar"));
    FileUtils.copyURLToFile(
        this.getClass().getResource("/HelloWorld.jar"), folder2.newFile("HelloWorld.jar"));

    uri1 = new File(folder1.getRoot(), "HelloWorld.jar").toURI();
    uri2 = folder2.getRoot().toURI();
  }
  @Test
  public void sanitizeSymlinkedWorkingDirectory() throws IOException {
    TemporaryFolder folder = new TemporaryFolder();
    folder.create();

    // Setup up a symlink to our working directory.
    Path symlinkedRoot = folder.getRoot().toPath().resolve("symlinked-root");
    java.nio.file.Files.createSymbolicLink(symlinkedRoot, tmp.getRootPath());

    // Run the build, setting PWD to the above symlink.  Typically, this causes compilers to use
    // the symlinked directory, even though it's not the right project root.
    Map<String, String> envCopy = Maps.newHashMap(System.getenv());
    envCopy.put("PWD", symlinkedRoot.toString());
    workspace
        .runBuckCommandWithEnvironmentAndContext(
            tmp.getRootPath(),
            Optional.<NGContext>absent(),
            Optional.<BuckEventListener>absent(),
            Optional.of(ImmutableMap.copyOf(envCopy)),
            "build",
            "//:simple#default,static")
        .assertSuccess();

    // Verify that we still sanitized this path correctly.
    Path lib = workspace.getPath("buck-out/gen/simple#default,static/libsimple.a");
    String contents = Files.asByteSource(lib.toFile()).asCharSource(Charsets.ISO_8859_1).read();
    assertFalse(lib.toString(), contents.contains(tmp.getRootPath().toString()));
    assertFalse(lib.toString(), contents.contains(symlinkedRoot.toString()));

    folder.delete();
  }
 public CreateSoapSTSDeploymentTest() throws IOException {
   inputWarFilePath =
       Paths.get("/com", "sun", "identity", "workflow", "slim-openam-soap-sts-server.war");
   customWsdlFilePath = Paths.get("/com", "sun", "identity", "workflow", "custom.wsdl");
   keystoreFilePath = Paths.get("/com", "sun", "identity", "workflow", "keystore.jks");
   temporaryFolder = new TemporaryFolder();
   temporaryFolder.create();
   outputWarFile = temporaryFolder.newFile("test-openam-soap-sts-server.war");
 }
 @Override
 @Before
 public void setUp() throws Exception {
   jenkinsHome = new TemporaryFolder();
   jenkinsHome.create();
   buildInfo =
       new BPBuildInfo(TaskListener.NULL, "", new FilePath(jenkinsHome.getRoot()), null, null);
   super.setUp();
 }
Exemplo n.º 6
0
  public static File writeYarnSiteConfigXML(Configuration yarnConf) throws IOException {
    tmp.create();
    File yarnSiteXML = new File(tmp.newFolder().getAbsolutePath() + "/yarn-site.xml");

    try (FileWriter writer = new FileWriter(yarnSiteXML)) {
      yarnConf.writeXml(writer);
      writer.flush();
    }
    return yarnSiteXML;
  }
  @Test(timeout = 5 * 60 * 1000)
  @Ignore
  public void shouldGenerateLargeGraphInAReasonableAmountOfTime() throws IOException {
    TemporaryFolder folder = new TemporaryFolder();
    folder.create();

    BatchInserter batchInserter = BatchInserters.inserter(folder.getRoot().getAbsolutePath());

    new BatchGraphGenerator(batchInserter)
        .generateGraph(getGeneratorConfiguration(100_000, 5_000_000));

    folder.delete();
  }
Exemplo n.º 8
0
 /**
  * Creates and starts an embedded Kafka broker.
  *
  * @param config Broker configuration settings. Used to modify, for example, on which port the
  *     broker should listen to. Note that you cannot change the `log.dirs` setting currently.
  */
 public KafkaEmbedded(Properties config) throws IOException {
   tmpFolder = new TemporaryFolder();
   tmpFolder.create();
   logDir = tmpFolder.newFolder();
   effectiveConfig = effectiveConfigFrom(config);
   boolean loggingEnabled = true;
   KafkaConfig kafkaConfig = new KafkaConfig(effectiveConfig, loggingEnabled);
   log.debug(
       "Starting embedded Kafka broker (with log.dirs={} and ZK ensemble at {}) ...",
       logDir,
       zookeeperConnect());
   kafka = TestUtils.createServer(kafkaConfig, SystemTime$.MODULE$);
   log.debug(
       "Startup of embedded Kafka broker at {} completed (with ZK ensemble at {}) ...",
       brokerList(),
       zookeeperConnect());
 }
  private void assertUsingBatchInserter(int numberOfNodes, int numberOfEdges) throws IOException {
    TemporaryFolder folder = new TemporaryFolder();
    folder.create();

    BatchInserter batchInserter = BatchInserters.inserter(folder.getRoot().getAbsolutePath());

    new BatchGraphGenerator(batchInserter)
        .generateGraph(getGeneratorConfiguration(numberOfNodes, numberOfEdges));

    GraphDatabaseService database =
        new GraphDatabaseFactory().newEmbeddedDatabase(folder.getRoot().getAbsolutePath());

    assertCorrectNumberOfNodesAndRelationships(database, numberOfNodes, numberOfEdges);

    database.shutdown();

    folder.delete();
  }
Exemplo n.º 10
0
  @Before
  public void before() throws Exception {
    fakeRepo = new TemporaryFolder();
    fakeRepo.create();
    File fakeChangedPom = fakeRepo.newFile("pom.xml");
    System.setProperty("maven.repo.local", fakeChangedPom.getParent());
    // Set command line returns
    when(mavenVersionCommandProcess.getInputStream())
        .thenReturn(
            new ByteArrayInputStream(
                ("Maven home: " + fakeRepo.getRoot().getPath()).getBytes(StandardCharsets.UTF_8)));

    when(mavenSettingCommandProcess.getInputStream())
        .thenReturn(
            new ByteArrayInputStream(
                ("<localRepository>" + fakeRepo.getRoot().getPath() + "</localRepository>")
                    .getBytes(StandardCharsets.UTF_8)));

    when(gitShortBranchNameCommandProcess.getInputStream())
        .thenReturn(new ByteArrayInputStream("test-branch".getBytes(StandardCharsets.UTF_8)));

    when(gitDiffNameCommandProcess.getInputStream())
        .thenReturn(
            new ByteArrayInputStream(fakeChangedPom.getPath().getBytes(StandardCharsets.UTF_8)));

    // Set runtime when executing commands
    when(runtime.exec(MAVEN_VERSION_COMMAND)).thenReturn(mavenVersionCommandProcess);

    when(runtime.exec(MAVEN_SETTINGS_COMMAND)).thenReturn(mavenSettingCommandProcess);

    when(runtime.exec(GIT_SHORT_BRANCH_NAME_COMMAND)).thenReturn(gitShortBranchNameCommandProcess);

    when(runtime.exec(matches(GIT_DIFF_NAME_COMMAND + ".*"))).thenReturn(gitDiffNameCommandProcess);

    // Set maven executor
    when(mavenBuildResult.getExitCode()).thenReturn(0);

    when(invoker.execute(any())).thenReturn(mavenBuildResult);

    owaspDiffRunner = new OwaspDiffRunner(runtime, invoker);
  }
 @BeforeMethod
 public void setUp() throws Exception {
   folder.create();
 }
 @Before
 public void setup() throws IOException {
   folder1.create();
 }