Search in sources :

Example 51 with Theory

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();
}
Also used : Lock(java.util.concurrent.locks.Lock) Theory(org.junit.experimental.theories.Theory)

Example 52 with Theory

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();
}
Also used : ExecutorService(java.util.concurrent.ExecutorService) Lock(java.util.concurrent.locks.Lock) Theory(org.junit.experimental.theories.Theory)

Example 53 with Theory

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();
}
Also used : Lock(java.util.concurrent.locks.Lock) Theory(org.junit.experimental.theories.Theory)

Example 54 with Theory

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();
}
Also used : Lock(java.util.concurrent.locks.Lock) Theory(org.junit.experimental.theories.Theory)

Example 55 with Theory

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));
}
Also used : MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Theory(org.junit.experimental.theories.Theory)

Aggregations

Theory (org.junit.experimental.theories.Theory)107 DataPoint (org.junit.experimental.theories.DataPoint)23 Test (org.junit.Test)22 Header (io.aeron.logbuffer.Header)15 DirectBuffer (org.agrona.DirectBuffer)15 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)13 DebugReceiveChannelEndpoint (io.aeron.driver.ext.DebugReceiveChannelEndpoint)11 DebugSendChannelEndpoint (io.aeron.driver.ext.DebugSendChannelEndpoint)11 UdpChannel (io.aeron.driver.media.UdpChannel)11 MediaDriver (io.aeron.driver.MediaDriver)8 Lock (java.util.concurrent.locks.Lock)7 InterpreterResult (org.apache.zeppelin.interpreter.InterpreterResult)7 LongAdder (java.util.concurrent.atomic.LongAdder)6 UnsafeBuffer (org.agrona.concurrent.UnsafeBuffer)6 PrimitiveCollection (org.neo4j.collection.primitive.PrimitiveCollection)6 InOrder (org.mockito.InOrder)5 InputStream (java.io.InputStream)4 BaseStream (java.util.stream.BaseStream)4 InterpreterContext (org.apache.zeppelin.interpreter.InterpreterContext)4 Metric (org.springframework.boot.actuate.metrics.Metric)4