1 17 package org.apache.servicemix.sca; 18 19 import java.io.File ; 20 import java.net.URL ; 21 import java.net.URLClassLoader ; 22 23 import junit.framework.Assert; 24 import junit.framework.TestCase; 25 26 import org.apache.servicemix.sca.assembly.JbiBinding; 27 import org.apache.servicemix.sca.tuscany.TuscanyRuntime; 28 import org.apache.tuscany.common.monitor.impl.NullMonitorFactory; 29 import org.apache.tuscany.model.assembly.Binding; 30 import org.apache.tuscany.model.assembly.Component; 31 import org.apache.tuscany.model.assembly.EntryPoint; 32 import org.apache.tuscany.model.assembly.ExternalService; 33 import org.apache.tuscany.model.assembly.Module; 34 35 38 public class AssemblyLoaderTest extends TestCase { 39 40 protected void setUp() throws Exception { 41 super.setUp(); 42 Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); 43 } 44 45 public void testLoader() throws Exception { 46 String name = "bigbank"; 47 String uri = getClass().getResource("bigbank/sca.module").toString(); 48 49 URL url = getClass().getResource("bigbank/sca.module"); 50 URL parentUrl = new File (url.toURI()).getParentFile().toURL(); 51 ClassLoader cl = new URLClassLoader (new URL [] { parentUrl }, getClass().getClassLoader()); 52 53 TuscanyRuntime rt = new TuscanyRuntime(name, uri, cl, new NullMonitorFactory()); 54 assertNotNull(rt); 55 56 Module module = rt.getModuleComponent().getModuleImplementation(); 57 58 Assert.assertTrue(module.getName().equals("org.apache.servicemix.sca.bigbank")); 59 60 Component component = module.getComponent("AccountServiceComponent"); 61 Assert.assertTrue(component != null); 62 63 EntryPoint entryPoint = module.getEntryPoint("AccountService"); 64 Assert.assertTrue(entryPoint != null); 65 66 ExternalService externalService = module.getExternalService("StockQuoteService"); 67 Assert.assertTrue(externalService != null); 68 69 Binding binding = externalService.getBindings().get(0); 70 Assert.assertTrue(binding instanceof JbiBinding); 71 } 72 } 73 | Popular Tags |