![JAR search and dependency download from the Maven repository](/logo.png)
com.mockrunner.example.struts.MemoryBasedRepository Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mockrunner-jdk1.3-j2ee1.3 Show documentation
Show all versions of mockrunner-jdk1.3-j2ee1.3 Show documentation
Mockrunner is a lightweight framework for unit testing applications
in the J2EE environment. It supports servlets, filters, tag classes
and Struts actions. It includes a JDBC a JMS and a JCA test
framework and can be used to test EJB based applications.
The newest version!
package com.mockrunner.example.struts;
import java.util.HashMap;
import javax.servlet.ServletContext;
/**
* A simple data repository stored in the .
* The implementation is not thread safe. Used by
* {@link StoreDataActionTest}.
*/
public class MemoryBasedRepository
{
private HashMap dataStore;
private MemoryBasedRepository()
{
dataStore = new HashMap();
}
public static MemoryBasedRepository instance(ServletContext context)
{
MemoryBasedRepository instance = (MemoryBasedRepository)context.getAttribute(MemoryBasedRepository.class.getName());
if(null != instance) return instance;
instance = new MemoryBasedRepository();
context.setAttribute(MemoryBasedRepository.class.getName(), instance);
return instance;
}
public void set(String id, Object data)
{
dataStore.put(id, data);
}
public Object get(String id)
{
return dataStore.get(id);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy