Search in sources :

Example 1 with ExportedServiceImpl

use of org.apache.aries.application.modelling.impl.ExportedServiceImpl in project aries by apache.

the class DeployedBundlesTest method createModelledServiceBundle.

public static ModelledResource createModelledServiceBundle(String bundleName, String bundleVersion, Collection<String> importService, Collection<String> exportService) throws InvalidAttributeException {
    Attributes att = new Attributes();
    att.put(new Attributes.Name(Constants.BUNDLE_SYMBOLICNAME), bundleName);
    att.put(new Attributes.Name(Constants.BUNDLE_VERSION), bundleVersion);
    att.put(new Attributes.Name(Constants.BUNDLE_MANIFESTVERSION), "2");
    List<ImportedService> importedServices = new ArrayList<ImportedService>();
    for (String s : importService) {
        importedServices.add(new ImportedServiceImpl(false, s, null, null, null, false));
    }
    List<ExportedService> exportedServices = new ArrayList<ExportedService>();
    for (String s : exportService) {
        exportedServices.add(new ExportedServiceImpl(null, 0, Collections.singleton(s), Collections.<String, Object>emptyMap()));
    }
    return new ModelledResourceImpl(null, att, importedServices, exportedServices);
}
Also used : ImportedServiceImpl(org.apache.aries.application.modelling.impl.ImportedServiceImpl) ModelledResourceImpl(org.apache.aries.application.modelling.impl.ModelledResourceImpl) ExportedService(org.apache.aries.application.modelling.ExportedService) Attributes(java.util.jar.Attributes) ArrayList(java.util.ArrayList) ImportedService(org.apache.aries.application.modelling.ImportedService) ExportedServiceImpl(org.apache.aries.application.modelling.impl.ExportedServiceImpl)

Example 2 with ExportedServiceImpl

use of org.apache.aries.application.modelling.impl.ExportedServiceImpl in project aries by apache.

the class ExportedServiceTest method checkEquality.

@Test
public void checkEquality() {
    //   public ExportedService (String name, int ranking, Collection<String> ifaces, 
    // Map<String, String> serviceProperties ) { 
    Map<String, Object> props = new HashMap<String, Object>();
    props.put("away", "www.away.com");
    props.put("home", "www.home.net");
    WrappedServiceMetadata wsm1 = new ExportedServiceImpl(null, 0, Arrays.asList("a.b.c", "d.e.f"), props);
    WrappedServiceMetadata wsm2 = new ExportedServiceImpl(null, 0, Arrays.asList("d.e.f", "a.b.c"), props);
    assertTrue("Basic equality test", wsm1.equals(wsm2));
    assertTrue("Basic equality test", wsm2.equals(wsm1));
    assertTrue("Hashcodes equal", wsm1.hashCode() == wsm2.hashCode());
    wsm2 = new ExportedServiceImpl(null, 0, Arrays.asList("d.e.f", "a.b.c", "g.e.f"), props);
    assertFalse("Adding an interface makes them different", wsm1.equals(wsm2));
    assertFalse("Adding an interface makes them different", wsm2.equals(wsm1));
    assertFalse("Hashcodes should differ", wsm1.hashCode() == wsm2.hashCode());
    props = new HashMap<String, Object>(props);
    props.put("interim", "w3.interim.org");
    wsm1 = new ExportedServiceImpl(null, 0, Arrays.asList("a.b.c", "d.e.f", "g.e.f"), props);
    assertFalse("Adding a service property makes them different", wsm1.equals(wsm2));
    assertFalse("Adding a service property makes them different", wsm2.equals(wsm1));
    assertFalse("Hashcodes still different", wsm1.hashCode() == wsm2.hashCode());
}
Also used : HashMap(java.util.HashMap) WrappedServiceMetadata(org.apache.aries.application.modelling.WrappedServiceMetadata) ExportedServiceImpl(org.apache.aries.application.modelling.impl.ExportedServiceImpl) Test(org.junit.Test)

Aggregations

ExportedServiceImpl (org.apache.aries.application.modelling.impl.ExportedServiceImpl)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Attributes (java.util.jar.Attributes)1 ExportedService (org.apache.aries.application.modelling.ExportedService)1 ImportedService (org.apache.aries.application.modelling.ImportedService)1 WrappedServiceMetadata (org.apache.aries.application.modelling.WrappedServiceMetadata)1 ImportedServiceImpl (org.apache.aries.application.modelling.impl.ImportedServiceImpl)1 ModelledResourceImpl (org.apache.aries.application.modelling.impl.ModelledResourceImpl)1 Test (org.junit.Test)1