ProvisioningService implements ProvisioningServiceMBean { public void addInformationFromZip(String zipURL) throws IOException { if (zipURL == null || zipURL.length() < 1) { throw new IOException("Argument zipURL cannot be null or empty"); } InputStream is = createStream(zipURL); ZipInputStream zis = new ZipInputStream(is); try { provisioningService.addInformation(zis); } finally { zis.close(); } } ProvisioningService(org.osgi.service.provisioning.ProvisioningService provisioningService); void addInformationFromZip(String zipURL); void addInformation(TabularData info); @SuppressWarnings("unchecked") TabularData listInformation(); void setInformation(TabularData info);  }
@Test public void testAddInformationFromZip() throws Exception { org.osgi.service.provisioning.ProvisioningService provService = mock(org.osgi.service.provisioning.ProvisioningService.class); ProvisioningService mbean = new ProvisioningService(provService); ProvisioningService spiedMBean = spy(mbean); InputStream is = mock(InputStream.class); doReturn(is).when(spiedMBean).createStream("file: spiedMBean.addInformationFromZip("file: verify(provService).addInformation(any(ZipInputStream.class)); verify(is).close(); }