Beispiel #1
0
 private SVNProperties getBaseDavCache(SvnOperationFactory svnOperationFactory, File file)
     throws SVNException {
   final SVNProperties baseDavCache;
   final SVNWCDb db = new SVNWCDb();
   try {
     db.open(ISVNWCDb.SVNWCDbOpenMode.ReadOnly, svnOperationFactory.getOptions(), false, false);
     baseDavCache = db.getBaseDavCache(file);
   } finally {
     db.close();
   }
   return baseDavCache;
 }
  @Test
  public void testRefusedAddVariant() throws Exception {
    SVNWCDb db = new SVNWCDb();
    final File ioFile = new File(myWorkingCopyRoot, filename + System.currentTimeMillis());
    ioFile.createNewFile();

    System.out.println(getStatus(ioFile));

    SVNWCContext context = null;
    try {
      db.open(ISVNWCDb.SVNWCDbOpenMode.ReadWrite, new DefaultSVNOptions(), true, true);
      context =
          new SVNWCContext(
              db,
              new ISVNEventHandler() {
                @Override
                public void handleEvent(SVNEvent event, double progress) throws SVNException {}

                @Override
                public void checkCancelled() throws SVNCancelException {}
              });

      File file = context.acquireWriteLock(myWorkingCopyRoot, false, true);
      boolean failed = false;
      try {
        SVNWCClient client = new SVNWCClient((ISVNRepositoryPool) null, new DefaultSVNOptions());
        client.doAdd(ioFile, true, false, false, true);
      } catch (SVNException e) {
        Assert.assertEquals(155004, e.getErrorMessage().getErrorCode().getCode());
        failed = true;
      }
      Assert.assertTrue(failed);

      System.out.println(getStatus(ioFile));
    } finally {
      if (context != null) {
        context.releaseWriteLock(myWorkingCopyRoot);
      }
      ioFile.delete();
      db.close();
    }
  }