use of org.junit.experimental.theories.Theory in project grakn by graknlabs.
the class LockTest method whenTwoLocksCreated_TheyCanBothBeAcquired.
@Theory
public void whenTwoLocksCreated_TheyCanBothBeAcquired(Locks locks) {
Lock lock1 = getLock(locks, LOCK_NAME + UUID.randomUUID());
Lock lock2 = getLock(locks, LOCK_NAME + UUID.randomUUID());
assertThat(lock1.tryLock(), is(true));
assertThat(lock2.tryLock(), is(true));
lock1.unlock();
lock2.unlock();
}
use of org.junit.experimental.theories.Theory in project grakn by graknlabs.
the class LockTest method whenMultipleOfSameLock_OnlyOneAtATimeCanBeAcquired.
@Theory
public void whenMultipleOfSameLock_OnlyOneAtATimeCanBeAcquired(Locks locks) throws ExecutionException, InterruptedException {
Lock lock1 = getLock(locks, LOCK_NAME);
Lock lock2 = copy(lock1);
Callable<Boolean> r = lock2::tryLock;
ExecutorService execSvc = Executors.newSingleThreadExecutor();
lock1.lock();
Boolean acquired = execSvc.submit(r).get();
assertThat(acquired, is(false));
lock1.unlock();
assertThat(lock2.tryLock(), is(true));
lock2.unlock();
}
use of org.junit.experimental.theories.Theory in project grakn by graknlabs.
the class LockTest method whenGettingLockWithManyIllegalCharactersInPath_LockIsAcquired.
@Theory
public void whenGettingLockWithManyIllegalCharactersInPath_LockIsAcquired(Locks locks) {
String lockName = "/ATTRIBUTE-url-http://dbpedia.org/resource/Jorhat_College";
Lock lock = getLock(locks, lockName);
assertThat(lock.tryLock(), is(true));
lock.unlock();
}
use of org.junit.experimental.theories.Theory in project grakn by graknlabs.
the class LockTest method whenGettingLockWithIllegalCharactersInPath_LockIsAcquired.
@Theory
public void whenGettingLockWithIllegalCharactersInPath_LockIsAcquired(Locks locks) {
String lockName = "/\ud800";
Lock lock = getLock(locks, lockName);
assertThat(lock.tryLock(), is(true));
lock.unlock();
}
use of org.junit.experimental.theories.Theory in project gocd by gocd.
the class EchoAttributeServletTest method shouldEchoAttributeInBody.
@Theory
public void shouldEchoAttributeInBody(Req dataPt) throws UnsupportedEncodingException {
MockHttpServletRequest req = new MockHttpServletRequest();
req.setAttribute(EchoAttributeServlet.ECHO_BODY_ATTRIBUTE, "some-random-echo-body");
MockHttpServletResponse res = new MockHttpServletResponse();
res.setContentType("foo/bar");
dataPt.call(servlet, req, res);
assertThat(res.getContentAsString(), is("some-random-echo-body"));
assertThat(res.getContentType(), is("foo/bar"));
assertThat(res.getStatus(), is(200));
}
Aggregations