RemoteServiceAdminCore implements RemoteServiceAdmin { @Override @SuppressWarnings({ "rawtypes", "unchecked" }) public List<ExportRegistration> exportService(ServiceReference serviceReference, Map additionalProperties) throws IllegalArgumentException, UnsupportedOperationException { Map<String, Object> serviceProperties = getProperties(serviceReference); if (additionalProperties != null) { overlayProperties(serviceProperties, additionalProperties); } Map<String, Object> key = makeKey(serviceProperties); List<String> interfaceNames = getInterfaceNames(serviceProperties); if (isImportedService(serviceReference) || !isExportConfigSupported(serviceProperties)) { return Collections.emptyList(); } List<ExportRegistration> exportRegs = getExistingAndLock(key, interfaceNames); if (exportRegs != null) { return exportRegs; } try { ExportRegistration exportReg = exportService(interfaceNames, serviceReference, serviceProperties); exportRegs = new ArrayList<>(); if (exportReg != null) { exportRegs.add(exportReg); } store(key, exportRegs); return exportRegs; } finally { unlock(key); } } RemoteServiceAdminCore(BundleContext context,
            BundleContext apiContext,
            EventProducer eventProducer,
            DistributionProvider provider,
            PackageUtil packageUtil); @Override @SuppressWarnings({ "rawtypes", "unchecked" }) List<ExportRegistration> exportService(ServiceReference serviceReference, Map additionalProperties); @Override Collection<ExportReference> getExportedServices(); @Override Collection<ImportReference> getImportedEndpoints(); @Override ImportRegistration importService(EndpointDescription endpoint); void close();  }
@Test public void testExportWrongConfig() throws Exception { final Map<String, Object> sProps = new HashMap<>(); sProps.put("objectClass", new String[] {"java.lang.Runnable"}); sProps.put("service.id", 51L); sProps.put("myProp", "myVal"); sProps.put("service.exported.interfaces", "*"); sProps.put(RemoteConstants.SERVICE_EXPORTED_CONFIGS, "org.apache.cxf.ws"); ServiceReference sref = mockServiceReference(sProps); c.replay(); List<ExportRegistration> ereg = rsaCore.exportService(sref, null); assertEquals(0, ereg.size()); c.verify(); }
@Test public void testExportOneConfigSupported() throws Exception { final Map<String, Object> sProps = new HashMap<>(); sProps.put("objectClass", new String[] {"java.lang.Runnable"}); sProps.put("service.id", 51L); sProps.put("myProp", "myVal"); sProps.put("service.exported.interfaces", "*"); sProps.put(RemoteConstants.SERVICE_EXPORTED_CONFIGS, new String[]{MYCONFIG, "aconfig"}); ServiceReference sref = mockServiceReference(sProps); provider.endpoint = createEndpoint(sProps); c.replay(); List<ExportRegistration> ereg = rsaCore.exportService(sref, null); assertEquals(1, ereg.size()); ExportRegistration first = ereg.iterator().next(); EndpointDescription exportedEndpoint = first.getExportReference().getExportedEndpoint(); assertThat(exportedEndpoint.getConfigurationTypes(), contains(MYCONFIG)); }