Search in sources :

Example 1 with SVNWCDb

use of org.tmatesoft.svn.core.internal.wc17.db.SVNWCDb in project intellij-community by JetBrains.

the class SvnBusyOnAddTest method testRefusedAdd.

@Test
public void testRefusedAdd() throws Exception {
    SVNWCDb db = new SVNWCDb();
    final File ioFile = new File(myWorkingCopyRoot, filename);
    ioFile.getParentFile().mkdirs();
    ioFile.createNewFile();
    try {
        db.open(ISVNWCDb.SVNWCDbOpenMode.ReadWrite, new DefaultSVNOptions(), true, true);
        SVNWCContext 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;
        } finally {
            context.releaseWriteLock(myWorkingCopyRoot);
        }
        Assert.assertTrue(failed);
        SVNStatusClient readClient = new SVNStatusClient((ISVNRepositoryPool) null, new DefaultSVNOptions());
        //readClient.doStatus(ioFile, false);
        readClient.doStatus(myWorkingCopyRoot, false);
    } finally {
        ioFile.delete();
        db.close();
    }
}
Also used : DefaultSVNOptions(org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions) SVNException(org.tmatesoft.svn.core.SVNException) ISVNWCDb(org.tmatesoft.svn.core.internal.wc17.db.ISVNWCDb) SVNWCDb(org.tmatesoft.svn.core.internal.wc17.db.SVNWCDb) SVNWCContext(org.tmatesoft.svn.core.internal.wc17.SVNWCContext) SVNCancelException(org.tmatesoft.svn.core.SVNCancelException) File(java.io.File) Test(org.junit.Test)

Example 2 with SVNWCDb

use of org.tmatesoft.svn.core.internal.wc17.db.SVNWCDb in project intellij-community by JetBrains.

the class SvnBusyOnAddTest method testRefusedAddVariant.

@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();
    }
}
Also used : SVNWCContext(org.tmatesoft.svn.core.internal.wc17.SVNWCContext) DefaultSVNOptions(org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions) SVNException(org.tmatesoft.svn.core.SVNException) ISVNWCDb(org.tmatesoft.svn.core.internal.wc17.db.ISVNWCDb) SVNWCDb(org.tmatesoft.svn.core.internal.wc17.db.SVNWCDb) File(java.io.File) Test(org.junit.Test)

Aggregations

File (java.io.File)2 Test (org.junit.Test)2 SVNException (org.tmatesoft.svn.core.SVNException)2 DefaultSVNOptions (org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions)2 SVNWCContext (org.tmatesoft.svn.core.internal.wc17.SVNWCContext)2 ISVNWCDb (org.tmatesoft.svn.core.internal.wc17.db.ISVNWCDb)2 SVNWCDb (org.tmatesoft.svn.core.internal.wc17.db.SVNWCDb)2 SVNCancelException (org.tmatesoft.svn.core.SVNCancelException)1