Package org.apache.aries.unittest.mocks

Examples of org.apache.aries.unittest.mocks.MethodCall


     
      refRunnable.run();
     
      assertEquals("The default runnable was called when a service was bound", 1, defaultRunnable.getCount());
     
      Skeleton.getSkeleton(mockService).assertCalled(new MethodCall(Runnable.class, "run"));
     
      reg.unregister();
     
      refRunnable.run();
     
View Full Code Here


    BundleContext ctx = Skeleton.newMock(BundleContext.class);
    Bundle bpBundle = Skeleton.newMock(Bundle.class);
    Bundle testBundle = Skeleton.newMock(Bundle.class);
   
    Skeleton.getSkeleton(ctx).setReturnValue(
        new MethodCall(BundleContext.class, "getBundle"), bpBundle);
   
    BlueprintQuiesceParticipant bqp = new BlueprintQuiesceParticipant(ctx, new BlueprintExtender() {
      @Override
      protected BlueprintContainerImpl getBlueprintContainerImpl(Bundle bundle) {
        return null;
View Full Code Here

   
    @Before
    public void setup() {
        context = Skeleton.newMock(BundleContext.class);
        Skeleton.getSkeleton(context).setReturnValue(
                new MethodCall(BundleContext.class, "getServiceReference", "org.osgi.service.framework.CompositeBundleFactory"),
                Skeleton.newMock(ServiceReference.class));
    }
View Full Code Here

    }
   
    private CompositeBundle composite(String symbolicName, String version) {
        CompositeBundle cb = Skeleton.newMock(CompositeBundle.class);
        Skeleton cbSkel = Skeleton.getSkeleton(cb);
        cbSkel.setReturnValue(new MethodCall(CompositeBundle.class, "getSymbolicName"), symbolicName);
        cbSkel.setReturnValue(new MethodCall(CompositeBundle.class, "getVersion"), new Version(version));
        return cb;
    }
View Full Code Here

  @Test
  public void testLookupWithICF() throws NamingException
  {
    InitialContextFactory icf = Skeleton.newMock(InitialContextFactory.class);
    bc.registerService(new String[] {InitialContextFactory.class.getName(), icf.getClass().getName()}, icf, new Properties());
    Skeleton.getSkeleton(icf).setReturnValue(new MethodCall(Context.class, "lookup", "/"), Skeleton.newMock(Context.class));
   
    Properties props = new Properties();
    props.put(Context.INITIAL_CONTEXT_FACTORY, icf.getClass().getName());
    props.put(JNDIConstants.BUNDLE_CONTEXT, bc);
    InitialContext ctx = new InitialContext(props);
View Full Code Here

  @Test
  public void testLookupWithoutICFButWithURLLookup() throws NamingException
  {
    ObjectFactory factory = Skeleton.newMock(ObjectFactory.class);
    Context ctx = Skeleton.newMock(Context.class);
    Skeleton.getSkeleton(factory).setReturnValue(new MethodCall(ObjectFactory.class, "getObjectInstance", Object.class, Name.class, Context.class, Hashtable.class),
                                                 ctx);
    Skeleton.getSkeleton(ctx).setReturnValue(new MethodCall(Context.class, "lookup", String.class), "someText");
   
    Properties props = new Properties();
    props.put(JNDIConstants.JNDI_URLSCHEME, "testURL");
    bc.registerService(ObjectFactory.class.getName(), factory, props);
   
View Full Code Here

    bc.registerService(new String[] {InitialContextFactoryBuilder.class.getName(), icf.getClass().getName()}, icf, new Properties());
   
    LdapContext backCtx = Skeleton.newMock(LdapContext.class);
    InitialContextFactory fac = Skeleton.newMock(InitialContextFactory.class);
    Skeleton.getSkeleton(fac).setReturnValue(
        new MethodCall(InitialContextFactory.class, "getInitialContext", Hashtable.class),
        backCtx);
    Skeleton.getSkeleton(icf).setReturnValue(
        new MethodCall(InitialContextFactoryBuilder.class, "createInitialContextFactory", Hashtable.class),
        fac);
   
    Properties props = new Properties();
    props.put(JNDIConstants.BUNDLE_CONTEXT, bc);
    props.put(Context.INITIAL_CONTEXT_FACTORY, "dummy.factory");
    InitialLdapContext ilc = new InitialLdapContext(props, new Control[0]);
   
    ExtendedRequest req = Skeleton.newMock(ExtendedRequest.class);
    ilc.extendedOperation(req);
    Skeleton.getSkeleton(backCtx).assertCalled(new MethodCall(LdapContext.class, "extendedOperation", req));
  }
View Full Code Here

   * @param toReturn
   * @return
   */
  private Context dummyContext(Object toReturn) {
      Context ctx = Skeleton.newMock(Context.class);
      Skeleton.getSkeleton(ctx).setReturnValue(new MethodCall(Context.class, "lookup", String.class), toReturn);
      Skeleton.getSkeleton(ctx).setReturnValue(new MethodCall(Context.class, "lookup", Name.class), toReturn);
      return ctx;
  }
View Full Code Here

  @Test
  public void testURLReferenceWithMatchingHandler() throws Exception
  {
    String testObject = "Test object";
    ObjectFactory factory = Skeleton.newMock(ObjectFactory.class);
    Skeleton.getSkeleton(factory).setReturnValue(new MethodCall(ObjectFactory.class, "getObjectInstance", Object.class, Name.class, Context.class, Hashtable.class), testObject);

    Properties props = new Properties();
    props.setProperty("osgi.jndi.urlScheme", "wibble");

    bc.registerService(ObjectFactory.class.getName(), factory, props);
View Full Code Here

  @Test
  public void testURLReferenceUsingURLObjectFactoryFinder() throws Exception
  {
    String testObject = "Test object";
    URLObjectFactoryFinder factory = Skeleton.newMock(URLObjectFactoryFinder.class);
    Skeleton.getSkeleton(factory).setReturnValue(new MethodCall(ObjectFactory.class, "getObjectInstance", Object.class, Name.class, Context.class, Hashtable.class), testObject);

    bc.registerService(URLObjectFactoryFinder.class.getName(), factory, new Properties());

    Reference ref = new Reference(null);
    ref.add(new StringRefAddr("URL", "wibble"));
View Full Code Here

TOP

Related Classes of org.apache.aries.unittest.mocks.MethodCall

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.