@Override public Object getAttribute(String name) { checkActive(); return this.attributes.get(name); }
@Override public void removeAttribute(String name) { checkActive(); Assert.notNull(name, "Attribute name must not be null"); this.attributes.remove(name); }
@Override public Enumeration<String> getAttributeNames() { checkActive(); return Collections.enumeration(new LinkedHashSet<>(this.attributes.keySet())); }
@Override public void setAttribute(String name, @Nullable Object value) { checkActive(); Assert.notNull(name, "Attribute name must not be null"); if (value != null) { this.attributes.put(name, value); } else { this.attributes.remove(name); } }
@Override @Nullable public HttpSession getSession(boolean create) { checkActive(); // Reset session if invalidated. if (this.session instanceof MockHttpSession && ((MockHttpSession) this.session).isInvalid()) { this.session = null; } // Create new session if necessary. if (this.session == null && create) { this.session = new MockHttpSession(this.servletContext); } return this.session; }
@Override public Object getAttribute(String name) { checkActive(); return this.attributes.get(name); }
@Override public Object getAttribute(String name) { checkActive(); return this.attributes.get(name); }
@Override public void removeAttribute(String name) { checkActive(); Assert.notNull(name, "Attribute name must not be null"); this.attributes.remove(name); }
@Override public void removeAttribute(String name) { checkActive(); Assert.notNull(name, "Attribute name must not be null"); this.attributes.remove(name); }
@Override public Enumeration<String> getAttributeNames() { checkActive(); return Collections.enumeration(new LinkedHashSet<>(this.attributes.keySet())); }
@Override public Enumeration<String> getAttributeNames() { checkActive(); return Collections.enumeration(new LinkedHashSet<String>(this.attributes.keySet())); }
@Override public void setAttribute(String name, Object value) { checkActive(); Assert.notNull(name, "Attribute name must not be null"); if (value != null) { this.attributes.put(name, value); } else { this.attributes.remove(name); } }
@Override public void setAttribute(String name, @Nullable Object value) { checkActive(); Assert.notNull(name, "Attribute name must not be null"); if (value != null) { this.attributes.put(name, value); } else { this.attributes.remove(name); } }
@Override @Nullable public HttpSession getSession(boolean create) { checkActive(); // Reset session if invalidated. if (this.session instanceof MockHttpSession && ((MockHttpSession) this.session).isInvalid()) { this.session = null; } // Create new session if necessary. if (this.session == null && create) { this.session = new MockHttpSession(this.servletContext); } return this.session; }
@Override public HttpSession getSession(boolean create) { checkActive(); // Reset session if invalidated. if (this.session instanceof MockHttpSession && ((MockHttpSession) this.session).isInvalid()) { this.session = null; } // Create new session if necessary. if (this.session == null && create) { this.session = new MockHttpSession(this.servletContext); } return this.session; }