Examples of MockUtil


Examples of org.apache.niolex.commons.test.MockUtil

      }
    }

    @Test
    public void testRandLong() throws Exception {
        new MockUtil() {};
        Assert.assertNotEquals(MockUtil.randLong(), MockUtil.randLong());
    }
View Full Code Here

Examples of org.mockito.internal.util.MockUtil

    public ThrowsException(Throwable throwable) {
        this.throwable = throwable;
    }

    public Object answer(InvocationOnMock invocation) throws Throwable {
        if (new MockUtil().isMock(throwable)) {
            throw throwable;
        }
        Throwable t = throwable.fillInStackTrace();
        filter.filter(t);
        throw t;
View Full Code Here

Examples of org.mockito.internal.util.MockUtil

     * @see org.mockito.stubbing.Answer#answer(org.mockito.invocation.InvocationOnMock)
     */
    public Object answer(InvocationOnMock invocation) {
        if (Invocation.isToString(invocation)) {
            Object mock = invocation.getMock();
            MockName name = new MockUtil().getMockName(mock);
            if (name.isSurrogate()) {
                return "Mock for " + ClassNameFinder.classNameForMock(mock) + ", hashCode: " + mock.hashCode();
            } else {
                return name.toString();
            }
View Full Code Here

Examples of org.mockito.internal.util.MockUtil

     * @return invocations
     */
    public List<Invocation> getAllInvocations(List<? extends Object> mocks) {
        Set<Invocation> invocationsInOrder = new TreeSet<Invocation>(new SequenceNumberComparator());
        for (Object mock : mocks) {
            List<Invocation> fromSingleMock = new MockUtil().getMockHandler(mock).getRegisteredInvocations();
            invocationsInOrder.addAll(fromSingleMock);
        }
       
        return new LinkedList<Invocation>(invocationsInOrder);
    }
View Full Code Here

Examples of org.mockito.internal.util.MockUtil

            return invocation;
        }
    }

    private String qualifiedMethodName() {
        return new MockUtil().getMockName(mock) + "." + method.getName();
    }
View Full Code Here

Examples of org.mockito.internal.util.MockUtil

        return allInvocations.get(allInvocations.size()-1);
    }

    public Object[] ignoreStubs(Object... mocks) {
        for (Object m : mocks) {
            InvocationContainer invocationContainer = new MockUtil().getMockHandler(m).getInvocationContainer();
            List<Invocation> ins = invocationContainer.getInvocations();
            for (Invocation in : ins) {
                if (in.stubInfo() != null) {
                    in.ignoreForVerification();
                }
View Full Code Here

Examples of org.mockito.internal.util.MockUtil

                    instance = report.fieldInstance();
                } catch (MockitoException e) {
                    new Reporter().cannotInitializeForSpyAnnotation(field.getName(), e);
                }
                try {
                    if (new MockUtil().isMock(instance)) {
                        // instance has been spied earlier
                        // for example happens when MockitoAnnotations.initMocks is called two times.
                        Mockito.reset(instance);
                    } else {
                        field.setAccessible(true);
View Full Code Here

Examples of org.mockito.internal.util.MockUtil

    final List<Answer> answers = new LinkedList<Answer>();
    private final Reporter reporter = new Reporter();

    public <T> T when(T mock) {
        MockUtil mockUtil = new MockUtil();
       
        if (mock == null) {
            reporter.nullPassedToWhenMethod();
        } else {
            if (!mockUtil.isMock(mock)) {
                reporter.notAMockPassedToWhenMethod();
            }
        }
       
        mockUtil.getMockHandler(mock).setAnswersForStubbing(answers);
        return mock;
    }
View Full Code Here

Examples of org.mockito.internal.util.MockUtil

    public ThrowsException(Throwable throwable) {
        this.throwable = throwable;
    }

    public Object answer(InvocationOnMock invocation) throws Throwable {
        if (new MockUtil().isMock(throwable)) {
            throw throwable;
        }
        Throwable t = throwable.fillInStackTrace();
        filter.filter(t);
        throw t;
View Full Code Here

Examples of org.mockito.internal.util.MockUtil

    private Object getMock(InvocationOnMock invocation) {
        Class<?> clz = invocation.getMethod().getReturnType();
        final Object mock = Mockito.mock(clz, this);

        MockHandlerInterface<Object> handler = new MockUtil().getMockHandler(invocation.getMock());
        InvocationContainerImpl container = (InvocationContainerImpl)handler.getInvocationContainer();
        container.addAnswer(new Answer<Object>() {
            public Object answer(InvocationOnMock invocation) throws Throwable {
                return mock;
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.