Package org.axonframework.eventhandling

Examples of org.axonframework.eventhandling.Cluster


        // to choose the name of the created thread.
        ExecutorService executor = Executors.newSingleThreadExecutor();

        // we initialize the asynchronous cluster. We don't need transactions (NoTransactionManager) and allow all
        // events to be handled concurrently (FullConcurrencyPolicy).
        Cluster asyncCluster = new AsynchronousCluster("async", executor, new FullConcurrencyPolicy());
        // and we initialize a simple cluster
        Cluster standardCluster = new SimpleCluster("simple");

        // to make sure Listeners are assigned to their respective cluster, we create a number of selectors that we
        // combine into a single ClusterSelector using a CompositeClusterSelector
        ClusterSelector clusterSelector = new CompositeClusterSelector(Arrays.<ClusterSelector>asList(
                // this one will accept
View Full Code Here


        testSubject = new DefaultClusterSelector();
    }

    @Test
    public void testSameInstanceIsReturned() {
        Cluster cluster1 = testSubject.selectCluster(mock(EventListener.class));
        Cluster cluster2 = testSubject.selectCluster(mock(EventListener.class));
        Cluster cluster3 = testSubject.selectCluster(mock(EventListener.class));

        assertSame(cluster1, cluster2);
        assertSame(cluster2, cluster3);
    }
View Full Code Here

        assertSame(cluster2, cluster3);
    }

    @Test
    public void testProvidedInstanceIsReturned() {
        Cluster mock = mock(Cluster.class);
        testSubject = new DefaultClusterSelector(mock);
        assertSame(mock, testSubject.selectCluster(mock(EventListener.class)));
    }
View Full Code Here

public class ClusterMessageListenerTest {

    @Test
    public void testMessageListenerInvokesAllClusters() throws Exception {
        Serializer serializer = new XStreamSerializer();
        Cluster cluster = mock(Cluster.class);
        ClusterMessageListener testSubject = new ClusterMessageListener(cluster,
                                                                        new DefaultAMQPMessageConverter(serializer));

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        EventMessageWriter outputStream = new EventMessageWriter(new DataOutputStream(baos), serializer);
View Full Code Here

    }

    @Test
    public void testMessageListenerIgnoredOnDeserializationFailure() throws Exception {
        Serializer serializer = new XStreamSerializer();
        Cluster cluster = mock(Cluster.class);
        ClusterMessageListener testSubject = new ClusterMessageListener(cluster,
                                                                        new DefaultAMQPMessageConverter(serializer));

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        EventMessageWriter outputStream = new EventMessageWriter(new DataOutputStream(baos), serializer);
View Full Code Here

*/
public class ClassNamePatternClusterSelectorTest {

    @Test
    public void testMatchesPattern() throws Exception {
        Cluster cluster = mock(Cluster.class);
        Pattern pattern = Pattern.compile("org\\.axonframework.*\\$1");
        ClassNamePatternClusterSelector testSubject = new ClassNamePatternClusterSelector(pattern, cluster);

        Cluster actual = testSubject.selectCluster(new EventListener() {
            @Override
            public void handle(EventMessage event) {
            }
        });
        assertSame(cluster, actual);
View Full Code Here

        cluster = mock(Cluster.class);
    }

    @Test
    public void testSelectorDelegatesInOrder() throws Exception {
        Cluster cluster = mock(Cluster.class);

        when(selector2.selectCluster(isA(EventListener.class))).thenReturn(cluster);
        testSubject = new CompositeClusterSelector(Arrays.asList(selector1, selector2, selector3));

        Cluster actual = testSubject.selectCluster(mockListener);
        assertSame(cluster, actual);
        verify(selector1).selectCluster(mockListener);
        verify(selector2).selectCluster(mockListener);
        verify(selector3, never()).selectCluster(any(EventListener.class));
    }
View Full Code Here

    @Test
    public void testSelectorDelegatesInOrder_NoClusterFound() throws Exception {
        testSubject = new CompositeClusterSelector(Arrays.asList(selector1, selector2, selector3));

        Cluster actual = testSubject.selectCluster(mockListener);
        assertNull(actual);
        verify(selector1).selectCluster(mockListener);
        verify(selector2).selectCluster(mockListener);
        verify(selector3).selectCluster(mockListener);
    }
View Full Code Here

    @Autowired
    private ApplicationContext applicationContext;

    @Test
    public void testBeansAreProperlyConfigured() {
        Cluster cluster1 = applicationContext.getBean("replayingCluster", Cluster.class);
        Cluster cluster2 = applicationContext.getBean("replayingClusterWithDefaults", Cluster.class);

        assertNotNull(cluster1);
        assertNotNull(cluster2);
        assertTrue(cluster1 instanceof ReplayingCluster);
        assertTrue(cluster2 instanceof ReplayingCluster);
View Full Code Here

    @Autowired
    private DefaultListableBeanFactory beanFactory;

    @Test
    public void testBeansAreProperlyConfigured() {
        Cluster cluster1 = applicationContext.getBean("firstCluster", Cluster.class);
        Cluster cluster2 = applicationContext.getBean("defaultCluster", Cluster.class);
        Cluster cluster3 = applicationContext.getBean("replayingCluster", Cluster.class);
        Cluster cluster4 = applicationContext.getBean("defaultOrderedCluster", Cluster.class);
        Cluster cluster5 = applicationContext.getBean("customOrderedCluster", Cluster.class);
        ClusterSelector selector1 = applicationContext.getBean("firstCluster$selector", ClusterSelector.class);
        ClusterSelector selector2 = applicationContext.getBean("defaultCluster$defaultSelector", ClusterSelector.class);

        assertNotNull(cluster1);
        assertNotNull(cluster2);
View Full Code Here

TOP

Related Classes of org.axonframework.eventhandling.Cluster

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.