@Test
public void testMultipleProviders() throws Exception {

    Bundle spiFlyBundle = mockSpiFlyBundle();
    Dictionary<String, String> headers = new Hashtable<String, String>();
    headers.put(SpiFlyConstants.SPI_CONSUMER_HEADER, "*");
    Bundle consumerBundle = mockConsumerBundle(headers, spiFlyBundle);
    activator.addConsumerWeavingData(consumerBundle, SpiFlyConstants.SPI_CONSUMER_HEADER);
    WeavingHook wh = new ClientWeavingHook(spiFlyBundle.getBundleContext(), activator);
    // Weave the TestClient class.
    URL clsUrl = getClass().getResource("TestClient.class");
    WovenClass wc = new MyWovenClass(clsUrl, "org.apache.aries.spifly.dynamic.TestClient", consumerBundle);
    wh.weave(wc);
    Bundle providerBundle1 = mockProviderBundle("impl1", 1);
    Bundle providerBundle2 = mockProviderBundle("impl2", 2);
    activator.registerProviderBundle("org.apache.aries.mytest.MySPI", providerBundle1, new HashMap<String, Object>());
    activator.registerProviderBundle("org.apache.aries.mytest.MySPI", providerBundle2, new HashMap<String, Object>());
    // Invoke the woven class and check that it propertly sets the TCCL so that the
    // META-INF/services/org.apache.aries.mytest.MySPI files from impl1 and impl2 are visible.
    Class<?> cls = wc.getDefinedClass();
    Method method = cls.getMethod("test", new Class [] {String.class});
    Object result = method.invoke(cls.newInstance(), "hello");
    Set<String> expected = new HashSet<String>(Arrays.asList("olleh", "HELLO", "5"));
    Assert.assertEquals("All three services should be invoked", expected, result);
}