/**
   * Enable static content to be served from a given base in the classpath.
   *
   * @param base The path prefix to use for static content.
   * @return
   */
  @SuppressWarnings("unchecked")
  default T staticContent(String base) {
    // as(WARArchive.class).addModule("org.wildfly.swarm.undertow", "runtime");

    try {
      // Add all the static content from the current app to the archive
      Archive allResources = DefaultWarDeploymentFactory.archiveFromCurrentApp();
      // Here we define static as basically anything that's not a
      // Java class file or under WEB-INF or META-INF
      mergeIgnoringDuplicates(allResources, base, Filters.exclude(".*\\.class$"));
    } catch (Exception ex) {
      log.log(Level.WARNING, "Error setting up static resources", ex);
    }

    Node node = get(EXTERNAL_MOUNT_PATH);
    UndertowExternalMountsAsset asset;
    if (node == null) {
      asset = new UndertowExternalMountsAsset();
      add(asset, EXTERNAL_MOUNT_PATH);
    } else {
      Asset tempAsset = node.getAsset();
      if (!(tempAsset instanceof UndertowExternalMountsAsset)) {
        asset = new UndertowExternalMountsAsset(tempAsset.openStream());
        add(asset, EXTERNAL_MOUNT_PATH);
      } else {
        asset = (UndertowExternalMountsAsset) node.getAsset();
      }
    }

    // Add external mounts for static content so changes are picked up
    // immediately during development
    Path webResources = Paths.get(System.getProperty("user.dir"), "src", "main", "webapp");
    if (base != null) {
      webResources = webResources.resolve(base);
    }
    if (Files.exists(webResources)) {
      asset.externalMount(webResources.toString());
    }
    webResources = Paths.get(System.getProperty("user.dir"), "src", "main", "resources");
    if (base != null) {
      webResources = webResources.resolve(base);
    }
    if (Files.exists(webResources)) {
      asset.externalMount(webResources.toString());
    }

    return (T) this;
  }
 protected static byte[] toBytes(Asset asset) {
   try {
     ByteArrayOutputStream baos = new ByteArrayOutputStream();
     InputStream is = asset.openStream();
     try {
       Utils.copyStream(is, baos);
     } finally {
       Utils.safeClose(is);
     }
     return baos.toByteArray();
   } catch (IOException e) {
     throw new IllegalStateException(e);
   }
 }
  default JBossDeploymentStructureAsset getDescriptorAsset() {
    String path = PRIMARY_JBOSS_DEPLOYMENT_DESCRIPTOR_PATH;
    Node jbossDS = this.get(PRIMARY_JBOSS_DEPLOYMENT_DESCRIPTOR_PATH);
    if (jbossDS == null) {
      jbossDS = this.get(SECONDARY_JBOSS_DEPLOYMENT_DESCRIPTOR_PATH);
      if (jbossDS != null) {
        path = SECONDARY_JBOSS_DEPLOYMENT_DESCRIPTOR_PATH;
      }
    }
    Asset asset;

    if (jbossDS == null) {
      asset = new JBossDeploymentStructureAsset();
    } else {
      asset = jbossDS.getAsset();
      if (!(asset instanceof JBossDeploymentStructureAsset)) {
        asset = new JBossDeploymentStructureAsset(asset.openStream());
      }
    }

    this.add(asset, path);

    return (JBossDeploymentStructureAsset) asset;
  }
  /**
   * {@inheritDoc}
   *
   * @see
   *     org.jboss.shrinkwrap.impl.base.exporter.StreamExporterTestBase#ensureAssetInExportedFile(java.io.File,
   *     org.jboss.shrinkwrap.api.ArchivePath, org.jboss.shrinkwrap.api.asset.Asset)
   */
  protected final void ensureAssetInExportedFile(
      final File file, final ArchivePath path, final Asset asset) throws IOException {
    // Precondition checks
    assert file != null : "file must be specified";
    assert path != null : "path must be specified";
    assert asset != null : "asset must be specified";

    // Get as Exported File
    final InputStream actualStream = this.getContentsFromExportedFile(file, path);
    assert actualStream != null
        : "No contents found at path " + path + " in " + file.getAbsolutePath();
    byte[] actualContents = IOUtil.asByteArray(actualStream);
    byte[] expectedContents = IOUtil.asByteArray(asset.openStream());
    Assert.assertArrayEquals(expectedContents, actualContents);
  }