Examples of BundleMock


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

Examples of org.apache.aries.mocks.BundleMock

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

    InitialContext ctx = new InitialContext();
   
    Object s = ctx.lookup("osgi:service/java.lang.Runnable/(rubbish=smelly)");
   
    assertNotNull("We didn't get a service back from our lookup :(", s);
   
    service.run();
   
    Skeleton.getSkeleton(service).assertCalledExactNumberOfTimes(new MethodCall(Runnable.class, "run"), 1);

    Skeleton.getSkeleton(mock.getBundleContext()).assertCalled(new MethodCall(BundleContext.class, "getServiceReferences", "java.lang.Runnable", "(rubbish=smelly)"));
  }
View Full Code Here

Examples of org.apache.aries.mocks.BundleMock

  @Test(expected=NameNotFoundException.class)
  public void testLookupWhenServiceHasBeenRemoved() throws NamingException
  {
    reg.unregister();

    BundleMock mock = new BundleMock("scooby.doo", new Properties());
   
    Thread.currentThread().setContextClassLoader(mock.getClassLoader());

    InitialContext ctx = new InitialContext();
   
    ctx.lookup("osgi:service/java.lang.Runnable");
  }
View Full Code Here

Examples of org.apache.aries.mocks.BundleMock

   * @throws NamingException
   */
  @Test(expected=NameNotFoundException.class)
  public void testLookupForServiceWeNeverHad() throws NamingException
  {
    BundleMock mock = new BundleMock("scooby.doo", new Properties());
   
    Thread.currentThread().setContextClassLoader(mock.getClassLoader());

    InitialContext ctx = new InitialContext();
   
    ctx.lookup("osgi:service/java.lang.Integer");
  }
View Full Code Here

Examples of org.apache.aries.mocks.BundleMock

  }

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

    InitialContext ctx = new InitialContext();
   
    String className = Runnable.class.getName();
   
View Full Code Here

Examples of org.apache.aries.mocks.BundleMock

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

    InitialContext ctx = new InitialContext();
   
    String className = Runnable.class.getName();
   
View Full Code Here

Examples of org.apache.aries.mocks.BundleMock

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

    InitialContext ctx = new InitialContext();
   
    String className = Runnable.class.getName();
   
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.