You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ri...@apache.org on 2010/06/22 15:41:24 UTC
svn commit: r956888 - in /qpid/trunk/qpid/java:
broker-plugins/experimental/info/
broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/
broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/util/
broker-plugins/experimental...
Author: ritchiem
Date: Tue Jun 22 13:41:24 2010
New Revision: 956888
URL: http://svn.apache.org/viewvc?rev=956888&view=rev
Log:
QPID-2555 : Modified the MANIFEST to include org.apache.qpid.common and org.apache.qpid.server.registry
Patch provided by Sorin Suciu
Removed:
qpid/trunk/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/BrokerInfoService.java
qpid/trunk/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/BrokerInfoServiceImpl.java
qpid/trunk/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/ActivatorTest.java
qpid/trunk/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/BrokerInfoServiceImplTest.java
Modified:
qpid/trunk/qpid/java/broker-plugins/experimental/info/MANIFEST.MF
qpid/trunk/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/Activator.java
qpid/trunk/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/Info.java
qpid/trunk/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/util/HttpPoster.java
qpid/trunk/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/HttpPosterTest.java
qpid/trunk/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/InfoServlet.java
qpid/trunk/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/InfoTest.java
qpid/trunk/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/XMLWriterTest.java
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/plugins/PluginManager.java
Modified: qpid/trunk/qpid/java/broker-plugins/experimental/info/MANIFEST.MF
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/experimental/info/MANIFEST.MF?rev=956888&r1=956887&r2=956888&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/experimental/info/MANIFEST.MF (original)
+++ qpid/trunk/qpid/java/broker-plugins/experimental/info/MANIFEST.MF Tue Jun 22 13:41:24 2010
@@ -5,7 +5,9 @@ Bundle-SymbolicName: qpid_info_plugin;si
Bundle-Version: 1.0.0
Bundle-Activator: org.apache.qpid.info.Activator
Import-Package: org.apache.qpid.server.configuration,
- org.osgi.framework
+ org.osgi.framework,
+ org.apache.qpid.common,
+ org.apache.qpid.server.registry
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ClassPath: .
Bundle-ActivationPolicy: lazy
Modified: qpid/trunk/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/Activator.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/Activator.java?rev=956888&r1=956887&r2=956888&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/Activator.java (original)
+++ qpid/trunk/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/Activator.java Tue Jun 22 13:41:24 2010
@@ -19,60 +19,204 @@
*
*/
-/**
- *
- * @author sorin
- *
- * Activator class for the tracking services
- */
-
package org.apache.qpid.info;
import java.io.File;
-import java.io.FileInputStream;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import java.util.Properties;
import org.apache.qpid.info.util.HttpPoster;
+import org.apache.qpid.info.util.IniFileReader;
+import org.apache.qpid.info.util.SoapClient;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
+/**
+ * The Activator class for the OSGI info service
+ *
+ */
public class Activator implements BundleActivator
{
+ private final List<String> soapPropList = Arrays.asList("soap.hostname",
+ "soap.port", "soap.path", "soap.action", "soap.envelope");
+
+ private final List<String> httpPropList = Arrays.asList("http.url",
+ "http.envelope");
+
+ InfoServiceImpl service = null;
+
BundleContext _ctx = null;
+ Map<String, Properties> infoprops = new HashMap<String, Properties>();
+
+ /**
+ * Start bundle method
+ *
+ * @param ctx
+ * the bundle context
+ */
public void start(BundleContext ctx) throws Exception
{
if (null != ctx)
{
- BrokerInfoServiceImpl service = new BrokerInfoServiceImpl(ctx);
- ctx.registerService(BrokerInfoService.class.getName(), service,
- null);
_ctx = ctx;
- HttpPoster hp;
- try
- {
- Properties props = new Properties();
- String QPID_WORK = System.getenv("QPID_WORK");
- props.load(new FileInputStream(QPID_WORK + File.separator
- + "etc" + File.separator + "qpidinfo.properties"));
- hp = new HttpPoster(props, service.invoke().toXML());
- hp.run();
- } catch (Exception ex)
- {
- // Silently drop any exception
- }
+ service = new InfoServiceImpl();
+ ctx.registerService(InfoService.class.getName(), service, null);
+ sendInfo("STARTUP");
}
}
+ /**
+ * Getter for the bundle context
+ *
+ * @return BundleContext the bundle context
+ */
public BundleContext getBundleContext()
{
return _ctx;
}
+ /**
+ * Stop the bundle method
+ *
+ * @param ctx
+ * the bundle context
+ */
public void stop(BundleContext ctx) throws Exception
{
- // no need to do anything here, osgi will unregister the service for us
+ sendInfo("SHUTDOWN");
+ }
+
+ /**
+ * Sends the information message
+ *
+ * @param action
+ * label that identifies if we are starting up or shutting down
+ */
+ private void sendInfo(String action)
+ {
+ if ((null == _ctx) && (null == service))
+ {
+ // invalid state
+ return;
+ }
+
+ IniFileReader ifr = new IniFileReader();
+ try
+ {
+ String QPID_HOME = System.getProperty("QPID_HOME");
+ String cfgFilePath = QPID_HOME + File.separator + "etc"
+ + File.separator + "qpidinfo.properties";
+ ifr.load(cfgFilePath);
+ } catch (Exception ex)
+ {
+ // drop the exception
+ return;
+ }
+
+ // If we have no sections, something has gone really wrong, abort
+ if (ifr.getSections().size() == 0)
+ return;
+
+ Info<? extends Map<String, ?>> info = service.invoke(action);
+ String protocol = ifr.getSections().get("").getProperty("protocol");
+ sendMessages(protocol, ifr, info);
+ }
+
+ /**
+ * Sends all the messages configured in the properties file
+ *
+ * @param protocol
+ * indicates what protocol to be used: http and soap implemented
+ * for now
+ * @param ifr
+ * an instance of IniFileReader class
+ * @param info
+ * an instance of an Info object, encapsulating the information
+ * we want to send
+ */
+ private void sendMessages(String protocol, IniFileReader ifr,
+ Info<? extends Map<String, ?>> info)
+ {
+ if (null != protocol)
+ {
+ // Set the global properties first (as they are the defaults)
+ Properties defaultProps = ifr.getSections().get("");
+ if (protocol.toLowerCase().startsWith("http"))
+ {
+ for (String section : ifr.getSections().keySet())
+ {
+ // Skip the defaults
+ if (section.equals(""))
+ continue;
+ Properties props = new Properties();
+ props.putAll(defaultProps);
+ props.putAll(ifr.getSections().get(section));
+ if (isValid(protocol, props))
+ {
+ new HttpPoster(props, info.toXML()).run();
+ }
+ }
+
+ } else if (protocol.toLowerCase().startsWith("soap"))
+ {
+ for (String section : ifr.getSections().keySet())
+ {
+ Properties props = new Properties();
+ props.putAll(defaultProps);
+ props.putAll(ifr.getSections().get(section));
+ if (isValid(protocol, props))
+ {
+ new SoapClient(info.toMap(), props).sendSOAPMessage();
+ }
+ }
+ }
+ } else
+ {
+ return;
+ }
+ }
+
+ /**
+ * Checks if the properties for a specified protocol are valid
+ *
+ * @param protocol
+ * String representing the protocol
+ * @param props
+ * The properties associate with the specified protocol
+ */
+ private boolean isValid(String protocol, Properties props)
+ {
+ if (null == protocol)
+ return false;
+ String value = "";
+ if (protocol.toLowerCase().startsWith("http"))
+ {
+ for (String prop : httpPropList)
+ {
+ if (null == props.get(prop))
+ return false;
+ }
+ return true;
+ }
+
+ if (protocol.toLowerCase().startsWith("soap"))
+ {
+ for (String prop : soapPropList)
+ {
+ value = props.getProperty(prop);
+ if (null == value)
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+ return false;
}
+} // end class
-}
Modified: qpid/trunk/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/Info.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/Info.java?rev=956888&r1=956887&r2=956888&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/Info.java (original)
+++ qpid/trunk/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/Info.java Tue Jun 22 13:41:24 2010
@@ -35,15 +35,24 @@ import java.util.Properties;
import org.apache.qpid.info.util.XMLWriter;
+/**
+ * The Info class encapsulates all the informations we are collecting
+ * and it is able to render it in different data representations
+ */
public class Info<T extends Map<String, ?>>
{
private T _info;
+ /**
+ * Constructor.
+ * @param info instantiates the object with a Map<String,?>
+ */
public Info(T info)
{
_info = info;
}
+ @Override
public String toString()
{
String result = "";
@@ -55,21 +64,25 @@ public class Info<T extends Map<String,
return result;
}
- public Properties toProps()
- {
+ /**
+ * Renders Info map to a property object
+ * @return A Properties object representing the Info map
+ */
+ public Properties toProps() {
Properties props = new Properties();
- if (null == _info)
- return null;
- for (Iterator<String> it = _info.keySet().iterator(); it.hasNext();)
- {
- String key = it.next();
- props.put(key, _info.get(key));
+ if (null==_info) return null;
+ for (Iterator<String> it = _info.keySet().iterator(); it.hasNext();) {
+ String key = it.next();
+ props.put(key, _info.get(key));
}
return props;
}
-
- public StringBuffer toStringBuffer()
- {
+
+ /**
+ * Renders Info map to a StringBuffer
+ * @return A StringBuffer object representing the Info map
+ */
+ public StringBuffer toStringBuffer() {
StringBuffer sb = new StringBuffer();
for (Iterator<String> it = _info.keySet().iterator(); it.hasNext();)
{
@@ -78,22 +91,39 @@ public class Info<T extends Map<String,
}
return sb;
}
-
- public StringBuffer toXML()
+
+ /**
+ * Renders Info map to a StringBuffer containing an XML string
+ * @return A StringBuffer object containing an XML representation of the Info map
+ */
+ public StringBuffer toXML()
{
XMLWriter xw = new XMLWriter(new StringBuffer());
xw.writeXMLHeader();
Map<String, String> attr = new HashMap<String, String>();
xw.writeOpenTag("qpidinfo", attr);
String key;
- for (Iterator<String> it = _info.keySet().iterator(); it.hasNext();)
- {
+ for (Iterator<String> it = _info.keySet().iterator(); it.hasNext();) {
attr.clear();
key = it.next();
- xw.writeTag(key, attr, _info.get(key).toString());
- }
+ xw.writeTag(key, attr, _info.get(key).toString());
+ }
xw.writeCloseTag("qpidinfo");
return xw.getXML();
}
+
+ /**
+ * Renders Info map to a HashMap
+ * @return A HashMap object representing the Info map
+ */
+ public HashMap<String,String> toMap() {
+ String key;
+ HashMap<String,String> infoMap = new HashMap<String,String>();
+ for (Iterator<String> it = _info.keySet().iterator(); it.hasNext();) {
+ key = it.next();
+ infoMap.put(key, _info.get(key).toString());
+ }
+ return infoMap;
+ }
}
Modified: qpid/trunk/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/util/HttpPoster.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/util/HttpPoster.java?rev=956888&r1=956887&r2=956888&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/util/HttpPoster.java (original)
+++ qpid/trunk/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/util/HttpPoster.java Tue Jun 22 13:41:24 2010
@@ -36,62 +36,92 @@ import java.util.Properties;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
+import java.net.InetAddress;
import java.net.URL;
import java.net.URLConnection;
+import java.net.UnknownHostException;
+
+public class HttpPoster implements Runnable
+{
+ private final String url;
+
+ private final Hashtable<String, String> header;
-public class HttpPoster implements Runnable {
- private final String url;
- private final Hashtable<String,String> header;
private final List<String> response = new ArrayList<String>();
- private final StringBuffer _buf;
- //
- public HttpPoster(Properties props, StringBuffer buf)
+
+ private final StringBuffer _buf;
+
+ /**
+ * Constructor
+ * @param props Properties containing the URL
+ * @param buf Buffer containing the message to be posted
+ */
+ public HttpPoster(Properties props, StringBuffer buf)
+ {
+ _buf = buf;
+ if (null != props)
+ {
+ url = props.getProperty("http.url");
+ header = new Hashtable<String, String>();
+ try
+ {
+ String hostname = InetAddress.getLocalHost().getHostName();
+ header.put("hostname", hostname);
+ } catch (UnknownHostException e)
+ {
+ // Silently ignoring the error ;)
+ }
+ } else
+ {
+ url = null;
+ header = null;
+ }
+ }
+ /**
+ * Posts the message from the _buf StringBuffer to the http server
+ */
+ public void run()
{
- _buf = buf;
- if (null!= props) {
- url = props.getProperty("URL");
- header = new Hashtable<String, String>();
- String hostname = props.getProperty("hostname");
- if (null!= hostname) header.put("hostname", hostname);
- } else {
- url = null;
- header = null;
- }
- }
- //
- @Override
- public void run()
+ if (null == url)
+ return;
+ String line;
+ URL urlDest;
+ URLConnection urlConn;
+ try
{
- if (null==url) return;
- String line;
- URL urlDest;
- URLConnection urlConn;
- try {
- urlDest = new URL(url);
- urlConn = urlDest.openConnection();
- urlConn.setDoOutput(true);
- urlConn.setUseCaches(false);
- for (Iterator<String> it=header.keySet().iterator(); it.hasNext();) {
- String prop = (String)it.next();
- urlConn.setRequestProperty(prop, header.get(prop));
- }
- OutputStreamWriter wr = new OutputStreamWriter(urlConn.getOutputStream());
+ urlDest = new URL(url);
+ urlConn = urlDest.openConnection();
+ urlConn.setDoOutput(true);
+ urlConn.setUseCaches(false);
+ for (Iterator<String> it = header.keySet().iterator(); it.hasNext();)
+ {
+ String prop = (String) it.next();
+ urlConn.setRequestProperty(prop, header.get(prop));
+ }
+ OutputStreamWriter wr = new OutputStreamWriter(urlConn
+ .getOutputStream());
wr.write(_buf.toString());
wr.flush();
// Get the response
- BufferedReader rd = new BufferedReader(new InputStreamReader(urlConn.getInputStream()));
- while ((line = rd.readLine()) != null) {
+ BufferedReader rd = new BufferedReader(new InputStreamReader(
+ urlConn.getInputStream()));
+ while ((line = rd.readLine()) != null)
+ {
response.add(line);
- }
- } catch (Exception ex) {
- return;
- }
- }
-
- public List<String> getResponse()
+ }
+ } catch (Exception ex)
{
- return response;
- }
-
-}
+ return;
+ }
+ }
+
+ /**
+ * Retrieves the response from the http server
+ * @return List<String> response received from the http server
+ */
+ public List<String> getResponse()
+ {
+ return response;
+ }
+}
Modified: qpid/trunk/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/HttpPosterTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/HttpPosterTest.java?rev=956888&r1=956887&r2=956888&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/HttpPosterTest.java (original)
+++ qpid/trunk/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/HttpPosterTest.java Tue Jun 22 13:41:24 2010
@@ -35,52 +35,73 @@ import junit.framework.TestCase;
public class HttpPosterTest extends TestCase
{
- private HttpPoster hp;
-
- private Properties props;
-
- private StringBuffer sb;
-
private ServletTester tester;
private String baseURL;
private final String contextPath = "/info";
- protected void setUp() throws Exception
+ /*
+ * This method generates a dummy HttpPoster with a dummy body containing a
+ * single line. The url we are posting to can be controlled by the parameter
+ * url
+ *
+ * @param url
+ */
+ private HttpPoster getHttpPoster(String url)
{
- super.setUp();
+ StringBuffer sb = new StringBuffer("test=TEST");
+ Properties props = new Properties();
+ props.put("http.url", url);
+ return new HttpPoster(props, sb);
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception
+ {
tester = new ServletTester();
tester.setContextPath("/");
tester.addServlet(InfoServlet.class, contextPath);
baseURL = tester.createSocketConnector(true);
tester.start();
- //
- props = new Properties();
- props.put("URL", baseURL + contextPath);
- props.put("hostname", "localhost");
- sb = new StringBuffer("test=TEST");
- hp = new HttpPoster(props, sb);
-
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see junit.framework.TestCase#tearDown()
+ */
protected void tearDown() throws Exception
{
super.tearDown();
- hp = null;
- props = null;
- sb = null;
tester.stop();
}
- public void testHttpPoster()
+ /*
+ * This test is posting a string to an embedded Jetty Servlet and captures
+ * the response message. If the servlet receives the message ok, it will
+ * print Ok. A failure test is following where we post to a non-existent URL
+ */
+ public void testHttpPoster() throws Exception
{
+ // Test HttpPoster posts correctly to the servlet
+ HttpPoster hp = getHttpPoster(baseURL + contextPath);
assertNotNull(hp);
hp.run();
List<String> response = hp.getResponse();
assertTrue(response.size() > 0);
assertEquals("OK <br>", response.get(0).toString());
+
+ // Failure Test
+ hp = getHttpPoster("http://localhost/nonexistent");
+ hp.run();
+ response = hp.getResponse();
+ assertTrue(response.size() == 0);
+
}
}
Modified: qpid/trunk/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/InfoServlet.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/InfoServlet.java?rev=956888&r1=956887&r2=956888&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/InfoServlet.java (original)
+++ qpid/trunk/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/InfoServlet.java Tue Jun 22 13:41:24 2010
@@ -1,5 +1,5 @@
/*
- *
+ *
* 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
@@ -7,17 +7,18 @@
* 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.
- *
+ *
*/
+
package org.apache.qpid.info.test;
import java.io.BufferedReader;
@@ -53,4 +54,4 @@ public class InfoServlet extends Generic
System.out.println("ServletResponse: OK");
}
-}
+}
\ No newline at end of file
Modified: qpid/trunk/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/InfoTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/InfoTest.java?rev=956888&r1=956887&r2=956888&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/InfoTest.java (original)
+++ qpid/trunk/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/InfoTest.java Tue Jun 22 13:41:24 2010
@@ -1,5 +1,5 @@
/*
- *
+ *
* 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
@@ -7,17 +7,18 @@
* 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.
- *
+ *
*/
+
package org.apache.qpid.info.test;
import java.util.HashMap;
@@ -39,6 +40,8 @@ public class InfoTest extends TestCase
{
super.setUp();
infoPayLoad = new HashMap<String, String>();
+ infoPayLoad.put("test", "Test");
+ info = new Info<HashMap<String, String>>(infoPayLoad);
}
protected void tearDown() throws Exception
@@ -48,48 +51,44 @@ public class InfoTest extends TestCase
infoPayLoad = null;
}
- public void testInfo()
- {
- info = new Info<HashMap<String, String>>(infoPayLoad);
- assertNotNull(info);
- }
-
+ /*
+ * Test the conversion toString() of the Info object
+ */
public void testToString()
{
- infoPayLoad.clear();
- infoPayLoad.put("test", "Test");
- info = new Info<HashMap<String, String>>(infoPayLoad);
- assertNotNull(info.toString());
- assertEquals("test=Test\n", info.toString());
+ assertNotNull("toString() returned null", info.toString());
+ assertEquals("toString() did not return the proper string",
+ "test=Test\n", info.toString());
}
+ /*
+ * Test the conversion toProps() of the Info object
+ */
public void testToProps()
{
Properties props = new Properties();
props.put("test", "Test");
- infoPayLoad.clear();
- infoPayLoad.put("test", "Test");
- info = new Info<HashMap<String, String>>(infoPayLoad);
- assertNotNull(info.toProps());
- assertEquals(props, info.toProps());
+ assertNotNull("toProperties() returned null", info.toProps());
+ assertEquals("toProperties not returned the proper object", props, info
+ .toProps());
}
+ /*
+ * Test the conversion toStringBuffer() of the Info object
+ */
public void testToStringBuffer()
{
StringBuffer sb = new StringBuffer("test=Test\n");
- infoPayLoad.clear();
- infoPayLoad.put("test", "Test");
- info = new Info<HashMap<String, String>>(infoPayLoad);
assertNotNull(info.toStringBuffer());
assertEquals(sb.toString(), info.toStringBuffer().toString());
}
+ /*
+ * Test conversion toXML() of the info object
+ */
public void testToXML()
{
String INDEND = " ";
- infoPayLoad.clear();
- infoPayLoad.put("test", "Test");
- info = new Info<HashMap<String, String>>(infoPayLoad);
StringBuffer sb = new StringBuffer();
sb.append("<?xml version=\"1.0\"?>\n");
sb.append("<qpidinfo>\n");
@@ -97,7 +96,24 @@ public class InfoTest extends TestCase
sb.append(INDEND + "Test\n");
sb.append("</test>\n");
sb.append("</qpidinfo>\n");
- assertEquals(info.toXML().toString(), sb.toString());
+ assertEquals("toString() does not return the proper string", info
+ .toXML().toString(), sb.toString());
+ }
+
+ /*
+ * Test the conversion toMap() of the Info object
+ */
+ public void testToMap()
+ {
+ HashMap<String, String> thm = info.toMap();
+ assertFalse("toMap() returned empty map", thm.isEmpty());
+ assertEquals("testToMap did not returned 1", 1, thm.size());
+ assertTrue("toMap() returned a map not containing expected key: test",
+ thm.containsKey("test"));
+ assertTrue(
+ "toMap() returned a map not containing the value for key test: Test",
+ thm.containsValue("Test"));
+
}
}
Modified: qpid/trunk/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/XMLWriterTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/XMLWriterTest.java?rev=956888&r1=956887&r2=956888&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/XMLWriterTest.java (original)
+++ qpid/trunk/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/XMLWriterTest.java Tue Jun 22 13:41:24 2010
@@ -1,5 +1,5 @@
/*
- *
+ *
* 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
@@ -7,17 +7,18 @@
* 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.
- *
+ *
*/
+
package org.apache.qpid.info.test;
import java.util.HashMap;
@@ -34,23 +35,11 @@ public class XMLWriterTest extends TestC
private XMLWriter xw = null;
- protected void setUp() throws Exception
- {
- super.setUp();
-
- }
-
- protected void tearDown() throws Exception
- {
- super.tearDown();
-
- }
-
public void testXMLWriter()
{
xw = new XMLWriter(new StringBuffer("Test"));
- assertNotNull(xw);
- assertEquals("Test", xw.getXML().toString());
+ assertNotNull("XMLWriter could not instantiate", xw);
+ assertEquals("XMLWriter.toString() failed","Test", xw.getXML().toString());
}
public void testWriteXMLHeader()
@@ -58,16 +47,16 @@ public class XMLWriterTest extends TestC
xw = new XMLWriter(new StringBuffer());
assertNotNull(xw);
xw.writeXMLHeader();
- assertEquals("<?xml version=\"1.0\"?>\n", xw.getXML().toString());
+ assertEquals("XMLWriter.writeXMLHeader(...) failed","<?xml version=\"1.0\"?>\n", xw.getXML().toString());
}
public void testWriteTag()
{
String INDEND = " ";
xw = new XMLWriter(new StringBuffer());
- assertNotNull(xw);
+ assertNotNull("XMLWriter could not instantiate", xw);
xw.writeTag("test", new HashMap<String, String>(), "TEST");
- assertEquals("<test>\n" + INDEND + "TEST\n" + "</test>\n", xw.getXML()
+ assertEquals("XMLWriter.writeTag(...) failed","<test>\n" + INDEND + "TEST\n" + "</test>\n", xw.getXML()
.toString());
}
@@ -77,10 +66,10 @@ public class XMLWriterTest extends TestC
assertNotNull(xw);
HashMap<String, String> attr = new HashMap<String, String>();
xw.writeOpenTag("test", attr);
- assertEquals("<test>\n", xw.getXML().toString());
+ assertEquals("XMLWriter.writeOpenTag(...) failed","<test>\n", xw.getXML().toString());
attr.put("id", "1");
xw.writeOpenTag("test1", attr);
- assertEquals("<test>\n" + "<test1 id=\"1\">\n", xw.getXML().toString());
+ assertEquals("XMLWriter.writeOpenTag(...) failed","<test>\n" + "<test1 id=\"1\">\n", xw.getXML().toString());
}
public void testWriteCloseTag()
Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/plugins/PluginManager.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/plugins/PluginManager.java?rev=956888&r1=956887&r2=956888&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/plugins/PluginManager.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/plugins/PluginManager.java Tue Jun 22 13:41:24 2010
@@ -114,6 +114,7 @@ public class PluginManager implements Cl
"org.osgi.util.tracker; version=1.0.0," +
"org.apache.qpid.junit.extensions.util; version=0.7," +
"org.apache.qpid; version=0.7," +
+ "org.apache.qpid.common; version=0.7," +
"org.apache.qpid.exchange; version=0.7," +
"org.apache.qpid.framing; version=0.7," +
"org.apache.qpid.protocol; version=0.7," +
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org