summaryrefslogtreecommitdiff
path: root/cpp/src/tests/AsyncCompletion.cpp
diff options
context:
space:
mode:
authorRajith Muditha Attapattu <rajith@apache.org>2011-05-27 15:44:23 +0000
committerRajith Muditha Attapattu <rajith@apache.org>2011-05-27 15:44:23 +0000
commit66765100f4257159622cefe57bed50125a5ad017 (patch)
treea88ee23bb194eb91f0ebb2d9b23ff423e3ea8e37 /cpp/src/tests/AsyncCompletion.cpp
parent1aeaa7b16e5ce54f10c901d75c4d40f9f88b9db6 (diff)
parent88b98b2f4152ef59a671fad55a0d08338b6b78ca (diff)
downloadqpid-python-rajith_jms_client.tar.gz
Creating a branch for experimenting with some ideas for JMS client.rajith_jms_client
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/rajith_jms_client@1128369 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/tests/AsyncCompletion.cpp')
-rw-r--r--cpp/src/tests/AsyncCompletion.cpp120
1 files changed, 0 insertions, 120 deletions
diff --git a/cpp/src/tests/AsyncCompletion.cpp b/cpp/src/tests/AsyncCompletion.cpp
deleted file mode 100644
index e32097106f..0000000000
--- a/cpp/src/tests/AsyncCompletion.cpp
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- *
- * 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 "unit_test.h"
-#include "test_tools.h"
-#include "BrokerFixture.h"
-#include "qpid/broker/NullMessageStore.h"
-#include "qpid/sys/BlockingQueue.h"
-#include "qpid/client/AsyncSession.h"
-#include "qpid/sys/Time.h"
-#include "qpid/framing/QueueQueryResult.h"
-#include "qpid/client/TypedResult.h"
-
-using namespace std;
-using namespace qpid;
-using namespace client;
-using namespace framing;
-
-namespace qpid { namespace broker {
-class TransactionContext;
-class PersistableQueue;
-}}
-
-using broker::PersistableMessage;
-using broker::NullMessageStore;
-using broker::TransactionContext;
-using broker::PersistableQueue;
-using sys::TIME_SEC;
-using boost::intrusive_ptr;
-
-/** @file Unit tests for async completion.
- * Using a dummy store, verify that the broker indicates async completion of
- * message enqueues at the correct time.
- */
-
-namespace qpid {
-namespace tests {
-
-class AsyncCompletionMessageStore : public NullMessageStore {
- public:
- sys::BlockingQueue<boost::intrusive_ptr<PersistableMessage> > enqueued;
-
- AsyncCompletionMessageStore() : NullMessageStore() {}
- ~AsyncCompletionMessageStore(){}
-
- void enqueue(TransactionContext*,
- const boost::intrusive_ptr<PersistableMessage>& msg,
- const PersistableQueue& )
- {
- enqueued.push(msg);
- }
-};
-
-QPID_AUTO_TEST_SUITE(AsyncCompletionTestSuite)
-
-QPID_AUTO_TEST_CASE(testWaitTillComplete) {
- SessionFixture fix;
- AsyncCompletionMessageStore* store = new AsyncCompletionMessageStore;
- boost::shared_ptr<qpid::broker::MessageStore> p;
- p.reset(store);
- fix.broker->setStore(p);
- AsyncSession s = fix.session;
-
- static const int count = 3;
-
- s.queueDeclare("q", arg::durable=true);
- Completion transfers[count];
- for (int i = 0; i < count; ++i) {
- Message msg(boost::lexical_cast<string>(i), "q");
- msg.getDeliveryProperties().setDeliveryMode(PERSISTENT);
- transfers[i] = s.messageTransfer(arg::content=msg);
- }
-
- // Get hold of the broker-side messages.
- typedef vector<intrusive_ptr<PersistableMessage> > BrokerMessages;
- BrokerMessages enqueued;
- for (int j = 0; j < count; ++j)
- enqueued.push_back(store->enqueued.pop(TIME_SEC));
-
- // Send a sync, make sure it does not complete till all messages are complete.
- // In reverse order for fun.
- Completion sync = s.executionSync(arg::sync=true);
- for (int k = count-1; k >= 0; --k) {
- BOOST_CHECK(!transfers[k].isComplete()); // Should not be complete yet.
- BOOST_CHECK(!sync.isComplete()); // Should not be complete yet.
- enqueued[k]->enqueueComplete();
- }
- sync.wait(); // Should complete now, all messages are completed.
-}
-
-QPID_AUTO_TEST_CASE(testGetResult) {
- SessionFixture fix;
- AsyncSession s = fix.session;
-
- s.queueDeclare("q", arg::durable=true);
- TypedResult<QueueQueryResult> tr = s.queueQuery("q");
- QueueQueryResult qq = tr.get();
- BOOST_CHECK_EQUAL(qq.getQueue(), "q");
- BOOST_CHECK_EQUAL(qq.getMessageCount(), 0U);
-}
-
-QPID_AUTO_TEST_SUITE_END()
-
-}} // namespace qpid::tests