public SetupOfAgentPluginsFile(File pluginsZipFile) throws IOException {
   this.pluginsZipFile = pluginsZipFile;
   this.bundledPluginsDir = TestFileUtil.createTempFolder("bundled");
   this.externalPluginsDir = TestFileUtil.createTempFolder("external");
   this.dummyFileSoZipFileIsNotEmpty = TestFileUtil.createTempFile("dummy.txt");
   this.zipUtil = new ZipUtil();
 }
Ejemplo n.º 2
0
  @Test
  public void shouldNotThrowExceptionIfUserSpecifiesNonFolderFileThatExistsAsSrc()
      throws Exception {
    final File nonFolderFileThatExists =
        TestFileUtil.createTestFile(
            TestFileUtil.createTempFolder("tempFolder"), "nonFolderFileThatExists");
    final TestArtifactPlan compositeTestArtifact =
        new TestArtifactPlan(new TestArtifactPlan(nonFolderFileThatExists.getPath(), "testoutput"));

    compositeTestArtifact.publish(mockArtifactPublisher, rootPath);
    doNothing().when(mockArtifactPublisher).upload(any(File.class), any(String.class));
  }
Ejemplo n.º 3
0
  // This is bug #2320 - Cruise doing full checkouts most times
  @Test
  public void shouldNotDeleteWorkingDirIfMaterialsAreCheckedOutToSubfoldersWithTheSameRootBug2320()
      throws Exception {
    SvnMaterial svnMaterial1 = repo.createMaterial("multiple-materials/trunk/part1", "root/part1");
    SvnMaterial svnMaterial2 = repo.createMaterial("multiple-materials/trunk/part2", "root/part2");
    Materials materials = new Materials(svnMaterial1, svnMaterial2);

    Revision revision =
        latestRevision(svnMaterial1, pipelineDir, new TestSubprocessExecutionContext());

    updateMaterials(materials, revision);

    assertThat(new File(pipelineDir, "root/part1").exists(), is(true));
    assertThat(new File(pipelineDir, "root/part2").exists(), is(true));

    File testFile = new File(pipelineDir, "root/part1/test-file");
    testFile.createNewFile();
    assertThat(testFile.exists(), is(true));
    // simulates what a build will do
    TestFileUtil.createTestFolder(pipelineDir, ArtifactLogUtil.CRUISE_OUTPUT_FOLDER);
    assertThat(pipelineDir.listFiles().length, is(2));

    updateMaterials(materials, revision);

    assertThat(new File(pipelineDir, "root/part1").exists(), is(true));
    assertThat(new File(pipelineDir, "root/part2").exists(), is(true));

    assertThat("Should not delete the part1 directory", testFile.exists(), is(true));
  }
Ejemplo n.º 4
0
  @Test
  public void shouldNotDeleteDirectoriesWhenThereIsACruiseOutputDirectory() throws Exception {
    SvnMaterial svnMaterial1 = repo.createMaterial("multiple-materials/trunk/part1", "part1");
    SvnMaterial svnMaterial2 = repo.createMaterial("multiple-materials/trunk/part2", "part2");
    Materials materials = new Materials(svnMaterial1, svnMaterial2);

    Revision revision =
        latestRevision(svnMaterial1, pipelineDir, new TestSubprocessExecutionContext());

    updateMaterials(materials, revision);

    assertThat(new File(pipelineDir, "part1").exists(), is(true));
    assertThat(new File(pipelineDir, "part2").exists(), is(true));

    File testFile = new File(pipelineDir, "part1/test-file");
    testFile.createNewFile();
    assertThat(testFile.exists(), is(true));
    // simulates what a build will do
    TestFileUtil.createTestFolder(pipelineDir, ArtifactLogUtil.CRUISE_OUTPUT_FOLDER);
    assertThat(pipelineDir.listFiles().length, is(3));

    updateMaterials(materials, revision);

    assertThat(new File(pipelineDir, "part1").exists(), is(true));
    assertThat(new File(pipelineDir, "part2").exists(), is(true));

    assertThat("Should not delete the part1 directory", testFile.exists(), is(true));
  }
Ejemplo n.º 5
0
 private File mergeAllTestResultToSingleFile(File[] allTestFiles) throws IOException {
   FileOutputStream mergedResourcesStream = null;
   try {
     File mergedResource = TestFileUtil.createUniqueTempFile("mergedFile.xml");
     mergedResourcesStream = new FileOutputStream(mergedResource);
     merge(allTestFiles, mergedResourcesStream);
     return mergedResource;
   } finally {
     IOUtils.closeQuietly(mergedResourcesStream);
   }
 }
Ejemplo n.º 6
0
  @Before
  public void setUp() throws Exception {
    tempFolder =
        TestFileUtil.createTempFolder("tempCommandLineTestFolder-" + System.currentTimeMillis());
    toDelete.add(tempFolder);

    subFolder = new File(tempFolder, "subFolder");
    subFolder.mkdirs();
    File file = new File("./originalCommand");
    file.createNewFile();
    file.setExecutable(true);
    toDelete.add(file);
  }
 @Before
 public void setup() throws Exception {
   dbHelper.onSetUp();
   configHelper.onSetUp();
   configHelper.usingCruiseConfigDao(goConfigDao).initializeConfigFile();
   hgTestRepo = new HgTestRepo("hgTestRepo1");
   hgMaterial = MaterialsMother.hgMaterial(hgTestRepo.projectRepositoryUrl());
   hgMaterial.setFilter(new Filter(new IgnoredFiles("helper/**/*.*")));
   workingFolder = TestFileUtil.createTempFolder("workingFolder");
   outputStreamConsumer = inMemoryConsumer();
   mingleConfig =
       configHelper.addPipeline(
           "cruise", STAGE_NAME, this.hgMaterial.config(), "unit", "functional");
 }
  @Test
  public void shouldReturnAgentPluginsZipWhenRequested() throws Exception {
    File pluginZipFile = TestFileUtil.createTempFile("plugins.zip");
    FileUtils.writeStringToFile(pluginZipFile, "content");
    when(pluginsZip.md5()).thenReturn("md5");
    when(systemEnvironment.get(SystemEnvironment.ALL_PLUGINS_ZIP_PATH))
        .thenReturn(pluginZipFile.getAbsolutePath());

    controller.downloadPluginsZip(response);

    String actual = response.getContentAsString();
    assertEquals("application/octet-stream", response.getContentType());
    assertEquals("content", actual);
  }
Ejemplo n.º 9
0
  public void start() throws Exception {
    server = new Server(serverPort);

    File keystore = TestFileUtil.createUniqueTempFile("keystore");
    File truststore = TestFileUtil.createUniqueTempFile("truststore");
    File agentKeystore = TestFileUtil.createUniqueTempFile("agentstore");
    createX509Certificate(keystore, truststore, agentKeystore);

    server.addConnector(sslConnector(keystore, truststore, sslPort));
    WebAppContext wac = new WebAppContext("testdata/goserverstub", "/go");
    wac.setConfigurationClasses(
        new String[] {
          WebInfConfiguration.class.getCanonicalName(),
          WebXmlConfiguration.class.getCanonicalName(),
          JettyWebXmlConfiguration.class.getCanonicalName()
        });

    addFakeArtifactiPublisherServlet(wac);
    addFakeAgentCertificateServlet(wac);
    server.setHandler(wac);
    server.setStopAtShutdown(true);
    server.start();
  }
Ejemplo n.º 10
0
 @Before
 public void setup() {
   workingFolder = TestFileUtil.createTempFolder("workingFolder");
 }
Ejemplo n.º 11
0
 @Before
 public void createRepo() throws IOException {
   repo = new SvnTestRepo();
   pipelineDir = TestFileUtil.createTempFolder("working-dir-" + UUID.randomUUID());
 }
 @After
 public void tearDown() throws Exception {
   cleanupAgentPluginsFile();
   TestFileUtil.cleanTempFiles();
 }
 private File setupUnzippedPluginsDirectoryStructure() throws IOException {
   File dir = TestFileUtil.createTempFolder("unzipped-plugins");
   FileUtils.forceMkdir(new File(dir, "bundled"));
   FileUtils.forceMkdir(new File(dir, "external"));
   return dir;
 }