diff options
author | Alan Conway <aconway@apache.org> | 2007-08-27 15:52:47 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2007-08-27 15:52:47 +0000 |
commit | d7b1ad93da22a7c1caf499b9eec7200a7ae52b6e (patch) | |
tree | 4943e75d94dc060bd8ba0206de9be3d85481b7a4 /cpp/src/tests/Session.cpp | |
parent | 366b7287350d47f788a0d1af1a1bf73328e4ec1f (diff) | |
download | qpid-python-d7b1ad93da22a7c1caf499b9eec7200a7ae52b6e.tar.gz |
* src/qpid/broker/SessionState.h: State of a session.
* src/qpid/broker/SuspendedSessions.h, .cpp: Stores suspended sessions.
* src/tests/Session.cpp: Test session classes.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@570164 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/tests/Session.cpp')
-rw-r--r-- | cpp/src/tests/Session.cpp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/cpp/src/tests/Session.cpp b/cpp/src/tests/Session.cpp new file mode 100644 index 0000000000..445f612111 --- /dev/null +++ b/cpp/src/tests/Session.cpp @@ -0,0 +1,59 @@ +/* + * + * Copyright (c) 2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "qpid/broker/SuspendedSessions.h" + +#define BOOST_AUTO_TEST_MAIN +#include <boost/test/auto_unit_test.hpp> + +using namespace std; +using namespace qpid::framing; +using namespace qpid::broker; +using namespace qpid::sys; + +BOOST_AUTO_TEST_CASE(testSuspendedSessions) { + SuspendedSessions suspended; + + SessionState s(0); // 0 timeout + BOOST_CHECK(s.isActive()); + suspended.suspend(s); + BOOST_CHECK(!s.isActive()); + try { + s = suspended.resume(s.getId()); + BOOST_FAIL("Expected session to be timed out."); + } catch (...) {} + + s = SessionState(1); // New session, 1 sec timeout. + try { + suspended.resume(s.getId()); + BOOST_FAIL("Expeced exception: non-existent session."); + } catch (...) {} + suspended.suspend(s); + BOOST_CHECK(!s.isActive()); + s = suspended.resume(s.getId()); + BOOST_CHECK(s.isActive()); + + suspended.suspend(s); // Real timeout + sleep(2); + try { + suspended.resume(s.getId()); + BOOST_FAIL("Expeced timeout."); + } catch (...) {} +} + + |