cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
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 GMT
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<String, Object> map = new HashMap<String, Object>();
         
-        List<Element> properties = endpointDescriptionElement.getChildren("property");
+        List<Element> 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<Element> values = arrayEl.getChildren("value");
+        List<Element> 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<Element> values = el.getChildren("value");
+        List<Element> 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<Filter>()
{            
+            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<String, Object> props = new Hashtable<String, Object>();
-        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<Object>()
{



Mime
View raw message