1 7 package com.inversoft.verge.mvc.controller.actionflow.config.test; 8 9 10 import com.inversoft.config.component.ComponentConfigBuilderRegistry; 11 import com.inversoft.junit.WebTestCase; 12 import com.inversoft.verge.mvc.controller.actionflow.config.ActionFlowConfigBuilder; 13 import com.inversoft.verge.mvc.controller.actionflow.config.ActionFlowConfigRegistry; 14 import com.inversoft.verge.mvc.controller.actionflow.config.ActionHandlerNodeBuilder; 15 import com.inversoft.verge.mvc.controller.actionflow.config.BaseNamespace; 16 import com.inversoft.verge.mvc.controller.actionflow.config.BaseNamespaceBuilder; 17 import com.inversoft.verge.mvc.controller.actionflow.config.Constants; 18 import com.inversoft.verge.mvc.controller.actionflow.config.DefaultTypes; 19 import com.inversoft.verge.mvc.controller.actionflow.config.Namespace; 20 import com.inversoft.verge.mvc.controller.actionflow.config.PresentationNodeBuilder; 21 22 23 32 public class ActionFlowConfigRegistryTest extends WebTestCase { 33 34 37 public ActionFlowConfigRegistryTest(String name) { 38 super(name); 39 setLocal(true); 40 } 41 42 43 46 public void testAll() { 47 53 54 RegistryAdapter registry = new RegistryAdapter(); 55 RegistryAdapter.setInstance(registry); 56 try { 57 BaseNamespace namespace = new BaseNamespace("test", DefaultTypes.NAMESPACE); 58 registry.register(namespace); 59 assertTrue("Should be same namespace", 60 ActionFlowConfigRegistry.getInstance(request).lookup("test") == namespace); 61 } catch (Exception e) { 62 fail(e.toString()); 63 } 64 } 65 66 69 public void testComponents() { 70 try { 71 ComponentConfigBuilderRegistry builderRegistry = 72 new ComponentConfigBuilderRegistry(ActionFlowConfigBuilder.BUILDERS_BUNDLE); 73 assertTrue("Should have ActionConfigBuilder", 74 builderRegistry.lookup(ActionFlowConfigBuilder.NAMESPACE_PREFIX + 75 Constants.NAMESPACE_BUILDER_NAME) != null && 76 builderRegistry.lookup(ActionFlowConfigBuilder.NAMESPACE_PREFIX + 77 Constants.NAMESPACE_BUILDER_NAME) instanceof BaseNamespaceBuilder); 78 assertTrue("Should have FormConfigBuilder", 79 builderRegistry.lookup(ActionFlowConfigBuilder.NODE_PREFIX + 80 Constants.ACTION_HANDLER_BUILDER_NAME) != null && 81 builderRegistry.lookup(ActionFlowConfigBuilder.NODE_PREFIX + 82 Constants.ACTION_HANDLER_BUILDER_NAME) instanceof ActionHandlerNodeBuilder); 83 assertTrue("Should have MappingConfigBuilder", 84 builderRegistry.lookup(ActionFlowConfigBuilder.NODE_PREFIX + 85 Constants.PRESENTATION_BUILDER_NAME) != null && 86 builderRegistry.lookup(ActionFlowConfigBuilder.NODE_PREFIX + 87 Constants.PRESENTATION_BUILDER_NAME) instanceof PresentationNodeBuilder); 88 } catch (Exception e) { 89 fail(e.toString()); 90 } 91 } 92 93 96 public static class RegistryAdapter extends ActionFlowConfigRegistry { 97 protected static void setInstance(ActionFlowConfigRegistry instance) { 98 ActionFlowConfigRegistry.setInstance(instance); 99 } 100 101 protected Namespace register(Namespace namespace) 102 throws IllegalArgumentException { 103 return super.register(namespace); 104 } 105 } 106 } | Popular Tags |