- public void testFilterProvided() {
- RequiredInterface req1 = new DefaultRequiredInterface("name",
- Runnable.class);
- RequiredInterface req2 = new DefaultRequiredInterface("name",
- Serializable.class);
- ProvidedInterface prov1 = new DefaultProvidedInterface("name",
- Runnable.class);
- ProvidedInterface prov2 = new DefaultProvidedInterface("name",
- Serializable.class);
- ProvidedInterface prov3 = new DefaultProvidedInterface("name",
- MyMultiple.class);
-
- Component client = new Application("client");
- Component dummy = new Application("dummy");
-
- InterfaceRestriction noRestriction = new InterfaceRestriction() {
- @Override
- public boolean isViolated(Component aClient,
- RequiredInterface aRequired, Component aServer,
- ProvidedInterface aProvided) {
- return false;
- }
- };
-
- AssertionUtils.assertEquals(new ProvidedInterface[] { prov1 },
- Container.filterProvidedServices(client, req1,
- createProvidedInput(new ProvidedInterface[] { prov1 },
- dummy), noRestriction));
- AssertionUtils.assertEquals(new ProvidedInterface[] { prov1 },
- Container.filterProvidedServices(client, req1,
- createProvidedInput(new ProvidedInterface[] { prov1,
- prov2 }, dummy), noRestriction));
- AssertionUtils.assertEquals(new ProvidedInterface[] { prov1, prov3 },
- Container.filterProvidedServices(client, req1,
- createProvidedInput(new ProvidedInterface[] { prov1,
- prov3 }, dummy), noRestriction));
-
- InterfaceRestriction everything = new InterfaceRestriction() {
- @Override
- public boolean isViolated(Component aClient,
- RequiredInterface aRequired, Component aServer,
- ProvidedInterface aProvided) {
- return true;
- }
- };
- AssertionUtils.assertEquals(new ProvidedInterface[0], Container
- .filterProvidedServices(client, req1, createProvidedInput(
- new ProvidedInterface[] { prov1, prov3 }, dummy),
- everything));
-
- }
-