From 748ab168eca0d6cc084d6c498159f445c41d7ee2 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Wed, 25 Feb 2009 22:53:43 +0000 Subject: Add FrameDecoder unit test, update comments in Cluster.h/cpp. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@747947 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/FrameDecoder.cpp | 73 +++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 qpid/cpp/src/tests/FrameDecoder.cpp (limited to 'qpid/cpp/src/tests/FrameDecoder.cpp') diff --git a/qpid/cpp/src/tests/FrameDecoder.cpp b/qpid/cpp/src/tests/FrameDecoder.cpp new file mode 100644 index 0000000000..b7f1ea1b89 --- /dev/null +++ b/qpid/cpp/src/tests/FrameDecoder.cpp @@ -0,0 +1,73 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 "qpid/framing/AMQFrame.h" +#include "qpid/framing/FrameDecoder.h" +#include "qpid/framing/AMQContentBody.h" +#include "qpid/framing/Buffer.h" +#include + + +QPID_AUTO_TEST_SUITE(FrameDecoderTest) + +using namespace std; +using namespace qpid::framing; + + +string makeData(int size) { + string data; + data.resize(size); + for (int i =0; i < size; ++i) + data[i] = 'a' + (i%26); + return data; +} +string encodeFrame(string data) { + AMQFrame f((AMQContentBody(data))); + string encoded; + encoded.resize(f.encodedSize()); + Buffer b(&encoded[0], encoded.size()); + f.encode(b); + return encoded; +} + +string getData(const AMQFrame& frame) { + const AMQContentBody* content = dynamic_cast(frame.getBody()); + BOOST_CHECK(content); + return content->getData(); +} + +QPID_AUTO_TEST_CASE(testByteFragments) { + string data = makeData(42); + string encoded = encodeFrame(data); + FrameDecoder decoder; + for (size_t i = 0; i < encoded.size()-1; ++i) { + Buffer buf(&encoded[i], 1); + BOOST_CHECK(!decoder.decode(buf)); + } + Buffer buf(&encoded[encoded.size()-1], 1); + BOOST_CHECK(decoder.decode(buf)); + BOOST_CHECK_EQUAL(data, getData(decoder.frame)); +} + + + +QPID_AUTO_TEST_SUITE_END() -- cgit v1.2.1 From 99e95eaf3713e70c3b78648c97d92659b61f89b8 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Mon, 2 Mar 2009 23:30:08 +0000 Subject: Replicate connection decoder fragments to new members. Refactoring: - Merge Decoder into ConnectionMap. - Process cluster controls in event queue thread. - Use counter not pointer for connection ID, avoid re-use. - Do all processing in event queue thread to avoid races (temporary pending performance measurements) git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@749473 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/FrameDecoder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/cpp/src/tests/FrameDecoder.cpp') diff --git a/qpid/cpp/src/tests/FrameDecoder.cpp b/qpid/cpp/src/tests/FrameDecoder.cpp index b7f1ea1b89..f5db66d5fe 100644 --- a/qpid/cpp/src/tests/FrameDecoder.cpp +++ b/qpid/cpp/src/tests/FrameDecoder.cpp @@ -65,7 +65,7 @@ QPID_AUTO_TEST_CASE(testByteFragments) { } Buffer buf(&encoded[encoded.size()-1], 1); BOOST_CHECK(decoder.decode(buf)); - BOOST_CHECK_EQUAL(data, getData(decoder.frame)); + BOOST_CHECK_EQUAL(data, getData(decoder.getFrame())); } -- cgit v1.2.1 From ffd20ee19a5fd027e0007c27a12dd402dbeca4f8 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Tue, 14 Jul 2009 14:32:39 +0000 Subject: Add directory to #include git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@793909 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/FrameDecoder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/cpp/src/tests/FrameDecoder.cpp') diff --git a/qpid/cpp/src/tests/FrameDecoder.cpp b/qpid/cpp/src/tests/FrameDecoder.cpp index f5db66d5fe..2d4e4c6f19 100644 --- a/qpid/cpp/src/tests/FrameDecoder.cpp +++ b/qpid/cpp/src/tests/FrameDecoder.cpp @@ -19,7 +19,7 @@ * */ -#include "unit_test.h" +#include "tests/unit_test.h" #include "qpid/framing/AMQFrame.h" #include "qpid/framing/FrameDecoder.h" #include "qpid/framing/AMQContentBody.h" -- cgit v1.2.1 From 795b3bb9e5c033abf33635119694e21e7143fc0a Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Tue, 14 Jul 2009 14:41:22 +0000 Subject: Remove incorrect directory from #include git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@793912 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/FrameDecoder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/cpp/src/tests/FrameDecoder.cpp') diff --git a/qpid/cpp/src/tests/FrameDecoder.cpp b/qpid/cpp/src/tests/FrameDecoder.cpp index 2d4e4c6f19..f5db66d5fe 100644 --- a/qpid/cpp/src/tests/FrameDecoder.cpp +++ b/qpid/cpp/src/tests/FrameDecoder.cpp @@ -19,7 +19,7 @@ * */ -#include "tests/unit_test.h" +#include "unit_test.h" #include "qpid/framing/AMQFrame.h" #include "qpid/framing/FrameDecoder.h" #include "qpid/framing/AMQContentBody.h" -- cgit v1.2.1 From 9259c46ecb8c5f3e98441080a26914bdea59bffe Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Wed, 9 Sep 2009 19:46:56 +0000 Subject: Tidied up namespace usage Miscelleneous whitespace fixes git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@813094 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/FrameDecoder.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'qpid/cpp/src/tests/FrameDecoder.cpp') diff --git a/qpid/cpp/src/tests/FrameDecoder.cpp b/qpid/cpp/src/tests/FrameDecoder.cpp index f5db66d5fe..9eeff2a41e 100644 --- a/qpid/cpp/src/tests/FrameDecoder.cpp +++ b/qpid/cpp/src/tests/FrameDecoder.cpp @@ -7,9 +7,9 @@ * to you 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 @@ -27,6 +27,9 @@ #include +namespace qpid { +namespace tests { + QPID_AUTO_TEST_SUITE(FrameDecoderTest) using namespace std; @@ -69,5 +72,7 @@ QPID_AUTO_TEST_CASE(testByteFragments) { } - + QPID_AUTO_TEST_SUITE_END() + +}} // namespace qpid::tests -- cgit v1.2.1