@Test public void testIsTransformationSet_afterApplyingOptionsWithTransform_isTrue() { TestOptions other = new TestOptions(); other.transform(Bitmap.class, transformation); options.apply(other); assertThat(options.isTransformationSet()).isTrue(); }
@Test public void testApplyingDontTransform_overridesTransformations() { options.transform(RuntimeEnvironment.application, transformation); options.dontTransform(); assertThat(options.isTransformationSet()).isFalse(); assertThat(options.isTransformationRequired()).isFalse(); assertThat(options.getTransformations()).isEmpty(); }
@Test public void testApplyingTransformation_overridesDontTransform() { options.dontTransform(); options.transform(RuntimeEnvironment.application, transformation); assertThat(options.isTransformationAllowed()).isTrue(); assertThat(options.isTransformationRequired()).isTrue(); assertThat(options.getTransformations()).containsEntry(Bitmap.class, transformation); }
@Test public void testApplyingDefaultOptions_withDontTransform_retainsDontTransform() { options.dontTransform(); options.apply(new TestOptions()); assertThat(options.isTransformationAllowed()).isFalse(); assertThat(options.isTransformationRequired()).isFalse(); assertThat(options.getTransformations()).isEmpty(); }
@Test public void testApplyingDefaultOptions_withTransform_retrainsTransform() { options.transform(RuntimeEnvironment.application, transformation); options.apply(new TestOptions()); assertThat(options.isTransformationAllowed()).isTrue(); assertThat(options.isTransformationRequired()).isTrue(); assertThat(options.getTransformations()).containsEntry(Bitmap.class, transformation); }
@Test public void testApplyingOptions_withDontTransform_overridesTransformations() { options.transform(RuntimeEnvironment.application, transformation); TestOptions other = new TestOptions(); other.dontTransform(); options.apply(other); assertThat(options.isTransformationAllowed()).isFalse(); assertThat(options.isTransformationSet()).isFalse(); assertThat(options.isTransformationRequired()).isFalse(); assertThat(options.getTransformations()).isEmpty(); }
@Test public void testReplaceDirectoryByDirectory() throws SVNException { final Sandbox sandbox = Sandbox.createWithCleanup("replaceDirectoryByDirectory", TestOptions.getInstance()); try { final SVNURL url = sandbox.createSvnRepository(); initWithDirectory(url); final WorkingCopy workingCopy = sandbox.checkoutNewWorkingCopy(url, -1); final long revision = replaceByDirectory(workingCopy); final File repositoryRoot = dump(url); assertValidReplaceKind(repositoryRoot, revision, SVNNodeKind.DIR); } finally { sandbox.dispose(); } }
@Test public void testLocksUnderRemovedDirectoryAreRemoved() throws Exception { final TestOptions options = TestOptions.getInstance(); final SvnOperationFactory svnOperationFactory = new SvnOperationFactory(); final Sandbox sandbox = Sandbox.createWithCleanup( getTestName() + ".testLocksUnderRemovedDirectoryAreRemoved", options); try { final SVNURL url = sandbox.createSvnRepository(); final CommitBuilder commitBuilder = new CommitBuilder(url); commitBuilder.addFile("directory/file"); commitBuilder.commit(); final WorkingCopy workingCopy = sandbox.checkoutNewWorkingCopy(url); final File workingCopyDirectory = workingCopy.getWorkingCopyDirectory(); final File directory = workingCopy.getFile("directory"); final File file = workingCopy.getFile("directory/file"); final SvnSetLock setLock = svnOperationFactory.createSetLock(); setLock.setSingleTarget(SvnTarget.fromFile(file)); setLock.run(); workingCopy.delete(directory); workingCopy.commit(""); SVNFileUtil.ensureDirectoryExists(directory); TestUtil.writeFileContentsString(file, ""); final SvnScheduleForAddition scheduleForAddition = svnOperationFactory.createScheduleForAddition(); scheduleForAddition.setAddParents(true); scheduleForAddition.setSingleTarget(SvnTarget.fromFile(file)); scheduleForAddition.run(); workingCopy.commit(""); final Map<File, SvnStatus> statuses = TestUtil.getStatuses(svnOperationFactory, workingCopyDirectory); final SvnStatus status = statuses.get(file); Assert.assertNull(status.getLock()); } finally { svnOperationFactory.dispose(); sandbox.dispose(); } }
@Test public void testRecursiveInfoGetsFileLock() throws Exception { final TestOptions options = TestOptions.getInstance(); final SvnOperationFactory svnOperationFactory = new SvnOperationFactory(); final Sandbox sandbox = Sandbox.createWithCleanup(getTestName() + ".testRecursiveInfoGetsFileLock", options); try { final SVNURL url = sandbox.createSvnRepository(); final CommitBuilder commitBuilder = new CommitBuilder(url); commitBuilder.addFile("directory/file"); commitBuilder.commit(); final SVNURL fileUrl = url.appendPath("directory/file", false); final String lockMessage = "lock message"; final SvnSetLock setLock = svnOperationFactory.createSetLock(); setLock.setSingleTarget(SvnTarget.fromURL(fileUrl)); setLock.setLockMessage(lockMessage); setLock.run(); final SVNLock[] lock = new SVNLock[1]; final SvnGetInfo getInfo = svnOperationFactory.createGetInfo(); getInfo.setDepth(SVNDepth.INFINITY); getInfo.setSingleTarget(SvnTarget.fromURL(url)); getInfo.setReceiver( new ISvnObjectReceiver<SvnInfo>() { public void receive(SvnTarget target, SvnInfo info) throws SVNException { if (target.getPathOrUrlDecodedString().endsWith("file")) { lock[0] = info.getLock(); } } }); getInfo.run(); Assert.assertNotNull(lock[0]); Assert.assertEquals("/directory/file", lock[0].getPath()); Assert.assertEquals(lockMessage, lock[0].getComment()); } finally { svnOperationFactory.dispose(); sandbox.dispose(); } }
@Test public void testCommitOfLockedFile() throws SVNException { final String fullFilePath = "Project/Prueba/Modify/prueba.txt"; final String filePath = "Prueba/Modify/prueba.txt"; final TestOptions options = TestOptions.getInstance(); final Sandbox sandbox = Sandbox.createWithCleanup(getClass().getSimpleName() + ".testModifyLocked", options); final SVNURL url = sandbox.createSvnRepository(); final CommitBuilder commitBuilder = new CommitBuilder(url); commitBuilder.addFile(fullFilePath); commitBuilder.commit(); // user paths relative to Project directory. SVNRepository repository = SVNRepositoryFactory.create(url.appendPath("Project", false)); repository.setAuthenticationManager(new BasicAuthenticationManager("user", "password")); final Map<String, Long> pathsToRevisions = new HashMap<String, Long>(); pathsToRevisions.put(filePath, 1l); repository.lock(pathsToRevisions, null, false, null); repository.closeSession(); // same user as one who owns the lock. repository.setAuthenticationManager(new BasicAuthenticationManager("user", "password")); final SVNLock lock = repository.getLock(filePath); Assert.assertNotNull(lock); Assert.assertNotNull(lock.getID()); Assert.assertEquals("user", lock.getOwner()); final Map<String, String> locks = new HashMap<String, String>(); try { tryCommit(filePath, repository, locks); Assert.fail(); } catch (SVNException e) { // no lock token. } locks.put(filePath, lock.getID()); SVNCommitInfo info = tryCommit(filePath, repository, locks); Assert.assertNotNull(info); Assert.assertEquals(2, info.getNewRevision()); }
@Test public void testMoveFileOutOfVersionControl() throws Exception { // SVNKIT-295 final TestOptions options = TestOptions.getInstance(); final SvnOperationFactory svnOperationFactory = new SvnOperationFactory(); final Sandbox sandbox = Sandbox.createWithCleanup(getTestName() + ".testMoveFileOutOfVersionControl", options); try { final SVNURL url = sandbox.createSvnRepository(); final CommitBuilder commitBuilder = new CommitBuilder(url); commitBuilder.addFile("file"); commitBuilder.commit(); final WorkingCopy workingCopy = sandbox.checkoutNewWorkingCopy(url); final File file = workingCopy.getFile("file"); final File unversionedDirectory = workingCopy.getFile("unversionedDirectory"); final File targetFile = new File(unversionedDirectory, "file"); final SVNClientManager clientManager = SVNClientManager.newInstance(); try { final SVNMoveClient moveClient = clientManager.getMoveClient(); moveClient.doMove(file, targetFile); final Map<File, SvnStatus> statuses = TestUtil.getStatuses(svnOperationFactory, workingCopy.getWorkingCopyDirectory()); Assert.assertEquals(SVNStatusType.STATUS_DELETED, statuses.get(file).getNodeStatus()); Assert.assertEquals( SVNStatusType.STATUS_UNVERSIONED, statuses.get(unversionedDirectory).getNodeStatus()); Assert.assertNull(statuses.get(targetFile)); } finally { clientManager.dispose(); } } finally { svnOperationFactory.dispose(); sandbox.dispose(); } }
@Test public void testRelocateCleansDavCache() throws Exception { final TestOptions options = TestOptions.getInstance(); Assume.assumeTrue(TestUtil.areAllApacheOptionsSpecified(options)); Assume.assumeTrue(TestUtil.isNewWorkingCopyTest()); final SvnOperationFactory svnOperationFactory = new SvnOperationFactory(); final Sandbox sandbox = Sandbox.createWithCleanup(getTestName() + ".testRelocateCleansDavCache", options); try { final SVNURL url = sandbox.createSvnRepositoryWithDavAccess(); final CommitBuilder commitBuilder = new CommitBuilder(url); commitBuilder.addFile("file"); commitBuilder.commit(); final WorkingCopy workingCopy = sandbox.checkoutNewWorkingCopy(url); final File workingCopyDirectory = workingCopy.getWorkingCopyDirectory(); final File file = new File(workingCopyDirectory, "file"); final SVNURL fsfsUrl = sandbox.getFSFSAccessUrl(url); final String wcUrlBeforeRelocate = getWcUrl(svnOperationFactory, file); Assert.assertNotNull(wcUrlBeforeRelocate); final SvnRelocate relocate = svnOperationFactory.createRelocate(); relocate.setSingleTarget(SvnTarget.fromFile(workingCopyDirectory)); relocate.setToUrl(fsfsUrl); relocate.run(); final String wcUrlAfterRelocate = getWcUrl(svnOperationFactory, file); Assert.assertNull(wcUrlAfterRelocate); } finally { svnOperationFactory.dispose(); sandbox.dispose(); } }
@Test public void testIsTransformationRequired_afterDontTransform_isFalse() { options.dontTransform(); assertThat(options.isTransformationRequired()).isFalse(); }
@Test public void testIsTransformationAllowed_byDefault_isTrue() { assertThat(options.isTransformationAllowed()).isTrue(); }
@Test public void testIsTransformationSet_byDefault_isFalse() { assertThat(options.isTransformationSet()).isFalse(); }