Repository: activemq-cpp Updated Branches: refs/heads/3.9.x 2ad5237ae -> e237191dc
http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/e237191d/activemq-cpp/src/main/activemq/transport/discovery/DiscoveryTransport.h ---------------------------------------------------------------------- diff --git a/activemq-cpp/src/main/activemq/transport/discovery/DiscoveryTransport.h b/activemq-cpp/src/main/activemq/transport/discovery/DiscoveryTransport.h deleted file mode 100644 index b0e47ce..0000000 --- a/activemq-cpp/src/main/activemq/transport/discovery/DiscoveryTransport.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * 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. - */ - -#ifndef _ACTIVEMQ_TRANSPORT_DISCOVERY_DISCOVERYTRANSPORT_H_ -#define _ACTIVEMQ_TRANSPORT_DISCOVERY_DISCOVERYTRANSPORT_H_ - -#include <activemq/util/Config.h> -#include <activemq/transport/CompositeTransport.h> -#include <activemq/transport/TransportFilter.h> -#include <activemq/transport/discovery/DiscoveryListener.h> -#include <activemq/transport/discovery/DiscoveryAgent.h> -#include <decaf/net/URI.h> -#include <decaf/util/Properties.h> - -namespace activemq { -namespace transport { -namespace discovery { - - class DiscoveryTransportData; - - class AMQCPP_API DiscoveryTransport : public TransportFilter, public DiscoveryListener { - public: - - static const std::string DISCOVERED_OPTION_PREFIX; - - private: - - DiscoveryTransport(const DiscoveryTransport&); - DiscoveryTransport& operator=(const DiscoveryTransport&); - - private: - - DiscoveryTransportData* impl; - - public: - - DiscoveryTransport(Pointer<CompositeTransport> next); - - virtual ~DiscoveryTransport(); - - virtual void start(); - - virtual void stop(); - - /** - * Sets the Discovery Agent that this transport will use to discover new Brokers. - * - * @param agent - * The Discovery Agent to use in this transport. - */ - void setDiscoveryAgent(decaf::lang::Pointer<DiscoveryAgent> agent); - - /** - * Returns the currently configured Discovery Agent - * - * @return the pointer to the currently configured agent or NULL if not set. - */ - Pointer<DiscoveryAgent> getDiscoveryAgent() const; - - /** - * Sets the properties that are used for configuration of discovered brokers. - * - * @param properties - * The supplied properties to use to configure new services. - */ - void setParameters(const decaf::util::Properties& properties); - - /** - * Gets the currently set parameters that are applied to newly discovered services URIs. - * - * @return the currently set Properties to apply to new service URIs. - */ - decaf::util::Properties getParameters() const; - - public: - - virtual void onServiceAdd(const activemq::commands::DiscoveryEvent* event); - - virtual void onServiceRemove(const activemq::commands::DiscoveryEvent* event); - - virtual void transportInterrupted(); - - virtual void transportResumed(); - - protected: - - virtual void doClose(); - - }; - -}}} - -#endif /* _ACTIVEMQ_TRANSPORT_DISCOVERY_DISCOVERYTRANSPORT_H_ */ http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/e237191d/activemq-cpp/src/main/activemq/transport/discovery/DiscoveryTransportFactory.cpp ---------------------------------------------------------------------- diff --git a/activemq-cpp/src/main/activemq/transport/discovery/DiscoveryTransportFactory.cpp b/activemq-cpp/src/main/activemq/transport/discovery/DiscoveryTransportFactory.cpp deleted file mode 100644 index 0006b59..0000000 --- a/activemq-cpp/src/main/activemq/transport/discovery/DiscoveryTransportFactory.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* - * 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 "DiscoveryTransportFactory.h" - -#include <activemq/transport/discovery/DiscoveryTransport.h> -#include <activemq/transport/discovery/DiscoveryAgentFactory.h> -#include <activemq/transport/discovery/DiscoveryAgentRegistry.h> -#include <activemq/transport/failover/FailoverTransport.h> -#include <activemq/transport/correlator/ResponseCorrelator.h> -#include <activemq/util/CompositeData.h> -#include <activemq/util/URISupport.h> -#include <activemq/exceptions/ActiveMQException.h> - -#include <decaf/lang/Boolean.h> -#include <decaf/lang/Integer.h> -#include <decaf/lang/Long.h> - -using namespace decaf; -using namespace decaf::util; -using namespace decaf::lang; -using namespace activemq; -using namespace activemq::exceptions; -using namespace activemq::util; -using namespace activemq::transport; -using namespace activemq::transport::discovery; -using namespace activemq::transport::failover; -using namespace activemq::transport::correlator; - -//////////////////////////////////////////////////////////////////////////////// -DiscoveryTransportFactory::~DiscoveryTransportFactory() { -} - -/////////////////////////////////////////////////////////////////////////////// -Pointer<Transport> DiscoveryTransportFactory::create(const decaf::net::URI& location) { - - try { - - // Create the initial Transport, then wrap it in the normal Filters - Pointer<Transport> transport(doCreateTransport(location)); - - // Create the Transport for response correlator - transport.reset(new ResponseCorrelator(transport)); - - return transport; - } - AMQ_CATCH_RETHROW(ActiveMQException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, ActiveMQException) - AMQ_CATCHALL_THROW(ActiveMQException) -} - -/////////////////////////////////////////////////////////////////////////////// -Pointer<Transport> DiscoveryTransportFactory::createComposite(const decaf::net::URI& location) { - try { - return doCreateTransport(location); - } - AMQ_CATCH_RETHROW(ActiveMQException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, ActiveMQException) - AMQ_CATCHALL_THROW(ActiveMQException) -} - -/////////////////////////////////////////////////////////////////////////////// -Pointer<Transport> DiscoveryTransportFactory::doCreateTransport(const decaf::net::URI& location) { - - try { - CompositeData composite = URISupport::parseComposite(location); - - // TODO create using factory and pass in params. - Pointer<CompositeTransport> failover(new FailoverTransport()); - - Pointer<DiscoveryTransport> transport(new DiscoveryTransport(failover)); - - // TODO set all discovery options on the transport. - - URI agentURI = composite.getComponents().get(0); - - DiscoveryAgentFactory* agentFactory = - DiscoveryAgentRegistry::getInstance().findFactory(agentURI.getScheme()); - - // TODO error? - - Pointer<DiscoveryAgent> agent = agentFactory->createAgent(agentURI); - transport->setDiscoveryAgent(agent); - - return transport; - } - AMQ_CATCH_RETHROW(ActiveMQException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, ActiveMQException) - AMQ_CATCHALL_THROW(ActiveMQException) -} http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/e237191d/activemq-cpp/src/main/activemq/transport/discovery/DiscoveryTransportFactory.h ---------------------------------------------------------------------- diff --git a/activemq-cpp/src/main/activemq/transport/discovery/DiscoveryTransportFactory.h b/activemq-cpp/src/main/activemq/transport/discovery/DiscoveryTransportFactory.h deleted file mode 100644 index 3faec6e..0000000 --- a/activemq-cpp/src/main/activemq/transport/discovery/DiscoveryTransportFactory.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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. - */ - -#ifndef _ACTIVEMQ_TRANSPORT_DISCOVERY_DISCOVERYTRANSPORTFACTORY_H_ -#define _ACTIVEMQ_TRANSPORT_DISCOVERY_DISCOVERYTRANSPORTFACTORY_H_ - -#include <activemq/util/Config.h> -#include <activemq/transport/AbstractTransportFactory.h> -#include <activemq/transport/Transport.h> -#include <decaf/net/URI.h> -#include <decaf/util/Properties.h> - -namespace activemq { -namespace transport { -namespace discovery { - - /** - * Creates an instance of a DiscoveryTransport. - * - * @since 3.9 - */ - class AMQCPP_API DiscoveryTransportFactory : public AbstractTransportFactory { - public: - - virtual ~DiscoveryTransportFactory(); - - virtual Pointer<Transport> create(const decaf::net::URI& location); - - virtual Pointer<Transport> createComposite(const decaf::net::URI& location); - - protected: - - virtual Pointer<Transport> doCreateTransport(const decaf::net::URI& location); - - }; - -}}} - -#endif /* _ACTIVEMQ_TRANSPORT_DISCOVERY_DISCOVERYTRANSPORTFACTORY_H_ */ http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/e237191d/activemq-cpp/src/main/activemq/transport/discovery/http/HttpDiscoveryAgent.cpp ---------------------------------------------------------------------- diff --git a/activemq-cpp/src/main/activemq/transport/discovery/http/HttpDiscoveryAgent.cpp b/activemq-cpp/src/main/activemq/transport/discovery/http/HttpDiscoveryAgent.cpp deleted file mode 100644 index 1a450bf..0000000 --- a/activemq-cpp/src/main/activemq/transport/discovery/http/HttpDiscoveryAgent.cpp +++ /dev/null @@ -1,197 +0,0 @@ -/* - * 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 <activemq/transport/discovery/http/HttpDiscoveryAgent.h> - -#include <decaf/lang/Long.h> -#include <decaf/net/URI.h> -#include <decaf/util/HashSet.h> -#include <decaf/util/concurrent/Mutex.h> -#include <decaf/net/SocketFactory.h> -#include <decaf/net/Socket.h> -#include <decaf/io/InputStream.h> -#include <decaf/io/OutputStream.h> -#include <decaf/io/DataInputStream.h> -#include <decaf/io/DataOutputStream.h> -#include <decaf/io/BufferedInputStream.h> -#include <decaf/io/BufferedOutputStream.h> - -using namespace activemq; -using namespace activemq::util; -using namespace activemq::transport; -using namespace activemq::transport::discovery; -using namespace activemq::transport::discovery::http; -using namespace decaf; -using namespace decaf::io; -using namespace decaf::net; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; -using namespace decaf::util; -using namespace decaf::util::concurrent; - -//////////////////////////////////////////////////////////////////////////////// -namespace activemq { -namespace transport { -namespace discovery { -namespace http { - - enum UpdateState { - SUSPENDED, - RESUMING, - RESUMED - }; - - class HttpDiscoveryAgentImpl { - private: - - HttpDiscoveryAgentImpl(const HttpDiscoveryAgentImpl&); - HttpDiscoveryAgentImpl& operator= (const HttpDiscoveryAgentImpl&); - - public: - - UpdateState updateState; - Mutex updateLock; - long long updateInterval; - URI registryUrl; - - public: - - HttpDiscoveryAgentImpl() : updateState(RESUMED), - updateLock(), - updateInterval(10 * 1000), - registryUrl() { - } - - HashSet<std::string> doLookup() { - - HashSet<std::string> result; - try { - return result; - } catch (Exception& e) { - std::cout << "Caught exception: " << e.getMessage() << std::endl; - } - - return result; - } - }; - -}}}} - -//////////////////////////////////////////////////////////////////////////////// -HttpDiscoveryAgent::HttpDiscoveryAgent() : AbstractDiscoveryAgent(), impl(new HttpDiscoveryAgentImpl) { -} - -//////////////////////////////////////////////////////////////////////////////// -HttpDiscoveryAgent::~HttpDiscoveryAgent() { - try { - delete this->impl; - } - DECAF_CATCHALL_NOTHROW() -} - -//////////////////////////////////////////////////////////////////////////////// -std::string HttpDiscoveryAgent::toString() const { - return "HttpDiscoveryAgent"; -} - -//////////////////////////////////////////////////////////////////////////////// -void HttpDiscoveryAgent::suspend() { - synchronized(&impl->updateLock) { - impl->updateState = SUSPENDED; - } -} - -//////////////////////////////////////////////////////////////////////////////// -void HttpDiscoveryAgent::resume() { - synchronized(&impl->updateLock) { - impl->updateState = RESUMING; - impl->updateLock.notify(); - } -} - -//////////////////////////////////////////////////////////////////////////////// -void HttpDiscoveryAgent::doStart() { - - if (impl->registryUrl.toString().empty()) { - impl->registryUrl = getDiscoveryURI(); - } - - resume(); -} - -//////////////////////////////////////////////////////////////////////////////// -void HttpDiscoveryAgent::doStop() { - suspend(); -} - -//////////////////////////////////////////////////////////////////////////////// -void HttpDiscoveryAgent::doAdvertizeSelf() { - -} - -//////////////////////////////////////////////////////////////////////////////// -void HttpDiscoveryAgent::setUpdateInterval(long long updateInterval) { - impl->updateInterval = updateInterval; -} - -//////////////////////////////////////////////////////////////////////////////// -long long HttpDiscoveryAgent::getUpdateInterval() const { - return impl->updateInterval; -} - -//////////////////////////////////////////////////////////////////////////////// -void HttpDiscoveryAgent::setRegistryURL(const std::string& registryUrl) { - impl->registryUrl.create(registryUrl); -} - -//////////////////////////////////////////////////////////////////////////////// -std::string HttpDiscoveryAgent::getRegistryURL() const{ - return impl->registryUrl.toString(); -} - -//////////////////////////////////////////////////////////////////////////////// -void HttpDiscoveryAgent::doDiscovery() { - try { - updateServices(); - synchronized(&impl->updateLock) { - do { - if (impl->updateState == RESUMING) { - impl->updateState = RESUMED; - } else { - impl->updateLock.wait(impl->updateInterval); - } - } while (impl->updateState == SUSPENDED && isStarted()); - } - } catch (InterruptedException& e) { - return; - } -} - -//////////////////////////////////////////////////////////////////////////////// -void HttpDiscoveryAgent::updateServices() { - DiscoveryListener* discoveryListener = getDiscoveryListener(); - if (discoveryListener != NULL) { - HashSet<std::string> activeServices = impl->doLookup(); - if (activeServices.isEmpty()) { - Pointer< Iterator<std::string> > discovered(activeServices.iterator()); - while (discovered->hasNext()) { - std::string service = discovered->next(); - processLiveService("", service); - } - } - } -} http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/e237191d/activemq-cpp/src/main/activemq/transport/discovery/http/HttpDiscoveryAgent.h ---------------------------------------------------------------------- diff --git a/activemq-cpp/src/main/activemq/transport/discovery/http/HttpDiscoveryAgent.h b/activemq-cpp/src/main/activemq/transport/discovery/http/HttpDiscoveryAgent.h deleted file mode 100644 index b31b461..0000000 --- a/activemq-cpp/src/main/activemq/transport/discovery/http/HttpDiscoveryAgent.h +++ /dev/null @@ -1,117 +0,0 @@ -/* - * 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. - */ - -#ifndef _ACTIVEMQ_TRANSPORT_DISCOVERY_HTTP_HTTPDISCOVERYAGENT_H_ -#define _ACTIVEMQ_TRANSPORT_DISCOVERY_HTTP_HTTPDISCOVERYAGENT_H_ - -#include <activemq/util/Config.h> - -#include <activemq/util/Suspendable.h> -#include <activemq/transport/discovery/AbstractDiscoveryAgent.h> - -namespace activemq { -namespace transport { -namespace discovery { -namespace http { - - class HttpDiscoveryAgentImpl; - - /** - * HTTP based discovery agent that reads a list of active Brokers from a GET - * request. - * - * @since 3.9.0 - */ - class AMQCPP_API HttpDiscoveryAgent : public AbstractDiscoveryAgent { - private: - - HttpDiscoveryAgent(const HttpDiscoveryAgent&); - HttpDiscoveryAgent& operator= (const HttpDiscoveryAgent&); - - private: - - HttpDiscoveryAgentImpl* impl; - - public: - - HttpDiscoveryAgent(); - - virtual ~HttpDiscoveryAgent(); - - /** - * Suspend updates from the configured HTTP registry service. - */ - virtual void suspend(); - - /** - * Resume updates from the configured HTTP registry service. - */ - virtual void resume(); - - /** - * Sets the amount of time the agent waits before attempting to fetch the list - * of registered Brokers from the configured HTTP registry service. - * - * @param updateInterval - * Time in milliseconds to wait between update attempts. - */ - void setUpdateInterval(long long updateInterval); - - /** - * Gets the amount of time the agent waits before attempting to fetch the list - * of registered Brokers from the configured HTTP registry service. - * - * @return Time in milliseconds to wait between update attempts. - */ - long long getUpdateInterval() const; - - /** - * Sets the URL for the Broker registry where the agent gets its updates. - * - * @param registryUrl - * The URL to poll for registry entries. - */ - void setRegistryURL(const std::string& registryUrl); - - /** - * Gets the URL for the Broker registry where the agent gets its updates. - * - * @return The URL to poll for registry entries. - */ - std::string getRegistryURL() const; - - public: - - virtual void doStart(); - - virtual void doStop(); - - virtual void doAdvertizeSelf(); - - virtual void doDiscovery(); - - virtual std::string toString() const; - - protected: - - virtual void updateServices(); - - }; - -}}}} - -#endif /* _ACTIVEMQ_TRANSPORT_DISCOVERY_HTTP_HTTPDISCOVERYAGENT_H_ */ http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/e237191d/activemq-cpp/src/main/activemq/transport/discovery/http/HttpDiscoveryAgentFactory.cpp ---------------------------------------------------------------------- diff --git a/activemq-cpp/src/main/activemq/transport/discovery/http/HttpDiscoveryAgentFactory.cpp b/activemq-cpp/src/main/activemq/transport/discovery/http/HttpDiscoveryAgentFactory.cpp deleted file mode 100644 index 2900e28..0000000 --- a/activemq-cpp/src/main/activemq/transport/discovery/http/HttpDiscoveryAgentFactory.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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 <activemq/transport/discovery/http/HttpDiscoveryAgentFactory.h> - -#include <activemq/transport/discovery/http/HttpDiscoveryAgent.h> -#include <activemq/exceptions/ActiveMQException.h> - -using namespace activemq; -using namespace activemq::exceptions; -using namespace activemq::util; -using namespace activemq::transport; -using namespace activemq::transport::discovery; -using namespace activemq::transport::discovery::http; -using namespace decaf; -using namespace decaf::lang; -using namespace decaf::util; - -//////////////////////////////////////////////////////////////////////////////// -HttpDiscoveryAgentFactory::~HttpDiscoveryAgentFactory() { -} - -//////////////////////////////////////////////////////////////////////////////// -Pointer<AbstractDiscoveryAgent> HttpDiscoveryAgentFactory::doCreateAgent() { - return Pointer<AbstractDiscoveryAgent>(new HttpDiscoveryAgent); -} - -//////////////////////////////////////////////////////////////////////////////// -void HttpDiscoveryAgentFactory::doConfigureAgent(Pointer<AbstractDiscoveryAgent> agent AMQCPP_UNUSED, const Properties& options AMQCPP_UNUSED) { - - try { - - } - AMQ_CATCH_RETHROW(ActiveMQException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, ActiveMQException) - AMQ_CATCHALL_THROW(ActiveMQException) -} http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/e237191d/activemq-cpp/src/main/activemq/transport/discovery/http/HttpDiscoveryAgentFactory.h ---------------------------------------------------------------------- diff --git a/activemq-cpp/src/main/activemq/transport/discovery/http/HttpDiscoveryAgentFactory.h b/activemq-cpp/src/main/activemq/transport/discovery/http/HttpDiscoveryAgentFactory.h deleted file mode 100644 index fc2958f..0000000 --- a/activemq-cpp/src/main/activemq/transport/discovery/http/HttpDiscoveryAgentFactory.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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. - */ - -#ifndef _ACTIVEMQ_TRANSPORT_DISCOVERY_HTTP_HTTPDISCOVERYAGENTFACTORY_H_ -#define _ACTIVEMQ_TRANSPORT_DISCOVERY_HTTP_HTTPDISCOVERYAGENTFACTORY_H_ - -#include <activemq/util/Config.h> - -#include <activemq/transport/discovery/AbstractDiscoveryAgentFactory.h> -#include <decaf/lang/Pointer.h> - -namespace activemq { -namespace transport { -namespace discovery { -namespace http { - - class AMQCPP_API HttpDiscoveryAgentFactory : public AbstractDiscoveryAgentFactory { - public: - - virtual ~HttpDiscoveryAgentFactory(); - - protected: - - virtual decaf::lang::Pointer<AbstractDiscoveryAgent> doCreateAgent(); - - virtual void doConfigureAgent(decaf::lang::Pointer<AbstractDiscoveryAgent> agent, - const decaf::util::Properties& options); - - }; - -}}}} - -#endif /* _ACTIVEMQ_TRANSPORT_DISCOVERY_HTTP_HTTPDISCOVERYAGENTFACTORY_H_ */ http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/e237191d/activemq-cpp/src/test/Makefile.am ---------------------------------------------------------------------- diff --git a/activemq-cpp/src/test/Makefile.am b/activemq-cpp/src/test/Makefile.am index ab6e7b9..1e0ec4b 100644 --- a/activemq-cpp/src/test/Makefile.am +++ b/activemq-cpp/src/test/Makefile.am @@ -55,10 +55,6 @@ cc_sources = \ activemq/transport/IOTransportTest.cpp \ activemq/transport/TransportRegistryTest.cpp \ activemq/transport/correlator/ResponseCorrelatorTest.cpp \ - activemq/transport/discovery/AbstractDiscoveryAgentFactoryTest.cpp \ - activemq/transport/discovery/AbstractDiscoveryAgentTest.cpp \ - activemq/transport/discovery/DiscoveryAgentRegistryTest.cpp \ - activemq/transport/discovery/DiscoveryTransportFactoryTest.cpp \ activemq/transport/failover/FailoverTransportTest.cpp \ activemq/transport/inactivity/InactivityMonitorTest.cpp \ activemq/transport/mock/MockTransportFactoryTest.cpp \ @@ -312,10 +308,6 @@ h_sources = \ activemq/transport/IOTransportTest.h \ activemq/transport/TransportRegistryTest.h \ activemq/transport/correlator/ResponseCorrelatorTest.h \ - activemq/transport/discovery/AbstractDiscoveryAgentFactoryTest.h \ - activemq/transport/discovery/AbstractDiscoveryAgentTest.h \ - activemq/transport/discovery/DiscoveryAgentRegistryTest.h \ - activemq/transport/discovery/DiscoveryTransportFactoryTest.h \ activemq/transport/failover/FailoverTransportTest.h \ activemq/transport/inactivity/InactivityMonitorTest.h \ activemq/transport/mock/MockTransportFactoryTest.h \ http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/e237191d/activemq-cpp/src/test/activemq/transport/discovery/AbstractDiscoveryAgentFactoryTest.cpp ---------------------------------------------------------------------- diff --git a/activemq-cpp/src/test/activemq/transport/discovery/AbstractDiscoveryAgentFactoryTest.cpp b/activemq-cpp/src/test/activemq/transport/discovery/AbstractDiscoveryAgentFactoryTest.cpp deleted file mode 100644 index 4435b2e..0000000 --- a/activemq-cpp/src/test/activemq/transport/discovery/AbstractDiscoveryAgentFactoryTest.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* - * 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 "AbstractDiscoveryAgentFactoryTest.h" - -#include <activemq/transport/discovery/AbstractDiscoveryAgent.h> -#include <activemq/transport/discovery/AbstractDiscoveryAgentFactory.h> -#include <activemq/transport/discovery/DiscoveryAgentRegistry.h> - -#include <decaf/net/URI.h> - -using namespace activemq; -using namespace activemq::transport; -using namespace activemq::transport::discovery; -using namespace decaf; -using namespace decaf::util; -using namespace decaf::net; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; - -//////////////////////////////////////////////////////////////////////////////// -namespace { - - class MockDiscoveryAgent : public AbstractDiscoveryAgent { - private: - - bool reported; - - public: - - virtual ~MockDiscoveryAgent() {} - - virtual std::string toString() const { return "MockDiscoveryAgent"; } - - protected: - - virtual void doStart() { - reported = false; - } - - virtual void doStop() {} - - virtual void doAdvertizeSelf() {} - - virtual void doDiscovery() { - try { - if (!reported) { - Thread::sleep(1000); - processLiveService("dummy", "mock://localhost"); - reported = true; - } else { - Thread::sleep(500); - } - } catch (InterruptedException& ex) { - } - } - }; - - class MockDiscoveryAgentFactory : public AbstractDiscoveryAgentFactory { - public: - - virtual ~MockDiscoveryAgentFactory() {} - - virtual decaf::lang::Pointer<AbstractDiscoveryAgent> doCreateAgent() { - return Pointer<AbstractDiscoveryAgent>(new MockDiscoveryAgent); - } - - }; - -} - -//////////////////////////////////////////////////////////////////////////////// -AbstractDiscoveryAgentFactoryTest::AbstractDiscoveryAgentFactoryTest() { -} - -//////////////////////////////////////////////////////////////////////////////// -AbstractDiscoveryAgentFactoryTest::~AbstractDiscoveryAgentFactoryTest() { -} - -//////////////////////////////////////////////////////////////////////////////// -void AbstractDiscoveryAgentFactoryTest::test() { - - DiscoveryAgentRegistry& registry = DiscoveryAgentRegistry::getInstance(); - registry.registerFactory("mock", new MockDiscoveryAgentFactory); - - CPPUNIT_ASSERT_EQUAL(1, (int) registry.getAgentNames().size()); - - DiscoveryAgentFactory* factory = registry.findFactory("mock"); - CPPUNIT_ASSERT(factory != NULL); - - Pointer<DiscoveryAgent> agent(factory->createAgent(URI("mock://default"))); - CPPUNIT_ASSERT(agent != NULL); - - Pointer<MockDiscoveryAgent> mock = agent.dynamicCast<MockDiscoveryAgent>(); - CPPUNIT_ASSERT(mock != NULL); - - registry.unregisterAllFactories(); -} http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/e237191d/activemq-cpp/src/test/activemq/transport/discovery/AbstractDiscoveryAgentFactoryTest.h ---------------------------------------------------------------------- diff --git a/activemq-cpp/src/test/activemq/transport/discovery/AbstractDiscoveryAgentFactoryTest.h b/activemq-cpp/src/test/activemq/transport/discovery/AbstractDiscoveryAgentFactoryTest.h deleted file mode 100644 index a69eeee..0000000 --- a/activemq-cpp/src/test/activemq/transport/discovery/AbstractDiscoveryAgentFactoryTest.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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. - */ - -#ifndef _ACTIVEMQ_TRANSPORT_DISCOVERY_ABSTRACTDISCOVERYAGENTFACTORYTEST_H_ -#define _ACTIVEMQ_TRANSPORT_DISCOVERY_ABSTRACTDISCOVERYAGENTFACTORYTEST_H_ - -#include <cppunit/TestFixture.h> -#include <cppunit/extensions/HelperMacros.h> - -namespace activemq { -namespace transport { -namespace discovery { - - class AbstractDiscoveryAgentFactoryTest : public CppUnit::TestFixture { - - CPPUNIT_TEST_SUITE(AbstractDiscoveryAgentFactoryTest); - CPPUNIT_TEST( test ); - CPPUNIT_TEST_SUITE_END(); - - public: - - AbstractDiscoveryAgentFactoryTest(); - virtual ~AbstractDiscoveryAgentFactoryTest(); - - void test(); - - }; - -}}} - -#endif /* _ACTIVEMQ_TRANSPORT_DISCOVERY_ABSTRACTDISCOVERYAGENTFACTORYTEST_H_ */ http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/e237191d/activemq-cpp/src/test/activemq/transport/discovery/AbstractDiscoveryAgentTest.cpp ---------------------------------------------------------------------- diff --git a/activemq-cpp/src/test/activemq/transport/discovery/AbstractDiscoveryAgentTest.cpp b/activemq-cpp/src/test/activemq/transport/discovery/AbstractDiscoveryAgentTest.cpp deleted file mode 100644 index 7595bd5..0000000 --- a/activemq-cpp/src/test/activemq/transport/discovery/AbstractDiscoveryAgentTest.cpp +++ /dev/null @@ -1,145 +0,0 @@ -/* - * 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 "AbstractDiscoveryAgentTest.h" - -#include <activemq/transport/discovery/DiscoveryListener.h> -#include <activemq/transport/discovery/AbstractDiscoveryAgent.h> -#include <activemq/transport/discovery/DiscoveryAgentFactory.h> -#include <activemq/transport/discovery/DiscoveryAgentRegistry.h> - -#include <decaf/net/URI.h> -#include <decaf/util/concurrent/CountDownLatch.h> - -using namespace activemq; -using namespace activemq::transport; -using namespace activemq::transport::discovery; -using namespace decaf; -using namespace decaf::util; -using namespace decaf::util::concurrent; -using namespace decaf::net; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; - -//////////////////////////////////////////////////////////////////////////////// -namespace { - - class MockDiscoveryAgent : public AbstractDiscoveryAgent { - private: - - bool reported; - - public: - - virtual ~MockDiscoveryAgent() {} - - virtual std::string toString() const { return "MockDiscoveryAgent"; } - - protected: - - virtual void doStart() { - reported = false; - } - - virtual void doStop() {} - - virtual void doAdvertizeSelf() {} - - virtual void doDiscovery() { - try { - if (!reported) { - Thread::sleep(1000); - processLiveService("dummy", "mock://localhost"); - reported = true; - } else { - Thread::sleep(500); - } - } catch (InterruptedException& ex) { - } - } - - }; - - class MockDiscoveryAgentFactory : public DiscoveryAgentFactory { - public: - - virtual ~MockDiscoveryAgentFactory() {} - - virtual decaf::lang::Pointer<DiscoveryAgent> createAgent(const decaf::net::URI& agentURI) { - return Pointer<DiscoveryAgent>(new MockDiscoveryAgent); - } - - }; - - class MockDiscoveryListener : public DiscoveryListener { - public: - - CountDownLatch* added; - CountDownLatch* removed; - - public: - - MockDiscoveryListener(CountDownLatch* added, CountDownLatch* removed) : - DiscoveryListener(), added(added), removed(removed) {} - virtual ~MockDiscoveryListener() {} - - virtual void onServiceAdd(const activemq::commands::DiscoveryEvent* event) { - added->countDown(); - } - - virtual void onServiceRemove(const activemq::commands::DiscoveryEvent* event) { - removed->countDown(); - } - }; - -} - -//////////////////////////////////////////////////////////////////////////////// -AbstractDiscoveryAgentTest::AbstractDiscoveryAgentTest() { -} - -//////////////////////////////////////////////////////////////////////////////// -AbstractDiscoveryAgentTest::~AbstractDiscoveryAgentTest() { -} - -//////////////////////////////////////////////////////////////////////////////// -void AbstractDiscoveryAgentTest::test() { - - CountDownLatch added(1); - CountDownLatch removed(1); - - MockDiscoveryListener listener(&added, &removed); - - DiscoveryAgentRegistry& registry = DiscoveryAgentRegistry::getInstance(); - registry.registerFactory("mock", new MockDiscoveryAgentFactory); - - CPPUNIT_ASSERT_EQUAL(1, (int) registry.getAgentNames().size()); - - DiscoveryAgentFactory* factory = registry.findFactory("mock"); - CPPUNIT_ASSERT(factory != NULL); - - Pointer<DiscoveryAgent> agent(factory->createAgent(URI("mock://default"))); - CPPUNIT_ASSERT(agent != NULL); - - agent->setDiscoveryListener(&listener); - agent->start(); - - CPPUNIT_ASSERT_MESSAGE("Should have discovered by now", added.await(60000)); - CPPUNIT_ASSERT_MESSAGE("Should have timed out by now", removed.await(60000)); - - registry.unregisterAllFactories(); -} http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/e237191d/activemq-cpp/src/test/activemq/transport/discovery/AbstractDiscoveryAgentTest.h ---------------------------------------------------------------------- diff --git a/activemq-cpp/src/test/activemq/transport/discovery/AbstractDiscoveryAgentTest.h b/activemq-cpp/src/test/activemq/transport/discovery/AbstractDiscoveryAgentTest.h deleted file mode 100644 index e7d681d..0000000 --- a/activemq-cpp/src/test/activemq/transport/discovery/AbstractDiscoveryAgentTest.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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. - */ - -#ifndef _ACTIVEMQ_TRANSPORT_DISCOVERY_ABSTRACTDISCOVERYAGENTTEST_H_ -#define _ACTIVEMQ_TRANSPORT_DISCOVERY_ABSTRACTDISCOVERYAGENTTEST_H_ - -#include <cppunit/TestFixture.h> -#include <cppunit/extensions/HelperMacros.h> - -namespace activemq { -namespace transport { -namespace discovery { - - class AbstractDiscoveryAgentTest : public CppUnit::TestFixture { - - CPPUNIT_TEST_SUITE(AbstractDiscoveryAgentTest); - CPPUNIT_TEST( test ); - CPPUNIT_TEST_SUITE_END(); - - public: - - AbstractDiscoveryAgentTest(); - virtual ~AbstractDiscoveryAgentTest(); - - void test(); - - }; - -}}} - -#endif /* _ACTIVEMQ_TRANSPORT_DISCOVERY_ABSTRACTDISCOVERYAGENTTEST_H_ */ http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/e237191d/activemq-cpp/src/test/activemq/transport/discovery/DiscoveryAgentRegistryTest.cpp ---------------------------------------------------------------------- diff --git a/activemq-cpp/src/test/activemq/transport/discovery/DiscoveryAgentRegistryTest.cpp b/activemq-cpp/src/test/activemq/transport/discovery/DiscoveryAgentRegistryTest.cpp deleted file mode 100644 index 891d2bf..0000000 --- a/activemq-cpp/src/test/activemq/transport/discovery/DiscoveryAgentRegistryTest.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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 "DiscoveryAgentRegistryTest.h" - -#include <activemq/transport/discovery/DiscoveryAgent.h> -#include <activemq/transport/discovery/DiscoveryAgentFactory.h> -#include <activemq/transport/discovery/DiscoveryAgentRegistry.h> - -#include <decaf/net/URI.h> - -using namespace activemq; -using namespace activemq::transport; -using namespace activemq::transport::discovery; -using namespace decaf; -using namespace decaf::util; -using namespace decaf::net; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; - -//////////////////////////////////////////////////////////////////////////////// -namespace { - - class MockDiscoveryAgent : public DiscoveryAgent { - public: - - virtual void start() {} - virtual void stop() {} - virtual void setDiscoveryListener(DiscoveryListener* listener) {} - virtual void registerService(const std::string& name) {} - virtual void serviceFailed(const activemq::commands::DiscoveryEvent& event) {} - virtual std::string toString() const { return "MockDiscoveryAgent"; } - virtual URI getDiscoveryURI() const { return URI(); } - virtual void setDiscoveryURI(const URI& discoveryURI) {} - }; - - class MockDiscoveryAgentFactory : public DiscoveryAgentFactory { - public: - - virtual ~MockDiscoveryAgentFactory() {} - - virtual decaf::lang::Pointer<DiscoveryAgent> createAgent(const decaf::net::URI& agentURI) { - return Pointer<DiscoveryAgent>(new MockDiscoveryAgent); - } - - }; - -} - -//////////////////////////////////////////////////////////////////////////////// -DiscoveryAgentRegistryTest::DiscoveryAgentRegistryTest() { -} - -//////////////////////////////////////////////////////////////////////////////// -DiscoveryAgentRegistryTest::~DiscoveryAgentRegistryTest() { -} - -//////////////////////////////////////////////////////////////////////////////// -void DiscoveryAgentRegistryTest::test() { - - DiscoveryAgentRegistry& registry = DiscoveryAgentRegistry::getInstance(); - registry.registerFactory("mock", new MockDiscoveryAgentFactory); - - CPPUNIT_ASSERT_EQUAL(1, (int) registry.getAgentNames().size()); - - DiscoveryAgentFactory* factory = registry.findFactory("mock"); - CPPUNIT_ASSERT(factory != NULL); - - Pointer<DiscoveryAgent> agent(factory->createAgent(URI("mock://default"))); - CPPUNIT_ASSERT(agent != NULL); - - Pointer<MockDiscoveryAgent> mock = agent.dynamicCast<MockDiscoveryAgent>(); - CPPUNIT_ASSERT(mock != NULL); - - registry.unregisterAllFactories(); -} http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/e237191d/activemq-cpp/src/test/activemq/transport/discovery/DiscoveryAgentRegistryTest.h ---------------------------------------------------------------------- diff --git a/activemq-cpp/src/test/activemq/transport/discovery/DiscoveryAgentRegistryTest.h b/activemq-cpp/src/test/activemq/transport/discovery/DiscoveryAgentRegistryTest.h deleted file mode 100644 index 761aec1..0000000 --- a/activemq-cpp/src/test/activemq/transport/discovery/DiscoveryAgentRegistryTest.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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. - */ - -#ifndef _ACTIVEMQ_TRANSPORT_DISCOVERY_DISCOVERYAGENTREGISTRYTEST_H_ -#define _ACTIVEMQ_TRANSPORT_DISCOVERY_DISCOVERYAGENTREGISTRYTEST_H_ - -#include <cppunit/TestFixture.h> -#include <cppunit/extensions/HelperMacros.h> - -namespace activemq { -namespace transport { -namespace discovery { - - class DiscoveryAgentRegistryTest : public CppUnit::TestFixture { - - CPPUNIT_TEST_SUITE( DiscoveryAgentRegistryTest ); - CPPUNIT_TEST( test ); - CPPUNIT_TEST_SUITE_END(); - - public: - - DiscoveryAgentRegistryTest(); - virtual ~DiscoveryAgentRegistryTest(); - - void test(); - - }; - -}}} - -#endif /* _ACTIVEMQ_TRANSPORT_DISCOVERY_DISCOVERYAGENTREGISTRYTEST_H_ */ http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/e237191d/activemq-cpp/src/test/activemq/transport/discovery/DiscoveryTransportFactoryTest.cpp ---------------------------------------------------------------------- diff --git a/activemq-cpp/src/test/activemq/transport/discovery/DiscoveryTransportFactoryTest.cpp b/activemq-cpp/src/test/activemq/transport/discovery/DiscoveryTransportFactoryTest.cpp deleted file mode 100644 index 1f188aa..0000000 --- a/activemq-cpp/src/test/activemq/transport/discovery/DiscoveryTransportFactoryTest.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/* - * 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 "DiscoveryTransportFactoryTest.h" - -#include <activemq/transport/discovery/DiscoveryAgent.h> -#include <activemq/transport/discovery/DiscoveryAgentFactory.h> -#include <activemq/transport/discovery/DiscoveryAgentRegistry.h> -#include <activemq/transport/discovery/DiscoveryTransportFactory.h> -#include <activemq/transport/discovery/DiscoveryTransport.h> - -#include <decaf/net/URI.h> - -using namespace activemq; -using namespace activemq::transport; -using namespace activemq::transport::discovery; -using namespace decaf; -using namespace decaf::util; -using namespace decaf::net; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; - -//////////////////////////////////////////////////////////////////////////////// -namespace { - - class MockDiscoveryAgent : public DiscoveryAgent { - public: - - virtual ~MockDiscoveryAgent() {} - - virtual void start() {} - virtual void stop() {} - virtual void setDiscoveryListener(DiscoveryListener* listener) {} - virtual void registerService(const std::string& name) {} - virtual void serviceFailed(const activemq::commands::DiscoveryEvent& event) {} - virtual std::string toString() const { return "MockDiscoveryAgent"; } - virtual URI getDiscoveryURI() const { return URI(); } - virtual void setDiscoveryURI(const URI& discoveryURI) {} - }; - - class MockDiscoveryAgentFactory : public DiscoveryAgentFactory { - public: - - virtual ~MockDiscoveryAgentFactory() {} - - virtual decaf::lang::Pointer<DiscoveryAgent> createAgent(const decaf::net::URI& agentURI) { - return Pointer<DiscoveryAgent>(new MockDiscoveryAgent); - } - - }; - - class MyTransportListener : public TransportListener { - public: - - MyTransportListener() {} - - virtual ~MyTransportListener() {} - - virtual void onCommand(const Pointer<Command> command) { - } - - virtual void onException(const decaf::lang::Exception& ex) { - } - - virtual void transportInterrupted() { - } - - virtual void transportResumed() { - } - }; - -} - -//////////////////////////////////////////////////////////////////////////////// -DiscoveryTransportFactoryTest::DiscoveryTransportFactoryTest() { -} - -//////////////////////////////////////////////////////////////////////////////// -DiscoveryTransportFactoryTest::~DiscoveryTransportFactoryTest() { -} - -//////////////////////////////////////////////////////////////////////////////// -void DiscoveryTransportFactoryTest::setUp() { - - DiscoveryAgentRegistry& registry = DiscoveryAgentRegistry::getInstance(); - registry.registerFactory("mock", new MockDiscoveryAgentFactory); -} - -//////////////////////////////////////////////////////////////////////////////// -void DiscoveryTransportFactoryTest::test() { - - DiscoveryTransportFactory factory; - - Pointer<Transport> transport = factory.create(URI("discovery:mock://default")); - CPPUNIT_ASSERT(transport != NULL); - - MyTransportListener listener; - - transport->setTransportListener(&listener); - transport->start(); - transport->close(); -} http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/e237191d/activemq-cpp/src/test/activemq/transport/discovery/DiscoveryTransportFactoryTest.h ---------------------------------------------------------------------- diff --git a/activemq-cpp/src/test/activemq/transport/discovery/DiscoveryTransportFactoryTest.h b/activemq-cpp/src/test/activemq/transport/discovery/DiscoveryTransportFactoryTest.h deleted file mode 100644 index 093dac0..0000000 --- a/activemq-cpp/src/test/activemq/transport/discovery/DiscoveryTransportFactoryTest.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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. - */ - -#ifndef _ACTIVEMQ_TRANSPORT_DISCOVERY_DISCOVERYTRANSPORTFACTORYTEST_H_ -#define _ACTIVEMQ_TRANSPORT_DISCOVERY_DISCOVERYTRANSPORTFACTORYTEST_H_ - -#include <cppunit/TestFixture.h> -#include <cppunit/extensions/HelperMacros.h> - -namespace activemq { -namespace transport { -namespace discovery { - - class DiscoveryTransportFactoryTest : public CppUnit::TestFixture { - - CPPUNIT_TEST_SUITE( DiscoveryTransportFactoryTest ); - CPPUNIT_TEST( test ); - CPPUNIT_TEST_SUITE_END(); - - public: - - DiscoveryTransportFactoryTest(); - virtual ~DiscoveryTransportFactoryTest(); - - void test(); - - virtual void setUp(); - - }; - -}}} - -#endif /* _ACTIVEMQ_TRANSPORT_DISCOVERY_DISCOVERYTRANSPORTFACTORYTEST_H_ */ http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/e237191d/activemq-cpp/src/test/testRegistry.cpp ---------------------------------------------------------------------- diff --git a/activemq-cpp/src/test/testRegistry.cpp b/activemq-cpp/src/test/testRegistry.cpp index 4936891..dcea2a7 100644 --- a/activemq-cpp/src/test/testRegistry.cpp +++ b/activemq-cpp/src/test/testRegistry.cpp @@ -121,15 +121,6 @@ CPPUNIT_TEST_SUITE_REGISTRATION( activemq::transport::mock::MockTransportFactory #include <activemq/transport/inactivity/InactivityMonitorTest.h> CPPUNIT_TEST_SUITE_REGISTRATION( activemq::transport::inactivity::InactivityMonitorTest ); -//#include <activemq/transport/discovery/DiscoveryAgentRegistryTest.h> -//CPPUNIT_TEST_SUITE_REGISTRATION( activemq::transport::discovery::DiscoveryAgentRegistryTest ); -//#include <activemq/transport/discovery/DiscoveryTransportFactoryTest.h> -//CPPUNIT_TEST_SUITE_REGISTRATION( activemq::transport::discovery::DiscoveryTransportFactoryTest ); -//#include <activemq/transport/discovery/AbstractDiscoveryAgentTest.h> -//CPPUNIT_TEST_SUITE_REGISTRATION( activemq::transport::discovery::AbstractDiscoveryAgentTest ); -//#include <activemq/transport/discovery/AbstractDiscoveryAgentFactoryTest.h> -//CPPUNIT_TEST_SUITE_REGISTRATION( activemq::transport::discovery::AbstractDiscoveryAgentFactoryTest ); - #include <activemq/transport/TransportRegistryTest.h> CPPUNIT_TEST_SUITE_REGISTRATION( activemq::transport::TransportRegistryTest ); #include <activemq/transport/IOTransportTest.h>
