@Override public T move(final ArchivePath source, final ArchivePath target) throws IllegalArgumentException, IllegalArchivePathException { return delegate.move(source, target); }
@Override public T move(final String source, final String target) throws IllegalArgumentException, IllegalArchivePathException { return delegate.move(source, target); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#move(java.lang.String, java.lang.String) */ @Override public T move(String source, String target) throws IllegalArgumentException, IllegalArchivePathException { this.getArchive().move(source, target); return covarientReturn(); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#move(org.jboss.shrinkwrap.api.ArchivePath, * org.jboss.shrinkwrap.api.ArchivePath) */ @Override public T move(ArchivePath source, ArchivePath target) throws IllegalArgumentException, IllegalArchivePathException { this.getArchive().move(source, target); return covarientReturn(); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#move(org.jboss.shrinkwrap.api.ArchivePath, * org.jboss.shrinkwrap.api.ArchivePath) */ @Override public T move(ArchivePath source, ArchivePath target) throws IllegalArgumentException, IllegalArchivePathException { this.getArchive().move(source, target); return covarientReturn(); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#move(java.lang.String, java.lang.String) */ @Override public T move(String source, String target) throws IllegalArgumentException, IllegalArchivePathException { this.getArchive().move(source, target); return covarientReturn(); }
@Test(expected = IllegalArchivePathException.class) public void shouldNotMoveAssetBecauseOfInexistentPath() { final Archive<JavaArchive> archive = ShrinkWrap.create(JavaArchive.class, "archive.jar"); final String sourcePath = "non-existent-path1"; final String targetPath = "path2"; archive.move(sourcePath, targetPath); }
archive.move(source.toString(), target.toString());
archive.move(source.toString(), target.toString());
@Test public void shouldMoveDirectory() { final Archive<JavaArchive> archive = ShrinkWrap.create(JavaArchive.class, "archive.jar"); final String sourcePath = "path1"; final String targetPath = "path2"; archive.addAsDirectory(sourcePath); archive.move(sourcePath, targetPath); Assert.assertTrue("Directory should be at the new path", archive.get(targetPath).getAsset() == null); }
@Test public void shouldMoveAsset() { final Archive<JavaArchive> archive = ShrinkWrap.create(JavaArchive.class, "archive.jar"); final String sourcePath = "path1"; final String targetPath = "path2"; archive.add(EmptyAsset.INSTANCE, sourcePath); archive.move(sourcePath, targetPath); Assert.assertEquals("The archive should have only one asset", 1, numAssets(archive)); Assert.assertNotNull("The asset should be at the target path", archive.get(targetPath)); }
@Test public void shouldMoveNotEmptyDirectory() { final Archive<JavaArchive> archive = ShrinkWrap.create(JavaArchive.class, "archive.jar"); final String sourcePath = "path1"; final String targetPath = "path2"; final String childDirName = "childDir"; final String childDirPath = sourcePath + "/" + childDirName; final String childDirTargetPath = targetPath + "/" + childDirName; final String childFileName = "file1"; final String childFilePath = childDirPath + "/" + childFileName; final String childFileTargetPath = childDirTargetPath + "/" + childFileName; archive.addAsDirectory(sourcePath); archive.addAsDirectory(childDirName); archive.add(EmptyAsset.INSTANCE, childFilePath); archive.move(sourcePath, targetPath); Assert.assertTrue("Directory should be at the new path", archive.get(targetPath).getAsset() == null); Assert.assertTrue("Child dir should be at the new path", archive.get(childDirTargetPath).getAsset() == null); Assert.assertTrue("Child asset should be at the new path", archive.get(childFileTargetPath).getAsset() != null); }