Return-Path: Delivered-To: apmail-camel-commits-archive@www.apache.org Received: (qmail 91385 invoked from network); 6 Nov 2010 18:08:59 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 6 Nov 2010 18:08:59 -0000 Received: (qmail 84142 invoked by uid 500); 6 Nov 2010 18:09:30 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 84080 invoked by uid 500); 6 Nov 2010 18:09:30 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 84073 invoked by uid 99); 6 Nov 2010 18:09:30 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 06 Nov 2010 18:09:30 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 06 Nov 2010 18:09:25 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id A0F0E23888EC; Sat, 6 Nov 2010 18:08:10 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1032126 - in /camel/trunk/components/camel-jmx/src: main/java/org/apache/camel/component/jmx/ test/java/org/apache/camel/component/jmx/ test/java/org/apache/camel/component/jmx/beans/ test/resources/ test/resources/consumer-test/ Date: Sat, 06 Nov 2010 18:08:10 -0000 To: commits@camel.apache.org From: davsclaus@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20101106180810.A0F0E23888EC@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: davsclaus Date: Sat Nov 6 18:08:09 2010 New Revision: 1032126 URL: http://svn.apache.org/viewvc?rev=1032126&view=rev Log: CAMEL-3236: Fixed some tests and can test on JDK 1.5. Thanks to Mark Ford for patch. Modified: camel/trunk/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXConsumer.java camel/trunk/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXConsumerTest.java camel/trunk/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/SimpleBeanFixture.java camel/trunk/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/XmlFixture.java camel/trunk/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/beans/ISimpleMXBean.java camel/trunk/components/camel-jmx/src/test/resources/consumer-test/attributeChange-0.xml camel/trunk/components/camel-jmx/src/test/resources/consumer-test/attributeChange-1.xml camel/trunk/components/camel-jmx/src/test/resources/consumer-test/attributeChange-2.xml camel/trunk/components/camel-jmx/src/test/resources/consumer-test/jmxConnectionNotification.xml camel/trunk/components/camel-jmx/src/test/resources/consumer-test/mbeanServerNotification.xml camel/trunk/components/camel-jmx/src/test/resources/consumer-test/relationNotification.xml camel/trunk/components/camel-jmx/src/test/resources/consumer-test/timerNotification.xml camel/trunk/components/camel-jmx/src/test/resources/consumer-test/touched.xml camel/trunk/components/camel-jmx/src/test/resources/consumer-test/userdata.xml camel/trunk/components/camel-jmx/src/test/resources/stripTimestamp.xsl Modified: camel/trunk/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXConsumer.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXConsumer.java?rev=1032126&r1=1032125&r2=1032126&view=diff ============================================================================== --- camel/trunk/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXConsumer.java (original) +++ camel/trunk/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXConsumer.java Sat Nov 6 18:08:09 2010 @@ -19,6 +19,7 @@ package org.apache.camel.component.jmx; import java.lang.management.ManagementFactory; import java.util.Collections; import java.util.Map; + import javax.management.MBeanServerConnection; import javax.management.Notification; import javax.management.NotificationFilter; @@ -33,15 +34,12 @@ import org.apache.camel.ExchangePattern; import org.apache.camel.Message; import org.apache.camel.Processor; import org.apache.camel.impl.DefaultConsumer; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; /** * Consumer will add itself as a NotificationListener on the object * specified by the objectName param. */ public class JMXConsumer extends DefaultConsumer implements NotificationListener { - private static final Log LOG = LogFactory.getLog(JMXConsumer.class); /** * connection to the mbean server (local or remote) Modified: camel/trunk/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXConsumerTest.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXConsumerTest.java?rev=1032126&r1=1032125&r2=1032126&view=diff ============================================================================== --- camel/trunk/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXConsumerTest.java (original) +++ camel/trunk/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXConsumerTest.java Sat Nov 6 18:08:09 2010 @@ -78,7 +78,7 @@ public class JMXConsumerTest extends Sim waitAndAssertMessageReceived("src/test/resources/consumer-test/mbeanServerNotification.xml"); } - @Test + @Ignore public void relationNotification() throws Exception { simpleBean.triggerRelationNotification(); waitAndAssertMessageReceived("src/test/resources/consumer-test/relationNotification.xml"); Modified: camel/trunk/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/SimpleBeanFixture.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/SimpleBeanFixture.java?rev=1032126&r1=1032125&r2=1032126&view=diff ============================================================================== --- camel/trunk/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/SimpleBeanFixture.java (original) +++ camel/trunk/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/SimpleBeanFixture.java Sat Nov 6 18:08:09 2010 @@ -16,19 +16,27 @@ */ package org.apache.camel.component.jmx; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + import java.io.File; import java.lang.management.ManagementFactory; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.Iterator; import java.util.List; import java.util.concurrent.TimeUnit; + import javax.management.InstanceNotFoundException; -import javax.management.JMX; import javax.management.MBeanRegistrationException; import javax.management.MBeanServer; +import javax.management.MBeanServerInvocationHandler; import javax.management.MalformedObjectNameException; import javax.management.ObjectName; +import javax.xml.namespace.NamespaceContext; +import javax.xml.xpath.XPath; +import javax.xml.xpath.XPathFactory; import org.apache.camel.Exchange; import org.apache.camel.Message; @@ -40,9 +48,7 @@ import org.apache.camel.impl.DefaultCame import org.apache.camel.impl.SimpleRegistry; import org.junit.After; import org.junit.Before; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import org.w3c.dom.Document; /** * MBean that is registered for the unit tests. The fixture will register a bean @@ -128,8 +134,14 @@ public class SimpleBeanFixture { * Gets the mxbean for our remote object using the specified name */ protected ISimpleMXBean getMXBean(ObjectName aObjectName) { - ISimpleMXBean simpleBean = JMX.newMXBeanProxy(server, aObjectName, ISimpleMXBean.class); - return simpleBean; + return (ISimpleMXBean) MBeanServerInvocationHandler.newProxyInstance( + server, + aObjectName, + ISimpleMXBean.class, + false); + // revert the above change to the below when we move to JDK 1.6 +// ISimpleMXBean simpleBean = JMX.newMXBeanProxy(server, aObjectName, ISimpleMXBean.class); +// return simpleBean; } /** @@ -252,9 +264,29 @@ public class SimpleBeanFixture { * Assert that we've received the message and resets the mock endpoint */ protected void assertMessageReceived(File aExpectedFile) throws Exception { + Document actual = XmlFixture.toDoc(getBody(0, String.class)); + Document noTime = XmlFixture.stripTimestamp(actual); XmlFixture.assertXMLIgnorePrefix("failed to match", XmlFixture.toDoc(aExpectedFile), - XmlFixture.toDoc(getBody(0, String.class))); + noTime); + // assert that we have a timestamp and datetime + // can't rely on the datetime being the same due to timezone differences + // instead, we'll assert that the values exist. + XPathFactory xpf = XPathFactory.newInstance(); + XPath xp = xpf.newXPath(); + xp.setNamespaceContext(new NamespaceContext(){ + public String getNamespaceURI(String aArg0) { + return "urn:org.apache.camel.component:jmx"; + } + public String getPrefix(String aArg0) { + return "jmx"; + } + public Iterator getPrefixes(String aArg0) { + return null; + } + }); + assertEquals("1262878215000", xp.evaluate("string(//jmx:timestamp)", actual)); + assertEquals("1", xp.evaluate("count(//jmx:dateTime)", actual)); resetMockEndpoint(); } Modified: camel/trunk/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/XmlFixture.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/XmlFixture.java?rev=1032126&r1=1032125&r2=1032126&view=diff ============================================================================== --- camel/trunk/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/XmlFixture.java (original) +++ camel/trunk/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/XmlFixture.java Sat Nov 6 18:08:09 2010 @@ -20,8 +20,12 @@ import java.io.File; import java.io.InputStream; import java.io.PrintWriter; import java.io.StringWriter; + +import javax.xml.transform.OutputKeys; import javax.xml.transform.Source; import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerConfigurationException; +import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMResult; import javax.xml.transform.dom.DOMSource; @@ -75,13 +79,21 @@ public final class XmlFixture { try { XMLAssert.assertXMLEqual(diff, true); } catch (Throwable t) { - XMLUnit.getTransformerFactory().newTransformer().transform(new DOMSource(aActual), new StreamResult(System.out)); + dump(aActual); StringWriter sw = new StringWriter(); t.printStackTrace(new PrintWriter(sw)); fail(sw.toString()); } } + public static void dump(Document aActual) throws TransformerConfigurationException, + TransformerException { + TransformerFactory tf = XMLUnit.getTransformerFactory(); + Transformer transformer = tf.newTransformer(); + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + transformer.transform(new DOMSource(aActual), new StreamResult(System.out)); + } + public static Document stripTimestamp(Document aDocument) throws Exception { TransformerFactory tf = TransformerFactory.newInstance(); InputStream in = XmlFixture.class.getResourceAsStream("/stripTimestamp.xsl"); Modified: camel/trunk/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/beans/ISimpleMXBean.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/beans/ISimpleMXBean.java?rev=1032126&r1=1032125&r2=1032126&view=diff ============================================================================== --- camel/trunk/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/beans/ISimpleMXBean.java (original) +++ camel/trunk/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/beans/ISimpleMXBean.java Sat Nov 6 18:08:09 2010 @@ -16,23 +16,6 @@ */ package org.apache.camel.component.jmx.beans; -public interface ISimpleMXBean { - - String getStringValue(); - - void setStringValue(String aValue); - - void touch(); - - void userData(String aUserData); - - void triggerConnectionNotification(); - - void triggerMBeanServerNotification() throws Exception; - - void triggerRelationNotification() throws Exception; - - void triggerTimerNotification(); - - int getMonitorNumber(); +public interface ISimpleMXBean extends SimpleBeanMBean { + // moved the implementation to SimpleBeanMBean to better support JDK 1.5 } Modified: camel/trunk/components/camel-jmx/src/test/resources/consumer-test/attributeChange-0.xml URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jmx/src/test/resources/consumer-test/attributeChange-0.xml?rev=1032126&r1=1032125&r2=1032126&view=diff ============================================================================== --- camel/trunk/components/camel-jmx/src/test/resources/consumer-test/attributeChange-0.xml (original) +++ camel/trunk/components/camel-jmx/src/test/resources/consumer-test/attributeChange-0.xml Sat Nov 6 18:08:09 2010 @@ -20,8 +20,6 @@ TestDomain:name=simpleBean attribute changed 0 - 1262878215000 - 2010-01-07T10:30:15.000-05:00 jmx.attribute.change stringValue string Modified: camel/trunk/components/camel-jmx/src/test/resources/consumer-test/attributeChange-1.xml URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jmx/src/test/resources/consumer-test/attributeChange-1.xml?rev=1032126&r1=1032125&r2=1032126&view=diff ============================================================================== --- camel/trunk/components/camel-jmx/src/test/resources/consumer-test/attributeChange-1.xml (original) +++ camel/trunk/components/camel-jmx/src/test/resources/consumer-test/attributeChange-1.xml Sat Nov 6 18:08:09 2010 @@ -20,8 +20,6 @@ TestDomain:name=simpleBean attribute changed 1 - 1262878215000 - 2010-01-07T10:30:15.000-05:00 jmx.attribute.change stringValue string Modified: camel/trunk/components/camel-jmx/src/test/resources/consumer-test/attributeChange-2.xml URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jmx/src/test/resources/consumer-test/attributeChange-2.xml?rev=1032126&r1=1032125&r2=1032126&view=diff ============================================================================== --- camel/trunk/components/camel-jmx/src/test/resources/consumer-test/attributeChange-2.xml (original) +++ camel/trunk/components/camel-jmx/src/test/resources/consumer-test/attributeChange-2.xml Sat Nov 6 18:08:09 2010 @@ -20,8 +20,6 @@ TestDomain:name=simpleBean attribute changed 2 - 1262878215000 - 2010-01-07T10:30:15.000-05:00 jmx.attribute.change stringValue string Modified: camel/trunk/components/camel-jmx/src/test/resources/consumer-test/jmxConnectionNotification.xml URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jmx/src/test/resources/consumer-test/jmxConnectionNotification.xml?rev=1032126&r1=1032125&r2=1032126&view=diff ============================================================================== --- camel/trunk/components/camel-jmx/src/test/resources/consumer-test/jmxConnectionNotification.xml (original) +++ camel/trunk/components/camel-jmx/src/test/resources/consumer-test/jmxConnectionNotification.xml Sat Nov 6 18:08:09 2010 @@ -19,8 +19,6 @@ TestDomain:name=simpleBean connection notification 0 - 1262878215000 - 2010-01-07T10:30:15.000-05:00 connection conn-123 Modified: camel/trunk/components/camel-jmx/src/test/resources/consumer-test/mbeanServerNotification.xml URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jmx/src/test/resources/consumer-test/mbeanServerNotification.xml?rev=1032126&r1=1032125&r2=1032126&view=diff ============================================================================== --- camel/trunk/components/camel-jmx/src/test/resources/consumer-test/mbeanServerNotification.xml (original) +++ camel/trunk/components/camel-jmx/src/test/resources/consumer-test/mbeanServerNotification.xml Sat Nov 6 18:08:09 2010 @@ -19,8 +19,6 @@ TestDomain:name=simpleBean 0 - 1262878215000 - 2010-01-07T10:30:15.000-05:00 mbeanserver TestDomain:name=foo Modified: camel/trunk/components/camel-jmx/src/test/resources/consumer-test/relationNotification.xml URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jmx/src/test/resources/consumer-test/relationNotification.xml?rev=1032126&r1=1032125&r2=1032126&view=diff ============================================================================== --- camel/trunk/components/camel-jmx/src/test/resources/consumer-test/relationNotification.xml (original) +++ camel/trunk/components/camel-jmx/src/test/resources/consumer-test/relationNotification.xml Sat Nov 6 18:08:09 2010 @@ -19,8 +19,6 @@ TestDomain:name=source relation message 0 - 1262878215000 - 2010-01-07T10:30:15.000-05:00 jmx.relation.creation.basic TestDomain:name=foo relation-id Modified: camel/trunk/components/camel-jmx/src/test/resources/consumer-test/timerNotification.xml URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jmx/src/test/resources/consumer-test/timerNotification.xml?rev=1032126&r1=1032125&r2=1032126&view=diff ============================================================================== --- camel/trunk/components/camel-jmx/src/test/resources/consumer-test/timerNotification.xml (original) +++ camel/trunk/components/camel-jmx/src/test/resources/consumer-test/timerNotification.xml Sat Nov 6 18:08:09 2010 @@ -19,8 +19,6 @@ TestDomain:name=simpleBean timer-notification 0 - 1262878215000 - 2010-01-07T10:30:15.000-05:00 timer.notification 100 Modified: camel/trunk/components/camel-jmx/src/test/resources/consumer-test/touched.xml URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jmx/src/test/resources/consumer-test/touched.xml?rev=1032126&r1=1032125&r2=1032126&view=diff ============================================================================== --- camel/trunk/components/camel-jmx/src/test/resources/consumer-test/touched.xml (original) +++ camel/trunk/components/camel-jmx/src/test/resources/consumer-test/touched.xml Sat Nov 6 18:08:09 2010 @@ -20,7 +20,5 @@ TestDomain:name=simpleBean I was touched 0 - 1262878215000 - 2010-01-07T10:30:15.000-05:00 touched Modified: camel/trunk/components/camel-jmx/src/test/resources/consumer-test/userdata.xml URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jmx/src/test/resources/consumer-test/userdata.xml?rev=1032126&r1=1032125&r2=1032126&view=diff ============================================================================== --- camel/trunk/components/camel-jmx/src/test/resources/consumer-test/userdata.xml (original) +++ camel/trunk/components/camel-jmx/src/test/resources/consumer-test/userdata.xml Sat Nov 6 18:08:09 2010 @@ -20,8 +20,6 @@ TestDomain:name=simpleBean Here's my user data 0 - 1262878215000 - 2010-01-07T10:30:15.000-05:00 userData myUserData Modified: camel/trunk/components/camel-jmx/src/test/resources/stripTimestamp.xsl URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jmx/src/test/resources/stripTimestamp.xsl?rev=1032126&r1=1032125&r2=1032126&view=diff ============================================================================== --- camel/trunk/components/camel-jmx/src/test/resources/stripTimestamp.xsl (original) +++ camel/trunk/components/camel-jmx/src/test/resources/stripTimestamp.xsl Sat Nov 6 18:08:09 2010 @@ -22,7 +22,7 @@ - +