Examples of MockServiceReference


Examples of org.apache.sling.commons.testing.osgi.MockServiceReference

    private ServletResourceProviderFactory factory = new ServletResourceProviderFactory(
        ROOT, new String[] {"/apps/"});

    public void testCreateMethodsDefault() {
        MockServiceReference msr = new MockServiceReference(null);

        msr.setProperty(ServletResolverConstants.SLING_SERVLET_RESOURCE_TYPES,
            RES_TYPE);
        // msr.setProperty(ServletResolverConstants.SLING_SERVLET_METHODS, "*");
        ServletResourceProvider srp = factory.create(msr);
        assertNotNull(srp);
        srp.setServlet(TEST_SERVLET);
View Full Code Here

Examples of org.apache.sling.commons.testing.osgi.MockServiceReference

        assertTrue(checkerSet.isEmpty());
    }

    public void testCreateMethodsSingle() {
        MockServiceReference msr = new MockServiceReference(null);

        msr.setProperty(ServletResolverConstants.SLING_SERVLET_RESOURCE_TYPES,
            RES_TYPE);
        msr.setProperty(ServletResolverConstants.SLING_SERVLET_METHODS, "GET");

        ServletResourceProvider srp = factory.create(msr);
        assertNotNull(srp);
        srp.setServlet(TEST_SERVLET);
View Full Code Here

Examples of org.apache.sling.commons.testing.osgi.MockServiceReference

        assertTrue(checkerSet.isEmpty());
    }

    public void testCreateMethodsMultiple() {
        MockServiceReference msr = new MockServiceReference(null);

        msr.setProperty(ServletResolverConstants.SLING_SERVLET_RESOURCE_TYPES,
            RES_TYPE);
        msr.setProperty(ServletResolverConstants.SLING_SERVLET_METHODS,
            new String[] { "GET", "POST", "PUT" });

        ServletResourceProvider srp = factory.create(msr);
        assertNotNull(srp);
        srp.setServlet(TEST_SERVLET);
View Full Code Here

Examples of org.apache.sling.commons.testing.osgi.MockServiceReference

        assertTrue(checkerSet.isEmpty());
    }

    public void testCreateMethodsAll() {
        MockServiceReference msr = new MockServiceReference(null);

        msr.setProperty(ServletResolverConstants.SLING_SERVLET_RESOURCE_TYPES,
            RES_TYPE);
        msr.setProperty(ServletResolverConstants.SLING_SERVLET_METHODS, "*");

        ServletResourceProvider srp = factory.create(msr);
        assertNotNull(srp);
        srp.setServlet(TEST_SERVLET);

View Full Code Here

Examples of org.springframework.osgi.mock.MockServiceReference

    public ServiceReference[] getAllServiceReferences(String clazz, String filter) throws InvalidSyntaxException {
        // just simulate when the bundle context doesn't have right service reference
        if (filter != null && filter.indexOf("name=test") > 0) {
            return null;
        }
        MockServiceReference reference = new MockServiceReference(getBundle(), new String[] {clazz});
        // setup the name property with the class name
        Dictionary properties = new Hashtable();
        properties.put("name", clazz);
        reference.setProperties(properties);
        return new ServiceReference[] {reference};
    }
View Full Code Here

Examples of org.springframework.osgi.mock.MockServiceReference

    public ServiceReference[] getAllServiceReferences(String clazz, String filter) throws InvalidSyntaxException {
        // just simulate when the bundle context doesn't have right service reference
        if (filter != null && filter.indexOf("name=test") > 0) {
            return null;
        }
        MockServiceReference reference = new MockServiceReference(getBundle(), new String[] {clazz});
        // setup the name property with the class name
        Dictionary properties = new Hashtable();
        properties.put("name", clazz);
        reference.setProperties(properties);
        return new ServiceReference[] {reference};
    }
View Full Code Here

Examples of org.springframework.osgi.mock.MockServiceReference

        List<ServiceReference> list = new ArrayList<ServiceReference>();
        try {
            String[] beanNames = applicationContext.getBeanNamesForType(Class.forName(clazz));
            if (beanNames != null && beanNames.length > 0) {
                for (String beanName : beanNames) {
                    list.add(new MockServiceReference(new MockBundle(beanName)));
                }
            }
        } catch (ClassNotFoundException e) {
            log.error("Error loading class name " + clazz + ": ", e);
        }
View Full Code Here

Examples of org.springframework.osgi.mock.MockServiceReference

    // initialise registered services
    registeredServices = new ServiceReference[dependent.length];

    for (int i = 0; i < registeredServices.length; i++) {
      registeredServices[i] = new MockServiceReference(DependencyMockBundle.this, createProps(i, serviceRanking,
        serviceId), null) {

        public Bundle[] getUsingBundles() {
          return dependent;
        }
View Full Code Here

Examples of org.springframework.osgi.mock.MockServiceReference

      Properties props = new Properties();
     
      props.put(OsgiServicePropertiesResolver.BEAN_NAME_PROPERTY_KEY, new Long(
          System.identityHashCode(dependencyBundle)));
     
      inUseServices[i] = new MockServiceReference() {
        public Bundle getBundle() {
          return dependencyBundle;
        }

        public Bundle[] getUsingBundles() {
View Full Code Here

Examples of org.springframework.osgi.mock.MockServiceReference

    BundleContext ctx = (BundleContext) ctxCtrl.getMock();

    MockControl servCtrl = MockControl.createControl(TestRunnerService.class);
    TestRunnerService runner = (TestRunnerService) servCtrl.getMock();

    ServiceReference ref = new MockServiceReference();

    ctxCtrl.expectAndReturn(ctx.getServiceReference(TestRunnerService.class.getName()), ref);
    ctxCtrl.expectAndReturn(ctx.getService(ref), runner);

    ctx.registerService((String) null, null, null);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.