Package org.jboss.test.kernel.config.support

Examples of org.jboss.test.kernel.config.support.SimpleCallbackBean


      List<CallbackMetaData> callbacks;
      CallbackMetaData callback;
      KernelControllerContext cc;
      Object target;
      Transformer<?> transformer;
      SimpleCallbackBean bean;

      Kernel kernel = bootstrap();
      KernelController controller = kernel.getController();
      try
      {
         beanMetaData = BeanMetaDataBuilder.createBuilder("t", TrimTransformer.class.getName()).getBeanMetaData();
         cc = controller.install(beanMetaData);
         assertNotNull(cc);
         assertEquals(ControllerState.INSTALLED, cc.getState());
         target = cc.getTarget();
         assertNotNull(target);
         transformer = assertInstanceOf(target, Transformer.class);

         // ct1

         builder = BeanMetaDataBuilder.createBuilder("ct1", SimpleCallbackBean.class.getName());
         builder.addPropertyInstallCallback("transformers");
         builder.addPropertyUninstallCallback("transformers");
         beanMetaData = builder.getBeanMetaData();

         callbacks = beanMetaData.getInstallCallbacks();
         assertNotNull(callbacks);
         assertEquals(1, callbacks.size());
         callback = callbacks.get(0);
         assertNotNull(callback);
         assertInstanceOf(callback, InstallCallbackMetaData.class, false);
         assertEquals("transformers", callback.getProperty());
         assertEquals(ControllerState.INSTALLED, callback.getDependentState());
         assertNull(callback.getState());
         assertNull(callback.getSignature());
         assertNull(callback.getMethodName());
         assertNull(callback.getCardinality());
         assertNull(callback.getParameters());

         callbacks = beanMetaData.getUninstallCallbacks();
         assertNotNull(callbacks);
         assertEquals(1, callbacks.size());
         callback = callbacks.get(0);
         assertNotNull(callback);
         assertInstanceOf(callback, UninstallCallbackMetaData.class, false);
         assertEquals("transformers", callback.getProperty());
         assertEquals(ControllerState.INSTALLED, callback.getDependentState());
         assertNull(callback.getState());
         assertNull(callback.getSignature());
         assertNull(callback.getMethodName());
         assertNull(callback.getCardinality());
         assertNull(callback.getParameters());

         cc = controller.install(beanMetaData);
         assertNotNull(cc);
         assertEquals(ControllerState.INSTALLED, cc.getState());
         target = cc.getTarget();
         assertNotNull(target);
         bean = assertInstanceOf(target, SimpleCallbackBean.class);
         assertNotNull(bean.getTransformers());
         assertEquals(1, bean.getTransformers().size());
         assertSame(transformer, bean.getTransformers().iterator().next());

         // ct2

         builder = BeanMetaDataBuilder.createBuilder("ct2", SimpleCallbackBean.class.getName());
         builder.addPropertyInstallCallback("transformers", Cardinality.ONE_TO_MANY);
         builder.addPropertyUninstallCallback("transformers", Cardinality.ONE_TO_MANY);
         beanMetaData = builder.getBeanMetaData();

         callbacks = beanMetaData.getInstallCallbacks();
         assertNotNull(callbacks);
         assertEquals(1, callbacks.size());
         callback = callbacks.get(0);
         assertNotNull(callback);
         assertInstanceOf(callback, InstallCallbackMetaData.class, false);
         assertEquals("transformers", callback.getProperty());
         assertEquals(ControllerState.INSTALLED, callback.getDependentState());
         assertNull(callback.getState());
         assertNull(callback.getSignature());
         assertNull(callback.getMethodName());
         assertEquals(Cardinality.ONE_TO_MANY, callback.getCardinality());
         assertNull(callback.getParameters());

         callbacks = beanMetaData.getUninstallCallbacks();
         assertNotNull(callbacks);
         assertEquals(1, callbacks.size());
         callback = callbacks.get(0);
         assertNotNull(callback);
         assertInstanceOf(callback, UninstallCallbackMetaData.class, false);
         assertEquals("transformers", callback.getProperty());
         assertEquals(ControllerState.INSTALLED, callback.getDependentState());
         assertNull(callback.getState());
         assertNull(callback.getSignature());
         assertNull(callback.getMethodName());
         assertEquals(Cardinality.ONE_TO_MANY, callback.getCardinality());
         assertNull(callback.getParameters());

         cc = controller.install(beanMetaData);
         assertNotNull(cc);
         assertEquals(ControllerState.INSTALLED, cc.getState());
         target = cc.getTarget();
         assertNotNull(target);
         bean = assertInstanceOf(target, SimpleCallbackBean.class);
         assertNotNull(bean.getTransformers());
         assertEquals(1, bean.getTransformers().size());
         assertSame(transformer, bean.getTransformers().iterator().next());

         // ct3

         builder = BeanMetaDataBuilder.createBuilder("ct3", SimpleCallbackBean.class.getName());
         builder.addPropertyInstallCallback("transformers", ControllerState.CREATE);
         builder.addPropertyUninstallCallback("transformers", ControllerState.CREATE);
         beanMetaData = builder.getBeanMetaData();

         callbacks = beanMetaData.getInstallCallbacks();
         assertNotNull(callbacks);
         assertEquals(1, callbacks.size());
         callback = callbacks.get(0);
         assertNotNull(callback);
         assertInstanceOf(callback, InstallCallbackMetaData.class, false);
         assertEquals("transformers", callback.getProperty());
         assertEquals(ControllerState.INSTALLED, callback.getDependentState());
         assertEquals(ControllerState.CREATE, callback.getState());
         assertNull(callback.getSignature());
         assertNull(callback.getMethodName());
         assertNull(callback.getCardinality());
         assertNull(callback.getParameters());

         callbacks = beanMetaData.getUninstallCallbacks();
         assertNotNull(callbacks);
         assertEquals(1, callbacks.size());
         callback = callbacks.get(0);
         assertNotNull(callback);
         assertInstanceOf(callback, UninstallCallbackMetaData.class, false);
         assertEquals("transformers", callback.getProperty());
         assertEquals(ControllerState.INSTALLED, callback.getDependentState());
         assertEquals(ControllerState.CREATE, callback.getState());
         assertNull(callback.getSignature());
         assertNull(callback.getMethodName());
         assertNull(callback.getCardinality());
         assertNull(callback.getParameters());

         cc = controller.install(beanMetaData);
         assertNotNull(cc);
         assertEquals(ControllerState.INSTALLED, cc.getState());
         target = cc.getTarget();
         assertNotNull(target);
         bean = assertInstanceOf(target, SimpleCallbackBean.class);
         assertNotNull(bean.getTransformers());
         assertEquals(1, bean.getTransformers().size());
         assertSame(transformer, bean.getTransformers().iterator().next());

         // ct4

         builder = BeanMetaDataBuilder.createBuilder("ct4", SimpleCallbackBean.class.getName());
         builder.addPropertyInstallCallback("transformers", Set.class.getName(), ControllerState.CREATE, ControllerState.START, Cardinality.ZERO_TO_ONE);
         builder.addPropertyUninstallCallback("transformers", Set.class.getName(), ControllerState.CREATE, ControllerState.START, Cardinality.ZERO_TO_ONE);
         beanMetaData = builder.getBeanMetaData();

         callbacks = beanMetaData.getInstallCallbacks();
         assertNotNull(callbacks);
         assertEquals(1, callbacks.size());
         callback = callbacks.get(0);
         assertNotNull(callback);
         assertInstanceOf(callback, InstallCallbackMetaData.class, false);
         assertEquals("transformers", callback.getProperty());
         assertEquals(ControllerState.START, callback.getDependentState());
         assertEquals(ControllerState.CREATE, callback.getState());
         assertEquals(Set.class.getName(), callback.getSignature());
         assertEquals(Cardinality.ZERO_TO_ONE, callback.getCardinality());
         assertNull(callback.getMethodName());
         assertNull(callback.getParameters());

         callbacks = beanMetaData.getUninstallCallbacks();
         assertNotNull(callbacks);
         assertEquals(1, callbacks.size());
         callback = callbacks.get(0);
         assertNotNull(callback);
         assertInstanceOf(callback, UninstallCallbackMetaData.class, false);
         assertEquals("transformers", callback.getProperty());
         assertEquals(ControllerState.START, callback.getDependentState());
         assertEquals(ControllerState.CREATE, callback.getState());
         assertEquals(Set.class.getName(), callback.getSignature());
         assertEquals(Cardinality.ZERO_TO_ONE, callback.getCardinality());
         assertNull(callback.getMethodName());
         assertNull(callback.getParameters());

         cc = controller.install(beanMetaData);
         assertNotNull(cc);
         assertEquals(ControllerState.INSTALLED, cc.getState());
         target = cc.getTarget();
         assertNotNull(target);
         bean = assertInstanceOf(target, SimpleCallbackBean.class);
         assertNotNull(bean.getTransformers());
         assertEquals(1, bean.getTransformers().size());
         assertSame(transformer, bean.getTransformers().iterator().next());

         // ct1

         builder = BeanMetaDataBuilder.createBuilder("mct1", SimpleCallbackBean.class.getName());
         builder.addMethodInstallCallback("addTransformer");
         builder.addMethodUninstallCallback("removeTransformer");
         beanMetaData = builder.getBeanMetaData();

         callbacks = beanMetaData.getInstallCallbacks();
         assertNotNull(callbacks);
         assertEquals(1, callbacks.size());
         callback = callbacks.get(0);
         assertNotNull(callback);
         assertInstanceOf(callback, InstallCallbackMetaData.class, false);
         assertEquals("addTransformer", callback.getMethodName());
         assertEquals(ControllerState.INSTALLED, callback.getDependentState());
         assertNull(callback.getState());
         assertNull(callback.getSignature());
         assertNull(callback.getProperty());
         assertNull(callback.getCardinality());
         assertNull(callback.getParameters());

         callbacks = beanMetaData.getUninstallCallbacks();
         assertNotNull(callbacks);
         assertEquals(1, callbacks.size());
         callback = callbacks.get(0);
         assertNotNull(callback);
         assertInstanceOf(callback, UninstallCallbackMetaData.class, false);
         assertEquals("removeTransformer", callback.getMethodName());
         assertEquals(ControllerState.INSTALLED, callback.getDependentState());
         assertNull(callback.getState());
         assertNull(callback.getSignature());
         assertNull(callback.getProperty());
         assertNull(callback.getCardinality());
         assertNull(callback.getParameters());

         cc = controller.install(beanMetaData);
         assertNotNull(cc);
         assertEquals(ControllerState.INSTALLED, cc.getState());
         target = cc.getTarget();
         assertNotNull(target);
         bean = assertInstanceOf(target, SimpleCallbackBean.class);
         assertNotNull(bean.getTransformers());
         assertEquals(1, bean.getTransformers().size());
         assertSame(transformer, bean.getTransformers().iterator().next());

         // ct2

         builder = BeanMetaDataBuilder.createBuilder("mct2", SimpleCallbackBean.class.getName());
         builder.addMethodInstallCallback("addTransformer", Cardinality.ONE_TO_MANY);
         builder.addMethodUninstallCallback("removeTransformer", Cardinality.ONE_TO_MANY);
         beanMetaData = builder.getBeanMetaData();

         callbacks = beanMetaData.getInstallCallbacks();
         assertNotNull(callbacks);
         assertEquals(1, callbacks.size());
         callback = callbacks.get(0);
         assertNotNull(callback);
         assertInstanceOf(callback, InstallCallbackMetaData.class, false);
         assertEquals("addTransformer", callback.getMethodName());
         assertEquals(ControllerState.INSTALLED, callback.getDependentState());
         assertNull(callback.getState());
         assertNull(callback.getSignature());
         assertNull(callback.getProperty());
         assertEquals(Cardinality.ONE_TO_MANY, callback.getCardinality());
         assertNull(callback.getParameters());

         callbacks = beanMetaData.getUninstallCallbacks();
         assertNotNull(callbacks);
         assertEquals(1, callbacks.size());
         callback = callbacks.get(0);
         assertNotNull(callback);
         assertInstanceOf(callback, UninstallCallbackMetaData.class, false);
         assertEquals("removeTransformer", callback.getMethodName());
         assertEquals(ControllerState.INSTALLED, callback.getDependentState());
         assertNull(callback.getState());
         assertNull(callback.getSignature());
         assertNull(callback.getProperty());
         assertEquals(Cardinality.ONE_TO_MANY, callback.getCardinality());
         assertNull(callback.getParameters());

         cc = controller.install(beanMetaData);
         assertNotNull(cc);
         assertEquals(ControllerState.INSTALLED, cc.getState());
         target = cc.getTarget();
         assertNotNull(target);
         bean = assertInstanceOf(target, SimpleCallbackBean.class);
         assertNotNull(bean.getTransformers());
         assertEquals(1, bean.getTransformers().size());
         assertSame(transformer, bean.getTransformers().iterator().next());

         // ct3

         builder = BeanMetaDataBuilder.createBuilder("mct3", SimpleCallbackBean.class.getName());
         builder.addMethodInstallCallback("addTransformer", ControllerState.CREATE);
         builder.addMethodUninstallCallback("removeTransformer", ControllerState.CREATE);
         beanMetaData = builder.getBeanMetaData();

         callbacks = beanMetaData.getInstallCallbacks();
         assertNotNull(callbacks);
         assertEquals(1, callbacks.size());
         callback = callbacks.get(0);
         assertNotNull(callback);
         assertInstanceOf(callback, InstallCallbackMetaData.class, false);
         assertEquals("addTransformer", callback.getMethodName());
         assertEquals(ControllerState.INSTALLED, callback.getDependentState());
         assertEquals(ControllerState.CREATE, callback.getState());
         assertNull(callback.getSignature());
         assertNull(callback.getProperty());
         assertNull(callback.getCardinality());
         assertNull(callback.getParameters());

         callbacks = beanMetaData.getUninstallCallbacks();
         assertNotNull(callbacks);
         assertEquals(1, callbacks.size());
         callback = callbacks.get(0);
         assertNotNull(callback);
         assertInstanceOf(callback, UninstallCallbackMetaData.class, false);
         assertEquals("removeTransformer", callback.getMethodName());
         assertEquals(ControllerState.INSTALLED, callback.getDependentState());
         assertEquals(ControllerState.CREATE, callback.getState());
         assertNull(callback.getSignature());
         assertNull(callback.getProperty());
         assertNull(callback.getCardinality());
         assertNull(callback.getParameters());

         cc = controller.install(beanMetaData);
         assertNotNull(cc);
         assertEquals(ControllerState.INSTALLED, cc.getState());
         target = cc.getTarget();
         assertNotNull(target);
         bean = assertInstanceOf(target, SimpleCallbackBean.class);
         assertNotNull(bean.getTransformers());
         assertEquals(1, bean.getTransformers().size());
         assertSame(transformer, bean.getTransformers().iterator().next());

         // ct4

         builder = BeanMetaDataBuilder.createBuilder("mct4", SimpleCallbackBean.class.getName());
         builder.addMethodInstallCallback("addTransformer", Transformer.class.getName(), ControllerState.CREATE, ControllerState.START, Cardinality.ZERO_TO_ONE);
         builder.addMethodUninstallCallback("removeTransformer", Transformer.class.getName(), ControllerState.CREATE, ControllerState.START, Cardinality.ZERO_TO_ONE);
         beanMetaData = builder.getBeanMetaData();

         callbacks = beanMetaData.getInstallCallbacks();
         assertNotNull(callbacks);
         assertEquals(1, callbacks.size());
         callback = callbacks.get(0);
         assertNotNull(callback);
         assertInstanceOf(callback, InstallCallbackMetaData.class, false);
         assertEquals("addTransformer", callback.getMethodName());
         assertEquals(ControllerState.START, callback.getDependentState());
         assertEquals(ControllerState.CREATE, callback.getState());
         assertEquals(Transformer.class.getName(), callback.getSignature());
         assertEquals(Cardinality.ZERO_TO_ONE, callback.getCardinality());
         assertNull(callback.getProperty());
         assertNull(callback.getParameters());

         callbacks = beanMetaData.getUninstallCallbacks();
         assertNotNull(callbacks);
         assertEquals(1, callbacks.size());
         callback = callbacks.get(0);
         assertNotNull(callback);
         assertInstanceOf(callback, UninstallCallbackMetaData.class, false);
         assertEquals("removeTransformer", callback.getMethodName());
         assertEquals(ControllerState.START, callback.getDependentState());
         assertEquals(ControllerState.CREATE, callback.getState());
         assertEquals(Transformer.class.getName(), callback.getSignature());
         assertEquals(Cardinality.ZERO_TO_ONE, callback.getCardinality());
         assertNull(callback.getProperty());
         assertNull(callback.getParameters());

         cc = controller.install(beanMetaData);
         assertNotNull(cc);
         assertEquals(ControllerState.INSTALLED, cc.getState());
         target = cc.getTarget();
         assertNotNull(target);
         bean = assertInstanceOf(target, SimpleCallbackBean.class);
         assertNotNull(bean.getTransformers());
         assertEquals(1, bean.getTransformers().size());
         assertSame(transformer, bean.getTransformers().iterator().next());
      }
      finally
      {
         controller.shutdown();
      }
View Full Code Here

TOP

Related Classes of org.jboss.test.kernel.config.support.SimpleCallbackBean

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.