Return-Path: Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: (qmail 25146 invoked from network); 10 Jan 2010 17:51:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 10 Jan 2010 17:51:13 -0000 Received: (qmail 90833 invoked by uid 500); 10 Jan 2010 17:51:13 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 90747 invoked by uid 500); 10 Jan 2010 17:51:13 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 90738 invoked by uid 99); 10 Jan 2010 17:51:13 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 10 Jan 2010 17:51:13 +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; Sun, 10 Jan 2010 17:51:12 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 0C18A23889E1; Sun, 10 Jan 2010 17:50:52 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r897669 - in /cxf/dosgi/trunk/discovery/local/src: main/java/org/apache/cxf/dosgi/discovery/local/ test/java/org/apache/cxf/dosgi/discovery/local/ Date: Sun, 10 Jan 2010 17:50:51 -0000 To: commits@cxf.apache.org From: davidb@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100110175052.0C18A23889E1@eris.apache.org> Author: davidb Date: Sun Jan 10 17:50:51 2010 New Revision: 897669 URL: http://svn.apache.org/viewvc?rev=897669&view=rev Log: More tests and cleanups. Added: cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/ActivatorTest.java (with props) Modified: cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/Activator.java cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryUtils.java cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryTest.java Modified: cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/Activator.java URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/Activator.java?rev=897669&r1=897668&r2=897669&view=diff ============================================================================== --- cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/Activator.java (original) +++ cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/Activator.java Sun Jan 10 17:50:51 2010 @@ -22,7 +22,7 @@ import org.osgi.framework.BundleContext; public class Activator implements BundleActivator { - private LocalDiscovery localDiscovery; + LocalDiscovery localDiscovery; public synchronized void start(BundleContext context) { localDiscovery = new LocalDiscovery(context); Modified: cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryUtils.java URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryUtils.java?rev=897669&r1=897668&r2=897669&view=diff ============================================================================== --- cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryUtils.java (original) +++ cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryUtils.java Sun Jan 10 17:50:51 2010 @@ -96,7 +96,7 @@ private static EndpointDescription getEndpointDescription(Element endpointDescriptionElement) { Map map = new HashMap(); - List properties = endpointDescriptionElement.getChildren("property"); + List properties = endpointDescriptionElement.getChildren(PROPERTY_ELEMENT); for (Element prop : properties) { boolean handled = handleArray(prop, map); if (handled) { @@ -111,8 +111,8 @@ continue; } - String name = prop.getAttributeValue("name"); - String value = prop.getAttributeValue("value"); + String name = prop.getAttributeValue(PROPERTY_NAME_ATTRIBUTE); + String value = prop.getAttributeValue(PROPERTY_VALUE_ATTRIBUTE); if (value == null) { value = prop.getText(); } @@ -159,7 +159,7 @@ } private static String getTypeName(Element prop) { - String type = prop.getAttributeValue("value-type"); + String type = prop.getAttributeValue(PROPERTY_VALUE_TYPE_ATTRIBUTE); if (type == null) { type = "String"; } @@ -173,7 +173,7 @@ return false; } - List values = arrayEl.getChildren("value"); + List values = arrayEl.getChildren(PROPERTY_VALUE_ATTRIBUTE); String type = getTypeName(prop); Class cls = null; if ("long".equals(type)) { @@ -204,7 +204,7 @@ Array.set(array, i, val); } - String name = prop.getAttributeValue("name"); + String name = prop.getAttributeValue(PROPERTY_NAME_ATTRIBUTE); map.put(name, array); return true; } catch (Exception e) { @@ -231,13 +231,13 @@ } String type = getTypeName(prop); - List values = el.getChildren("value"); + List values = el.getChildren(PROPERTY_VALUE_ATTRIBUTE); for (Element val : values) { Object obj = handleValue(val, type); col.add(obj); } - String name = prop.getAttributeValue("name"); + String name = prop.getAttributeValue(PROPERTY_NAME_ATTRIBUTE); map.put(name, col); return true; } @@ -248,7 +248,7 @@ return false; } - String name = prop.getAttributeValue("name"); + String name = prop.getAttributeValue(PROPERTY_NAME_ATTRIBUTE); map.put(name, sb); return true; } Added: cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/ActivatorTest.java URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/ActivatorTest.java?rev=897669&view=auto ============================================================================== --- cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/ActivatorTest.java (added) +++ cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/ActivatorTest.java Sun Jan 10 17:50:51 2010 @@ -0,0 +1,33 @@ +package org.apache.cxf.dosgi.discovery.local; + +import junit.framework.TestCase; + +import org.easymock.IAnswer; +import org.easymock.classextension.EasyMock; +import org.osgi.framework.BundleContext; +import org.osgi.framework.Filter; +import org.osgi.framework.FrameworkUtil; + +public class ActivatorTest extends TestCase { + public void testActivator() throws Exception { + BundleContext bc = EasyMock.createNiceMock(BundleContext.class); + EasyMock.expect(bc.createFilter((String) EasyMock.anyObject())).andAnswer(new IAnswer() { + public Filter answer() throws Throwable { + return FrameworkUtil.createFilter((String) EasyMock.getCurrentArguments()[0]); + } + }).anyTimes(); + EasyMock.replay(bc); + + Activator a = new Activator(); + a.start(bc); + assertNotNull(a.localDiscovery); + + a.localDiscovery = EasyMock.createMock(LocalDiscovery.class); + a.localDiscovery.shutDown(); + EasyMock.expectLastCall(); + EasyMock.replay(a.localDiscovery); + a.stop(bc); + + EasyMock.verify(a.localDiscovery); + } +} Propchange: cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/ActivatorTest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/ActivatorTest.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Modified: cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryTest.java URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryTest.java?rev=897669&r1=897668&r2=897669&view=diff ============================================================================== --- cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryTest.java (original) +++ cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryTest.java Sun Jan 10 17:50:51 2010 @@ -206,7 +206,7 @@ assertEquals(2, ld.endpointDescriptions.size()); final Hashtable props = new Hashtable(); - props.put(EndpointListener.ENDPOINT_LISTENER_SCOPE, "(objectClass=org.example.ClassA)"); + props.put(EndpointListener.ENDPOINT_LISTENER_SCOPE, new String [] {"(objectClass=org.example.ClassA)"}); ServiceReference sr = EasyMock.createMock(ServiceReference.class); EasyMock.expect(sr.getPropertyKeys()).andReturn(props.keySet().toArray(new String [] {})).anyTimes(); EasyMock.expect(sr.getProperty((String) EasyMock.anyObject())).andAnswer(new IAnswer() {