protected File buildLargeJar() throws Exception { final String fileName = "large.jar"; final JavaArchive archive = ShrinkWrap.create( JavaArchive.class, fileName ); // Build a large jar by adding a lorem ipsum file repeatedly. final Path loremipsumTxtFile = Paths.get( ScannerTests.class.getResource( "/org/hibernate/jpa/test/packaging/loremipsum.txt" ).toURI() ); for ( int i = 0; i < 100; i++ ) { ArchivePath path = ArchivePaths.create( "META-INF/file" + i ); archive.addAsResource( loremipsumTxtFile.toFile(), path ); } File testPackage = new File( shrinkwrapArchiveDirectory, fileName ); archive.as( ZipExporter.class ).exportTo( testPackage, true ); return testPackage; }
@Test public void shouldGenerateDependencies() throws Exception { Archive<?> archive = new JUnitDeploymentAppender().createAuxiliaryArchive(); Assert.assertTrue( "Should have added Extension", 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/junit/container/JUnitTestRunner.class"))); } }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#merge(org.jboss.shrinkwrap.api.Archive, java.lang.String, * org.jboss.shrinkwrap.api.Filter) */ @Override public T merge(final Archive<?> source, final String path, final Filter<ArchivePath> filter) throws IllegalArgumentException { Validate.notNull(path, "path must be specified"); return this.merge(source, ArchivePaths.create(path), filter); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#add(org.jboss.shrinkwrap.api.asset.Asset, java.lang.String, * java.lang.String) */ @Override public T add(final Asset asset, final String target, final String name) throws IllegalArgumentException { Validate.notNull(target, "target must be specified"); final ArchivePath path = ArchivePaths.create(target); return this.add(asset, path, name); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#getAsType(java.lang.Class, java.lang.String, * org.jboss.shrinkwrap.api.ArchiveFormat) */ @Override public <X extends Archive<X>> X getAsType(final Class<X> type, final String path, final ArchiveFormat archiveFormat) { Validate.notNull(path, "ArchiveFormat must be specified"); return getAsType(type, ArchivePaths.create(path), archiveFormat); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#merge(org.jboss.shrinkwrap.api.Archive, java.lang.String) */ @Override public T merge(final Archive<?> source, final String path) throws IllegalArgumentException { Validate.notNull(path, "path must be specified"); return this.merge(source, ArchivePaths.create(path)); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#addAsDirectory(java.lang.String) */ @Override public T addAsDirectory(final String path) throws IllegalArgumentException { // Precondition check Validate.notNullOrEmpty(path, "path must be specified"); // Delegate and return return this.addAsDirectory(ArchivePaths.create(path)); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#delete(java.lang.String) */ @Override public Node delete(String archivePath) { Validate.notNull(archivePath, "No path was specified"); return delete(ArchivePaths.create(archivePath)); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#contains(java.lang.String) */ @Override public boolean contains(final String path) throws IllegalArgumentException { Validate.notNull(path, "Path must be specified"); final ArchivePath archivePath = ArchivePaths.create(path); return this.contains(archivePath); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#contains(java.lang.String) */ @Override public boolean contains(final String path) throws IllegalArgumentException { Validate.notNull(path, "Path must be specified"); return this.contains(ArchivePaths.create(path)); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#getAsType(java.lang.Class, java.lang.String) */ @Override public <X extends Archive<X>> X getAsType(Class<X> type, String path) { Validate.notNull(path, "Path must be specified"); return getAsType(type, ArchivePaths.create(path)); }
@Override public T addAsManifestResource(Package resourcePackage, String resourceName) throws IllegalArgumentException { Validate.notNull(resourcePackage, "ResourcePackage must be specified"); Validate.notNull(resourceName, "ResourceName must be specified"); String classloaderResourceName = AssetUtil.getClassLoaderResourceName(resourcePackage, resourceName); ArchivePath target = ArchivePaths.create(classloaderResourceName); return addAsManifestResource(resourcePackage, resourceName, target); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#add(org.jboss.shrinkwrap.api.Archive, java.lang.String, java.lang.Class) */ @Override public T add(final Archive<?> archive, final String path, final Class<? extends StreamExporter> exporter) { Validate.notNull(archive, "Archive must be specified"); Validate.notNullOrEmpty(path, "Archive Path must be specified"); Validate.notNull(exporter, "exporter must be specified"); return this.add(archive, ArchivePaths.create(path), exporter); }
@Override public T addAsManifestResource(Package resourcePackage, String resourceName, String target) throws IllegalArgumentException { Validate.notNull(resourcePackage, "ResourcePackage must be specified"); Validate.notNull(resourceName, "ResourceName must be specified"); Validate.notNull(target, "Target must be specified"); return addAsManifestResource(resourcePackage, resourceName, ArchivePaths.create(target)); }
@Override public T addAsResource(Package resourcePackage, String resourceName, String target) throws IllegalArgumentException { Validate.notNull(resourcePackage, "ResourcePackage must be specified"); Validate.notNull(resourceName, "ResourceName must be specified"); Validate.notNull(target, "Target must be specified"); return addAsResource(resourcePackage, resourceName, ArchivePaths.create(target)); }
@Override public T addAsWebResource(Package resourcePackage, String resourceName, String target) throws IllegalArgumentException { Validate.notNull(resourcePackage, "ResourcePackage must be specified"); Validate.notNull(resourceName, "ResourceName must be specified"); Validate.notNull(target, "Target must be specified"); return addAsWebResource(resourcePackage, resourceName, ArchivePaths.create(target)); }
@Override public T addAsResource(Package resourcePackage, String resourceName) throws IllegalArgumentException { Validate.notNull(resourcePackage, "ResourcePackage must be specified"); Validate.notNull(resourceName, "ResourceName must be specified"); String classloaderResourceName = AssetUtil.getClassLoaderResourceName(resourcePackage, resourceName); ArchivePath target = ArchivePaths.create(classloaderResourceName); return addAsResource(resourcePackage, resourceName, target); }
@Override public T addAsApplicationResource(Package resourcePackage, String resourceName) throws IllegalArgumentException { Validate.notNull(resourcePackage, "ResourcePackage must be specified"); Validate.notNull(resourceName, "ResourceName must be specified"); String classloaderResourceName = AssetUtil.getClassLoaderResourceName(resourcePackage, resourceName); ArchivePath target = ArchivePaths.create(classloaderResourceName); return addAsApplicationResource(resourcePackage, resourceName, target); }
@Override public T addAsWebResource(Package resourcePackage, String resourceName) throws IllegalArgumentException { Validate.notNull(resourcePackage, "ResourcePackage must be specified"); Validate.notNull(resourceName, "ResourceName must be specified"); String classloaderResourceName = AssetUtil.getClassLoaderResourceName(resourcePackage, resourceName); ArchivePath target = ArchivePaths.create(classloaderResourceName); return addAsWebResource(resourcePackage, resourceName, target); }
@Override public T addAsApplicationResource(Package resourcePackage, String resourceName, String target) throws IllegalArgumentException { Validate.notNull(resourcePackage, "ResourcePackage must be specified"); Validate.notNull(resourceName, "ResourceName must be specified"); Validate.notNull(target, "Target must be specified"); return addAsApplicationResource(resourcePackage, resourceName, ArchivePaths.create(target)); }