Package org.springframework.osgi.mock

Examples of org.springframework.osgi.mock.MockBundleContext


  private GenericApplicationContext appContext;

  protected void setUp() throws Exception {

    BundleContext bundleContext = new MockBundleContext() {
      // service reference already registered
      public ServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException {
        return new ServiceReference[0];
      }
    };
View Full Code Here


    MockControl mc = MockControl.createNiceControl(Configuration.class);
    final Configuration cfg = (Configuration) mc.getMock();
    mc.expectAndReturn(cfg.getProperties(), new Properties());
    mc.replay();

    BundleContext bundleContext = new MockBundleContext() {

      // always return a ConfigurationAdmin
      public Object getService(ServiceReference reference) {
        return new MockConfigurationAdmin() {
View Full Code Here

          throw new RuntimeException(io);
        }
      }
    };

    context = new MockBundleContext(bundle) {
      public Object getService(ServiceReference reference) {
        String[] classes = OsgiServiceReferenceUtils.getServiceObjectClasses(reference);
        if (Arrays.equals(classes, new String[] { Shape.class.getName() }))
          return service;
        else
View Full Code Here

    configMock.expectAndReturn(cfg.getProperties(), config, MockControl.ONE_OR_MORE);

    adminControl.replay();
    configMock.replay();

    bundleContext = new MockBundleContext() {

      // add Configuration admin support
      public Object getService(ServiceReference reference) {
        return admin;
      }
View Full Code Here

    this.props = new Properties();
  }
 
  public void testEquinoxDetection() {
    props.put(Constants.FRAMEWORK_VENDOR,"Eclipse");
    BundleContext bc = new MockBundleContext(mockBundle,props);
    assertTrue("Detected as Equinox",OsgiPlatformDetector.isEquinox(bc));
    assertFalse(OsgiPlatformDetector.isKnopflerfish(bc));
    assertFalse(OsgiPlatformDetector.isFelix(bc));
  }
View Full Code Here

    assertFalse(OsgiPlatformDetector.isFelix(bc));
  }
 
  public void testKnopflerfishDetection() {
    props.put(Constants.FRAMEWORK_VENDOR,"Knopflerfish");
    BundleContext bc = new MockBundleContext(mockBundle,props);
    assertTrue("Detected as Knopflerfish",OsgiPlatformDetector.isKnopflerfish(bc));   
    assertFalse(OsgiPlatformDetector.isEquinox(bc));
    assertFalse(OsgiPlatformDetector.isFelix(bc));
  }
View Full Code Here

    assertFalse(OsgiPlatformDetector.isFelix(bc));
  }
 
  public void testFelixDetection() {
    props.put(Constants.FRAMEWORK_VENDOR,"Apache Software Foundation");
    BundleContext bc = new MockBundleContext(mockBundle,props);
    assertTrue("Detected as Felix",OsgiPlatformDetector.isFelix(bc));   
    assertFalse(OsgiPlatformDetector.isEquinox(bc));
    assertFalse(OsgiPlatformDetector.isKnopflerfish(bc));
  }
View Full Code Here

  private BundleContext context;

  protected void setUp() throws Exception {
    Method m = ReflectionUtils.findMethod(Object.class, "hashCode");
    context = new MockBundleContext();
    interceptor = new LocalBundleContextAdvice(context);
   
    invocation = new MockMethodInvocation(m) {
      public Object proceed() throws Throwable {
        assertSame("bundle context not set", context, LocalBundleContext.getInvokerBundleContext());
View Full Code Here

    services.put(ref1, service1);
    services.put(ref2, service2);
    services.put(ref3, service3);

    bundleContext = new MockBundleContext() {

      public ServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException {
        return new ServiceReference[] { ref1, ref2, ref3 };
      }
View Full Code Here

    CustomRegistrationListener.REG_CALLS = 0;
    CustomRegistrationListener.UNREG_CALLS = 0;

    registration = new MockServiceRegistration();

    bundleContext = new MockBundleContext() {

      public ServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException {
        return new ServiceReference[] { new MockServiceReference(new String[] { Cloneable.class.getName() }) };
      }
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.