From: Pieter v. Z. <pv...@us...> - 2005-08-03 08:50:22
|
Update of /cvsroot/coefficient/coefficient/src-test/za/org/coefficient/invokers/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6123/src-test/za/org/coefficient/invokers/test Modified Files: TestModuleInvoker.java Log Message: added XMLJndiUtil to create the modules Index: TestModuleInvoker.java =================================================================== RCS file: /cvsroot/coefficient/coefficient/src-test/za/org/coefficient/invokers/test/TestModuleInvoker.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TestModuleInvoker.java 2 Aug 2005 08:06:25 -0000 1.1 --- TestModuleInvoker.java 3 Aug 2005 08:50:05 -0000 1.2 *************** *** 4,11 **** package za.org.coefficient.invokers.test; import org.apache.commons.beanutils.MethodUtils; import org.apache.commons.beanutils.PropertyUtils; - import za.co.csir.icomtek.workflow.interfaces.WorkflowContext; import za.org.coefficient.authentication.Role; --- 4,12 ---- package za.org.coefficient.invokers.test; + import java.util.Hashtable; + import org.apache.commons.beanutils.MethodUtils; import org.apache.commons.beanutils.PropertyUtils; import za.co.csir.icomtek.workflow.interfaces.WorkflowContext; import za.org.coefficient.authentication.Role; *************** *** 15,18 **** --- 16,20 ---- import za.org.coefficient.interfaces.ThemeLocalIf; import za.org.coefficient.invokers.base.BaseInvoker; + import za.org.coefficient.util.common.XMLJndiUtil; import za.org.coefficient.util.ejb.SecurityUtil; *************** *** 27,30 **** --- 29,40 ---- private static final String CREATE = "create"; + private static Hashtable mockJNDI = null; + + private static String SERVER_XML_FILE = "server.xml.snippit"; + + static { + mockJNDI = XMLJndiUtil.createMockJNDI(SERVER_XML_FILE); + } + /** * Jul 19, 2005 *************** *** 41,94 **** * @see za.org.coefficient.invokers.base.BaseInvoker#getService(java.lang.String) * This method acts as a lookup for the module/class in JNDI. JNDI is ! * not used but simulated using a if statement to return an instance of ! * the requested object. This is done for testing so that we don't need * a container. */ public Object getService(String serviceName) throws Exception { - // new Object[]{"za.org.coefficient.modules.mailforum.MailForum"} Object module = null; ! System.out.println("TestModuleInvoker.getService()-> serviceName: " ! + serviceName); ! if (serviceName == "UserAdmin") { ! module = (Object) Class.forName( ! "za.org.coefficient.modules.user.UserAdmin").newInstance(); ! } else if (serviceName == "MailForum") { ! module = (Object) Class.forName( ! "za.org.coefficient.modules.mailforum.MailForum") ! .newInstance(); ! } else if (serviceName == "Configuration") { ! module = (Object) Class.forName( ! "za.org.coefficient.modules.configuration.Configuration") ! .newInstance(); ! ! } else if (serviceName == "Role") { ! // TODO:Pvzyl: we ! // need to improve ! // this. Why should ! // this be called in ! // an EJB? Move this ! // method to the ! // Role class ! module = (Object) Class.forName( ! "za.org.coefficient.util.common.Roles").newInstance(); ! ! } else if (serviceName == "AttributeDataManagement") { ! module = (Object) Class ! .forName( ! "za.org.coefficient.modules.attribute.AttributeDataManagement") ! .newInstance(); ! ! } else if (serviceName == "MemberAdmin") { ! module = (Object) Class.forName( ! "za.org.coefficient.modules.user.MemberAdmin") ! .newInstance(); ! ! } else if (serviceName == "DefaultTheme") { ! module = (Object) Class.forName( ! "za.org.coefficient.themes.defaultTheme.DefaultTheme") ! .newInstance(); ! ! } else { ! return null; } --- 51,63 ---- * @see za.org.coefficient.invokers.base.BaseInvoker#getService(java.lang.String) * This method acts as a lookup for the module/class in JNDI. JNDI is ! * not used but simulated using the XMLJndiUtil. ! * This is done for testing so that we don't need * a container. */ public Object getService(String serviceName) throws Exception { Object module = null; ! if (mockJNDI != null) { ! String className = (String) mockJNDI.get(serviceName); ! module = (Object) Class.forName(className).newInstance(); } *************** *** 141,145 **** CoefficientContext ctx) throws Exception { Object retVal = null; ! //is this the best place to put this security? return invokeOpOnModuleWithoutSecurity(module, operation, ctx); --- 110,114 ---- CoefficientContext ctx) throws Exception { Object retVal = null; ! // is this the best place to put this security? return invokeOpOnModuleWithoutSecurity(module, operation, ctx); |