/** * Reset some data */ @Before public void setup() throws Exception { sessionManager.setMaxInactiveInterval(30); region.clear(); }
setMaxInactiveInterval(interval == RegionConfiguration.DEFAULT_MAX_INACTIVE_INTERVAL ? RegionConfiguration.DEFAULT_MAX_INACTIVE_INTERVAL : interval * 60); } catch (NumberFormatException e) {
/** * This method was taken from StandardManager to set the default maxInactiveInterval based on the * container (to 30 minutes). * <p> * Set the Container with which this Manager has been associated. If it is a Context (the usual * case), listen for changes to the session timeout property. * * @param container The associated Container */ @Override public void setContainer(Container container) { // De-register from the old Container (if any) if ((this.container != null) && (this.container instanceof Context)) { ((Context) this.container).removePropertyChangeListener(this); } // Default processing provided by our superclass super.setContainer(container); // Register with the new Container (if any) if ((this.container != null) && (this.container instanceof Context)) { // Overwrite the max inactive interval with the context's session timeout. setMaxInactiveInterval(((Context) this.container).getSessionTimeout() * 60); ((Context) this.container).addPropertyChangeListener(this); } }
/** * Test setting the session expiration */ @Test public void testSessionExpiration1() throws Exception { // TestSessions only live for a second sessionManager.setMaxInactiveInterval(1); String key = "value_testSessionExpiration1"; String value = "Foo"; WebConversation wc = new WebConversation(); WebRequest req = new GetMethodWebRequest(String.format("http://localhost:%d/test", port)); // Set an attribute req.setParameter("cmd", QueryCommand.SET.name()); req.setParameter("param", key); req.setParameter("value", value); WebResponse response = wc.getResponse(req); // Sleep a while Thread.sleep(2000); // The attribute should not be accessible now... req.setParameter("cmd", QueryCommand.GET.name()); req.setParameter("param", key); response = wc.getResponse(req); assertEquals("", response.getText()); }
setMaxInactiveInterval(interval == RegionConfiguration.DEFAULT_MAX_INACTIVE_INTERVAL ? RegionConfiguration.DEFAULT_MAX_INACTIVE_INTERVAL : interval * 60); } catch (NumberFormatException e) {
/** * This method was taken from StandardManager to set the default maxInactiveInterval based on the * container (to 30 minutes). * <p> * Set the Container with which this Manager has been associated. If it is a Context (the usual * case), listen for changes to the session timeout property. * * @param container The associated Container */ @Override public void setContainer(Container container) { // De-register from the old Container (if any) if ((this.container != null) && (this.container instanceof Context)) { ((Context) this.container).removePropertyChangeListener(this); } // Default processing provided by our superclass super.setContainer(container); // Register with the new Container (if any) if ((this.container != null) && (this.container instanceof Context)) { // Overwrite the max inactive interval with the context's session timeout. setMaxInactiveInterval(((Context) this.container).getSessionTimeout() * 60); ((Context) this.container).addPropertyChangeListener(this); } }