use of org.apache.felix.scr.impl.manager.SingleComponentManager in project felix by apache.
the class ActivateMethodTest method checkMethod.
/**
* Checks whether a method with the given name can be found for the
* activate/deactivate method parameter list and whether the method returns
* the expected description when called.
*
* @param obj
* @param methodName
* @param methodDesc
* @param version DSVersion tested
*/
private void checkMethod(BaseObject obj, String methodName, String methodDesc, DSVersion version) {
ComponentContainer<?> container = newContainer();
SingleComponentManager<?> icm = new SingleComponentManager(container, new ComponentMethodsImpl());
ActivateMethod am = new ActivateMethod(methodName, methodName != null, obj.getClass(), version, false, false);
am.invoke(obj, new ActivatorParameter(m_ctx, -1), null, icm);
Method m = am.getMethod();
assertNotNull(m);
assertEquals(methodName, m.getName());
assertEquals(methodDesc, obj.getCalledMethod());
}
use of org.apache.felix.scr.impl.manager.SingleComponentManager in project felix by apache.
the class BindMethodTest method testMethod.
private void testMethod(final String methodName, final T1 component, final DSVersion dsVersion, final String expectCallPerformed) {
ComponentContainer container = newContainer();
SingleComponentManager icm = new SingleComponentManager(container, new ComponentMethodsImpl());
BindMethod bm = new BindMethod(methodName, component.getClass(), FakeService.class.getName(), dsVersion, false);
RefPair refPair = new SingleRefPair(m_serviceReference);
ComponentContextImpl<T1> cc = new ComponentContextImpl(icm, new MockBundle(), null);
assertTrue(bm.getServiceObject(cc, refPair, m_context, icm));
BindParameters bp = new BindParameters(cc, refPair);
bm.invoke(component, bp, null, icm);
assertEquals(expectCallPerformed, component.callPerformed);
}
use of org.apache.felix.scr.impl.manager.SingleComponentManager in project felix by apache.
the class ActivateMethodTest method checkMethod.
/**
* Checks whether a method with the given name can be found for the
* activate/deactivate method parameter list and whether the method returns
* the expected description when called.
*
* @param obj
* @param methodName
* @param methodDesc
* @param version DSVersion tested
*/
private void checkMethod(BaseObject obj, String methodName, String methodDesc, DSVersion version) {
ComponentContainer<?> container = newContainer();
SingleComponentManager<?> icm = new SingleComponentManager(container, new ComponentMethodsImpl());
ActivateMethod am = new ActivateMethod(methodName, methodName != null, obj.getClass(), version, false, false);
am.invoke(obj, new ActivatorParameter(new ComponentContextImpl(icm, m_bundle, null), -1), null);
Method m = am.getMethod();
assertNotNull(m);
assertEquals(methodName, m.getName());
assertEquals(methodDesc, obj.getCalledMethod());
}
use of org.apache.felix.scr.impl.manager.SingleComponentManager in project felix by apache.
the class ActivateMethodTest method ensureMethodNotFoundMethod.
/**
* Ensures no method with the given name accepting any of the
* activate/deactive method parameters can be found.
*
* @param obj
* @param methodName
* @param version DS version tested
* @throws InvocationTargetException
* @throws IllegalAccessException
*/
private void ensureMethodNotFoundMethod(BaseObject obj, String methodName, DSVersion version) {
ComponentContainer container = newContainer();
SingleComponentManager icm = new SingleComponentManager(container, new ComponentMethodsImpl());
ActivateMethod am = new ActivateMethod(methodName, methodName != null, obj.getClass(), version, false, false);
am.invoke(obj, new ActivatorParameter(new ComponentContextImpl(icm, m_bundle, null), -1), null);
Method m = am.getMethod();
assertNull(m);
assertNull(obj.getCalledMethod());
}
use of org.apache.felix.scr.impl.manager.SingleComponentManager in project felix by apache.
the class ActivateMethodTest method newContainer.
private ComponentContainer newContainer() {
final ComponentMetadata metadata = newMetadata();
ComponentContainer container = new ComponentContainer() {
@Override
public ComponentActivator getActivator() {
final ComponentActivator ca = Mockito.mock(ComponentActivator.class);
Mockito.when(ca.getBundleContext()).thenReturn(Mockito.mock(BundleContext.class));
return ca;
}
@Override
public ComponentMetadata getComponentMetadata() {
return metadata;
}
@Override
public void disposed(SingleComponentManager component) {
}
public boolean isEnabled() {
return false;
}
@Override
public ComponentLogger getLogger() {
return new MockComponentLogger();
}
};
return container;
}
Aggregations