1 28 29 package org.objectweb.util.explorer.core.code; 30 31 import org.objectweb.fractal.adl.ADLException; 32 import org.objectweb.fractal.adl.Factory; 33 import org.objectweb.fractal.adl.FactoryFactory; 34 import org.objectweb.fractal.api.Component; 35 import org.objectweb.fractal.api.NoSuchInterfaceException; 36 import org.objectweb.fractal.api.control.IllegalLifeCycleException; 37 import org.objectweb.fractal.util.Fractal; 38 import org.objectweb.util.explorer.core.code.api.Code; 39 import org.objectweb.util.explorer.core.code.api.CodeDescription; 40 import org.objectweb.util.explorer.core.code.api.CodeProvider; 41 import org.objectweb.util.explorer.core.code.lib.BasicCodeDescription; 42 import org.objectweb.util.trace.TraceSystem; 43 44 import junit.framework.Assert; 45 import junit.framework.TestCase; 46 47 55 public class CodeInterpreterTest 56 extends TestCase 57 { 58 59 65 71 public CodeInterpreterTest(){ 72 TraceSystem.setLevel("debug"); 73 } 74 75 81 87 public void testBindingName(){ 88 89 CodeDescription codeDesc = new BasicCodeDescription(); 90 codeDesc.setLanguage("Java"); 91 codeDesc.setCode("org.objectweb.util.explorer.core.code.TestClass"); 92 93 try{ 94 Factory f = FactoryFactory.getFactory(FactoryFactory.FRACTAL_BACKEND); 95 Component codeInterpreter = (Component)f.newComponent("org.objectweb.util.explorer.core.code.CodeInterpreter",null); 96 Fractal.getLifeCycleController(codeInterpreter).startFc(); 97 CodeProvider cd = (CodeProvider)codeInterpreter.getFcInterface(CodeProvider.CODE_PROVIDER); 98 Code code = cd.getCode(codeDesc); 99 Assert.assertEquals(TestClass.MESSAGE,((TestClass)code.createInstance()).getMessage()); 100 } catch (ADLException e){ 101 e.printStackTrace(); 102 } catch (IllegalLifeCycleException e) { 103 e.printStackTrace(); 104 } catch (NoSuchInterfaceException e) { 105 e.printStackTrace(); 106 } 107 } 108 109 } 110 | Popular Tags |