Beispiel #1
0
  @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();
    }
  }
Beispiel #2
0
  @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();
    }
  }