Package org.axonframework.testutils

Examples of org.axonframework.testutils.MockException


    @Test
    public void testExceptionPropagated() {
        testSubject.setSuppressExceptions(false);
        EventMessage event = new GenericEventMessage<Object>(new Object());
        doThrow(new MockException()).when(mockSaga1).handle(event);
        try {
            testSubject.handle(event);
            fail("Expected exception to be propagated");
        } catch (RuntimeException e) {
            assertEquals("Mock", e.getMessage());
View Full Code Here


    }

    @Test
    public void testExceptionSuppressed() {
        EventMessage event = new GenericEventMessage<Object>(new Object());
        doThrow(new MockException()).when(mockSaga1).handle(event);

        testSubject.handle(event);

        verify(mockSaga1).handle(event);
        verify(mockSaga2).handle(event);
View Full Code Here

    }

    @SuppressWarnings({"ThrowableResultOfMethodCallIgnored"})
    @Test
    public void testInterceptCommand_FailedExecution() throws Throwable {
        RuntimeException mockException = new MockException();
        when(mockInterceptorChain.proceed()).thenThrow(mockException);
        UnitOfWork uow = DefaultUnitOfWork.startAndGet();

        GenericCommandMessage command = new GenericCommandMessage("Command!");
        try {
View Full Code Here

        public SomeWeirdResource getSomeWeirdResource() {
            return someWeirdResource;
        }

        public void setSomeWeirdResource(SomeWeirdResource someWeirdResource) {
            throw new MockException();
        }
View Full Code Here

    }

    @Test
    public void testUnitOfWorkRolledBackOnCommitFailure_ErrorOnPrepareCommit() {
        UnitOfWorkListener mockListener = mock(UnitOfWorkListener.class);
        doThrow(new MockException()).when(mockListener).onPrepareCommit(isA(UnitOfWork.class),
                                                                        anySetOf(AggregateRoot.class),
                                                                        anyListOf(EventMessage.class));
        testSubject.registerListener(mockListener);
        testSubject.start();
        try {
View Full Code Here

    @SuppressWarnings({"unchecked"})
    @Test
    public void testUnitOfWorkRolledBackOnCommitFailure_ErrorOnCommitAggregate() {
        UnitOfWorkListener mockListener = mock(UnitOfWorkListener.class);
        doThrow(new MockException()).when(callback).save(isA(AggregateRoot.class));
        testSubject.registerListener(mockListener);
        testSubject.registerAggregate(mockAggregateRoot, mockEventBus, callback);
        testSubject.start();
        try {
            testSubject.commit();
View Full Code Here

    public void testUnitOfWorkRolledBackOnCommitFailure_ErrorOnDispatchEvents() {
        UnitOfWorkListener mockListener = mock(UnitOfWorkListener.class);
        when(mockListener.onEventRegistered(isA(UnitOfWork.class), Matchers.<EventMessage<Object>>any()))
                .thenAnswer(new ReturnParameterAnswer(1));

        doThrow(new MockException()).when(mockEventBus).publish(isA(EventMessage.class));
        testSubject.start();
        testSubject.registerListener(mockListener);
        testSubject.publishEvent(new GenericEventMessage<Object>(new Object()), mockEventBus);
        try {
            testSubject.commit();
View Full Code Here

                }
                return null;
            }
        }).when(mockEventStore).visitEvents(isA(EventVisitor.class));

        final MockException toBeThrown = new MockException();
        doThrow(toBeThrown).when(delegateCluster).publish(messages.get(5));

        try {
            testSubject.startReplay();
            fail("Expected exception");
View Full Code Here

                }
            }
        });
        t.start();
        assertTrue(t.isAlive());
        RuntimeException exception = new MockException();
        testSubject.onFailure(exception);
        t.join(THREAD_JOIN_TIMEOUT);
        assertTrue(resultFromParallelThread instanceof ExecutionException);
        assertEquals(exception, ((Exception) resultFromParallelThread).getCause());
    }
View Full Code Here

        @AggregateIdentifier
        private String identifier;

        private ExceptionThrowingAggregate() {
            throw new MockException();
        }
View Full Code Here

TOP

Related Classes of org.axonframework.testutils.MockException

Copyright © 2018 www.massapicom. 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.