ResolveContext extends org.osgi.service.resolver.ResolveContext { @Override public int insertHostedCapability(List<Capability> capabilities, HostedCapability hostedCapability) { int sz = capabilities.size(); capabilities.add(sz, hostedCapability); return sz; } ResolveContext(SubsystemResource resource); @Override List<Capability> findProviders(Requirement requirement); @Override int insertHostedCapability(List<Capability> capabilities, HostedCapability hostedCapability); @Override boolean isEffective(Requirement requirement); @Override Collection<Resource> getMandatoryResources(); @Override Collection<Resource> getOptionalResources(); @Override Map<Resource, Wiring> getWirings();  }
@Test public void testInsertHostedCapability() throws Exception { Activator prev = getActivator(); try { Activator activator = createActivator(); setActivator(activator); SubsystemResource res = new SubsystemResource(new File(".")); ResolveContext rc = new ResolveContext(res); HostedCapability hc = EasyMock.createNiceMock(HostedCapability.class); List<Capability> caps = new ArrayList<Capability>() { @Override public boolean add(Capability e) { throw new UnsupportedOperationException(); } @Override public boolean addAll(Collection<? extends Capability> c) { throw new UnsupportedOperationException(); } @Override public boolean addAll(int index, Collection<? extends Capability> c) { throw new UnsupportedOperationException(); } }; caps.add(0, EasyMock.createNiceMock(HostedCapability.class)); assertEquals(1, rc.insertHostedCapability(caps, hc)); assertSame(hc, caps.get(1)); } finally { setActivator(prev); } }