Package org.rioproject.associations

Examples of org.rioproject.associations.AssociationDescriptor


            }
        }

        private List<ServiceElement> getMatchingServiceElements(final DeploymentMap dMap) {
            List<ServiceElement> matching = new ArrayList<ServiceElement>();
            AssociationDescriptor ad = association.getAssociationDescriptor();
            String[] adInterfaces = ad.getInterfaceNames();
            Arrays.sort(adInterfaces);
            for(ServiceElement elem : dMap.getServiceElements()) {
                List<String> list = new ArrayList<String>();
                for(ClassBundle cb : elem.getExportBundles()) {
                    list.add(cb.getClassName());
                }
                String[] cbInterfaces = list.toArray(new String[list.size()]);
                if(Arrays.equals(adInterfaces, cbInterfaces)) {
                    if(ad.matchOnName()) {
                        if(ad.getName().equals(elem.getName())) {
                            matching.add(elem);
                        }
                    } else {
                        matching.add(elem);
                    }
View Full Code Here


    @Test
    public void testEagerInjection() {
        DefaultAssociationManagement aMgr = new DefaultAssociationManagement();
        Target5 target = new Target5();
        aMgr.setBackend(target);
        AssociationDescriptor descriptor = createAssociationDescriptor();
        descriptor.setLazyInject(false);
        Association<Dummy> a = aMgr.addAssociationDescriptor(descriptor);
        Assert.assertTrue(target.injectedCount==1);
        Assert.assertNotNull(target.dummy);
        Assert.assertEquals(Association.State.PENDING, target.dummy.getState());
    }
View Full Code Here

    private AssociationDescriptor createAssociationDescriptor() {
        return createAssociationDescriptor(null);
    }

    private AssociationDescriptor createAssociationDescriptor(String name) {
        AssociationDescriptor ad = new AssociationDescriptor();
        ad.setName(name);
        ad.setInterfaceNames(Dummy.class.getName());
        ad.setPropertyName("dummy");
        return ad;
    }
View Full Code Here

*/
public class AssociationCollectionTest {

    @Test
    public void testAdd() {
        Association<Dummy> a = new DefaultAssociation<Dummy>(new AssociationDescriptor());
        for(int i=0; i<10; i++)
            a.addServiceItem(AssociationUtils.makeServiceItem(i));

        Assert.assertEquals("Should have 10 associated services", 10, a.getServiceCount());

View Full Code Here

        }
    }

    @Test
    public void testAddRemove() {
        Association<Dummy> a = new DefaultAssociation<Dummy>(new AssociationDescriptor());
        for(int i=0; i<10; i++)
            a.addServiceItem(AssociationUtils.makeServiceItem(i));

        Assert.assertEquals("Should have 10 associated services", 10, a.getServiceCount());
        ServiceItem[] items = a.getServiceItems();
View Full Code Here

        Assert.assertEquals("Should have 0 associated services", 0, a.getServiceCount());
    }

    @Test
    public void testNext() {
        Association<Dummy> a = new DefaultAssociation<Dummy>(new AssociationDescriptor());
        for(int i=0; i<10; i++)
            a.addServiceItem(AssociationUtils.makeServiceItem(i));

        Assert.assertEquals("Should have 10 associated services", 10, a.getServiceCount());
        for(int i=0; i<a.getServiceCount(); i++) {
View Full Code Here

        Assert.assertEquals(0, ((Dummy)a.getNextServiceItem().service).getIndex());       
    }

    @Test
    public void testNextAndAdd() {
        Association<Dummy> a = new DefaultAssociation<Dummy>(new AssociationDescriptor());
        for(int i=0; i<10; i++)
            a.addServiceItem(AssociationUtils.makeServiceItem(i));

        Assert.assertEquals("Should have 10 associated services", 10, a.getServiceCount());
        for(int i=0; i<a.getServiceCount(); i++) {
View Full Code Here

        Assert.assertEquals(10, ((Dummy)a.getNextServiceItem().service).getIndex());
    }

    @Test
    public void testNextAndRemove() {
        Association<Dummy> a = new DefaultAssociation<Dummy>(new AssociationDescriptor());
        for(int i=0; i<10; i++)
            a.addServiceItem(AssociationUtils.makeServiceItem(i));

        Assert.assertEquals("Should have 10 associated services", 10, a.getServiceCount());
        for(int i=0; i<a.getServiceCount(); i++) {
View Full Code Here

        Assert.assertEquals(2, ((Dummy)a.getNextServiceItem().service).getIndex());
    }

    @Test
    public void testIterable() {
        Association<Dummy> a = new DefaultAssociation<Dummy>(new AssociationDescriptor());
        for(int i=0; i<10; i++)
            a.addServiceItem(AssociationUtils.makeServiceItem(i));

        Assert.assertEquals("Should have 10 associated services", 10, a.getServiceCount());
        int i=0;
View Full Code Here

        }
    }

    @Test
    public void testEmpty() {
        Association<Dummy> a = new DefaultAssociation<Dummy>(new AssociationDescriptor());
        Assert.assertNull(a.getNextServiceItem());
        Assert.assertNull(a.getService());
        Assert.assertNull(a.getServiceItem());
        Assert.assertNull(a.removeService(new DummyImpl(0)));
        Assert.assertEquals(0, a.getServices().size());
View Full Code Here

TOP

Related Classes of org.rioproject.associations.AssociationDescriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.