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 | |
| 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')
| -rw-r--r-- | cpp/src/tests/Makefile.am | 5 | ||||
| -rw-r--r-- | cpp/src/tests/Session.cpp | 59 |
2 files changed, 64 insertions, 0 deletions
diff --git a/cpp/src/tests/Makefile.am b/cpp/src/tests/Makefile.am index db9da392ea..34e7e973ac 100644 --- a/cpp/src/tests/Makefile.am +++ b/cpp/src/tests/Makefile.am @@ -19,6 +19,11 @@ CLEANFILES= # # Unit test programs. # +TESTS+=Session +check_PROGRAMS+=Session +Session_SOURCES=Session.cpp +Session_LDADD=-lboost_unit_test_framework $(lib_broker) + TESTS+=Blob check_PROGRAMS+=Blob Blob_SOURCES=Blob.cpp ../qpid/framing/Blob.cpp 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 (...) {} +} + + |
