Search in sources :

Example 1 with MockBundle

use of org.apache.felix.scr.impl.MockBundle 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);
}
Also used : SingleComponentManager(org.apache.felix.scr.impl.manager.SingleComponentManager) ComponentContextImpl(org.apache.felix.scr.impl.manager.ComponentContextImpl) BindMethod(org.apache.felix.scr.impl.inject.BindMethod) RefPair(org.apache.felix.scr.impl.manager.RefPair) SingleRefPair(org.apache.felix.scr.impl.manager.SingleRefPair) BindParameters(org.apache.felix.scr.impl.inject.BindParameters) ComponentContainer(org.apache.felix.scr.impl.manager.ComponentContainer) FakeService(org.apache.felix.scr.impl.manager.components.FakeService) MockBundle(org.apache.felix.scr.impl.MockBundle) T1(org.apache.felix.scr.impl.manager.components.T1) SingleRefPair(org.apache.felix.scr.impl.manager.SingleRefPair)

Example 2 with MockBundle

use of org.apache.felix.scr.impl.MockBundle in project felix by apache.

the class XmlHandlerTest method readMetadata.

// ---------- helper
private List readMetadata(final Reader reader) throws IOException, ComponentException, XmlPullParserException, Exception {
    try {
        final KXml2SAXParser parser = new KXml2SAXParser(reader);
        XmlHandler handler = new XmlHandler(new MockBundle(), logger, false, false);
        parser.parseXML(handler);
        return handler.getComponentMetadataList();
    } finally {
        try {
            reader.close();
        } catch (IOException ignore) {
        }
    }
}
Also used : XmlHandler(org.apache.felix.scr.impl.xml.XmlHandler) MockBundle(org.apache.felix.scr.impl.MockBundle) IOException(java.io.IOException) KXml2SAXParser(org.apache.felix.scr.impl.parser.KXml2SAXParser)

Aggregations

MockBundle (org.apache.felix.scr.impl.MockBundle)2 IOException (java.io.IOException)1 BindMethod (org.apache.felix.scr.impl.inject.BindMethod)1 BindParameters (org.apache.felix.scr.impl.inject.BindParameters)1 ComponentContainer (org.apache.felix.scr.impl.manager.ComponentContainer)1 ComponentContextImpl (org.apache.felix.scr.impl.manager.ComponentContextImpl)1 RefPair (org.apache.felix.scr.impl.manager.RefPair)1 SingleComponentManager (org.apache.felix.scr.impl.manager.SingleComponentManager)1 SingleRefPair (org.apache.felix.scr.impl.manager.SingleRefPair)1 FakeService (org.apache.felix.scr.impl.manager.components.FakeService)1 T1 (org.apache.felix.scr.impl.manager.components.T1)1 KXml2SAXParser (org.apache.felix.scr.impl.parser.KXml2SAXParser)1 XmlHandler (org.apache.felix.scr.impl.xml.XmlHandler)1