1 23 24 package org.objectweb.fractal.julia.conform; 25 26 import org.objectweb.fractal.api.Component; 27 import org.objectweb.fractal.api.factory.GenericFactory; 28 import org.objectweb.fractal.api.type.TypeFactory; 29 import org.objectweb.fractal.api.type.ComponentType; 30 import org.objectweb.fractal.api.type.InterfaceType; 31 32 import org.objectweb.fractal.julia.conform.components.I; 33 import org.objectweb.fractal.julia.conform.components.C; 34 import org.objectweb.fractal.julia.conform.components.CAttributes; 35 36 import org.objectweb.fractal.util.Fractal; 37 38 public class TestComponent extends Test { 39 40 protected Component boot; 41 protected TypeFactory tf; 42 protected GenericFactory gf; 43 44 protected ComponentType t; 45 46 protected final static String AC = "attribute-controller/"+PKG+".CAttributes/false,false,false"; 47 protected final static String sI = "server/"+PKG+".I/false,false,false"; 48 protected final static String cI = "client/"+PKG+".I/true,false,false"; 49 50 54 public TestComponent (final String name) { 55 super(name); 56 } 57 58 protected void setUp () throws Exception { 59 boot = Fractal.getBootstrapComponent(); 60 tf = Fractal.getTypeFactory(boot); 61 gf = Fractal.getGenericFactory(boot); 62 t = tf.createFcType(new InterfaceType[] { 63 tf.createFcItfType("attribute-controller", CAttributes.class.getName(), false, false, false), 64 tf.createFcItfType("server", I.class.getName(), false, false, false), 65 tf.createFcItfType("client", I.class.getName(), true, true, false) 66 }); 67 } 68 69 73 public void testParametricPrimitive () throws Exception { 74 Component c = gf.newFcInstance(t, "parametricPrimitive", C.class.getName()); 75 Fractal.getLifeCycleController(c).startFc(); 76 I i = (I)c.getFcInterface("server"); 77 checkInterface(i); 78 79 CAttributes ca = (CAttributes)c.getFcInterface("attribute-controller"); 80 ca.setX1(true); 81 assertEquals(true, ca.getX1()); 82 ca.setX2((byte)1); 83 assertEquals((byte)1, ca.getX2()); 84 ca.setX3((char)1); 85 assertEquals((char)1, ca.getX3()); 86 ca.setX4((short)1); 87 assertEquals((short)1, ca.getX4()); 88 ca.setX5((int)1); 89 assertEquals((int)1, ca.getX5()); 90 ca.setX6(1); 91 assertEquals((long)1, ca.getX6()); 92 ca.setX7(1); 93 assertEquals((float)1, ca.getX7(), 0); 94 ca.setX8(1); 95 assertEquals((double)1, ca.getX8(), 0); 96 ca.setX9("1"); 97 assertEquals("1", ca.getX9()); 98 ca.setWriteOnlyX11(true); 99 assertEquals(true, i.n(false, null)); 100 } 101 102 public void testParametricPrimitiveTemplate () throws Exception { 103 Component c = gf.newFcInstance( 104 t, "parametricPrimitiveTemplate", new Object [] { "parametricPrimitive", C.class.getName() }); 105 106 CAttributes ca = (CAttributes)c.getFcInterface("attribute-controller"); 107 ca.setX1(true); 108 ca.setX2((byte)1); 109 ca.setX3((char)1); 110 ca.setX4((short)1); 111 ca.setX5((int)1); 112 ca.setX6(1); 113 ca.setX7(1); 114 ca.setX8(1); 115 ca.setX9("1"); 116 ca.setWriteOnlyX11(true); 117 118 c = Fractal.getFactory(c).newFcInstance(); 119 Fractal.getLifeCycleController(c).startFc(); 120 ca = (CAttributes)c.getFcInterface("attribute-controller"); 121 122 assertEquals(true, ca.getX1()); 123 assertEquals((byte)1, ca.getX2()); 124 assertEquals((char)1, ca.getX3()); 125 assertEquals((short)1, ca.getX4()); 126 assertEquals((int)1, ca.getX5()); 127 assertEquals((long)1, ca.getX6()); 128 assertEquals((float)1, ca.getX7(), 0); 129 assertEquals((double)1, ca.getX8(), 0); 130 assertEquals("1", ca.getX9()); 131 assertEquals(true, ((I)c.getFcInterface("server")).n(false, null)); 132 } 133 } 134 | Popular Tags |