qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject svn commit: r450861 - in /incubator/qpid/trunk/qpid/cpp: broker/inc/HeadersExchange.h broker/test/HeadersExchangeTest.cpp broker/test/ValueTest.cpp common/framing/src/AMQBody.cpp common/framing/src/AMQHeartbeatBody.cpp
Date Thu, 28 Sep 2006 14:20:55 GMT
Author: aconway
Date: Thu Sep 28 07:20:54 2006
New Revision: 450861

URL: http://svn.apache.org/viewvc?view=rev&rev=450861
Log:
New files missed from yesterdays checkin, apologies!

Added:
    incubator/qpid/trunk/qpid/cpp/broker/inc/HeadersExchange.h   (with props)
    incubator/qpid/trunk/qpid/cpp/broker/test/HeadersExchangeTest.cpp   (with props)
    incubator/qpid/trunk/qpid/cpp/broker/test/ValueTest.cpp   (with props)
    incubator/qpid/trunk/qpid/cpp/common/framing/src/AMQBody.cpp   (with props)
    incubator/qpid/trunk/qpid/cpp/common/framing/src/AMQHeartbeatBody.cpp   (with props)

Added: incubator/qpid/trunk/qpid/cpp/broker/inc/HeadersExchange.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/broker/inc/HeadersExchange.h?view=auto&rev=450861
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/broker/inc/HeadersExchange.h (added)
+++ incubator/qpid/trunk/qpid/cpp/broker/inc/HeadersExchange.h Thu Sep 28 07:20:54 2006
@@ -0,0 +1,60 @@
+/*
+ *
+ * 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.
+ *
+ */
+#ifndef _HeadersExchange_
+#define _HeadersExchange_
+
+#include <vector>
+#include "Exchange.h"
+#include "FieldTable.h"
+#include "Message.h"
+#include "MonitorImpl.h"
+#include "Queue.h"
+
+namespace qpid {
+namespace broker {
+
+
+class HeadersExchange : public virtual Exchange {    
+    typedef std::pair<qpid::framing::FieldTable, Queue::shared_ptr> Binding;
+    typedef std::vector<Binding> Bindings;
+
+    Bindings bindings;
+    qpid::concurrent::MonitorImpl lock;
+
+  public:
+    static const std::string typeName;
+
+    HeadersExchange(const string& name);
+        
+    virtual void bind(Queue::shared_ptr queue, const string& routingKey, qpid::framing::FieldTable*
args);
+
+    virtual void unbind(Queue::shared_ptr queue, const string& routingKey, qpid::framing::FieldTable*
args);
+
+    virtual void route(Message::shared_ptr& msg, const string& routingKey, qpid::framing::FieldTable*
args);
+
+    virtual ~HeadersExchange();
+
+    static bool match(const qpid::framing::FieldTable& bindArgs, const qpid::framing::FieldTable&
msgArgs);
+};
+
+
+
+}
+}
+
+#endif

Propchange: incubator/qpid/trunk/qpid/cpp/broker/inc/HeadersExchange.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/cpp/broker/test/HeadersExchangeTest.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/broker/test/HeadersExchangeTest.cpp?view=auto&rev=450861
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/broker/test/HeadersExchangeTest.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/broker/test/HeadersExchangeTest.cpp Thu Sep 28 07:20:54
2006
@@ -0,0 +1,115 @@
+/*
+ *
+ * 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 "HeadersExchange.h"
+#include "FieldTable.h"
+#include "Value.h"
+#include <cppunit/TestCase.h>
+#include <cppunit/TextTestRunner.h>
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/plugin/TestPlugIn.h>
+
+using namespace qpid::broker;
+using namespace qpid::framing;
+
+class HeadersExchangeTest : public CppUnit::TestCase
+{
+    CPPUNIT_TEST_SUITE(HeadersExchangeTest);
+    CPPUNIT_TEST(testMatchAll);
+    CPPUNIT_TEST(testMatchAny);
+    CPPUNIT_TEST(testMatchEmptyValue);
+    CPPUNIT_TEST(testMatchEmptyArgs);
+    CPPUNIT_TEST(testMatchNoXMatch);
+    CPPUNIT_TEST_SUITE_END();
+
+  public:
+
+    void testMatchAll() 
+    {
+        FieldTable b, m;
+        b.setString("x-match", "all");
+        b.setString("foo", "FOO");
+        b.setInt("n", 42);
+        m.setString("foo", "FOO");
+        m.setInt("n", 42);
+        CPPUNIT_ASSERT(HeadersExchange::match(b, m));
+
+        // Ignore extras.
+        m.setString("extra", "x");
+        CPPUNIT_ASSERT(HeadersExchange::match(b, m));
+        
+        // Fail mismatch, wrong value.
+        m.setString("foo", "NotFoo");
+        CPPUNIT_ASSERT(!HeadersExchange::match(b, m));
+
+        // Fail mismatch, missing value
+        m.erase("foo");
+        CPPUNIT_ASSERT(!HeadersExchange::match(b, m));
+    }
+
+    void testMatchAny() 
+    {
+        FieldTable b, m;
+        b.setString("x-match", "any");
+        b.setString("foo", "FOO");
+        b.setInt("n", 42);
+        m.setString("foo", "FOO");
+        CPPUNIT_ASSERT(HeadersExchange::match(b, m));
+        m.erase("foo");
+        CPPUNIT_ASSERT(!HeadersExchange::match(b, m));
+        m.setInt("n", 42);
+        CPPUNIT_ASSERT(HeadersExchange::match(b, m));
+    }
+
+    void testMatchEmptyValue() 
+    {
+        FieldTable b, m;
+        b.setString("x-match", "all");
+        b.getMap()["foo"] = FieldTable::ValuePtr(new EmptyValue());
+        b.getMap()["n"] = FieldTable::ValuePtr(new EmptyValue());
+        CPPUNIT_ASSERT(!HeadersExchange::match(b, m));
+        m.setString("foo", "blah");
+        m.setInt("n", 123);
+    }
+
+    void testMatchEmptyArgs()
+    {
+        FieldTable b, m;
+        m.setString("foo", "FOO");
+        
+        b.setString("x-match", "all");
+        CPPUNIT_ASSERT(HeadersExchange::match(b, m));
+        b.setString("x-match", "any");
+        CPPUNIT_ASSERT(!HeadersExchange::match(b, m));
+    }
+    
+
+    void testMatchNoXMatch() 
+    {
+        FieldTable b, m;
+        b.setString("foo", "FOO");
+        m.setString("foo", "FOO");
+        CPPUNIT_ASSERT(!HeadersExchange::match(b, m));
+    }
+    
+    
+};
+    
+// make this test suite a plugin.
+CPPUNIT_PLUGIN_IMPLEMENT();
+CPPUNIT_TEST_SUITE_REGISTRATION(HeadersExchangeTest);

Propchange: incubator/qpid/trunk/qpid/cpp/broker/test/HeadersExchangeTest.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/cpp/broker/test/ValueTest.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/broker/test/ValueTest.cpp?view=auto&rev=450861
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/broker/test/ValueTest.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/broker/test/ValueTest.cpp Thu Sep 28 07:20:54 2006
@@ -0,0 +1,99 @@
+#include "Value.h"
+#include <cppunit/TestCase.h>
+#include <cppunit/TextTestRunner.h>
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/plugin/TestPlugIn.h>
+
+using namespace qpid::framing;
+
+
+// Allow CPPUNIT_EQUALS to print a Tokens.
+// TODO aconway 2006-09-19: Make it a template and put it in a shared test lib.
+//
+template <class T>
+CppUnit::OStringStream& operator <<(CppUnit::OStringStream& out,
+                                    const ValueOps<T>& v)
+{
+    out << v.getValue();
+    return out;
+}
+
+
+class ValueTest : public CppUnit::TestCase 
+{
+    CPPUNIT_TEST_SUITE(ValueTest);
+    CPPUNIT_TEST(testStringValueEquals);
+    CPPUNIT_TEST(testIntegerValueEquals);
+    CPPUNIT_TEST(testDecimalValueEquals);
+    CPPUNIT_TEST(testFieldTableValueEquals);
+    CPPUNIT_TEST_SUITE_END();
+
+    StringValue s;
+    IntegerValue i;
+    DecimalValue d;
+    FieldTableValue ft;
+    EmptyValue e;
+
+  public:
+    ValueTest() :
+        s("abc"),
+        i(42),
+        d(1234,2)
+        
+    {
+        ft.getValue().setString("foo", "FOO");
+        ft.getValue().setInt("magic", 7);
+    }
+    
+    void testStringValueEquals() 
+    {
+        
+        CPPUNIT_ASSERT(StringValue("abc") == s);
+        CPPUNIT_ASSERT(s != StringValue("foo"));
+        CPPUNIT_ASSERT(s != e);
+        CPPUNIT_ASSERT(e != d);
+        CPPUNIT_ASSERT(e != ft);
+    }
+
+    void testIntegerValueEquals()
+    {
+        CPPUNIT_ASSERT(IntegerValue(42) == i);
+        CPPUNIT_ASSERT(IntegerValue(5) != i);
+        CPPUNIT_ASSERT(i != e);
+        CPPUNIT_ASSERT(i != d);
+    }
+
+    void testDecimalValueEquals() 
+    {
+        CPPUNIT_ASSERT(DecimalValue(1234, 2) == d);
+        CPPUNIT_ASSERT(DecimalValue(12345, 2) != d);
+        CPPUNIT_ASSERT(DecimalValue(1234, 3) != d);
+        CPPUNIT_ASSERT(d != s);
+    }
+
+
+    void testFieldTableValueEquals()
+    {
+        CPPUNIT_ASSERT_EQUAL(std::string("FOO"),
+                             ft.getValue().getString("foo"));
+        CPPUNIT_ASSERT_EQUAL(7, ft.getValue().getInt("magic"));
+        
+        FieldTableValue f2;
+        CPPUNIT_ASSERT(ft != f2);
+        f2.getValue().setString("foo", "FOO");
+        CPPUNIT_ASSERT(ft != f2);
+        f2.getValue().setInt("magic", 7);
+        CPPUNIT_ASSERT_EQUAL(ft,f2);
+        CPPUNIT_ASSERT(ft == f2);
+        f2.getValue().setString("foo", "BAR");
+        CPPUNIT_ASSERT(ft != f2);
+        CPPUNIT_ASSERT(ft != i);
+    }
+    
+};
+
+    
+// Make this test suite a plugin.
+CPPUNIT_PLUGIN_IMPLEMENT();
+CPPUNIT_TEST_SUITE_REGISTRATION(ValueTest);
+

Propchange: incubator/qpid/trunk/qpid/cpp/broker/test/ValueTest.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/cpp/common/framing/src/AMQBody.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/src/AMQBody.cpp?view=auto&rev=450861
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/framing/src/AMQBody.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/common/framing/src/AMQBody.cpp Thu Sep 28 07:20:54 2006
@@ -0,0 +1,33 @@
+/*
+ *
+ * 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 "AMQBody.h"
+#include <iostream>
+
+std::ostream& qpid::framing::operator<<(std::ostream& out, const qpid::framing::AMQBody&
body) 
+{
+    body.print(out);
+    return out;
+}
+        
+
+qpid::framing::AMQBody::~AMQBody() {}
+
+void qpid::framing::AMQBody::print(std::ostream& out) const {
+    out << "unknown body";
+}

Propchange: incubator/qpid/trunk/qpid/cpp/common/framing/src/AMQBody.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/cpp/common/framing/src/AMQHeartbeatBody.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/src/AMQHeartbeatBody.cpp?view=auto&rev=450861
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/framing/src/AMQHeartbeatBody.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/common/framing/src/AMQHeartbeatBody.cpp Thu Sep 28 07:20:54
2006
@@ -0,0 +1,26 @@
+/*
+ *
+ * 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 "AMQHeartbeatBody.h"
+#include <iostream>
+
+qpid::framing::AMQHeartbeatBody::~AMQHeartbeatBody() {}
+
+void qpid::framing::AMQHeartbeatBody::print(std::ostream& out) const {
+    out << "heartbeat";
+}

Propchange: incubator/qpid/trunk/qpid/cpp/common/framing/src/AMQHeartbeatBody.cpp
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message