Package org.springframework.osgi.mock

Examples of org.springframework.osgi.mock.MockBundleContext


    Dictionary headers = new Hashtable();
    headers.put(Constants.BUNDLE_NAME, "Extender mock bundle");
    final EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(headers);
    aBundle.setEntryReturnOnNextCallToGetEntry(new ClassPathResource("META-INF/spring/moved-extender.xml").getURL());

    MockBundleContext ctx = new MockBundleContext() {

      public Bundle getBundle() {
        return aBundle;
      }
    };

    this.listener.start(ctx);

    Dictionary hdrs = new Hashtable();
    hdrs.put(ConfigUtils.SPRING_CONTEXT_HEADER, "bla bla");
    MockBundle anotherBundle = new MockBundle(hdrs);
    anotherBundle.setBundleId(1);

    BundleEvent event = new BundleEvent(BundleEvent.STARTED, anotherBundle);

    BundleListener listener = (BundleListener) ctx.getBundleListeners().iterator().next();

    TestTaskExecutor.called = false;

    listener.bundleChanged(event);
    assertTrue("task executor should have been called if configured properly", TestTaskExecutor.called);
View Full Code Here


    assertEquals(fl, filter);

  }

    protected BundleContext getBundleContext() {
        return new MockBundleContext() {
            public Filter createFilter(String filter) throws InvalidSyntaxException {
                return FrameworkUtil.createFilter(filter);
            }
        };
    }
View Full Code Here


  protected void setUp() throws Exception {
    super.setUp();
    processor = new ServiceReferenceInjectionBeanPostProcessor();
    context = new MockBundleContext();
    processor.setBundleContext(context);
    processor.setBeanClassLoader(getClass().getClassLoader());
    MockControl factoryControl = MockControl.createControl(BeanFactory.class);
    BeanFactory factory = (BeanFactory) factoryControl.getMock();
    processor.setBeanFactory(factory);
View Full Code Here

      public String toString() {
        return "bean2";
      }
    };

    BundleContext context = new MockBundleContext() {

      public Object getService(org.osgi.framework.ServiceReference reference) {
        String clazz = ((String[]) reference.getProperty(Constants.OBJECTCLASS))[0];
        if (clazz == null)
          return null;
View Full Code Here

      public String toString() {
        return "bean2";
      }
    };

    BundleContext context = new MockBundleContext() {

      public Object getService(org.osgi.framework.ServiceReference reference) {
        String clazz = ((String[]) reference.getProperty(Constants.OBJECTCLASS))[0];
        if (clazz == null)
          return null;
View Full Code Here

      public String toString() {
        return "bean2";
      }
    };

    BundleContext context = new MockBundleContext() {

      public Object getService(org.osgi.framework.ServiceReference reference) {
        String clazz = ((String[]) reference.getProperty(Constants.OBJECTCLASS))[0];
        if (clazz == null)
          return null;
View Full Code Here

      public String toString() {
        return "bean2";
      }
    };

    BundleContext context = new MockBundleContext() {

      public Object getService(org.osgi.framework.ServiceReference reference) {
        String clazz = ((String[]) reference.getProperty(Constants.OBJECTCLASS))[0];
        if (clazz == null)
          return null;
View Full Code Here

    regCtrl.verify();
    ctxCtrl.verify();
  }

  public void testLoadTest() throws Exception {
    BundleContext ctx = new MockBundleContext();

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

    try {
View Full Code Here

  private Properties prop = new Properties();


  protected void setUp() throws Exception {

    final BundleContext ctx = new MockBundleContext();
    prop.setProperty("foo", "bar");

    platform = new AbstractOsgiPlatform() {

      Properties getPlatformProperties() {
View Full Code Here

    deployment = null;
    deployer = null;
  }

  public void testBundleContextSet() throws Exception {
    BundleContext bc = new MockBundleContext();
    deployer.setBundleContext(bc);
    deployer.afterPropertiesSet();
    assertSame(bc, deployer.getBundleContext());
  }
View Full Code Here

TOP

Related Classes of org.springframework.osgi.mock.MockBundleContext

Copyright © 2018 www.massapicom. 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.