/** * Creates the {@link com.mockrunner.mock.web.MockServletContext} using <code>new</code>. * This method can be overridden to return a subclass of {@link com.mockrunner.mock.web.MockServletContext}. * @return the {@link com.mockrunner.mock.web.MockServletContext} */ public MockServletContext createMockServletContext() { return new MockServletContext(); }
public synchronized void addResourcePath(String path, String resourcePath) { ArrayList list = new ArrayList(); list.add(resourcePath); addResourcePaths(path, list); }
private synchronized void handleAttributeListenerCalls(String key, Object value, Object oldValue) { if(null != oldValue) { if(value != null) { callAttributeListenersReplacedMethod(key, oldValue); } else { callAttributeListenersRemovedMethod(key, oldValue); } } else { if(value != null) { callAttributeListenersAddedMethod(key, value); } } }
private void setUpServletContextResourcePath(String[] resourcesFiles) { for (String file : resourcesFiles) { try { File streamFile = new File(file); FileInputStream stream = new FileInputStream(streamFile); byte[] fileData = StreamUtil.getStreamAsByteArray(stream); mockFactory.getMockServletContext().setResourceAsStream(file, fileData); mockFactory.getMockServletContext().setResource(file, streamFile.toURI().toURL()); } catch (Exception exc) { throw new NestedApplicationException(exc); } } }
public synchronized void setResourceAsStream(String path, InputStream inputStream) { setResourceAsStream(path, StreamUtil.getStreamAsByteArray(inputStream)); }
public synchronized RequestDispatcher getNamedDispatcher(String name) { return getRequestDispatcher(name); }
public synchronized void setAttribute(String key, Object value) { Object oldValue = attributes.get(key); if(null == value) { attributes.remove(key); } else { attributes.put(key, value); } handleAttributeListenerCalls(key, value, oldValue); }
public synchronized void removeAttribute(String key) { Object value = attributes.get(key); attributes.remove(key); if(null != value) { callAttributeListenersRemovedMethod(key, value); } }
public MockServletContext() { resetAll(); }
return (ValidatorResources)mockFactory.getMockServletContext().getAttribute(key);
private void setUpServletContextResourcePath(String[] resourcesFiles) { for(int ii = 0; ii < resourcesFiles.length; ii++) { String file = resourcesFiles[ii]; try { File streamFile = new File(file); FileInputStream stream = new FileInputStream(streamFile); byte[] fileData = StreamUtil.getStreamAsByteArray(stream); mockFactory.getMockServletContext().setResourceAsStream(file, fileData); mockFactory.getMockServletContext().setResource(file, streamFile.toURL()); } catch(Exception exc) { throw new NestedApplicationException(exc); } } }
public synchronized void setResourceAsStream(String path, InputStream inputStream) { setResourceAsStream(path, StreamUtil.getStreamAsByteArray(inputStream)); }
public synchronized RequestDispatcher getNamedDispatcher(String name) { return getRequestDispatcher(name); }
public synchronized void setAttribute(String key, Object value) { Object oldValue = attributes.get(key); if(null == value) { attributes.remove(key); } else { attributes.put(key, value); } handleAttributeListenerCalls(key, value, oldValue); }
public synchronized void removeAttribute(String key) { Object value = attributes.get(key); attributes.remove(key); if(null != value) { callAttributeListenersRemovedMethod(key, value); } }
public MockServletContext() { resetAll(); }
return (ValidatorResources)mockFactory.getMockServletContext().getAttribute(key);
private synchronized void handleAttributeListenerCalls(String key, Object value, Object oldValue) { if(null != oldValue) { if(value != null) { callAttributeListenersReplacedMethod(key, oldValue); } else { callAttributeListenersRemovedMethod(key, oldValue); } } else { if(value != null) { callAttributeListenersAddedMethod(key, value); } } }
private void setUpServletContextResourcePath(String[] resourcesFiles) { for(int ii = 0; ii < resourcesFiles.length; ii++) { String file = resourcesFiles[ii]; try { File streamFile = new File(file); FileInputStream stream = new FileInputStream(streamFile); byte[] fileData = StreamUtil.getStreamAsByteArray(stream); mockFactory.getMockServletContext().setResourceAsStream(file, fileData); mockFactory.getMockServletContext().setResource(file, streamFile.toURL()); } catch(Exception exc) { throw new NestedApplicationException(exc); } } }
public synchronized void setResourceAsStream(String path, InputStream inputStream) { setResourceAsStream(path, StreamUtil.getStreamAsByteArray(inputStream)); }