http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/internal/LocalDiscovery.java ---------------------------------------------------------------------- diff --git a/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/internal/LocalDiscovery.java b/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/internal/LocalDiscovery.java deleted file mode 100644 index 2761cf3..0000000 --- a/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/internal/LocalDiscovery.java +++ /dev/null @@ -1,242 +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. - */ -package org.apache.cxf.dosgi.discovery.local.internal; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; - -import org.apache.cxf.dosgi.discovery.local.util.Utils; -import org.apache.cxf.dosgi.endpointdesc.EndpointDescriptionBundleParser; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; -import org.osgi.framework.BundleEvent; -import org.osgi.framework.BundleListener; -import org.osgi.framework.ServiceReference; -import org.osgi.service.remoteserviceadmin.EndpointDescription; -import org.osgi.service.remoteserviceadmin.EndpointListener; -import org.osgi.util.tracker.ServiceTracker; - -public class LocalDiscovery implements BundleListener { - - // this is effectively a set which allows for multiple service descriptions with the - // same interface name but different properties and takes care of itself with respect to concurrency - ConcurrentHashMap<EndpointDescription, Bundle> endpointDescriptions = - new ConcurrentHashMap<EndpointDescription, Bundle>(); - Map<EndpointListener, Collection<String>> listenerToFilters = - new HashMap<EndpointListener, Collection<String>>(); - Map<String, Collection<EndpointListener>> filterToListeners = - new HashMap<String, Collection<EndpointListener>>(); - final BundleContext bundleContext; - - EndpointDescriptionBundleParser bundleParser; - ServiceTracker<EndpointListener, EndpointListener> listenerTracker; - - public LocalDiscovery(BundleContext bc) { - this.bundleParser = new EndpointDescriptionBundleParser(); - bundleContext = bc; - - listenerTracker = new ServiceTracker<EndpointListener, EndpointListener>(bundleContext, - EndpointListener.class, null) { - - @Override - public EndpointListener addingService(ServiceReference<EndpointListener> reference) { - EndpointListener service = super.addingService(reference); - addListener(reference, service); - return service; - } - - @Override - public void modifiedService(ServiceReference<EndpointListener> reference, EndpointListener service) { - super.modifiedService(reference, service); - removeListener(service); - - // This may cause duplicate registrations of remote services, - // but that's fine and should be filtered out on another level. - // See Remote Service Admin spec section 122.6.3 - addListener(reference, service); - } - - @Override - public void removedService(ServiceReference<EndpointListener> reference, EndpointListener service) { - super.removedService(reference, service); - removeListener(service); - } - }; - listenerTracker.open(); - - bundleContext.addBundleListener(this); - processExistingBundles(); - } - - private void processExistingBundles() { - Bundle[] bundles = bundleContext.getBundles(); - if (bundles == null) { - return; - } - - for (Bundle b : bundles) { - if (b.getState() == Bundle.ACTIVE) { - findDeclaredRemoteServices(b); - } - } - } - - void addListener(ServiceReference<EndpointListener> endpointListenerRef, EndpointListener endpointListener) { - List<String> filters = Utils.getStringPlusProperty(endpointListenerRef, - EndpointListener.ENDPOINT_LISTENER_SCOPE); - if (filters.isEmpty()) { - return; - } - - synchronized (listenerToFilters) { - listenerToFilters.put(endpointListener, filters); - for (String filter : filters) { - Collection<EndpointListener> listeners = filterToListeners.get(filter); - if (listeners == null) { - listeners = new ArrayList<EndpointListener>(); - filterToListeners.put(filter, listeners); - } - listeners.add(endpointListener); - } - } - - triggerCallbacks(filters, endpointListener); - } - - /** - * If the tracker was removed or the scope was changed this doesn't require - * additional callbacks on the tracker. Its the responsibility of the tracker - * itself to clean up any orphans. See Remote Service Admin spec 122.6.3 - * @param endpointListener - */ - void removeListener(EndpointListener endpointListener) { - synchronized (listenerToFilters) { - Collection<String> filters = listenerToFilters.remove(endpointListener); - if (filters == null) { - return; - } - - for (String filter : filters) { - Collection<EndpointListener> listeners = filterToListeners.get(filter); - if (listeners != null) { - listeners.remove(endpointListener); - if (listeners.isEmpty()) { - filterToListeners.remove(filter); - } - } - } - } - } - - private Map<String, Collection<EndpointListener>> getMatchingListeners(EndpointDescription endpoint) { - // return a copy of matched filters/listeners so that caller doesn't need to hold locks while triggering events - Map<String, Collection<EndpointListener>> matched = new HashMap<String, Collection<EndpointListener>>(); - synchronized (listenerToFilters) { - for (Entry<String, Collection<EndpointListener>> entry : filterToListeners.entrySet()) { - String filter = entry.getKey(); - if (Utils.matchFilter(bundleContext, filter, endpoint)) { - matched.put(filter, new ArrayList<EndpointListener>(entry.getValue())); - } - } - } - return matched; - } - - public void shutDown() { - bundleContext.removeBundleListener(this); - listenerTracker.close(); - } - - // BundleListener method - public void bundleChanged(BundleEvent be) { - switch (be.getType()) { - case BundleEvent.STARTED: - findDeclaredRemoteServices(be.getBundle()); - break; - case BundleEvent.STOPPED: - removeServicesDeclaredInBundle(be.getBundle()); - break; - default: - } - } - - private void findDeclaredRemoteServices(Bundle bundle) { - List<EndpointDescription> endpoints = bundleParser.getAllEndpointDescriptions(bundle); - for (EndpointDescription endpoint : endpoints) { - endpointDescriptions.put(endpoint, bundle); - addedEndpointDescription(endpoint); - } - } - - private void removeServicesDeclaredInBundle(Bundle bundle) { - for (Iterator<Entry<EndpointDescription, Bundle>> i = endpointDescriptions.entrySet().iterator(); - i.hasNext();) { - Entry<EndpointDescription, Bundle> entry = i.next(); - if (bundle.equals(entry.getValue())) { - removedEndpointDescription(entry.getKey()); - i.remove(); - } - } - } - - private void addedEndpointDescription(EndpointDescription endpoint) { - triggerCallbacks(endpoint, true); - } - - private void removedEndpointDescription(EndpointDescription endpoint) { - triggerCallbacks(endpoint, false); - } - - private void triggerCallbacks(EndpointDescription endpoint, boolean added) { - for (Map.Entry<String, Collection<EndpointListener>> entry : getMatchingListeners(endpoint).entrySet()) { - String filter = entry.getKey(); - for (EndpointListener listener : entry.getValue()) { - triggerCallbacks(listener, filter, endpoint, added); - } - } - } - - private void triggerCallbacks(EndpointListener endpointListener, String filter, - EndpointDescription endpoint, boolean added) { - if (!Utils.matchFilter(bundleContext, filter, endpoint)) { - return; - } - - if (added) { - endpointListener.endpointAdded(endpoint, filter); - } else { - endpointListener.endpointRemoved(endpoint, filter); - } - } - - private void triggerCallbacks(Collection<String> filters, EndpointListener endpointListener) { - for (String filter : filters) { - for (EndpointDescription endpoint : endpointDescriptions.keySet()) { - triggerCallbacks(endpointListener, filter, endpoint, true); - } - } - } - -}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/util/Utils.java ---------------------------------------------------------------------- diff --git a/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/util/Utils.java b/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/util/Utils.java deleted file mode 100644 index 990ae9f..0000000 --- a/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/util/Utils.java +++ /dev/null @@ -1,125 +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. - */ -package org.apache.cxf.dosgi.discovery.local.util; - -import java.io.StringReader; -import java.io.StringWriter; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Dictionary; -import java.util.Hashtable; -import java.util.List; -import java.util.regex.Pattern; - -import javax.xml.transform.OutputKeys; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.stream.StreamResult; -import javax.xml.transform.stream.StreamSource; - -import org.osgi.framework.BundleContext; -import org.osgi.framework.Filter; -import org.osgi.framework.ServiceReference; -import org.osgi.service.remoteserviceadmin.EndpointDescription; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public final class Utils { - - private static final Logger LOG = LoggerFactory.getLogger(Utils.class); - - private Utils() { - // prevent instantiation - } - - public static List<String> getStringPlusProperty(ServiceReference<?> sr, String key) { - Object value = sr.getProperty(key); - if (value == null) { - return Collections.emptyList(); - } - - if (value instanceof String) { - return Collections.singletonList((String) value); - } - - if (value instanceof String[]) { - String[] values = (String[]) value; - List<String> result = new ArrayList<String>(values.length); - for (String v : values) { - if (v != null) { - result.add(v); - } - } - return Collections.unmodifiableList(result); - } - - if (value instanceof Collection<?>) { - Collection<?> values = (Collection<?>) value; - List<String> result = new ArrayList<String>(values.size()); - for (Object v : values) { - if (v instanceof String) { - result.add((String) v); - } - } - return Collections.unmodifiableList(result); - } - - return Collections.emptyList(); - } - - public static boolean matchFilter(BundleContext bctx, String filter, EndpointDescription endpoint) { - if (filter == null) { - return false; - } - - try { - Filter f = bctx.createFilter(filter); - Dictionary<String, Object> dict = new Hashtable<String, Object>(endpoint.getProperties()); - return f.match(dict); - } catch (Exception e) { - LOG.error("Problem creating a Filter from " + filter, e); - return false; - } - } - - public static String normXML(String s) { - String s2 = stripComment(s); - String s3 = stripProlog(s2); - try { - TransformerFactory transFactory = TransformerFactory.newInstance(); - Transformer transformer = transFactory.newTransformer(); - StringWriter buffer = new StringWriter(); - transformer.setOutputProperty(OutputKeys.INDENT, "yes"); - transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); - transformer.transform(new StreamSource(new StringReader(s3)), new StreamResult(buffer)); - return buffer.toString(); - } catch (Exception e) { - return ""; - } - } - - private static String stripComment(String s) { - return Pattern.compile("<!--(.*?)-->", Pattern.DOTALL).matcher(s).replaceAll(""); - } - - private static String stripProlog(String s) { - return s.replaceAll("<\\?(.*?)\\?>", ""); - } -} http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/discovery/local/src/main/java/org/apache/cxf/dosgi/endpointdesc/EndpointDescriptionBundleParser.java ---------------------------------------------------------------------- diff --git a/discovery/local/src/main/java/org/apache/cxf/dosgi/endpointdesc/EndpointDescriptionBundleParser.java b/discovery/local/src/main/java/org/apache/cxf/dosgi/endpointdesc/EndpointDescriptionBundleParser.java deleted file mode 100644 index edeaeac..0000000 --- a/discovery/local/src/main/java/org/apache/cxf/dosgi/endpointdesc/EndpointDescriptionBundleParser.java +++ /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. - */ -package org.apache.cxf.dosgi.endpointdesc; - -import java.net.URL; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Dictionary; -import java.util.Enumeration; -import java.util.List; -import java.util.Map; - -import org.osgi.framework.Bundle; -import org.osgi.service.remoteserviceadmin.EndpointDescription; -import org.osgi.xmlns.rsa.v1_0.EndpointDescriptionType; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public final class EndpointDescriptionBundleParser { - private static final Logger LOG = LoggerFactory.getLogger(EndpointDescriptionBundleParser.class); - - private static final String REMOTE_SERVICES_HEADER_NAME = "Remote-Service"; - private static final String REMOTE_SERVICES_DIRECTORY = "OSGI-INF/remote-service/"; - - private EndpointDescriptionParser parser; - - public EndpointDescriptionBundleParser() { - parser = new EndpointDescriptionParser(); - } - - public List<EndpointDescription> getAllEndpointDescriptions(Bundle b) { - List<EndpointDescriptionType> elements = getAllDescriptionElements(b); - - List<EndpointDescription> endpoints = new ArrayList<EndpointDescription>(elements.size()); - for (EndpointDescriptionType epd : elements) { - Map<String, Object> props = new PropertiesMapper().toProps(epd.getProperty()); - endpoints.add(new EndpointDescription(props)); - } - return endpoints; - } - - List<EndpointDescriptionType> getAllDescriptionElements(Bundle b) { - Enumeration<URL> urls = getEndpointDescriptionURLs(b); - List<EndpointDescriptionType> elements = new ArrayList<EndpointDescriptionType>(); - while (urls.hasMoreElements()) { - URL resourceURL = (URL) urls.nextElement(); - try { - elements.addAll(parser.getEndpointDescriptions(resourceURL.openStream())); - } catch (Exception ex) { - LOG.warn("Problem parsing: " + resourceURL, ex); - } - } - return elements; - } - - Enumeration<URL> getEndpointDescriptionURLs(Bundle b) { - String origDir = getRemoteServicesDir(b); - - // Split origDir into dir and file pattern - String filePattern = "*.xml"; - String dir; - if (origDir.endsWith("/")) { - dir = origDir.substring(0, origDir.length() - 1); - } else { - int idx = origDir.lastIndexOf('/'); - if (idx >= 0 & origDir.length() > idx) { - filePattern = origDir.substring(idx + 1); - dir = origDir.substring(0, idx); - } else { - filePattern = origDir; - dir = ""; - } - } - - Enumeration<URL> urls = b.findEntries(dir, filePattern, false); - return (urls == null) ? Collections.enumeration(new ArrayList<URL>()) : urls; - } - - private static String getRemoteServicesDir(Bundle b) { - Dictionary<?, ?> headers = b.getHeaders(); - Object header = null; - if (headers != null) { - header = headers.get(REMOTE_SERVICES_HEADER_NAME); - } - return (header == null) ? REMOTE_SERVICES_DIRECTORY : header.toString(); - } - -} http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/discovery/local/src/main/java/org/apache/cxf/dosgi/endpointdesc/EndpointDescriptionParser.java ---------------------------------------------------------------------- diff --git a/discovery/local/src/main/java/org/apache/cxf/dosgi/endpointdesc/EndpointDescriptionParser.java b/discovery/local/src/main/java/org/apache/cxf/dosgi/endpointdesc/EndpointDescriptionParser.java deleted file mode 100644 index fb502c8..0000000 --- a/discovery/local/src/main/java/org/apache/cxf/dosgi/endpointdesc/EndpointDescriptionParser.java +++ /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. - */ -package org.apache.cxf.dosgi.endpointdesc; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.List; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBElement; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Marshaller; -import javax.xml.bind.Unmarshaller; -import javax.xml.namespace.QName; -import javax.xml.transform.Source; -import javax.xml.transform.stream.StreamSource; - -import org.osgi.xmlns.rsa.v1_0.EndpointDescriptionType; -import org.osgi.xmlns.rsa.v1_0.EndpointDescriptionsType; - -public class EndpointDescriptionParser { - private JAXBContext jaxbContext; - - public EndpointDescriptionParser() { - try { - jaxbContext = JAXBContext.newInstance(EndpointDescriptionsType.class.getPackage().getName(), - this.getClass().getClassLoader()); - } catch (JAXBException e) { - throw new RuntimeException(e.getMessage(), e); - } - } - - public List<EndpointDescriptionType> getEndpointDescriptions(InputStream is) { - try { - Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); - Source source = new StreamSource(is); - JAXBElement<EndpointDescriptionsType> jaxb = unmarshaller.unmarshal(source, EndpointDescriptionsType.class); - EndpointDescriptionsType decorations = jaxb.getValue(); - return decorations.getEndpointDescription(); - } catch (Exception ex) { - throw new RuntimeException(ex.getMessage(), ex); - } - } - - public void writeTo(EndpointDescriptionsType endpointDescriptions, OutputStream os) { - try { - Marshaller marshaller = jaxbContext.createMarshaller(); - marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); - QName name = new QName("http://www.osgi.org/xmlns/rsa/v1.0.0", "endpoint-descriptions"); - JAXBElement<EndpointDescriptionsType> el = - new JAXBElement<EndpointDescriptionsType>(name, EndpointDescriptionsType.class, - endpointDescriptions); - marshaller.marshal(el, os); - } catch (Exception ex) { - throw new RuntimeException(ex.getMessage(), ex); - } finally { - try { - os.close(); - } catch (IOException e) { - // Ignore - } - } - } - - public byte[] getData(EndpointDescriptionType endpointDescription) { - EndpointDescriptionsType endpointDescriptions = new EndpointDescriptionsType(); - endpointDescriptions.getEndpointDescription().add(endpointDescription); - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - writeTo(endpointDescriptions, bos); - return bos.toByteArray(); - } -} http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/discovery/local/src/main/java/org/apache/cxf/dosgi/endpointdesc/PropertiesMapper.java ---------------------------------------------------------------------- diff --git a/discovery/local/src/main/java/org/apache/cxf/dosgi/endpointdesc/PropertiesMapper.java b/discovery/local/src/main/java/org/apache/cxf/dosgi/endpointdesc/PropertiesMapper.java deleted file mode 100644 index a7ed445..0000000 --- a/discovery/local/src/main/java/org/apache/cxf/dosgi/endpointdesc/PropertiesMapper.java +++ /dev/null @@ -1,345 +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. - */ -package org.apache.cxf.dosgi.endpointdesc; - -import java.io.Serializable; -import java.io.StringWriter; -import java.lang.reflect.Array; -import java.lang.reflect.Constructor; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.xml.bind.JAXBElement; -import javax.xml.transform.OutputKeys; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; - -import org.w3c.dom.Node; -import org.osgi.xmlns.rsa.v1_0.ArrayType; -import org.osgi.xmlns.rsa.v1_0.ObjectFactory; -import org.osgi.xmlns.rsa.v1_0.PropertyType; -import org.osgi.xmlns.rsa.v1_0.ValueType; -import org.osgi.xmlns.rsa.v1_0.XmlType; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class PropertiesMapper { - private static final Logger LOG = LoggerFactory.getLogger(PropertiesMapper.class); - - public Map<String, Object> toProps(List<PropertyType> properties) { - Map<String, Object> map = new HashMap<String, Object>(); - for (PropertyType prop : properties) { - map.put(prop.getName(), getValue(prop)); - } - return map; - } - - private Object getValue(PropertyType prop) { - Object value = null; - String type = getTypeName(prop); - Object content = getFirstNonText(prop.getContent()); - if (content instanceof JAXBElement<?>) { - JAXBElement<?> el = (JAXBElement<?>)content; - if (el.getDeclaredType() == ArrayType.class) { - String elName = el.getName().getLocalPart(); - ArrayType inValue = (ArrayType)el.getValue(); - if ("array".equals(elName)) { - value = getArray(inValue, type); - } else if ("set".equals(elName)) { - value = handleCollection(inValue, new HashSet<Object>(), type); - } else if ("list".equals(elName)) { - value = handleCollection(inValue, new ArrayList<Object>(), type); - } - } else if (el.getDeclaredType() == XmlType.class) { - value = readXML((XmlType)el.getValue(), type); - } - } else { - if (prop.getValue() != null) { - value = instantiate(type, prop.getValue()); - } else { - if (prop.getContent().size() > 0) { - value = instantiate(type, prop.getContent().get(0).toString()); - } - } - } - return value; - } - - private Object getFirstNonText(List<Serializable> contentList) { - for (Object content : contentList) { - if (content instanceof JAXBElement<?>) { - return content; - } - } - return null; - } - - private static String getTypeName(PropertyType prop) { - String type = prop.getValueType(); - return type == null ? "String" : type; - } - - private Object getArray(ArrayType arrayEl, String type) { - List<ValueType> values = arrayEl.getValue(); - Class<?> cls = null; - if ("long".equals(type)) { - cls = long.class; - } else if ("double".equals(type)) { - cls = double.class; - } else if ("float".equals(type)) { - cls = float.class; - } else if ("int".equals(type)) { - cls = int.class; - } else if ("byte".equals(type)) { - cls = byte.class; - } else if ("boolean".equals(type)) { - cls = boolean.class; - } else if ("short".equals(type)) { - cls = short.class; - } - - try { - if (cls == null) { - cls = ClassLoader.getSystemClassLoader().loadClass("java.lang." + type); - } - Object array = Array.newInstance(cls, values.size()); - - for (int i = 0; i < values.size(); i++) { - Object val = getValue(values.get(i), type); - Array.set(array, i, val); - } - - return array; - } catch (Exception e) { - LOG.warn("Could not create array for Endpoint Description", e); - return null; - } - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - private Collection handleCollection(ArrayType el, Collection value, String type) { - List<ValueType> values = el.getValue(); - for (ValueType val : values) { - Object obj = getValue(val, type); - value.add(obj); - } - return value; - } - - private Object getValue(ValueType value, String type) { - if (value.getContent().size() == 1 && value.getContent().get(0) instanceof String) { - return handleValue((String)value.getContent().get(0), type); - } - JAXBElement<?> valueContent = (JAXBElement<?>)getFirstNonText(value.getContent()); - if (valueContent.getDeclaredType() == XmlType.class) { - return readXML((XmlType)valueContent.getValue(), type); - } - return ""; - } - - private String readXML(XmlType el, String type) { - if (el == null) { - return null; - } - if (!"String".equals(type)) { - LOG.warn("Embedded XML must be of type String, found: " + type); - return null; - } - Node xmlContent = (Node)el.getAny(); - xmlContent.normalize(); - try { - TransformerFactory transFactory = TransformerFactory.newInstance(); - Transformer transformer = transFactory.newTransformer(); - StringWriter buffer = new StringWriter(); - transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); - transformer.transform(new DOMSource(xmlContent), new StreamResult(buffer)); - return buffer.toString(); - } catch (Exception e) { - return ""; - } - } - - private static Object handleValue(String val, String type) { - return instantiate(type, val); - } - - private static Object instantiate(String type, String value) { - if ("String".equals(type)) { - return value; - } - - value = value.trim(); - String boxedType = null; - if ("long".equals(type)) { - boxedType = "Long"; - } else if ("double".equals(type)) { - boxedType = "Double"; - } else if ("float".equals(type)) { - boxedType = "Float"; - } else if ("int".equals(type)) { - boxedType = "Integer"; - } else if ("byte".equals(type)) { - boxedType = "Byte"; - } else if ("char".equals(type)) { - boxedType = "Character"; - } else if ("boolean".equals(type)) { - boxedType = "Boolean"; - } else if ("short".equals(type)) { - boxedType = "Short"; - } - - if (boxedType == null) { - boxedType = type; - } - String javaType = "java.lang." + boxedType; - - try { - if ("Character".equals(boxedType)) { - return new Character(value.charAt(0)); - } else { - Class<?> cls = ClassLoader.getSystemClassLoader().loadClass(javaType); - Constructor<?> ctor = cls.getConstructor(String.class); - return ctor.newInstance(value); - } - } catch (Exception e) { - LOG.warn("Could not create Endpoint Property of type " + type + " and value " + value); - return null; - } - } - - public List<PropertyType> fromProps(Map<String, Object> m) { - List<PropertyType> props = new ArrayList<PropertyType>(); - for (Map.Entry<String, Object> entry : m.entrySet()) { - String key = entry.getKey(); - Object val = entry.getValue(); - - PropertyType propEl = new PropertyType(); - propEl.setName(key); - ObjectFactory factory = new ObjectFactory(); - if (val.getClass().isArray()) { - ArrayType arrayEl = new ArrayType(); - propEl.getContent().add(factory.createArray(arrayEl)); - for (Object o : normalizeArray(val)) { - setValueType(propEl, o); - ValueType valueType = new ValueType(); - valueType.getContent().add(o.toString()); - arrayEl.getValue().add(valueType); - } - } else if (val instanceof List) { - ArrayType listEl = new ArrayType(); - propEl.getContent().add(factory.createList(listEl)); - handleCollectionValue((Collection<?>) val, propEl, listEl); - } else if (val instanceof Set) { - ArrayType setEl = new ArrayType(); - propEl.getContent().add(factory.createSet(setEl)); - handleCollectionValue((Collection<?>) val, propEl, setEl); - } else if (val instanceof String - || val instanceof Character - || val instanceof Boolean - || val instanceof Byte) { - setValueType(propEl, val); - propEl.setValue(val.toString()); - } else if (val instanceof Long - || val instanceof Double - || val instanceof Float - || val instanceof Integer - || val instanceof Short) { - // various numbers.. maybe "val instanceof Number"? - setValueType(propEl, val); - propEl.setValue(val.toString()); - } else { - // Don't add this property as the value type is not supported - continue; - } - props.add(propEl); - } - return props; - } - - private static Object[] normalizeArray(Object val) { - List<Object> l = new ArrayList<Object>(); - if (val instanceof int[]) { - int[] ia = (int[]) val; - for (int i : ia) { - l.add(i); - } - } else if (val instanceof long[]) { - long[] la = (long[]) val; - for (long i : la) { - l.add(i); - } - } else if (val instanceof float[]) { - float[] fa = (float[]) val; - for (float f : fa) { - l.add(f); - } - } else if (val instanceof byte[]) { - byte[] ba = (byte[]) val; - for (byte b : ba) { - l.add(b); - } - } else if (val instanceof boolean[]) { - boolean[] ba = (boolean[]) val; - for (boolean b : ba) { - l.add(b); - } - } else if (val instanceof short[]) { - short[] sa = (short[]) val; - for (short s : sa) { - l.add(s); - } - } else if (val instanceof char[]) { - char[] ca = (char[]) val; - for (char c : ca) { - l.add(c); - } - } else { - return (Object[]) val; - } - return l.toArray(); - } - - private static void handleCollectionValue(Collection<?> val, PropertyType propEl, ArrayType listEl) { - for (Object o : val) { - setValueType(propEl, o); - ValueType valueType = new ValueType(); - valueType.getContent().add(o.toString()); - listEl.getValue().add(valueType); - } - } - - private static void setValueType(PropertyType propEl, Object val) { - if (val instanceof String) { - return; - } - - String dataType = val.getClass().getName(); - if (dataType.startsWith("java.lang.")) { - dataType = dataType.substring("java.lang.".length()); - } - propEl.setValueType(dataType); - } -} http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/discovery/local/src/main/resources/endpoint-description.xsd ---------------------------------------------------------------------- diff --git a/discovery/local/src/main/resources/endpoint-description.xsd b/discovery/local/src/main/resources/endpoint-description.xsd deleted file mode 100644 index b3254c1..0000000 --- a/discovery/local/src/main/resources/endpoint-description.xsd +++ /dev/null @@ -1,61 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.osgi.org/xmlns/rsa/v1.0.0" targetNamespace="http://www.osgi.org/xmlns/rsa/v1.0.0"> - <element name="endpoint-descriptions" - type="tns:EndpointDescriptionsType"> - </element> - - <complexType name="EndpointDescriptionsType"> - <sequence> - <element maxOccurs="unbounded" minOccurs="0" - ref="tns:endpoint-description"> - </element> - </sequence> - </complexType> - - <complexType name="EndpointDescriptionType"> - <sequence> - <element ref="tns:property" maxOccurs="unbounded" minOccurs="0"></element> - </sequence> - </complexType> - - <complexType name="PropertyType" mixed="true"> - <choice> - <element ref="tns:array"></element> - <element ref="tns:list"></element> - <element ref="tns:set"></element> - <element ref="tns:xml"></element> - </choice> - <attribute name="name" type="string"></attribute> - <attribute name="value-type" type="string"></attribute> - <attribute name="value" type="string"></attribute> - </complexType> - - <complexType name="ArrayType"> - <sequence> - <element maxOccurs="unbounded" minOccurs="0" - ref="tns:value"> - </element> - </sequence> - </complexType> - <element name="endpoint-description" - type="tns:EndpointDescriptionType"> - </element> - <element name="property" type="tns:PropertyType"></element> - <element name="array" type="tns:ArrayType"></element> - <element name="list" type="tns:ArrayType"></element> - <element name="set" type="tns:ArrayType"></element> - - <complexType name="XmlType"> - <sequence> - <any></any> - </sequence> - </complexType> - <element name="value" type="tns:ValueType"></element> - <element name="xml" type="tns:XmlType"></element> - - <complexType name="ValueType" mixed="true"> - <sequence> - <element ref="tns:xml"></element> - </sequence> - </complexType> -</schema> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/internal/ActivatorTest.java ---------------------------------------------------------------------- diff --git a/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/internal/ActivatorTest.java b/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/internal/ActivatorTest.java deleted file mode 100644 index a0bdc87..0000000 --- a/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/internal/ActivatorTest.java +++ /dev/null @@ -1,52 +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. - */ -package org.apache.cxf.dosgi.discovery.local.internal; - -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); - } -} http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/internal/LocalDiscoveryTest.java ---------------------------------------------------------------------- diff --git a/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/internal/LocalDiscoveryTest.java b/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/internal/LocalDiscoveryTest.java deleted file mode 100644 index ccbaca7..0000000 --- a/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/internal/LocalDiscoveryTest.java +++ /dev/null @@ -1,409 +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. - */ -package org.apache.cxf.dosgi.discovery.local.internal; - -import java.net.URL; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Dictionary; -import java.util.HashSet; -import java.util.Hashtable; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import junit.framework.TestCase; - -import org.easymock.EasyMock; -import org.easymock.IAnswer; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; -import org.osgi.framework.BundleEvent; -import org.osgi.framework.BundleListener; -import org.osgi.framework.Filter; -import org.osgi.framework.FrameworkUtil; -import org.osgi.framework.InvalidSyntaxException; -import org.osgi.framework.ServiceListener; -import org.osgi.framework.ServiceReference; -import org.osgi.service.remoteserviceadmin.EndpointDescription; -import org.osgi.service.remoteserviceadmin.EndpointListener; - -public class LocalDiscoveryTest extends TestCase { - - public void testLocalDiscovery() throws Exception { - Filter filter = EasyMock.createMock(Filter.class); - EasyMock.replay(filter); - - BundleContext bc = EasyMock.createMock(BundleContext.class); - EasyMock.expect(bc.createFilter("(objectClass=org.osgi.service.remoteserviceadmin.EndpointListener)")) - .andReturn(filter); - bc.addServiceListener((ServiceListener) EasyMock.anyObject(), - EasyMock.eq("(objectClass=org.osgi.service.remoteserviceadmin.EndpointListener)")); - EasyMock.expectLastCall(); - EasyMock.expect(bc.getServiceReferences("org.osgi.service.remoteserviceadmin.EndpointListener", null)) - .andReturn(null); - bc.addBundleListener((BundleListener) EasyMock.anyObject()); - EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() { - public Object answer() throws Throwable { - assertEquals(LocalDiscovery.class, EasyMock.getCurrentArguments()[0].getClass()); - return null; - } - }); - EasyMock.expect(bc.getBundles()).andReturn(null); - EasyMock.replay(bc); - - LocalDiscovery ld = new LocalDiscovery(bc); - assertSame(bc, ld.bundleContext); - assertNotNull(ld.listenerTracker); - - EasyMock.verify(bc); - - EasyMock.reset(bc); - bc.removeBundleListener(ld); - EasyMock.expectLastCall(); - bc.removeServiceListener((ServiceListener) EasyMock.anyObject()); - EasyMock.expectLastCall(); - EasyMock.replay(bc); - - ld.shutDown(); - EasyMock.verify(bc); - } - - public void testPreExistingBundles() throws Exception { - Filter filter = EasyMock.createMock(Filter.class); - EasyMock.replay(filter); - - BundleContext bc = EasyMock.createMock(BundleContext.class); - EasyMock.expect(bc.createFilter("(objectClass=org.osgi.service.remoteserviceadmin.EndpointListener)")) - .andReturn(filter); - bc.addServiceListener((ServiceListener) EasyMock.anyObject(), - EasyMock.eq("(objectClass=org.osgi.service.remoteserviceadmin.EndpointListener)")); - EasyMock.expectLastCall(); - EasyMock.expect(bc.getServiceReferences("org.osgi.service.remoteserviceadmin.EndpointListener", null)) - .andReturn(null); - bc.addBundleListener((BundleListener) EasyMock.anyObject()); - EasyMock.expectLastCall(); - - Bundle b1 = EasyMock.createMock(Bundle.class); - EasyMock.expect(b1.getState()).andReturn(Bundle.RESOLVED); - EasyMock.replay(b1); - Bundle b2 = EasyMock.createMock(Bundle.class); - EasyMock.expect(b2.getState()).andReturn(Bundle.ACTIVE); - Dictionary<String, String> headers = new Hashtable<String, String>(); - headers.put("Remote-Service", "OSGI-INF/remote-service/"); - EasyMock.expect(b2.getHeaders()).andReturn(headers); - - URL rs3URL = getClass().getResource("/ed3.xml"); - URL rs4URL = getClass().getResource("/ed4.xml"); - List<URL> urls = Arrays.asList(rs3URL, rs4URL); - EasyMock.expect(b2.findEntries("OSGI-INF/remote-service", "*.xml", false)) - .andReturn(Collections.enumeration(urls)); - EasyMock.replay(b2); - - EasyMock.expect(bc.getBundles()).andReturn(new Bundle[] {b1, b2}); - EasyMock.replay(bc); - - LocalDiscovery ld = new LocalDiscovery(bc); - - assertEquals(3, ld.endpointDescriptions.size()); - Set<String> expected = new HashSet<String>( - Arrays.asList("http://somewhere:12345", "http://somewhere:1", "http://somewhere")); - Set<String> actual = new HashSet<String>(); - for (Map.Entry<EndpointDescription, Bundle> entry : ld.endpointDescriptions.entrySet()) { - assertSame(b2, entry.getValue()); - actual.add(entry.getKey().getId()); - } - assertEquals(expected, actual); - } - - public void testBundleChanged() throws Exception { - LocalDiscovery ld = getLocalDiscovery(); - - Bundle bundle = EasyMock.createMock(Bundle.class); - EasyMock.expect(bundle.getSymbolicName()).andReturn("testing.bundle").anyTimes(); - EasyMock.expect(bundle.getState()).andReturn(Bundle.ACTIVE); - Dictionary<String, String> headers = new Hashtable<String, String>(); - headers.put("Remote-Service", "OSGI-INF/rsa/"); - EasyMock.expect(bundle.getHeaders()).andReturn(headers); - EasyMock.expect(bundle.findEntries("OSGI-INF/rsa", "*.xml", false)) - .andReturn(Collections.enumeration( - Collections.singleton(getClass().getResource("/ed3.xml")))); - EasyMock.replay(bundle); - - BundleEvent be0 = new BundleEvent(BundleEvent.INSTALLED, bundle); - ld.bundleChanged(be0); - assertEquals(0, ld.endpointDescriptions.size()); - - // Create an EndpointListener - final Map<String, Object> props = new Hashtable<String, Object>(); - props.put(EndpointListener.ENDPOINT_LISTENER_SCOPE, "(objectClass=*)"); - @SuppressWarnings("unchecked") - ServiceReference<EndpointListener> 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>() { - public Object answer() throws Throwable { - return props.get(EasyMock.getCurrentArguments()[0]); - } - }).anyTimes(); - EasyMock.replay(sr); - - EndpointListener endpointListener = EasyMock.createMock(EndpointListener.class); - endpointListener.endpointAdded((EndpointDescription) EasyMock.anyObject(), EasyMock.eq("(objectClass=*)")); - EasyMock.expectLastCall(); - EasyMock.replay(endpointListener); - ld.addListener(sr, endpointListener); - - // Start the bundle - BundleEvent be = new BundleEvent(BundleEvent.STARTED, bundle); - ld.bundleChanged(be); - assertEquals(1, ld.endpointDescriptions.size()); - EndpointDescription endpoint = ld.endpointDescriptions.keySet().iterator().next(); - assertEquals("http://somewhere:12345", endpoint.getId()); - assertSame(bundle, ld.endpointDescriptions.get(endpoint)); - - EasyMock.verify(endpointListener); - - // Stop the bundle - EasyMock.reset(endpointListener); - endpointListener.endpointRemoved((EndpointDescription) EasyMock.anyObject(), EasyMock.eq("(objectClass=*)")); - EasyMock.expectLastCall(); - EasyMock.replay(endpointListener); - - BundleEvent be1 = new BundleEvent(BundleEvent.STOPPED, bundle); - ld.bundleChanged(be1); - assertEquals(0, ld.endpointDescriptions.size()); - - EasyMock.verify(endpointListener); - } - - public void testEndpointListenerService() throws Exception { - LocalDiscovery ld = getLocalDiscovery(); - - Bundle bundle = EasyMock.createMock(Bundle.class); - EasyMock.expect(bundle.getState()).andReturn(Bundle.ACTIVE); - Dictionary<String, String> headers = new Hashtable<String, String>(); - headers.put("Remote-Service", "OSGI-INF/rsa/ed4.xml"); - EasyMock.expect(bundle.getHeaders()).andReturn(headers); - EasyMock.expect(bundle.findEntries("OSGI-INF/rsa", "ed4.xml", false)) - .andReturn(Collections.enumeration( - Collections.singleton(getClass().getResource("/ed4.xml")))); - EasyMock.replay(bundle); - - BundleEvent be = new BundleEvent(BundleEvent.STARTED, bundle); - ld.bundleChanged(be); - assertEquals(2, ld.endpointDescriptions.size()); - - final Map<String, Object> props = new Hashtable<String, Object>(); - props.put(EndpointListener.ENDPOINT_LISTENER_SCOPE, new String[] {"(objectClass=org.example.ClassA)"}); - @SuppressWarnings("unchecked") - ServiceReference<EndpointListener> 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>() { - public Object answer() throws Throwable { - return props.get(EasyMock.getCurrentArguments()[0]); - } - }).anyTimes(); - - EasyMock.replay(sr); - - EasyMock.reset(ld.bundleContext); - EndpointListener el = EasyMock.createMock(EndpointListener.class); - EasyMock.expect(ld.bundleContext.getService(sr)).andReturn(el); - EasyMock.expect(ld.bundleContext.ungetService(sr)).andReturn(true); - EasyMock.expect(ld.bundleContext.createFilter((String) EasyMock.anyObject())).andAnswer(new IAnswer<Filter>() { - public Filter answer() throws Throwable { - return FrameworkUtil.createFilter((String) EasyMock.getCurrentArguments()[0]); - } - }).anyTimes(); - EasyMock.replay(ld.bundleContext); - - el.endpointAdded((EndpointDescription) EasyMock.anyObject(), - EasyMock.eq("(objectClass=org.example.ClassA)")); - EasyMock.expectLastCall(); - EasyMock.replay(el); - - // Add the EndpointListener Service - assertEquals("Precondition failed", 0, ld.listenerToFilters.size()); - assertEquals("Precondition failed", 0, ld.filterToListeners.size()); - assertSame(el, ld.listenerTracker.addingService(sr)); - - assertEquals(1, ld.listenerToFilters.size()); - assertEquals(Collections.singletonList("(objectClass=org.example.ClassA)"), ld.listenerToFilters.get(el)); - assertEquals(1, ld.filterToListeners.size()); - assertEquals(Collections.singletonList(el), ld.filterToListeners.get("(objectClass=org.example.ClassA)")); - - EasyMock.verify(el); - - // Modify the EndpointListener Service - // no need to reset the mock for this... - props.put(EndpointListener.ENDPOINT_LISTENER_SCOPE, - "(|(objectClass=org.example.ClassA)(objectClass=org.example.ClassB))"); - - EasyMock.reset(el); - final Set<String> actualEndpoints = new HashSet<String>(); - el.endpointAdded((EndpointDescription) EasyMock.anyObject(), - EasyMock.eq("(|(objectClass=org.example.ClassA)(objectClass=org.example.ClassB))")); - EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() { - public Object answer() throws Throwable { - EndpointDescription endpoint = (EndpointDescription) EasyMock.getCurrentArguments()[0]; - actualEndpoints.addAll(endpoint.getInterfaces()); - return null; - } - }).times(2); - EasyMock.replay(el); - - ld.listenerTracker.modifiedService(sr, el); - assertEquals(1, ld.listenerToFilters.size()); - assertEquals(Arrays.asList("(|(objectClass=org.example.ClassA)(objectClass=org.example.ClassB))"), - ld.listenerToFilters.get(el)); - assertEquals(1, ld.filterToListeners.size()); - assertEquals(Collections.singletonList(el), - ld.filterToListeners.get("(|(objectClass=org.example.ClassA)(objectClass=org.example.ClassB))")); - - EasyMock.verify(el); - Set<String> expectedEndpoints = new HashSet<String>(Arrays.asList("org.example.ClassA", "org.example.ClassB")); - assertEquals(expectedEndpoints, actualEndpoints); - - // Remove the EndpointListener Service - ld.listenerTracker.removedService(sr, el); - assertEquals(0, ld.listenerToFilters.size()); - assertEquals(0, ld.filterToListeners.size()); - } - - public void testRegisterTracker() throws Exception { - LocalDiscovery ld = getLocalDiscovery(); - - final Map<String, Object> props = new Hashtable<String, Object>(); - props.put(EndpointListener.ENDPOINT_LISTENER_SCOPE, "(objectClass=Aaaa)"); - @SuppressWarnings("unchecked") - ServiceReference<EndpointListener> 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>() { - public Object answer() throws Throwable { - return props.get(EasyMock.getCurrentArguments()[0]); - } - }).anyTimes(); - EasyMock.replay(sr); - - EndpointListener endpointListener = EasyMock.createMock(EndpointListener.class); - EasyMock.replay(endpointListener); - - assertEquals("Precondition failed", 0, ld.listenerToFilters.size()); - assertEquals("Precondition failed", 0, ld.filterToListeners.size()); - ld.addListener(sr, endpointListener); - - assertEquals(1, ld.listenerToFilters.size()); - assertEquals(Collections.singletonList("(objectClass=Aaaa)"), ld.listenerToFilters.get(endpointListener)); - assertEquals(1, ld.filterToListeners.size()); - assertEquals(Collections.singletonList(endpointListener), ld.filterToListeners.get("(objectClass=Aaaa)")); - - // Add another one with the same scope filter - @SuppressWarnings("unchecked") - ServiceReference<EndpointListener> sr2 = EasyMock.createMock(ServiceReference.class); - EasyMock.expect(sr2.getPropertyKeys()).andReturn(props.keySet().toArray(new String[] {})).anyTimes(); - EasyMock.expect(sr2.getProperty((String) EasyMock.anyObject())).andAnswer(new IAnswer<Object>() { - public Object answer() throws Throwable { - return props.get(EasyMock.getCurrentArguments()[0]); - } - }).anyTimes(); - EasyMock.replay(sr2); - - EndpointListener endpointListener2 = EasyMock.createMock(EndpointListener.class); - EasyMock.replay(endpointListener2); - ld.addListener(sr2, endpointListener2); - - assertEquals(2, ld.listenerToFilters.size()); - assertEquals(Collections.singletonList("(objectClass=Aaaa)"), ld.listenerToFilters.get(endpointListener)); - assertEquals(Collections.singletonList("(objectClass=Aaaa)"), ld.listenerToFilters.get(endpointListener2)); - - assertEquals(1, ld.filterToListeners.size()); - List<EndpointListener> endpointListeners12 = Arrays.asList(endpointListener, endpointListener2); - assertEquals(endpointListeners12, ld.filterToListeners.get("(objectClass=Aaaa)")); - - // Add another listener with a multi-value scope - final Map<String, Object> props2 = new Hashtable<String, Object>(); - props2.put(EndpointListener.ENDPOINT_LISTENER_SCOPE, Arrays.asList("(objectClass=X)", "(objectClass=Y)")); - @SuppressWarnings("unchecked") - ServiceReference<EndpointListener> sr3 = EasyMock.createMock(ServiceReference.class); - EasyMock.expect(sr3.getPropertyKeys()).andReturn(props2.keySet().toArray(new String[] {})).anyTimes(); - EasyMock.expect(sr3.getProperty((String) EasyMock.anyObject())).andAnswer(new IAnswer<Object>() { - public Object answer() throws Throwable { - return props2.get(EasyMock.getCurrentArguments()[0]); - } - }).anyTimes(); - EasyMock.replay(sr3); - - EndpointListener endpointListener3 = EasyMock.createMock(EndpointListener.class); - EasyMock.replay(endpointListener3); - ld.addListener(sr3, endpointListener3); - - assertEquals(3, ld.listenerToFilters.size()); - assertEquals(Collections.singletonList("(objectClass=Aaaa)"), ld.listenerToFilters.get(endpointListener)); - assertEquals(Collections.singletonList("(objectClass=Aaaa)"), ld.listenerToFilters.get(endpointListener2)); - assertEquals(Arrays.asList("(objectClass=X)", "(objectClass=Y)"), ld.listenerToFilters.get(endpointListener3)); - - assertEquals(3, ld.filterToListeners.size()); - assertEquals(endpointListeners12, ld.filterToListeners.get("(objectClass=Aaaa)")); - assertEquals(Collections.singletonList(endpointListener3), ld.filterToListeners.get("(objectClass=X)")); - assertEquals(Collections.singletonList(endpointListener3), ld.filterToListeners.get("(objectClass=Y)")); - } - - public void testClearTracker() throws Exception { - LocalDiscovery ld = getLocalDiscovery(); - - EndpointListener endpointListener = EasyMock.createMock(EndpointListener.class); - ld.listenerToFilters.put(endpointListener, - new ArrayList<String>(Arrays.asList("(a=b)", "(objectClass=foo.bar.Bheuaark)"))); - ld.filterToListeners.put("(a=b)", new ArrayList<EndpointListener>(Arrays.asList(endpointListener))); - ld.filterToListeners.put("(objectClass=foo.bar.Bheuaark)", - new ArrayList<EndpointListener>(Arrays.asList(endpointListener))); - - assertEquals(1, ld.listenerToFilters.size()); - assertEquals(2, ld.filterToListeners.size()); - assertEquals(1, ld.filterToListeners.values().iterator().next().size()); - ld.removeListener(EasyMock.createMock(EndpointListener.class)); - assertEquals(1, ld.listenerToFilters.size()); - assertEquals(2, ld.filterToListeners.size()); - assertEquals(1, ld.filterToListeners.values().iterator().next().size()); - ld.removeListener(endpointListener); - assertEquals(0, ld.listenerToFilters.size()); - assertEquals(0, ld.filterToListeners.size()); - } - - private LocalDiscovery getLocalDiscovery() throws InvalidSyntaxException { - BundleContext bc = EasyMock.createMock(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(); - bc.addServiceListener((ServiceListener) EasyMock.anyObject(), - EasyMock.eq("(objectClass=org.osgi.service.remoteserviceadmin.EndpointListener)")); - EasyMock.expectLastCall(); - EasyMock.expect(bc.getServiceReferences("org.osgi.service.remoteserviceadmin.EndpointListener", null)) - .andReturn(null); - bc.addBundleListener((BundleListener) EasyMock.anyObject()); - EasyMock.expectLastCall(); - EasyMock.expect(bc.getBundles()).andReturn(null); - EasyMock.replay(bc); - - return new LocalDiscovery(bc); - } -} http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/discovery/local/src/test/java/org/apache/cxf/dosgi/endpointdesc/EndpointDescriptionBundleParserTest.java ---------------------------------------------------------------------- diff --git a/discovery/local/src/test/java/org/apache/cxf/dosgi/endpointdesc/EndpointDescriptionBundleParserTest.java b/discovery/local/src/test/java/org/apache/cxf/dosgi/endpointdesc/EndpointDescriptionBundleParserTest.java deleted file mode 100644 index 4884c50..0000000 --- a/discovery/local/src/test/java/org/apache/cxf/dosgi/endpointdesc/EndpointDescriptionBundleParserTest.java +++ /dev/null @@ -1,138 +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. - */ -package org.apache.cxf.dosgi.endpointdesc; - -import java.net.URL; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import junit.framework.TestCase; - -import org.apache.cxf.dosgi.discovery.local.util.Utils; -import org.easymock.EasyMock; -import org.osgi.framework.Bundle; -import org.osgi.service.remoteserviceadmin.EndpointDescription; - -public class EndpointDescriptionBundleParserTest extends TestCase { - - private Bundle createBundleContaining(URL ed1URL) { - Bundle b = EasyMock.createNiceMock(Bundle.class); - EasyMock.expect(b.findEntries( - EasyMock.eq("OSGI-INF/remote-service"), - EasyMock.eq("*.xml"), EasyMock.anyBoolean())).andReturn( - Collections.enumeration(Arrays.asList(ed1URL))).anyTimes(); - EasyMock.replay(b); - return b; - } - - public void testAllEndpoints1() { - URL ed1URL = getClass().getResource("/ed1.xml"); - - Bundle b = createBundleContaining(ed1URL); - - List<EndpointDescription> endpoints = new EndpointDescriptionBundleParser().getAllEndpointDescriptions(b); - assertEquals(4, endpoints.size()); - EndpointDescription endpoint0 = endpoints.get(0); - assertEquals("http://somewhere:12345", endpoint0.getId()); - assertEquals(Arrays.asList("SomeService"), endpoint0.getInterfaces()); - assertEquals(Arrays.asList("confidentiality"), - endpoint0.getProperties().get("osgi.remote.requires.intents")); - assertEquals("testValue", endpoint0.getProperties().get("testKey")); - - EndpointDescription endpoint1 = endpoints.get(1); - assertEquals("myScheme://somewhere:12345", endpoint1.getId()); - assertEquals(Arrays.asList("SomeOtherService", "WithSomeSecondInterface"), endpoint1.getInterfaces()); - - EndpointDescription endpoint2 = endpoints.get(2); - assertEquals("http://somewhere", endpoint2.getId()); - assertEquals(Arrays.asList("SomeOtherService", "WithSomeSecondInterface"), endpoint2.getInterfaces()); - - EndpointDescription endpoint3 = endpoints.get(3); - assertEquals("http://somewhere:1/2/3/4?5", endpoint3.getId()); - assertEquals(Arrays.asList("SomeOtherService", "WithSomeSecondInterface"), endpoint3.getInterfaces()); - } - - public void testAllEndpoints2() throws Exception { - URL ed2URL = getClass().getResource("/ed2.xml"); - - Bundle b = createBundleContaining(ed2URL); - - List<EndpointDescription> endpoints = new EndpointDescriptionBundleParser().getAllEndpointDescriptions(b); - assertEquals(2, endpoints.size()); - EndpointDescription endpoint0 = endpoints.get(0); - assertEquals("foo:bar", endpoint0.getId()); - assertEquals(Arrays.asList("com.acme.HelloService"), endpoint0.getInterfaces()); - assertEquals(Arrays.asList("SOAP"), endpoint0.getIntents()); - // changed from exported to imported - assertEquals("org.apache.cxf.ws", endpoint0.getProperties().get("service.imported.configs")); - - EndpointDescription endpoint1 = endpoints.get(1); - Map<String, Object> props = endpoint1.getProperties(); - assertEquals(Arrays.asList("com.acme.HelloService", "some.other.Service"), endpoint1.getInterfaces()); - assertEquals("org.apache.cxf.ws", props.get("service.imported.configs")); - // exports should have been removed - assertNull(props.get("service.exported.configs")); - - assertEquals(Utils.normXML("<other:t1 xmlns:other='http://www.acme.org/xmlns/other/v1.0.0' " - + "xmlns='http://www.acme.org/xmlns/other/v1.0.0'><foo type='bar'>haha</foo>\n" - + " </other:t1>"), - Utils.normXML((String) props.get("someXML"))); - assertEquals(Long.MAX_VALUE, props.get("long")); - assertEquals(-1L, props.get("long2")); - assertEquals(Double.MAX_VALUE, props.get("double")); - assertEquals(1.0d, props.get("Double2")); - assertEquals(42.24f, props.get("float")); - assertEquals(1.0f, props.get("Float2")); - assertEquals(17, props.get("int")); - assertEquals(42, props.get("Integer2")); - assertEquals((byte) 127, props.get("byte")); - assertEquals((byte) -128, props.get("Byte2")); - assertEquals(Boolean.TRUE, props.get("boolean")); - assertEquals(Boolean.TRUE, props.get("Boolean2")); - assertEquals((short) 99, props.get("short")); - assertEquals((short) -99, props.get("Short2")); - assertEquals('@', props.get("char")); - assertEquals('X', props.get("Character2")); - - int[] intArray = (int[]) props.get("int-array"); - assertTrue(Arrays.equals(new int[] {1, 2}, intArray)); - - Integer[] integerArray = (Integer[]) props.get("Integer-array"); - assertTrue(Arrays.equals(new Integer[] {2, 1}, integerArray)); - - assertEquals(Arrays.asList(true, false), props.get("bool-list")); - assertEquals(new HashSet<Object>(), props.get("long-set")); - Set<String> stringSet = new HashSet<String>(); - stringSet.add("Hello there"); - stringSet.add("How are you?"); - assertEquals(stringSet, props.get("string-set")); - assertEquals("Hello", props.get("other1").toString().trim()); - - List<?> l = (List<?>) props.get("other2"); - assertEquals(1, l.size()); - assertEquals(Utils.normXML("<other:t2 xmlns:other='http://www.acme.org/xmlns/other/v1.0.0' " - + "xmlns='http://www.osgi.org/xmlns/rsa/v1.0.0'/>"), - Utils.normXML((String) l.get(0))); - } - -} http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/discovery/local/src/test/java/org/apache/cxf/dosgi/endpointdesc/EndpointDescriptionParserTest.java ---------------------------------------------------------------------- diff --git a/discovery/local/src/test/java/org/apache/cxf/dosgi/endpointdesc/EndpointDescriptionParserTest.java b/discovery/local/src/test/java/org/apache/cxf/dosgi/endpointdesc/EndpointDescriptionParserTest.java deleted file mode 100644 index 97e4b45..0000000 --- a/discovery/local/src/test/java/org/apache/cxf/dosgi/endpointdesc/EndpointDescriptionParserTest.java +++ /dev/null @@ -1,49 +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. - */ -package org.apache.cxf.dosgi.endpointdesc; - -import java.io.IOException; -import java.net.URL; -import java.util.List; - -import org.easymock.EasyMock; -import org.junit.Assert; -import org.junit.Test; -import org.osgi.framework.Bundle; -import org.osgi.xmlns.rsa.v1_0.EndpointDescriptionType; - -public class EndpointDescriptionParserTest { - - @Test - public void testNoRemoteServicesXMLFiles() { - Bundle b = EasyMock.createNiceMock(Bundle.class); - EasyMock.replay(b); - - List<EndpointDescriptionType> rsElements = new EndpointDescriptionBundleParser().getAllDescriptionElements(b); - Assert.assertEquals(0, rsElements.size()); - } - - @Test - public void testEndpointDescriptionsFromURL() throws IOException { - URL ed1URL = getClass().getResource("/ed1.xml"); - List<EndpointDescriptionType> edElements = new EndpointDescriptionParser(). - getEndpointDescriptions(ed1URL.openStream()); - Assert.assertEquals(4, edElements.size()); - } -} http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/discovery/local/src/test/java/org/apache/cxf/dosgi/endpointdesc/PropertiesMapperTest.java ---------------------------------------------------------------------- diff --git a/discovery/local/src/test/java/org/apache/cxf/dosgi/endpointdesc/PropertiesMapperTest.java b/discovery/local/src/test/java/org/apache/cxf/dosgi/endpointdesc/PropertiesMapperTest.java deleted file mode 100644 index bc21198..0000000 --- a/discovery/local/src/test/java/org/apache/cxf/dosgi/endpointdesc/PropertiesMapperTest.java +++ /dev/null @@ -1,97 +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. - */ -package org.apache.cxf.dosgi.endpointdesc; - -import java.io.ByteArrayInputStream; -import java.net.URL; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.xml.sax.InputSource; - -import org.custommonkey.xmlunit.XMLAssert; -import org.junit.Test; -import org.osgi.xmlns.rsa.v1_0.EndpointDescriptionType; -import org.osgi.xmlns.rsa.v1_0.PropertyType; - -public class PropertiesMapperTest { - private static final String LF = "\n"; - - @Test - public void testCreateXML() throws Exception { - Map<String, Object> m = new LinkedHashMap<String, Object>(); - m.put("service.imported.configs", "org.apache.cxf.ws"); - m.put("endpoint.id", "foo:bar"); - m.put("objectClass", new String[] {"com.acme.HelloService", "some.other.Service"}); - m.put("SomeObject", new Object()); - m.put("long", 9223372036854775807L); - m.put("Long2", -1L); - m.put("double", 1.7976931348623157E308); - m.put("Double2", 1.0d); - m.put("float", 42.24f); - m.put("Float2", 1.0f); - m.put("int", 17); - m.put("Integer2", 42); - m.put("byte", (byte) 127); - m.put("Byte2", (byte) -128); - m.put("boolean", true); - m.put("Boolean2", false); - m.put("short", (short) 99); - m.put("Short2", (short) -99); - m.put("char", '@'); - m.put("Character2", 'X'); - - List<Boolean> boolList = new ArrayList<Boolean>(); - boolList.add(true); - boolList.add(false); - m.put("bool-list", boolList); - m.put("empty-set", new HashSet<Object>()); - - Set<String> stringSet = new LinkedHashSet<String>(); - stringSet.add("Hello there"); - stringSet.add("How are you?"); - m.put("string-set", stringSet); - - int[] intArray = new int[] {1, 2}; - m.put("int-array", intArray); - - String xml = "<xml>" + LF - + "<t1 xmlns=\"http://www.acme.org/xmlns/other/v1.0.0\">" + LF - + "<foo type='bar'>haha</foo>" + LF - + "</t1>" + LF - + "</xml>"; - m.put("someXML", xml); - - List<PropertyType> props = new PropertiesMapper().fromProps(m); - EndpointDescriptionType epd = new EndpointDescriptionType(); - epd.getProperty().addAll(props); - byte[] epData = new EndpointDescriptionParser().getData(epd); - - URL edURL = getClass().getResource("/ed2-generated.xml"); - InputSource expectedXml = new InputSource(edURL.openStream()); - InputSource actualXml = new InputSource(new ByteArrayInputStream(epData)); - XMLAssert.assertXMLEqual(expectedXml, actualXml); - } - -} http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/discovery/local/src/test/resources/ed1.xml ---------------------------------------------------------------------- diff --git a/discovery/local/src/test/resources/ed1.xml b/discovery/local/src/test/resources/ed1.xml deleted file mode 100644 index 95b1994..0000000 --- a/discovery/local/src/test/resources/ed1.xml +++ /dev/null @@ -1,72 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!-- - 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. ---> - -<endpoint-descriptions xmlns="http://www.osgi.org/xmlns/rsa/v1.0.0" - xmlns:other="http://www.acme.org/xmlns/other/v1.0.0"> - <endpoint-description> - <property name="objectClass"> - <array> - <value>SomeService</value> - </array> - </property> - <property name="osgi.remote.requires.intents"> - <list> - <value>confidentiality</value> - </list> - </property> - <property name="testKey" value="testValue"/> - <property name="endpoint.id">http://somewhere:12345</property> - <property name="service.imported.configs" value="org.apache.cxf.ws"/> - </endpoint-description> - - <endpoint-description> - <property name="objectClass"> - <array> - <value>SomeOtherService</value> - <value>WithSomeSecondInterface</value> - </array> - </property> - <property name="endpoint.id" value-type="String" value="myScheme://somewhere:12345" /> - <property name="service.imported.configs" value="org.apache.cxf.ws"/> - </endpoint-description> - - <endpoint-description> - <property name="objectClass" value-type="String"> - <array> - <value>SomeOtherService</value> - <value>WithSomeSecondInterface</value> - </array> - </property> - <property name="endpoint.id" value="http://somewhere" /> - <property name="service.imported.configs" value="org.apache.cxf.ws"/> - </endpoint-description> - - <endpoint-description> - <property name="objectClass"> - <array> - <value>SomeOtherService</value> - <value>WithSomeSecondInterface</value> - </array> - </property> - <property name="endpoint.id" value-type="String">http://somewhere:1/2/3/4?5</property> - <property name="service.imported.configs" value="org.apache.cxf.ws"/> - </endpoint-description> -</endpoint-descriptions> http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/discovery/local/src/test/resources/ed2-generated.xml ---------------------------------------------------------------------- diff --git a/discovery/local/src/test/resources/ed2-generated.xml b/discovery/local/src/test/resources/ed2-generated.xml deleted file mode 100644 index 5e2a5ef..0000000 --- a/discovery/local/src/test/resources/ed2-generated.xml +++ /dev/null @@ -1,54 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<endpoint-descriptions xmlns="http://www.osgi.org/xmlns/rsa/v1.0.0"> - <endpoint-description> - <property name="service.imported.configs" value="org.apache.cxf.ws" /> - <property name="endpoint.id" value="foo:bar" /> - <property name="objectClass"> - <array> - <value>com.acme.HelloService</value> - <value>some.other.Service</value> - </array> - </property> - <property name="long" value-type="Long" value="9223372036854775807" /> - <property name="Long2" value-type="Long" value="-1" /> - <property name="double" value-type="Double" - value="1.7976931348623157E308" /> - <property name="Double2" value-type="Double" value="1.0" /> - <property name="float" value-type="Float" value="42.24" /> - <property name="Float2" value-type="Float" value="1.0" /> - <property name="int" value-type="Integer" value="17" /> - <property name="Integer2" value-type="Integer" value="42" /> - <property name="byte" value-type="Byte" value="127" /> - <property name="Byte2" value-type="Byte" value="-128" /> - <property name="boolean" value-type="Boolean" value="true" /> - <property name="Boolean2" value-type="Boolean" value="false" /> - <property name="short" value-type="Short" value="99" /> - <property name="Short2" value-type="Short" value="-99" /> - <property name="char" value-type="Character" value="@" /> - <property name="Character2" value-type="Character" - value="X" /> - <property name="bool-list" value-type="Boolean"> - <list> - <value>true</value> - <value>false</value> - </list> - </property> - <property name="empty-set"> - <set /> - </property> - <property name="string-set"> - <set> - <value>Hello there</value> - <value>How are you?</value> - </set> - </property> - <property name="int-array" value-type="Integer"> - <array> - <value>1</value> - <value>2</value> - </array> - </property> - <property name="someXML" - value="<xml>
<t1 xmlns="http://www.acme.org/xmlns/other/v1.0.0">
<foo type='bar'>haha</foo>
</t1>
</xml>" /> - </endpoint-description> -</endpoint-descriptions> http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/discovery/local/src/test/resources/ed2.xml ---------------------------------------------------------------------- diff --git a/discovery/local/src/test/resources/ed2.xml b/discovery/local/src/test/resources/ed2.xml deleted file mode 100644 index e3c42b9..0000000 --- a/discovery/local/src/test/resources/ed2.xml +++ /dev/null @@ -1,99 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<endpoint-descriptions xmlns="http://www.osgi.org/xmlns/rsa/v1.0.0" - xmlns:other="http://www.acme.org/xmlns/other/v1.0.0"> - <endpoint-description> - <property name="objectClass"> - <array> - <value>com.acme.HelloService</value> - </array> - </property> - <property name="service.intents">SOAP</property> - <property name="service.imported.configs" value="org.apache.cxf.ws"/> - <property name="endpoint.id">foo:bar</property> - </endpoint-description> - <endpoint-description> - <property name="service.imported.configs" value="org.apache.cxf.ws"/> - <property name="endpoint.id">foo:bar</property> - <property name="objectClass" value-type="String"> - <array> - <value>com.acme.HelloService</value> - <value>some.other.Service</value> - </array> - </property> - - <property name="someXML" value-type="String"> - <!-- Literal XML to be parsed into the String --> - <xml> - <other:t1 xmlns="http://www.acme.org/xmlns/other/v1.0.0"> - <foo type="bar">haha</foo> - </other:t1> - </xml> - </property> - - <property name="long" value-type="long">9223372036854775807</property> - <property name="Long2" value-type="Long" value="-1"/> - <property name="double" value-type="double">1.7976931348623157E308</property> - <property name="Double2" value-type="Double">1.0</property> - <property name="float" value-type="float">42.24</property> - <property name="Float2" value-type="Float" value="1.0"/> - <property name="int" value-type="int">17</property> - <property name="Integer2" value-type="Integer" value="42"/> - <property name="byte" value-type="byte">127</property> - <property name="Byte2" value-type="Byte" value="-128"/> - <property name="boolean" value-type="boolean">true</property> - <property name="Boolean2" value-type="Boolean" value="true"/> - <property name="short" value-type="short">99</property> - <property name="Short2" value-type="Short" value="-99"/> - <property name="char" value-type="char">@</property> - <property name="Character2" value-type="Character" value="X"/> - - <property name="bool-list" value-type="boolean"> - <list> - <value>true</value> - <value>false</value> - </list> - </property> - <property name="long-set" value-type="long"> - <set/> <!-- empty set --> - </property> - <property name="string-set"> - <set> - <value>Hello there</value> - <value>How are you?</value> - </set> - </property> - <property name="int-array" value-type="int"> - <array> - <value>1</value> - <value>2</value> - </array> - </property> - <property name="Integer-array" value-type="Integer"> - <array> - <value>2</value> - <value>1</value> - </array> - </property> - <property name="service.exported.configs"> - org.apache.cxf.ws - </property> - - <property name="other1"> - Hello - <other:t1/> - <!-- the above tag is a custom extension --> - </property> - <property name="other2"> - <list> - <value> - <!-- A value specified as literal XML --> - <xml> - <other:t2/> - </xml> - </value> - </list> - <!-- This is a custom extension --> - <other:t1/> - </property> - </endpoint-description> -</endpoint-descriptions>