@Test public void testfilterWasUsedForProbeInvoker() throws Exception { BundleContext bundleContext = mock(BundleContext.class); RemoteBundleContextImpl remoteBundleContext = new RemoteBundleContextImpl(bundleContext); String rightFilter = "(Probe-Signature=PAXPROBE-the-right-one)"; when(bundleContext.createFilter(anyString())).thenReturn(null); try{ remoteBundleContext.remoteCall(RemoteBundleContextImplTest.class, "filterWasUsedForProbeInvoker", new Class<?>[] {}, rightFilter, RelativeTimeout.TIMEOUT_DEFAULT, new Object[] {}); } catch(NullPointerException e) { } verify(bundleContext).createFilter(contains(rightFilter)); }
@Override public Object remoteCall(final Class<?> serviceType, final String methodName, final Class<?>[] methodParams, String filter, final RelativeTimeout timeout, final Object... actualParams) throws NoSuchServiceException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { LOG.trace("Remote call of [" + serviceType.getName() + "." + methodName + "]"); Object service = ServiceLookup.getService(bundleContext, serviceType, timeout.getValue(), filter); Object obj = null; try { obj = serviceType.getMethod(methodName, methodParams).invoke(service, actualParams); } catch (InvocationTargetException t) { if (t.getTargetException().getCause() instanceof RerunTestException) { LOG.debug("rerun the test"); service = ServiceLookup.getService(bundleContext, serviceType, timeout.getValue(), filter); obj = serviceType.getMethod(methodName, methodParams).invoke(service, actualParams); } else { throw t; } } return obj; }
RemoteBundleContextImpl implements RemoteBundleContext, Serializable { @Override public Object remoteCall(final Class<?> serviceType, final String methodName, final Class<?>[] methodParams, String filter, final RelativeTimeout timeout, final Object... actualParams) throws NoSuchServiceException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { LOG.trace("Remote call of [" + serviceType.getName() + "." + methodName + "]"); Object service = ServiceLookup.getService(bundleContext, serviceType, timeout.getValue(), filter); Object obj = null; try { obj = serviceType.getMethod(methodName, methodParams).invoke(service, actualParams); } catch (InvocationTargetException t) { if (t.getTargetException().getCause() instanceof RerunTestException) { LOG.debug("rerun the test"); service = ServiceLookup.getService(bundleContext, serviceType, timeout.getValue(), filter); obj = serviceType.getMethod(methodName, methodParams).invoke(service, actualParams); } else { throw t; } } return obj; } }
RemoteBundleContextImpl implements RemoteBundleContext, Serializable { @Override public Object remoteCall(final Class<?> serviceType, final String methodName, final Class<?>[] methodParams, String filter, final RelativeTimeout timeout, final Object... actualParams) throws NoSuchServiceException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { LOG.trace("Remote call of [" + serviceType.getName() + "." + methodName + "]"); Object service = ServiceLookup.getService(bundleContext, serviceType, timeout.getValue(), filter); Object obj = null; try { obj = serviceType.getMethod(methodName, methodParams).invoke(service, actualParams); } catch (InvocationTargetException t) { if (t.getTargetException().getCause() instanceof RerunTestException) { LOG.debug("rerun the test"); service = ServiceLookup.getService(bundleContext, serviceType, timeout.getValue(), filter); obj = serviceType.getMethod(methodName, methodParams).invoke(service, actualParams); } else { throw t; } } return obj; } RemoteBundleContextImpl(final BundleContext bundleContext); }
RemoteBundleContextImpl implements RemoteBundleContext, Serializable { @Override public Object remoteCall(final Class<?> serviceType, final String methodName, final Class<?>[] methodParams, String filter, final RelativeTimeout timeout, final Object... actualParams) throws NoSuchServiceException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { LOG.trace("Remote call of [" + serviceType.getName() + "." + methodName + "]"); Object service = ServiceLookup.getService(bundleContext, serviceType, timeout.getValue(), filter); Object obj = null; try { obj = serviceType.getMethod(methodName, methodParams).invoke(service, actualParams); } catch (InvocationTargetException t) { if (t.getTargetException().getCause() instanceof RerunTestException) { LOG.debug("rerun the test"); service = ServiceLookup.getService(bundleContext, serviceType, timeout.getValue(), filter); obj = serviceType.getMethod(methodName, methodParams).invoke(service, actualParams); } else { throw t; } } return obj; } RemoteBundleContextImpl(final BundleContext bundleContext); @Override Object remoteCall(final Class<?> serviceType, final String methodName,
        final Class<?>[] methodParams, String filter, final RelativeTimeout timeout,
        final Object... actualParams); @Override long installBundle(final String bundleUrl); @Override long installBundle(final String bundleLocation, final byte[] bundle); @Override void uninstallBundle(long id); @Override void startBundle(long bundleId); @Override void stopBundle(long bundleId); @Override void setBundleStartLevel(long bundleId, int startLevel); @Override void waitForState(final long bundleId, final int state, final RelativeTimeout timeout); }
RemoteBundleContextImpl implements RemoteBundleContext, Serializable { @Override public Object remoteCall(final Class<?> serviceType, final String methodName, final Class<?>[] methodParams, String filter, final RelativeTimeout timeout, final Object... actualParams) throws NoSuchServiceException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { LOG.trace("Remote call of [" + serviceType.getName() + "." + methodName + "]"); Object service = ServiceLookup.getService(bundleContext, serviceType, timeout.getValue(), filter); Object obj = null; try { obj = serviceType.getMethod(methodName, methodParams).invoke(service, actualParams); } catch (InvocationTargetException t) { if (t.getTargetException().getCause() instanceof RerunTestException) { LOG.debug("rerun the test"); service = ServiceLookup.getService(bundleContext, serviceType, timeout.getValue(), filter); obj = serviceType.getMethod(methodName, methodParams).invoke(service, actualParams); } else { throw t; } } return obj; } RemoteBundleContextImpl(final BundleContext bundleContext); @Override Object remoteCall(final Class<?> serviceType, final String methodName,
        final Class<?>[] methodParams, String filter, final RelativeTimeout timeout,
        final Object... actualParams); @Override long installBundle(final String bundleUrl); @Override long installBundle(final String bundleLocation, final byte[] bundle); @Override void uninstallBundle(long id); @Override void startBundle(long bundleId); @Override void stopBundle(long bundleId); @Override void setBundleStartLevel(long bundleId, int startLevel); @Override void waitForState(final long bundleId, final int state, final RelativeTimeout timeout);  }