View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule;
8   
9   import org.mule.api.MuleContext;
10  import org.mule.api.context.MuleContextFactory;
11  import org.mule.api.endpoint.EndpointBuilder;
12  import org.mule.config.spring.SpringXmlConfigurationBuilder;
13  import org.mule.context.DefaultMuleContextFactory;
14  import org.mule.tck.junit4.AbstractMuleTestCase;
15  
16  import org.junit.Test;
17  
18  import static org.junit.Assert.assertEquals;
19  import static org.junit.Assert.assertFalse;
20  import static org.junit.Assert.assertNotNull;
21  import static org.junit.Assert.assertTrue;
22  
23  public class EmbeddedMuleTestCase extends AbstractMuleTestCase
24  {
25      @Test
26      public void testStartup() throws Exception
27      {
28          SpringXmlConfigurationBuilder builder = new SpringXmlConfigurationBuilder(
29              "org/mule/test/spring/mule-root-test.xml");
30          MuleContextFactory muleContextFactory = new DefaultMuleContextFactory();
31          MuleContext context = muleContextFactory.createMuleContext(builder);
32          // MuleContext must be started explicitly after MULE-1988
33          assertFalse(context.isStarted());
34          context.start();
35          assertTrue(context.isStarted());
36  
37          final EndpointBuilder endpoint = context.getRegistry().lookupEndpointBuilder("endpoint");
38          assertNotNull(endpoint);
39          assertEquals("test://value", endpoint.buildInboundEndpoint().getEndpointURI().toString());
40      }
41  }