コード例 #1
0
  @Test(expected = ArchiveExportException.class)
  public void testExportThrowsArchiveExceptionOnAssetWriteFailure() throws IOException {
    log.info("testExportThrowsArchiveExceptionOnAssetWriteFailure");
    Archive<?> archive = createArchiveWithAssets();

    // Check if a the path already contains a node so we remove it from the parent's children
    if (archive.contains(PATH_ONE)) {
      archive.delete(PATH_ONE);
    }

    archive.add(
        new Asset() {
          @Override
          public InputStream openStream() {
            throw new RuntimeException("Mock Exception from an Asset write");
          }
        },
        PATH_ONE);

    // Export
    final InputStream in = this.exportAsInputStream(archive);

    // Read in the full content (to in turn empty the underlying buffer and ensure we complete)
    final OutputStream sink =
        new OutputStream() {
          @Override
          public void write(int b) throws IOException {}
        };
    IOUtil.copyWithClose(in, sink);
  }
コード例 #2
0
  @Test
  public void shouldGenerateDependencies() throws Exception {
    Archive<?> archive = new TestNGDeploymentAppender().createAuxiliaryArchive();

    Assert.assertTrue(
        "Should have added TestRunner SPI",
        archive.contains(
            ArchivePaths.create(
                "/META-INF/services/org.jboss.arquillian.container.test.spi.TestRunner")));

    Assert.assertTrue(
        "Should have added TestRunner Impl",
        archive.contains(
            ArchivePaths.create("/org/jboss/arquillian/testng/container/TestNGTestRunner.class")));

    System.out.println(archive.toString(true));
  }
コード例 #3
0
  private void checkFractionsPresent(Archive uberjar) throws IOException {
    assertThat(uberjar.contains("META-INF/wildfly-swarm-manifest.yaml")).isTrue();

    String manifestContent = readFileFromArchive(uberjar, "META-INF/wildfly-swarm-manifest.yaml");

    for (String fraction : testingProject.fractionsThatShouldBePresent()) {
      assertThat(manifestContent).contains("org.wildfly.swarm." + fraction);
      assertThat(manifestContent).contains("org.wildfly.swarm:" + fraction);
      assertThat(uberjar.contains("m2repo/org/wildfly/swarm/" + fraction)).isTrue();
    }

    for (String fraction : testingProject.fractionsThatShouldBeMissing()) {
      assertThat(manifestContent).doesNotContain("org.wildfly.swarm." + fraction);
      assertThat(manifestContent).doesNotContain("org.wildfly.swarm:" + fraction);
      assertThat(uberjar.contains("m2repo/org/wildfly/swarm/" + fraction)).isFalse();
    }
  }
コード例 #4
0
  /** Check to see if a path is found in a nested archive */
  private boolean nestedContains(ArchivePath path) {
    // Iterate through nested archives
    for (Entry<ArchivePath, ArchiveAsset> nestedArchiveEntry : nestedArchives.entrySet()) {
      ArchivePath archivePath = nestedArchiveEntry.getKey();
      ArchiveAsset archiveAsset = nestedArchiveEntry.getValue();

      // Check to see if the requested path starts with the nested archive path
      if (startsWith(path, archivePath)) {
        Archive<?> nestedArchive = archiveAsset.getArchive();

        // Get the asset path from within the nested archive
        ArchivePath nestedAssetPath = getNestedPath(path, archivePath);

        // Recurse the call to the nested archive
        return nestedArchive.contains(nestedAssetPath);
      }
    }
    return false;
  }