Example #1
0
  @Test
  public void testCopyToDirectory() throws Exception {
    this.setup.groupBySetup();

    String uriTemplate = Paths.get(folder.getRoot().toURI()).toUri().toString();
    SQLResponse response = execute("copy characters to DIRECTORY ?", new Object[] {uriTemplate});
    assertThat(response.rowCount(), is(7L));
    List<String> lines = new ArrayList<>(7);
    DirectoryStream<Path> stream =
        Files.newDirectoryStream(Paths.get(folder.getRoot().toURI()), "*.json");
    for (Path entry : stream) {
      lines.addAll(Files.readAllLines(entry, StandardCharsets.UTF_8));
    }
    String[] list = folder.getRoot().list();
    assertThat(list.length, greaterThanOrEqualTo(1));
    for (String file : list) {
      assertThat(file, startsWith("characters_"));
    }

    assertThat(lines.size(), is(7));
    for (String line : lines) {
      assertThat(line, startsWith("{"));
      assertThat(line, endsWith("}"));
    }
  }
Example #2
0
  /** Fake installation on Unix. */
  @Test
  public void fakeUnixInstall() throws Exception {
    Assume.assumeFalse("If we're on Windows, don't bother doing this", Functions.isWindows());

    File bundle = File.createTempFile("fake-jdk-by-hudson", "sh");
    try {
      new FilePath(bundle)
          .write(
              "#!/bin/bash -ex\n"
                  + "mkdir -p jdk1.6.0_dummy/bin\n"
                  + "touch jdk1.6.0_dummy/bin/java",
              "ASCII");
      TaskListener l = StreamTaskListener.fromStdout();

      new JDKInstaller("", true)
          .install(
              new LocalLauncher(l),
              Platform.LINUX,
              new JDKInstaller.FilePathFileSystem(j.jenkins),
              l,
              tmp.getRoot().getPath(),
              bundle.getPath());

      assertTrue(new File(tmp.getRoot(), "bin/java").exists());
    } finally {
      bundle.delete();
    }
  }
  @Test
  public void testCacheFile() throws Exception {
    final DefaultConfiguration checkConfig = createCheckConfig(HiddenFieldCheck.class);

    final DefaultConfiguration treeWalkerConfig = createCheckConfig(TreeWalker.class);
    treeWalkerConfig.addAttribute("cacheFile", temporaryFolder.newFile().getPath());
    treeWalkerConfig.addChild(checkConfig);

    final DefaultConfiguration checkerConfig = new DefaultConfiguration("configuration");
    checkerConfig.addAttribute("charset", "UTF-8");
    checkerConfig.addChild(treeWalkerConfig);

    final Checker checker = new Checker();
    final Locale locale = Locale.ROOT;
    checker.setLocaleCountry(locale.getCountry());
    checker.setLocaleLanguage(locale.getLanguage());
    checker.setModuleClassLoader(Thread.currentThread().getContextClassLoader());
    checker.configure(checkerConfig);
    checker.addListener(new BriefLogger(stream));

    final String pathToEmptyFile = temporaryFolder.newFile("file.java").getPath();
    final String[] expected = {};

    verify(checker, pathToEmptyFile, pathToEmptyFile, expected);
    // one more time to reuse cache
    verify(checker, pathToEmptyFile, pathToEmptyFile, expected);
  }
  @Test
  public void test() throws Exception {
    int KEY_COUNT = 1000;
    TemporaryFolder tempFolder = new TemporaryFolder();

    File keyPath = tempFolder.newFile();

    String[] buckets = {"A", "B", "C", "D", "E", "F"};
    String[] keys = new String[KEY_COUNT];
    for (Integer i = 0; i < keys.length; ++i) {
      keys[i] = i.toString();
    }

    KeyJournal journal = new KeyJournal(keyPath, KeyJournal.Mode.WRITE);

    for (String bucket : buckets) {
      for (String key : keys) {
        journal.write(bucket, key);
      }
    }
    journal.close();

    KeyJournal readJournal = new KeyJournal(keyPath, KeyJournal.Mode.READ);

    int readCount = 0;
    for (Key key : readJournal) {
      if (!key.errorKey()) ++readCount;
    }

    assertTrue(readCount == buckets.length * keys.length);
  }
  @Test
  public void should_include_the_name_of_any_screenshots_where_present() throws Exception {
    TestOutcome testOutcome = TestOutcome.forTest("a_simple_test_case", SomeTestScenario.class);
    String expectedReport =
        "<acceptance-test-run title='A simple test case' name='a_simple_test_case' steps='2' successful='1' failures='1' skipped='0' ignored='0' pending='0' result='FAILURE'>\n"
            + "  <user-story id='net.thucydides.core.reports.integration.WhenGeneratingAnXMLReport.AUserStory' name='A user story' />\n"
            + "  <test-step result='SUCCESS'>\n"
            + "    <screenshots>\n"
            + "      <screenshot image='step_1.png' source='step_1.html'/>\n"
            + "    </screenshots>\n"
            + "    <description>step 1</description>\n"
            + "  </test-step>\n"
            + "  <test-step result='FAILURE'>\n"
            + "    <description>step 2</description>\n"
            + "  </test-step>\n"
            + "</acceptance-test-run>";

    File screenshot = temporaryDirectory.newFile("step_1.png");
    File source = temporaryDirectory.newFile("step_1.html");

    TestStep step1 = TestStepFactory.successfulTestStepCalled("step 1");
    step1.addScreenshot(new ScreenshotAndHtmlSource(screenshot, source));
    testOutcome.recordStep(step1);
    testOutcome.recordStep(TestStepFactory.failingTestStepCalled("step 2"));

    File xmlReport = reporter.generateReportFor(testOutcome);
    String generatedReportText = getStringFrom(xmlReport);

    assertThat(generatedReportText, isSimilarTo(expectedReport));
  }
  @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();
  }
Example #7
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);
  }
 @Test
 public void tryLock() {
   assertThat(temp.getRoot().list()).isEmpty();
   lock.tryLock();
   assertThat(temp.getRoot().toPath().resolve(".sonar_lock")).exists();
   lock.unlock();
 }
Example #9
0
  /** End-to-end installation test. */
  private void doTestAutoInstallation(String id, String fullversion) throws Exception {
    Assume.assumeTrue(
        "this is a really time consuming test, so only run it when we really want",
        Boolean.getBoolean("jenkins.testJDKInstaller"));

    retrieveUpdateCenterData();

    JDKInstaller installer = new JDKInstaller(id, true);

    JDK jdk =
        new JDK(
            "test",
            tmp.getRoot().getAbsolutePath(),
            Arrays.asList(new InstallSourceProperty(Arrays.<ToolInstaller>asList(installer))));

    j.jenkins.getJDKs().add(jdk);

    FreeStyleProject p = j.createFreeStyleProject();
    p.setJDK(jdk);
    p.getBuildersList().add(new Shell("java -fullversion\necho $JAVA_HOME"));
    FreeStyleBuild b = j.buildAndAssertSuccess(p);
    @SuppressWarnings("deprecation")
    String log = b.getLog();
    System.out.println(log);
    // make sure it runs with the JDK that just got installed
    assertTrue(log.contains(fullversion));
    assertTrue(log.contains(tmp.getRoot().getAbsolutePath()));
  }
Example #10
0
  @Test
  public void testCopyColumnsToDirectory() throws Exception {
    this.setup.groupBySetup();

    String uriTemplate = Paths.get(folder.getRoot().toURI()).toUri().toString();
    SQLResponse response =
        execute(
            "copy characters (name, details['job']) to DIRECTORY ?", new Object[] {uriTemplate});
    assertThat(response.cols().length, is(0));
    assertThat(response.rowCount(), is(7L));
    List<String> lines = new ArrayList<>(7);
    DirectoryStream<Path> stream =
        Files.newDirectoryStream(Paths.get(folder.getRoot().toURI()), "*.json");
    for (Path entry : stream) {
      lines.addAll(Files.readAllLines(entry, StandardCharsets.UTF_8));
    }
    Path path = Paths.get(folder.getRoot().toURI().resolve("characters_0_.json"));
    assertTrue(path.toFile().exists());
    assertThat(lines.size(), is(7));

    boolean foundJob = false;
    boolean foundName = false;
    for (String line : lines) {
      foundName = foundName || line.contains("Arthur Dent");
      foundJob = foundJob || line.contains("Sandwitch Maker");
      assertThat(line.split(",").length, is(2));
      assertThat(line.trim(), startsWith("["));
      assertThat(line.trim(), endsWith("]"));
    }
    assertTrue(foundJob);
    assertTrue(foundName);
  }
  @Ignore(
      "Test is ignored because currently it is not possible to register two block extensions in same instance. This may require deep changes on Asciidoctor Extensions API")
  @Test
  public void extensions_should_be_correctly_added() throws IOException {

    Asciidoctor asciidoctor = JRubyAsciidoctor.create();

    // To avoid registering the same extension over and over for all tests, service is instantiated
    // manually.
    new ArrowsAndBoxesExtension().register(asciidoctor);

    Options options =
        options()
            .inPlace(false)
            .toFile(new File(testFolder.getRoot(), "rendersample.html"))
            .safe(SafeMode.UNSAFE)
            .get();

    asciidoctor.renderFile(classpath.getResource("arrows-and-boxes-example.ad"), options);

    File renderedFile = new File(testFolder.getRoot(), "rendersample.html");
    Document doc = Jsoup.parse(renderedFile, "UTF-8");

    Element arrowsJs =
        doc.select("script[src=http://www.headjump.de/javascripts/arrowsandboxes.js").first();
    assertThat(arrowsJs, is(notNullValue()));

    Element arrowsCss =
        doc.select("link[href=http://www.headjump.de/stylesheets/arrowsandboxes.css").first();
    assertThat(arrowsCss, is(notNullValue()));

    Element arrowsAndBoxes = doc.select("pre[class=arrows-and-boxes").first();
    assertThat(arrowsAndBoxes, is(notNullValue()));
  }
Example #12
0
  /**
   * Setup input data
   *
   * @throws IOException
   */
  @Before
  public void setup() throws IOException {
    String exampleList =
        "n00007846_41	http://static.flickr.com/3423/3788747850_c9653099c2.jpg" + "\n"
        //		+
        //		"t3st	http://farm5.staticflickr.com/4013/4214727934_0ff14790f8.jpg" + "\n" +
        //		"test	http://farm3.static.flickr.com/2412/2364526179_6d19772ac4_b.jpg" + "\n" +
        //		"n00007846_383	http://secrets-of-flirting.com/girlfriend.jpg" + "\n" +
        //		"n00007846_499	http://z.about.com/d/kidstvmovies/1/0/a/8/sm3005.jpg" + "\n" +
        //		"n00007846_543	http://static.flickr.com/3455/3372482944_244c25c45f.jpg" + "\n" +
        //		"n00007846_612	http://static.flickr.com/3592/3376795744_e89f42f5c5.jpg" + "\n" +
        //		"n00007846_658	http://static.flickr.com/122/286394792_9232f00db3.jpg" + "\n" +
        //		"n00007846_709	http://static.flickr.com/3299/3621111660_bcb5907cb0.jpg" + "\n" +
        //		"n00007846_839	http://static.flickr.com/3628/3376796820_a1dd3e2ed7.jpg" + "\n" +
        //		"n00007846_846	http://static.flickr.com/3383/3653165852_8f8a06eaa6.jpg" + "\n" +
        //		"Special	designedToFail.com/image.wang" + "\n" +
        //		"Failcakes
        //	http://www.wave.co.nz/~bodyline/pages/catalogue/wetsuits/mens_summer/images/long-sleeve-inferno-L.jpg" + "\n" +
        //		"n00007846_991	http://www.cinema.bg/sff/images-person/David-Lanzmann.gif"
        ;

    exampleFile = folder.newFile("images.txt");

    PrintWriter pw = new PrintWriter(new FileWriter(exampleFile));
    pw.println(exampleList);
    pw.flush();
    pw.close();

    exampleOut = folder.newFile("example.images");
    exampleOut.delete();
  }
  @Test
  public void testCorrectSettingOfMaxSlots() throws Exception {

    File confFile = tmp.newFile("flink-conf.yaml");
    File jarFile = tmp.newFile("test.jar");
    new CliFrontend(tmp.getRoot().getAbsolutePath());

    String[] params = new String[] {"-yn", "2", "-ys", "3", jarFile.getAbsolutePath()};

    RunOptions runOptions = CliFrontendParser.parseRunCommand(params);

    FlinkYarnSessionCli yarnCLI = new TestCLI("y", "yarn");

    AbstractYarnClusterDescriptor descriptor =
        yarnCLI.createDescriptor("", runOptions.getCommandLine());

    // each task manager has 3 slots but the parallelism is 7. Thus the slots should be increased.
    Assert.assertEquals(3, descriptor.getTaskManagerSlots());
    Assert.assertEquals(2, descriptor.getTaskManagerCount());

    Configuration config = new Configuration();
    CliFrontend.setJobManagerAddressInConfig(config, new InetSocketAddress("test", 9000));
    ClusterClient client = new TestingYarnClusterClient(descriptor, config);
    Assert.assertEquals(6, client.getMaxSlots());
  }
  @Test
  public void testOutputFailed() throws IOException {
    ProjectFilesystem projectFilesystem = new ProjectFilesystem(tmpDir.getRoot().toPath());

    ChromeTraceBuildListener listener =
        new ChromeTraceBuildListener(
            projectFilesystem,
            new FakeClock(1409702151000000000L),
            new ObjectMapper(),
            Locale.US,
            TimeZone.getTimeZone("America/Los_Angeles"),
            /* tracesToKeep */ 3,
            false);
    try {
      assumeTrue("Can make the root directory read-only", tmpDir.getRoot().setReadOnly());
      listener.outputTrace(new BuildId("BUILD_ID"));
      fail("Expected an exception.");
    } catch (HumanReadableException e) {
      assertEquals(
          "Unable to write trace file: java.nio.file.AccessDeniedException: "
              + projectFilesystem.resolve(BuckConstant.BUCK_OUTPUT_PATH),
          e.getMessage());
    } finally {
      tmpDir.getRoot().setWritable(true);
    }
  }
  @Test
  public void findsCorrectFile() throws Exception {
    final File directory = testFolder.getRoot();

    final String fileNames[] = new String[] {"other.txt", "my.txt", "a.log", "b.log"};
    for (String fileName : fileNames) {
      testFolder.newFile(fileName);
    }

    final int pidValue = 42;
    final File file = testFolder.newFile("my.pid");
    writeToFile(file, String.valueOf(pidValue));

    final File other = testFolder.newFile("other.pid");
    writeToFile(other, "43");

    final File[] files = directory.listFiles();
    assertEquals(fileNames.length + 2, files.length);

    PidFile pidFile = new PidFile(directory, file.getName());
    assertEquals(file, pidFile.getFile());

    int value = pidFile.readPid();
    assertEquals(pidValue, value);
  }
Example #16
0
  @Before
  public void setUp() throws Exception {
    server = mock(Server.class);
    container = mock(Container.class);
    when(server.getContainer()).thenReturn(container);
    systemEnvironment = mock(SystemEnvironment.class);
    when(systemEnvironment.getServerPort()).thenReturn(1234);
    when(systemEnvironment.getSslServerPort()).thenReturn(4567);
    when(systemEnvironment.keystore()).thenReturn(temporaryFolder.newFolder());
    when(systemEnvironment.truststore()).thenReturn(temporaryFolder.newFolder());
    when(systemEnvironment.getWebappContextPath()).thenReturn("context");
    when(systemEnvironment.getCruiseWar()).thenReturn("cruise.war");
    when(systemEnvironment.getParentLoaderPriority()).thenReturn(true);
    when(systemEnvironment.useCompressedJs()).thenReturn(true);
    when(systemEnvironment.useNioSslSocket()).thenReturn(true);
    when(systemEnvironment.getListenHost()).thenReturn("localhost");
    when(systemEnvironment.getParentLoaderPriority()).thenReturn(false);
    when(systemEnvironment.get(SystemEnvironment.RESPONSE_BUFFER_SIZE)).thenReturn(1000);
    when(systemEnvironment.get(SystemEnvironment.IDLE_TIMEOUT)).thenReturn(2000);
    when(systemEnvironment.getJettyConfigFile()).thenReturn(new File("foo"));

    sslSocketFactory = mock(SSLSocketFactory.class);
    when(sslSocketFactory.getSupportedCipherSuites()).thenReturn(new String[] {});
    goJetty6CipherSuite = mock(GoJetty6CipherSuite.class);
    when(goJetty6CipherSuite.getExcludedCipherSuites()).thenReturn(new String[] {"CS1", "CS2"});
    configuration = mock(Jetty6GoWebXmlConfiguration.class);
    jetty6Server =
        new Jetty6Server(
            systemEnvironment, "pwd", sslSocketFactory, server, goJetty6CipherSuite, configuration);
  }
  /**
   * This tests whether the RocksDB backends uses the temp directories that are provided from the
   * {@link Environment} when no db storage path is set.
   *
   * @throws Exception
   */
  @Test
  public void testUseTempDirectories() throws Exception {
    String checkpointPath = tempFolder.newFolder().toURI().toString();
    RocksDBStateBackend rocksDbBackend = new RocksDBStateBackend(checkpointPath);

    File dir1 = tempFolder.newFolder();
    File dir2 = tempFolder.newFolder();

    File[] tempDirs = new File[] {dir1, dir2};

    assertNull(rocksDbBackend.getDbStoragePaths());

    Environment env = getMockEnvironment(tempDirs);
    RocksDBKeyedStateBackend<Integer> keyedBackend =
        (RocksDBKeyedStateBackend<Integer>)
            rocksDbBackend.createKeyedStateBackend(
                env,
                env.getJobID(),
                "test_op",
                IntSerializer.INSTANCE,
                1,
                new KeyGroupRange(0, 0),
                env.getTaskKvStateRegistry());

    File instanceBasePath = keyedBackend.getInstanceBasePath();
    assertThat(
        instanceBasePath.getAbsolutePath(),
        anyOf(startsWith(dir1.getAbsolutePath()), startsWith(dir2.getAbsolutePath())));
  }
 @Before
 public void setup() throws IOException {
   file = folder.newFile("log.txt");
   pathToEmptyFile = file.getAbsolutePath();
   File file2 = folder.newFile("content.txt");
   writeContentTo(file2, "Some content");
 }
  @Before
  public void setUp() throws Exception {
    assumeThat(TD_API_KEY, not(isEmptyOrNullString()));
    projectDir = folder.getRoot().toPath().toAbsolutePath().normalize();
    config = folder.newFile().toPath();
    Files.write(config, asList("secrets.td.apikey = " + TD_API_KEY));
    outfile = projectDir.resolve("outfile");

    client = TDClient.newBuilder(false).setApiKey(TD_API_KEY).build();
    database = "tmp_" + UUID.randomUUID().toString().replace('-', '_');
    client.createDatabase(database);

    table = "test";
    String insertJobId =
        client.submit(
            TDJobRequest.newPrestoQuery(database, "create table " + table + " as select 1"));

    TestUtils.expect(Duration.ofMinutes(5), jobSuccess(client, insertJobId));

    String selectCountJobId =
        client.submit(TDJobRequest.newPrestoQuery(database, "select count(*) from " + table));
    TestUtils.expect(Duration.ofMinutes(5), jobSuccess(client, selectCountJobId));

    List<ArrayNode> result = downloadResult(selectCountJobId);
    assertThat(result.get(0).get(0).asInt(), is(1));
  }
  @Test
  public void testGZUncompressRetries()
      throws ServiceException, IOException, SegmentLoadingException {
    final String bucket = "bucket";
    final String keyPrefix = "prefix/dir/0";
    final RestS3Service s3Client = EasyMock.createStrictMock(RestS3Service.class);
    final byte[] value = bucket.getBytes("utf8");

    final File tmpFile = temporaryFolder.newFile("gzTest.gz");

    try (OutputStream outputStream = new GZIPOutputStream(new FileOutputStream(tmpFile))) {
      outputStream.write(value);
    }

    S3Object object0 = new S3Object();

    object0.setBucketName(bucket);
    object0.setKey(keyPrefix + "/renames-0.gz");
    object0.setLastModifiedDate(new Date(0));
    object0.setDataInputStream(new FileInputStream(tmpFile));

    File tmpDir = temporaryFolder.newFolder("gzTestDir");

    S3ServiceException exception = new S3ServiceException();
    exception.setErrorCode("NoSuchKey");
    exception.setResponseCode(404);
    EasyMock.expect(
            s3Client.getObjectDetails(
                EasyMock.eq(object0.getBucketName()), EasyMock.eq(object0.getKey())))
        .andReturn(null)
        .once();
    EasyMock.expect(
            s3Client.getObjectDetails(
                EasyMock.eq(object0.getBucketName()), EasyMock.eq(object0.getKey())))
        .andReturn(object0)
        .once();
    EasyMock.expect(s3Client.getObject(EasyMock.eq(bucket), EasyMock.eq(object0.getKey())))
        .andThrow(exception)
        .once();
    EasyMock.expect(
            s3Client.getObjectDetails(
                EasyMock.eq(object0.getBucketName()), EasyMock.eq(object0.getKey())))
        .andReturn(object0)
        .once();
    EasyMock.expect(s3Client.getObject(EasyMock.eq(bucket), EasyMock.eq(object0.getKey())))
        .andReturn(object0)
        .once();
    S3DataSegmentPuller puller = new S3DataSegmentPuller(s3Client);

    EasyMock.replay(s3Client);
    FileUtils.FileCopyResult result =
        puller.getSegmentFiles(new S3DataSegmentPuller.S3Coords(bucket, object0.getKey()), tmpDir);
    EasyMock.verify(s3Client);

    Assert.assertEquals(value.length, result.size());
    File expected = new File(tmpDir, "renames-0");
    Assert.assertTrue(expected.exists());
    Assert.assertEquals(value.length, expected.length());
  }
 private Resource createFile(String path, String content) throws IOException {
   final File file = new File(folder.getRoot(), path);
   file.getParentFile().mkdirs();
   final Writer writer = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
   writer.write(content);
   writer.close();
   return new FileResource(folder.getRoot(), path);
 }
Example #22
0
 private void createTempFiles() throws IOException {
   for (int i = 0; i < MUSIC_FILE_NUMBER; i++) {
     File file = tempSourceFolder.newFile("test_music_file_" + i + ".mp3");
     file.createNewFile();
     File imageFile = tempSourceFolder.newFile("test_image_file_" + i + ".jpeg");
     imageFile.createNewFile();
   }
 }
Example #23
0
  @Before
  public void setUp() throws Exception {
    assumeThat(runEcho(), is(true));

    projectDir = folder.getRoot().toPath().toAbsolutePath().normalize();
    config = folder.newFile().toPath();
    outfile = projectDir.resolve("outfile");
  }
 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");
 }
Example #25
0
 @Before
 public void setUpRepos() throws Exception {
   buckRepoRoot = temp.newFolder().toPath();
   thirdPartyRelative = Paths.get("third-party").resolve("java");
   thirdParty = buckRepoRoot.resolve(thirdPartyRelative);
   localRepo = temp.newFolder().toPath();
   resolver =
       new Resolver(buckRepoRoot, thirdPartyRelative, localRepo, httpd.getUri("/").toString());
 }
 @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();
 }
  @Before
  public void setUpProject() throws IOException {
    orchestrator.resetData();
    orchestrator
        .getServer()
        .restoreProfile(FileLocation.ofClasspath("/duplication/xoo-duplication-profile.xml"));

    FileUtils.copyDirectory(ItUtils.projectDir(PROJECT_DIR), temp.getRoot());
    projectDir = temp.getRoot();
  }
Example #28
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;
  }
  @Before
  public void setUp() throws IOException {
    temporaryFolder.newFile("context1.context");
    temporaryFolder.newFile("context2.context");
    temporaryFolder.newFile("context3.context");
    temporaryFolder.newFile("unknown.file");

    persistenceService = new ContextFilePersistenceService();
    persistenceService.setStorageFolderPath(temporaryFolder.getRoot().getAbsolutePath());
  }
Example #30
0
  public static final PropertiesManager makePm(TemporaryFolder testFolder, String... props)
      throws IOException {
    PropertiesManager pm = new PropertiesManager();
    pm.setProperty("tmpdir", testFolder.newFolder("tmp").getCanonicalPath());
    pm.setProperty("configdir", testFolder.newFolder("config").getCanonicalPath());
    pm.setProperty("rrddir", testFolder.newFolder("rrddir").getCanonicalPath());
    pm.setProperty("autocreate", "true");

    return finishPm(pm, props);
  }