Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed 'the fix' in the previous commit

  • Loading branch information...
commit 14391af1ba0e91d366827564bec5111c03ea52d7 1 parent e0141e5
@abuijze abuijze authored
View
5 core/src/main/java/org/axonframework/saga/annotation/AsyncSagaProcessingEvent.java
@@ -20,7 +20,6 @@
import org.axonframework.domain.EventMessage;
import org.axonframework.saga.AssociationValue;
import org.axonframework.saga.Saga;
-import org.axonframework.saga.SagaCreationPolicy;
/**
* Placeholder for information required by the AsyncSagaEventProcessor for processing Events.
@@ -114,9 +113,7 @@ public void reset(EventMessage event, Class<? extends AbstractAnnotatedSaga> sag
this.sagaType = sagaType;
this.handler = handler;
this.newSaga = newSagaInstance;
- if (handler.getCreationPolicy() != SagaCreationPolicy.NONE) {
- this.associationValue = handler.getAssociationValue(event);
- }
+ this.associationValue = handler.getAssociationValue(event);
}
/**
View
53 core/src/test/java/org/axonframework/saga/annotation/AsyncAnnotatedSagaManagerTest.java
@@ -16,6 +16,8 @@
package org.axonframework.saga.annotation;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
import org.axonframework.domain.EventMessage;
import org.axonframework.eventhandling.EventBus;
import org.axonframework.saga.Saga;
@@ -42,10 +44,14 @@
private EventBus eventBus;
private AsyncAnnotatedSagaManagerTest.StubInMemorySagaRepository sagaRepository;
private ExecutorService executorService;
+ private static final Logger logger = Logger.getLogger(AsyncSagaEventProcessor.class);
+ private Level oldLevel;
@SuppressWarnings("unchecked")
@Before
public void setUp() {
+ oldLevel = logger.getLevel();
+ logger.setLevel(Level.OFF);
eventBus = mock(EventBus.class);
testSubject = new AsyncAnnotatedSagaManager(eventBus, StubAsyncSaga.class);
sagaRepository = new StubInMemorySagaRepository();
@@ -56,6 +62,12 @@ public void setUp() {
testSubject.setBufferSize(64);
}
+ @After
+ public void tearDown() {
+ testSubject.stop();
+ logger.setLevel(oldLevel);
+ }
+
@Test
public void testSingleSagaLifeCycle() throws InterruptedException {
testSubject.start();
@@ -110,8 +122,30 @@ public void testNullAssociationIgnoresEvent() throws InterruptedException {
assertEquals("Incorrect live saga count", 0, sagaRepository.getLiveSagas());
}
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testExceptionsFromHandlerAreIgnored() throws InterruptedException {
+ testSubject = new AsyncAnnotatedSagaManager(eventBus, StubAsyncSaga.class);
+ testSubject.setSagaRepository(sagaRepository);
+ executorService = Executors.newCachedThreadPool();
+ testSubject.setExecutor(executorService);
+ testSubject.setProcessorCount(3);
+ testSubject.setBufferSize(64);
+
+ testSubject.start();
- @Test
+ testSubject.handle(asEventMessage(new ForceCreateNewEvent("test")));
+ testSubject.handle(asEventMessage(new GenerateErrorOnHandlingEvent("test")));
+
+ testSubject.stop();
+ executorService.shutdown();
+ assertTrue("Service refused to stop in 1 second", executorService.awaitTermination(1, TimeUnit.SECONDS));
+ assertEquals("Incorrect known saga count", 1, sagaRepository.getKnownSagas());
+ assertEquals("Incorrect live saga count", 1, sagaRepository.getLiveSagas());
+ logger.setLevel(oldLevel);
+ }
+
+ @Test
public void testMultipleDisconnectedSagaLifeCycle_WithOptionalStart() throws InterruptedException {
testSubject = new AsyncAnnotatedSagaManager(eventBus, StubAsyncSaga.class, AnotherStubAsyncSaga.class,
ThirdStubAsyncSaga.class);
@@ -147,15 +181,9 @@ public void testMultipleDisconnectedSagaLifeCycle_WithOptionalStart() throws Int
publicationList.add(asEventMessage(new OptionallyCreateNewEvent(newAssociation)));
publicationList.add(asEventMessage(new DeleteEvent(newAssociation)));
// this exception should never be thrown, as the previous event ends the saga
- publicationList.add(asEventMessage(new GenerateErrorOnHandlingEvent(firstAssociation)));
return publicationList;
}
- @After
- public void tearDown() {
- testSubject.stop();
- }
-
public static class ThirdStubAsyncSaga extends AnotherStubAsyncSaga {
}
@@ -166,37 +194,28 @@ public void tearDown() {
public static class StubAsyncSaga extends AbstractAnnotatedSaga {
- private int optionallyNewInvocations;
- private int forceNewInvocations;
- private int updateInvocations;
- private int deleteInvocations;
-
@StartSaga(forceNew = false)
@SagaEventHandler(associationProperty = "association")
public void handleOptionallyCreateNew(OptionallyCreateNewEvent event) {
-// optionallyNewInvocations++;
}
@StartSaga(forceNew = true)
@SagaEventHandler(associationProperty = "association")
public void handleOptionallyCreateNew(ForceCreateNewEvent event) {
-// optionallyNewInvocations++;
}
@SagaEventHandler(associationProperty = "association")
public void handleAddAssociation(AddAssociationEvent event) {
-// updateInvocations++;
associateWith("association", event.getNewAssociation());
}
@SagaEventHandler(associationProperty = "association")
public void handleUpdate(UpdateEvent event) {
-// updateInvocations++;
}
@SagaEventHandler(associationProperty = "association")
public void createError(GenerateErrorOnHandlingEvent event) {
- throw new RuntimeException("Handled an event that should cause an exception");
+ throw new RuntimeException("Stub");
}
@EndSaga
Please sign in to comment.
Something went wrong with that request. Please try again.