use of org.tmatesoft.svn.core.SVNException in project intellij-community by JetBrains.
the class SvnAuthenticationTest method testWhenNotSaved.
public void testWhenNotSaved() throws Exception {
final TestListener listener = new TestListener(mySynchObject);
myAuthenticationManager.addListener(listener);
final SavedOnceListener savedOnceListener = new SavedOnceListener();
myAuthenticationManager.addListener(savedOnceListener);
myInteractiveProvider.setSaveData(false);
final SVNURL url = SVNURL.parseURIEncoded("http://some.host.com/repo");
final SVNException[] exception = new SVNException[1];
final Boolean[] result = new Boolean[1];
synchronousBackground(() -> {
try {
listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
commonScheme(url, false, null);
//long start = System.currentTimeMillis();
//waitListenerStep(start, listener, 2);
Assert.assertEquals(2, listener.getCnt());
savedOnceListener.assertNotSaved(url, ISVNAuthenticationManager.PASSWORD);
// cause is not cleared though
savedOnceListener.reset();
SvnConfiguration.RUNTIME_AUTH_CACHE.clear();
listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
commonScheme(url, false, null);
Assert.assertEquals(4, listener.getCnt());
//start = System.currentTimeMillis();
//waitListenerStep(start, listener, 4);
} catch (SVNException e) {
exception[0] = e;
}
result[0] = true;
});
Assert.assertTrue(result[0]);
myTestInteraction.assertNothing();
Assert.assertEquals(4, listener.getCnt());
listener.assertForAwt();
savedOnceListener.assertForAwt();
savedOnceListener.assertNotSaved(url, ISVNAuthenticationManager.PASSWORD);
if (exception[0] != null) {
throw exception[0];
}
}
use of org.tmatesoft.svn.core.SVNException in project intellij-community by JetBrains.
the class SvnAuthenticationTest method testWhenAuthCredsNoInConfig.
public void testWhenAuthCredsNoInConfig() throws Exception {
final TestListener listener = new TestListener(mySynchObject);
myAuthenticationManager.addListener(listener);
final SavedOnceListener savedOnceListener = new SavedOnceListener();
myAuthenticationManager.addListener(savedOnceListener);
final File config = new File(myConfiguration.getConfigurationDirectory(), "config");
final String contents = FileUtil.loadFile(config);
final String auth = "[auth]";
final int idx = contents.indexOf(auth);
Assert.assertTrue(idx != -1);
final String newContents = contents.substring(0, idx + auth.length()) + "\nstore-auth-creds=no\n" + contents.substring(idx + auth.length());
final File oldConfig = new File(myConfiguration.getConfigurationDirectory(), "config_old");
FileUtil.rename(config, oldConfig);
try {
config.createNewFile();
FileUtil.appendToFile(config, newContents);
final SVNURL url = SVNURL.parseURIEncoded("http://some.host.com/repo");
final SVNException[] exception = new SVNException[1];
final Boolean[] result = new Boolean[1];
synchronousBackground(() -> {
try {
listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
commonScheme(url, false, null);
Assert.assertEquals(2, listener.getCnt());
Assert.assertEquals(1, myTestInteraction.getNumAuthWarn());
myTestInteraction.reset();
savedOnceListener.assertForAwt();
savedOnceListener.reset();
SvnConfiguration.RUNTIME_AUTH_CACHE.clear();
listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
commonScheme(url, false, null);
Assert.assertEquals(4, listener.getCnt());
Assert.assertEquals(1, myTestInteraction.getNumAuthWarn());
} catch (SVNException e) {
exception[0] = e;
}
result[0] = true;
});
Assert.assertTrue(result[0]);
Assert.assertEquals(1, myTestInteraction.getNumAuthWarn());
Assert.assertEquals(4, listener.getCnt());
listener.assertForAwt();
savedOnceListener.assertForAwt();
savedOnceListener.assertNotSaved(url, ISVNAuthenticationManager.PASSWORD);
if (exception[0] != null) {
throw exception[0];
}
} finally {
FileUtil.delete(config);
FileUtil.rename(oldConfig, config);
}
}
use of org.tmatesoft.svn.core.SVNException 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();
}
}
use of org.tmatesoft.svn.core.SVNException 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();
}
}
use of org.tmatesoft.svn.core.SVNException in project intellij-community by JetBrains.
the class SvnCachingRepositoryPoolTest method testCancel.
@Test
public void testCancel() throws Exception {
final SvnIdeaRepositoryPoolManager poolManager = new SvnIdeaRepositoryPoolManager(true, null, null, 1, 1);
final SVNURL url = SVNURL.parseURIEncoded("http://a.b.c");
poolManager.setCreator(svnurl -> new MockSvnRepository(svnurl, ISVNSession.DEFAULT));
final MockSvnRepository repository1 = (MockSvnRepository) poolManager.createRepository(url, true);
final Semaphore semaphore = new Semaphore();
semaphore.down();
poolManager.setCreator(svnurl -> {
semaphore.waitFor();
return new MockSvnRepository(svnurl, ISVNSession.DEFAULT);
});
final SVNException[] exc = new SVNException[1];
final Runnable target = () -> {
try {
final MockSvnRepository repository = (MockSvnRepository) poolManager.createRepository(url, true);
repository.fireConnectionClosed();
} catch (SVNException e) {
e.printStackTrace();
exc[0] = e;
}
};
final EmptyProgressIndicator indicator = new EmptyProgressIndicator();
Thread thread = new Thread(() -> ((ProgressManagerImpl) ProgressManager.getInstance()).executeProcessUnderProgress(target, indicator), "svn cache repo");
thread.start();
TimeoutUtil.sleep(10);
Assert.assertTrue(thread.isAlive());
indicator.cancel();
final Object obj = new Object();
while (!timeout(System.currentTimeMillis()) && thread.isAlive()) {
synchronized (obj) {
try {
obj.wait(300);
} catch (InterruptedException e) {
//
}
}
}
Assert.assertTrue(!thread.isAlive());
thread.join();
Assert.assertNotNull(exc[0]);
//repository1.fireConnectionClosed(); // also test that used are also closed.. in dispose
poolManager.dispose();
checkAfterDispose(poolManager);
}
Aggregations