@@ -0,0 +1,2256 @@
+package org.apache.aries.subsystem.obr.internal;%0A%0Aimport static org.junit.Assert.assertEquals;%0A%0Aimport org.apache.felix.bundlerepository.Requirement;%0Aimport org.easymock.EasyMock;%0Aimport org.junit.Test;%0Aimport org.osgi.resource.Namespace;%0Aimport org.osgi.resource.Resource;%0A%0Apublic class FelixRequirementAdapterTest %7B%0A%09@Test%0A%09public void testCardinalityDirectiveMultiple() %7B%0A%09%09Requirement req = EasyMock.createNiceMock(Requirement.class);%0A%09%09EasyMock.expect(req.getFilter()).andReturn(%22%22);%0A%09%09EasyMock.expect(req.isMultiple()).andReturn(true);%0A%09%09EasyMock.replay(req);%0A%09%09FelixRequirementAdapter adapter = new FelixRequirementAdapter(req, EasyMock.createNiceMock(Resource.class));%0A%09%09assertEquals(adapter.getDirectives().get(Namespace.REQUIREMENT_CARDINALITY_DIRECTIVE), Namespace.CARDINALITY_MULTIPLE);%0A%09%7D%0A%09%0A%09@Test%0A%09public void testCardinalityDirectiveSingle() %7B%0A%09%09Requirement req = EasyMock.createNiceMock(Requirement.class);%0A%09%09EasyMock.expect(req.getFilter()).andReturn(%22%22);%0A%09%09EasyMock.expect(req.isMultiple()).andReturn(false);%0A%09%09EasyMock.replay(req);%0A%09%09FelixRequirementAdapter adapter = new FelixRequirementAdapter(req, EasyMock.createNiceMock(Resource.class));%0A%09%09assertEquals(adapter.getDirectives().get(Namespace.REQUIREMENT_CARDINALITY_DIRECTIVE), Namespace.CARDINALITY_SINGLE);%0A%09%7D%0A%09%0A%09@Test%0A%09public void testResolutionDirectiveMandatory() %7B%0A%09%09Requirement req = EasyMock.createNiceMock(Requirement.class);%0A%09%09EasyMock.expect(req.getFilter()).andReturn(%22%22);%0A%09%09EasyMock.expect(req.isOptional()).andReturn(false);%0A%09%09EasyMock.replay(req);%0A%09%09FelixRequirementAdapter adapter = new FelixRequirementAdapter(req, EasyMock.createNiceMock(Resource.class));%0A%09%09assertEquals(adapter.getDirectives().get(Namespace.REQUIREMENT_RESOLUTION_DIRECTIVE), Namespace.RESOLUTION_MANDATORY);%0A%09%7D%0A%09%0A%09@Test%0A%09public void testResolutionDirectiveOptional() %7B%0A%09%09Requirement req = EasyMock.createNiceMock(Requirement.class);%0A%09%09EasyMock.expect(req.getFilter()).andReturn(%22%22);%0A%09%09EasyMock.expect(req.isOptional()).andReturn(true);%0A%09%09EasyMock.replay(req);%0A%09%09FelixRequirementAdapter adapter = new FelixRequirementAdapter(req, EasyMock.createNiceMock(Resource.class));%0A%09%09assertEquals(adapter.getDirectives().get(Namespace.REQUIREMENT_RESOLUTION_DIRECTIVE), Namespace.RESOLUTION_OPTIONAL);%0A%09%7D%0A%7D%0A

Add tests to verify optional requirements are not treated as mandatory.