List of usage examples for javax.servlet.http HttpSession removeValue
@Deprecated public void removeValue(String name);
From source file:org.codehaus.wadi.web.TestHttpSession.java
public void testRemoveValue(Manager manager) { HttpSession session = ((WADIHttpSession) manager.create(null)).getWrapper(); assertTrue(events.size() == 1); // sessionCreated String key = "foo"; Object val = new Listener(); session.setAttribute(key, val); assertTrue(events.size() == 3); // valueBound, attributeAdded events.clear();//from w w w. j a va 2 s . c o m session.removeValue(key); assertTrue(events.size() == 2); // valueUnBound, attributeRemoved { Pair pair = (Pair) events.get(0); assertTrue(pair != null); assertTrue(pair.getType().equals("valueUnbound")); HttpSessionEvent e = pair.getEvent(); assertTrue(session == e.getSession()); HttpSessionBindingEvent be = (HttpSessionBindingEvent) e; assertTrue(be.getName() == key); assertTrue(be.getValue() == val); } { Pair pair = (Pair) events.get(1); assertTrue(pair != null); assertTrue(pair.getType().equals("attributeRemoved")); HttpSessionEvent e = pair.getEvent(); assertTrue(session == e.getSession()); HttpSessionBindingEvent be = (HttpSessionBindingEvent) e; assertTrue(be.getName() == key); assertTrue(be.getValue() == val); } events.clear(); assertTrue(events.size() == 0); assertTrue(session.getAttribute(key) == null); }
From source file:org.codehaus.wadi.web.TestHttpSession.java
public void testNullName(Manager manager) { HttpSession session = ((WADIHttpSession) manager.create(null)).getWrapper(); try {//from w w w . ja v a2s . c o m session.setAttribute(null, "a"); assertTrue(false); } catch (IllegalArgumentException e) { } try { session.getAttribute(null); assertTrue(false); } catch (IllegalArgumentException e) { } try { session.removeAttribute(null); assertTrue(false); } catch (IllegalArgumentException e) { } try { session.putValue(null, "a"); assertTrue(false); } catch (IllegalArgumentException e) { } try { session.getValue(null); assertTrue(false); } catch (IllegalArgumentException e) { } try { session.removeValue(null); assertTrue(false); } catch (IllegalArgumentException e) { } }