Examples of BundleMock


Examples of mock.org.osgi.framework.BundleMock

    protected void setUp() throws Exception {
        super.setUp();

        // An authorized bundle.
        authorizedBundleMock =
                new BundleMock("authorizedBundleMock", expectations);

        authorizedBundleMock.expects.getLocation()
                .returns(AUTHORIZED_BUNDLE_LOCATION).any();
        authorizedBundleMock.expects
                .hasPermission(SecurityHelper.CONFIGURATION_PERMISSION)
                .returns(true).any();

        // An unauthorized bundle.
        unauthorizedBundleMock =
                new BundleMock("unauthorizedBundleMock", expectations);

        unauthorizedBundleMock.expects.getLocation()
                .returns(UNAUTHORIZED_BUNDLE_LOCATION).any();
        unauthorizedBundleMock.expects
                .hasPermission(SecurityHelper.CONFIGURATION_PERMISSION)
                .returns(false).any();

        // An attacking bundle.
        attackingBundleMock =
                new BundleMock("attackingBundleMock", expectations);

        attackingBundleMock.expects.getLocation()
                .returns(ATTACKING_BUNDLE_LOCATION)
                .any();
        attackingBundleMock.expects
View Full Code Here

Examples of mock.org.osgi.framework.BundleMock

    /**
     * Tests that all the mock objects can be initialised correctly.
     */
    public void testInitialisation() {
        new BundleMock("bundleMock", expectations);
        new BundleContextMock("bundleContextMock", expectations);
        new ServiceReferenceMock("serviceReferenceMock", expectations);
        new ServiceRegistrationMock("serviceRegistrationMock", expectations);
        new FilterMock("filterMock", expectations);
    }
View Full Code Here

Examples of org.apache.aries.mocks.BundleMock

  {
    client1 = Skeleton.newMock(Bundle.class);
    client2 = Skeleton.newMock(Bundle.class);
    emf1 = Skeleton.newMock(EntityManagerFactory.class);
    emf2 = Skeleton.newMock(EntityManagerFactory.class);
    context = Skeleton.newMock(new BundleMock("system.bundle", new Hashtable<Object, Object>()), Bundle.class).getBundleContext();
    mgr = new PersistenceContextManager(context, null);
    mgr.open();
  }
View Full Code Here

Examples of org.apache.aries.mocks.BundleMock

  private PersistenceProvider pp;
 
  @Before
  public void setUp() throws Exception
  {
    persistenceBundle = Skeleton.newMock(new BundleMock("scooby.doo", new Hashtable<String, Object>()), Bundle.class);
    persistenceBundleContext = persistenceBundle.getBundleContext();
   
    pp = Skeleton.newMock(PersistenceProvider.class);
   
    providerBundleP100 = Skeleton.newMock(new BundleMock("no.such.Provider", new Hashtable<String, Object>()), Bundle.class);
    Skeleton skel = Skeleton.getSkeleton(providerBundleP100);
    skel.setReturnValue(new MethodCall(Bundle.class, "getVersion"), new Version("1.0.0"));

    providerBundleP101 = Skeleton.newMock(new BundleMock("no.such.Provider", new Hashtable<String, Object>()), Bundle.class);
    skel = Skeleton.getSkeleton(providerBundleP101);
    skel.setReturnValue(new MethodCall(Bundle.class, "getVersion"), new Version("1.0.1"));

    providerBundleP110 = Skeleton.newMock(new BundleMock("no.such.Provider", new Hashtable<String, Object>()), Bundle.class);
    skel = Skeleton.getSkeleton(providerBundleP110);
    skel.setReturnValue(new MethodCall(Bundle.class, "getVersion"), new Version("1.1.0"));

    providerBundleP111 = Skeleton.newMock(new BundleMock("no.such.Provider", new Hashtable<String, Object>()), Bundle.class);
    skel = Skeleton.getSkeleton(providerBundleP111);
    skel.setReturnValue(new MethodCall(Bundle.class, "getVersion"), new Version("1.1.1"));

    extenderBundle = Skeleton.newMock(new BundleMock("extender", new Hashtable<String, Object>()), Bundle.class);
//    Skeleton.getSkeleton(extenderBundle).setReturnValue(new MethodCall(Bundle.class, "getResource", "schemas/persistence_1_0.xsd"), new File("unittest/resources/persistence_1_0.xsd").toURI().toURL());
   
  }
View Full Code Here

Examples of org.apache.aries.mocks.BundleMock

    private Bundle hostBundle;

    @Before
    public void setUp() throws Exception {
        hostBundle = Skeleton.newMock(new BundleMock("scooby.doo",
                new Hashtable<String, Object>()), Bundle.class);
    }
View Full Code Here

Examples of org.apache.aries.mocks.BundleMock

    private Bundle makeBundleWithExports(String symbolicName, String version,
            String exports) {
        Hashtable<String, Object> headers = new Hashtable<String, Object>();
        headers.put(Constants.BUNDLE_VERSION, version);
        headers.put(Constants.EXPORT_PACKAGE, exports);
        Bundle exportBundle = Skeleton.newMock(new BundleMock(symbolicName,
                headers), Bundle.class);
        return exportBundle;
    }
View Full Code Here

Examples of org.apache.aries.mocks.BundleMock

  }
 
  @Test
  public void testBaseLookup() throws NamingException
  {
     BundleMock mock = new BundleMock("scooby.doo", new Properties());
       
     Thread.currentThread().setContextClassLoader(mock.getClassLoader());

     InitialContext ctx = new InitialContext();
    
     Context ctx2 = (Context) ctx.lookup("osgi:service");
    
View Full Code Here

Examples of org.apache.aries.mocks.BundleMock

  }
 
  @Test
  public void testLookupWithPause() throws NamingException
  {
     BundleMock mock = new BundleMock("scooby.doo", new Properties());
       
     Thread.currentThread().setContextClassLoader(mock.getClassLoader());

     Hashtable<Object, Object> env = new Hashtable<Object, Object>();
     env.put(JNDIConstants.REBIND_TIMEOUT, 1000);
    
     InitialContext ctx = new InitialContext(env);
View Full Code Here

Examples of org.apache.aries.mocks.BundleMock

  @Test
  public void jndiLookupServiceNameTest() throws NamingException, SQLException
  {
    InitialContext ctx = new InitialContext(new Hashtable<Object, Object>());
   
    BundleMock mock = new BundleMock("scooby.doo", new Properties());
   
    Thread.currentThread().setContextClassLoader(mock.getClassLoader());
   
    DataSource first = Skeleton.newMock(DataSource.class);
    DataSource second = Skeleton.newMock(DataSource.class);
   
    Hashtable<String, String> properties = new Hashtable<String, String>();
View Full Code Here

Examples of org.apache.aries.mocks.BundleMock

  {
    System.setProperty(Context.URL_PKG_PREFIXES, "helloMatey");
       
    InitialContext ctx = new InitialContext(new Hashtable<Object, Object>());
   
    BundleMock mock = new BundleMock("scooby.doo.1", new Properties());
   
    Thread.currentThread().setContextClassLoader(mock.getClassLoader());
   
    Runnable s = (Runnable) ctx.lookup("osgi:service/java.lang.Runnable");
   
    assertNotNull("We didn't get a service back from our lookup :(", s);
   
    s.run();
   
    Skeleton.getSkeleton(service).assertCalledExactNumberOfTimes(new MethodCall(Runnable.class, "run"), 1);
   
    Skeleton skel = Skeleton.getSkeleton(mock.getBundleContext());
   
    skel.assertCalled(new MethodCall(BundleContext.class, "getServiceReferences", "java.lang.Runnable", null));

    ctx = new InitialContext(new Hashtable<Object, Object>());
   
    mock = new BundleMock("scooby.doo.2", new Properties());
   
    Thread.currentThread().setContextClassLoader(mock.getClassLoader());

    s = (Runnable) ctx.lookup("osgi:service/java.lang.Runnable");
   
    // Check we have the packages set correctly
   
    String packages = System.getProperty(Context.URL_PKG_PREFIXES, null);
   
    assertTrue(ctx.getEnvironment().containsValue(packages));

    assertNotNull("We didn't get a service back from our lookup :(", s);

    s.run();
   
    Skeleton.getSkeleton(service).assertCalledExactNumberOfTimes(new MethodCall(Runnable.class, "run"), 2);
      
    skel = Skeleton.getSkeleton(mock.getBundleContext());
    skel.assertCalled(new MethodCall(BundleContext.class, "getServiceReferences", "java.lang.Runnable", 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.