Package org.mule.api

Examples of org.mule.api.MuleContext


    @Test
    public void test() throws Exception
    {
        MuleContextManager muleContextManager = new MuleContextManager(new MockingConfiguration(false, new ArrayList<String>(), false, new Properties()));
        MuleContext muleContext = muleContextManager.startMule("munit-config.xml");
        muleContextManager.killMule(muleContext);


        assertTrue(TestMunitPlugin.started);
        assertTrue(TestMunitPlugin.disposed);
View Full Code Here


        this.configuration = configuration;
    }

    public MuleContext startMule(String resources) throws Exception
    {
        MuleContext context = createMule(resources);
        return startMule(context);
    }
View Full Code Here

    public MuleContext createMule(String resources) throws Exception
    {
        defineLogOutput(resources);

        MuleContext context;
        org.mule.api.context.MuleContextFactory muleContextFactory = new DefaultMuleContextFactory();

        List<ConfigurationBuilder> builders = new ArrayList<ConfigurationBuilder>();
        builders.add(new SimpleConfigurationBuilder(properties()));
        if (ClassUtils.isClassOnPath(CLASSNAME_ANNOTATIONS_CONFIG_BUILDER,
                                     getClass()))
        {
            builders.add((ConfigurationBuilder) ClassUtils.instanciateClass(
                    CLASSNAME_ANNOTATIONS_CONFIG_BUILDER, ClassUtils.NO_ARGS,
                    getClass()));
        }
        builders.add(getBuilder(resources));
        MuleContextBuilder contextBuilder = new DefaultMuleContextBuilder();
        configureMuleContext(contextBuilder);
        context = muleContextFactory
                .createMuleContext(builders, contextBuilder);
        ((DefaultMuleConfiguration) context.getConfiguration())
                .setShutdownTimeout(0);

        context.getNotificationManager().setNotificationDynamic(true);
        context.getNotificationManager().addInterfaceToType(MessageProcessorNotificationListener.class, MessageProcessorNotification.class);
        plugins = new MunitPluginFactory().loadPlugins(context);
        initialisePlugins();

        return context;
    }
View Full Code Here

        final MessageExchangePattern messageExchangePattern = MessageExchangePattern.REQUEST_RESPONSE;
        final int responseTimeout = 5;
        final String initialState = "state1";
        final String endpointEncoding = "enconding1";
        final String endpointBuilderName = "builderName1";
        final MuleContext muleContext = mock(MuleContext.class);
        final RetryPolicyTemplate retryPolicyTemplate = mock(RetryPolicyTemplate.class);
        final EndpointMessageProcessorChainFactory messageProcessorsFactory = mock(EndpointMessageProcessorChainFactory.class);
        final List<MessageProcessor> messageProcessors = new ArrayList<MessageProcessor>();
        final List<MessageProcessor> responseMessageProcessors = new ArrayList<MessageProcessor>();
        final String mimeType = "text/plain";
View Full Code Here

    @Override
    protected MuleContext createMuleContext() throws Exception
    {
        // Use a graceful shutdown but not the full 5s default
        MuleContext context = super.createMuleContext();
        ((DefaultMuleConfiguration) context.getConfiguration()).setShutdownTimeout(WAIT_TIME_MILLIS);
        return context;
    }
View Full Code Here

            return muleContext.getQueueManager().getQueueSession().getQueue(name).size();
        }
        else
        {
            // Don;t fool around trying to use objects that weren't started fully, just go to the disk
            MuleContext localMuleContext = new DefaultMuleContextBuilder().buildMuleContext();
            String workingDirectory = localMuleContext.getConfiguration().getWorkingDirectory();
            String path = workingDirectory + File.separator + QueuePersistenceObjectStore.DEFAULT_QUEUE_STORE + File.separator + name;

            File[] filesInQueue = new File(path).listFiles();
            return filesInQueue.length;
        }
View Full Code Here

    public void testCreatingTheObjectStoreThrowsMuleRuntimeException()
    {
        MuleRuntimeException muleRuntimeException = new MuleRuntimeException(CoreMessages.createStaticMessage("boom"));

        MuleContext mockContext = mock(MuleContext.class);
        when(mockContext.getConfiguration()).thenThrow(muleRuntimeException);

        QueuePersistenceObjectStore<Serializable> store =
            new QueuePersistenceObjectStore<Serializable>(mockContext);

        try
View Full Code Here

    /**
     * Test that an existing appContext can be added to Mule's internal Registries
     */
    public void testSpringConfigurationBuilder() throws Exception
    {
        MuleContext context = new DefaultMuleContextFactory().createMuleContext();
       
        ApplicationContext appContext = new ClassPathXmlApplicationContext("application-context.xml");
        ConfigurationBuilder builder = new SpringConfigurationBuilder(appContext);
        builder.configure(context);

        context.start();
       
        Object orange = context.getRegistry().lookupObject("orange");
        assertNotNull(orange);
        assertTrue(orange instanceof Orange);
        assertEquals("Pirulo", ((Orange) orange).getBrand());
    }
View Full Code Here

    /**
     * Test that the same bean from the 2nd appContext will have precedence over the 1st appContext
     */
    public void testSpringConfigurationBuilderPrecedence() throws Exception
    {
        MuleContext context = new DefaultMuleContextFactory().createMuleContext();
       
        ApplicationContext appContext = new ClassPathXmlApplicationContext("application-context.xml");
        ConfigurationBuilder builder = new SpringConfigurationBuilder(appContext);
        builder.configure(context);

        appContext = new ClassPathXmlApplicationContext("application-context-2.xml");
        builder = new SpringConfigurationBuilder(appContext);
        builder.configure(context);

        context.start();
       
        Object orange = context.getRegistry().lookupObject("orange");
        assertNotNull(orange);
        assertTrue(orange instanceof Orange);
        assertEquals("Tropicana", ((Orange) orange).getBrand());
    }
View Full Code Here

        assertEquals("Tropicana", ((Orange) orange).getBrand());
    }

    public void testSpringConfigurationBuilderBackwardsPrecedence() throws Exception
    {
        MuleContext context = new DefaultMuleContextFactory().createMuleContext();
       
        ApplicationContext appContext = new ClassPathXmlApplicationContext("application-context-2.xml");
        ConfigurationBuilder builder = new SpringConfigurationBuilder(appContext);
        builder.configure(context);

        appContext = new ClassPathXmlApplicationContext("application-context.xml");
        builder = new SpringConfigurationBuilder(appContext);
        builder.configure(context);

        context.start();
       
        Object orange = context.getRegistry().lookupObject("orange");
        assertNotNull(orange);
        assertTrue(orange instanceof Orange);
        assertEquals("Pirulo", ((Orange) orange).getBrand());
    }
View Full Code Here

TOP

Related Classes of org.mule.api.MuleContext

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.