@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>() {
            // Must use add(idx, obj), get the other add() overloads to complain
            @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);
    }
}