@Test
public void testInstallBundleFromURL() throws Exception {

    Bundle bundle = Mockito.mock(Bundle.class);
    Mockito.when(context.installBundle(Mockito.anyString(), Mockito.any(InputStream.class))).thenReturn(bundle);
    Mockito.when(bundle.getBundleId()).thenReturn(Long.valueOf(2));
    Framework spiedMBean = Mockito.spy(mbean);
    InputStream stream = Mockito.mock(InputStream.class);
    Mockito.doReturn(stream).when(spiedMBean).createStream("test.jar");
    long bundleId = spiedMBean.installBundleFromURL("file:test.jar", "test.jar");
    Assert.assertEquals(2, bundleId);
    Mockito.reset(context);
    Mockito.doReturn(stream).when(spiedMBean).createStream(Mockito.anyString());
    Mockito.when(context.installBundle(Mockito.anyString(), Mockito.any(InputStream.class))).thenThrow(
            new BundleException("location doesn't exist"));
    try {
        spiedMBean.installBundleFromURL("file:test2.jar", "test.jar");
        Assert.fail("Shouldn't go to this stage, location doesn't exist");
    } catch (IOException e) {
        // ok
    }
}