Search in sources :

Example 16 with Theory

use of org.junit.experimental.theories.Theory in project junit4 by junit-team.

the class ParameterizedAssertionErrorTest method sameHashCodeWhenEquals.

@Theory
public void sameHashCodeWhenEquals(Throwable targetException, String methodName, Object[] params) {
    ParameterizedAssertionError one = new ParameterizedAssertionError(targetException, methodName, params);
    ParameterizedAssertionError two = new ParameterizedAssertionError(targetException, methodName, params);
    assumeThat(one, is(two));
    assertThat(one.hashCode(), is(two.hashCode()));
}
Also used : ParameterizedAssertionError(org.junit.experimental.theories.internal.ParameterizedAssertionError) Theory(org.junit.experimental.theories.Theory)

Example 17 with Theory

use of org.junit.experimental.theories.Theory in project junit4 by junit-team.

the class WhenNoParametersMatch method showFailedAssumptionsWhenNoParametersFound.

@Theory
public void showFailedAssumptionsWhenNoParametersFound(int data, Matcher<Integer> matcher) throws Exception {
    assumeThat(data, not(matcher));
    AssumptionsFail.DATA = data;
    AssumptionsFail.MATCHER = matcher;
    String result = testResult(AssumptionsFail.class).toString();
    assertThat(result, containsString(matcher.toString()));
    assertThat(result, containsString("" + data));
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Theory(org.junit.experimental.theories.Theory)

Example 18 with Theory

use of org.junit.experimental.theories.Theory in project junit4 by junit-team.

the class PrintableResultTest method includeMultipleFailures.

@Theory
public void includeMultipleFailures(String secondExceptionName) {
    PrintableResult backtrace = new PrintableResult(Arrays.asList(new Failure(Description.createSuiteDescription("firstName"), new RuntimeException("firstException")), new Failure(Description.createSuiteDescription("secondName"), new RuntimeException(secondExceptionName))));
    assertThat(backtrace.toString(), containsString(secondExceptionName));
}
Also used : PrintableResult(org.junit.experimental.results.PrintableResult) Failure(org.junit.runner.notification.Failure) Theory(org.junit.experimental.theories.Theory)

Example 19 with Theory

use of org.junit.experimental.theories.Theory in project junit4 by junit-team.

the class PrintableResultTest method backTraceHasGoodToString.

@Theory(nullsAccepted = false)
public void backTraceHasGoodToString(String descriptionName, final String stackTraceClassName) {
    Failure failure = new Failure(Description.createSuiteDescription(descriptionName), new Throwable() {

        private static final long serialVersionUID = 1L;

        @Override
        public StackTraceElement[] getStackTrace() {
            return new StackTraceElement[] { new StackTraceElement(stackTraceClassName, "methodName", "fileName", 1) };
        }
    });
    assertThat(new PrintableResult(asList(failure)).toString(), allOf(containsString(descriptionName), containsString(stackTraceClassName)));
}
Also used : PrintableResult(org.junit.experimental.results.PrintableResult) Failure(org.junit.runner.notification.Failure) Theory(org.junit.experimental.theories.Theory)

Example 20 with Theory

use of org.junit.experimental.theories.Theory in project neo4j by neo4j.

the class PagedByteChannelsTest method mustCloseCursorOnClose.

@Theory
public void mustCloseCursorOnClose(ThrowingFunction<PagedFile, ? extends Channel, IOException> channelConstructor) throws Exception {
    AtomicInteger closeCounter = new AtomicInteger();
    PagedFile pf = new StubPagedFile(8192) {

        @Override
        public PageCursor io(long pageId, int pf_flags) throws IOException {
            return new DelegatingPageCursor(super.io(pageId, pf_flags)) {

                @Override
                public void close() {
                    super.close();
                    closeCounter.getAndIncrement();
                }
            };
        }
    };
    channelConstructor.apply(pf).close();
    assertThat(closeCounter.get(), is(1));
}
Also used : PagedFile(org.neo4j.io.pagecache.PagedFile) StubPagedFile(org.neo4j.io.pagecache.StubPagedFile) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) StubPagedFile(org.neo4j.io.pagecache.StubPagedFile) Theory(org.junit.experimental.theories.Theory)

Aggregations

Theory (org.junit.experimental.theories.Theory)97 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 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 BufferClaim (io.aeron.logbuffer.BufferClaim)3