Package org.mule.util.concurrent

Examples of org.mule.util.concurrent.Latch


        assertTrue(resString.indexOf("<test xmlns=\"http://foo\"") != -1);
    }

    public void testServerClientProxyWithWsdl2() throws Exception
    {
        final Latch latch = new Latch();
        ((FunctionalTestComponent) getComponent("serverClientProxyWithWsdl2")).setEventCallback(new EventCallback()
        {

            public void eventReceived(MuleEventContext context, Object component) throws Exception
            {
                latch.countDown();
            }
        });

        String msg = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
                     + "<soap:Body> <test xmlns=\"http://foo\"></test>" + "</soap:Body>" + "</soap:Envelope>";

        MuleClient client = new MuleClient(muleContext);
        MuleMessage result = client.send("http://localhost:" + getPorts().get(0) + "/services/proxyWithWsdl2", msg, null);
        String resString = result.getPayloadAsString();
        assertTrue(latch.await(1000, TimeUnit.MILLISECONDS));
        assertTrue(resString.indexOf("<test xmlns=\"http://foo\"") != -1);
    }
View Full Code Here


       
        // Set SystemExceptionStrategy to redeliver messages (this can only be configured programatically for now)
        ((DefaultSystemExceptionStrategy) muleContext.getExceptionListener()).setRollbackTxFilter(new WildcardFilter("*"));
       
        // Tell us when a MessageRedeliverdException has been handled
        messageRedelivered = new Latch();
        muleContext.registerListener(new ExceptionNotificationListener<ExceptionNotification>()
        {
            public void onNotification(ExceptionNotification notification)
            {
                if (notification.getException() instanceof MessageRedeliveredException)
View Full Code Here

    private void startMuleContext() throws MuleException, InterruptedException
    {
        final AtomicReference<Latch> contextStartedLatch = new AtomicReference<Latch>();

        contextStartedLatch.set(new Latch());
        muleContext.registerListener(new MuleContextNotificationListener<MuleContextNotification>()
        {
            public void onNotification(MuleContextNotification notification)
            {
                if (notification.getAction() == MuleContextNotification.CONTEXT_STARTED)
View Full Code Here

            // latch ref needs to be final for listener use, wrap in atomic ref
            final AtomicReference<Latch> contextStartedLatch = new AtomicReference<Latch>();
            if (isStartContext() && null != muleContext && muleContext.isStarted() == false)
            {
                contextStartedLatch.set(new Latch());
                muleContext.registerListener(new MuleContextNotificationListener<MuleContextNotification>()
                {
                    public void onNotification(MuleContextNotification notification)
                    {
                        if (notification.getAction() == MuleContextNotification.CONTEXT_STARTED)
View Full Code Here

        } finally {
            if (tx == null) {
                mgr.commit();
            }
            if(eventContext.isSynchronous()) {
                lock = new Latch();
                if(eventContext.getTimeout() == UMOEvent.TIMEOUT_WAIT_FOREVER) {
                    lock.await();
                } else {
                    lock.await(eventContext.getTimeout(), TimeUnit.MILLISECONDS);
                    if(result == null) {
View Full Code Here

    }

    @Test
    public void testReceiveSync() throws Exception
    {
        Latch receiveLatch = new Latch();
        setupTestServiceComponent(receiveLatch);

        sendMucMessageFromNewThread();
        assertTrue(receiveLatch.await(60, TimeUnit.SECONDS));
    }
View Full Code Here

        this.workManager = workManager;
        this.delegate = delegate;
        this.startLatch = startLatch;
        if (this.startLatch == null)
        {
            this.startLatch = new Latch();
            this.startLatch.countDown();
        }
    }
View Full Code Here

    @Override
    protected void doSetUp() throws Exception
    {
        bean = new DummyBean();
        initLatch = new Latch();
        startLatch = new Latch();
        stopLatch = new Latch();
        disposeLatch = new Latch();
    }
View Full Code Here

    @Test
    public void whenFailureCallSystemExceptionHandler() throws Exception
    {
        final HttpRequestDispatcher httpRequestDispatcher = new HttpRequestDispatcher(mockHttpConnector, mockRetryTemplate, mockServerSocket, mockWorkManager);
        final Latch acceptCalledLath = new Latch();
        sustituteLifecycleManager();
        when(mockConnectorLifecycleManager.getState().isStarted()).thenReturn(true);
        when(mockRetryTemplate.execute(any(RetryCallback.class), any(WorkManager.class))).thenAnswer(new Answer<Object>()
        {
            @Override
            public Object answer(InvocationOnMock invocationOnMock) throws Throwable
            {
                acceptCalledLath.release();
                throw new Exception();
            }
        });
        when(mockHttpConnector.getMuleContext().getExceptionListener()).thenReturn(mockExceptionListener);
        Thread dispatcherThread = createDispatcherThread(httpRequestDispatcher);
        try
        {
            dispatcherThread.start();
            if (!acceptCalledLath.await(WAIT_TIME, TimeUnit.MILLISECONDS))
            {
                fail("retry template should be executed");
            }

            Prober prober = new PollingProber(100, 1);
View Full Code Here

    @Test
    public void whenSocketAcceptedExecuteWork() throws Exception
    {
        final HttpRequestDispatcher httpRequestDispatcher = new HttpRequestDispatcher(mockHttpConnector, mockRetryTemplate, mockServerSocket, mockWorkManager);
        httpRequestDispatcher.requestHandOffExecutor = mockExecutor;
        final Latch acceptCalledLath = new Latch();
        sustituteLifecycleManager();
        when(mockConnectorLifecycleManager.getState().isStarted()).thenReturn(true);
        when(mockRetryTemplate.execute(any(RetryCallback.class), any(WorkManager.class))).thenAnswer(new Answer<RetryContext>()
        {
            @Override
            public RetryContext answer(InvocationOnMock invocationOnMock) throws Throwable
            {
                ((RetryCallback) invocationOnMock.getArguments()[0]).doWork(mockRetryContext);
                return null;
            }
        });
        Mockito.doAnswer(new Answer<Object>()
        {
            @Override
            public Object answer(InvocationOnMock invocationOnMock) throws Throwable
            {
                acceptCalledLath.release();
                return null;
            }
        }).when(mockExecutor).execute(any(HttpRequestDispatcherWork.class));
        Thread dispatcherThread = createDispatcherThread(httpRequestDispatcher);
        dispatcherThread.start();
        try
        {
            if (!acceptCalledLath.await(500, TimeUnit.MILLISECONDS))
            {
                fail("Work should have been scheduled");
            }
        }
        finally
View Full Code Here

TOP

Related Classes of org.mule.util.concurrent.Latch

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.