Package org.apache.aries.unittest.mocks

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


    setupPersistenceBundle("file4", "");
   
    mgr.open();
   
    //Check the persistence.xml was looked for
    Skeleton.getSkeleton(persistenceBundle).assertCalled(new MethodCall(Bundle.class, "getEntry", "META-INF/persistence.xml"));
    //Check we didn't use getResource()
    Skeleton.getSkeleton(persistenceBundle).assertNotCalled(new MethodCall(Bundle.class, "getResource", String.class));
    //Check we don't have an EMF
    BundleContextMock.assertNoServiceExists(EntityManagerFactory.class.getName());
   
    assertNotNull("We should have an EntityManagerFactoryManager", getTrackedObject());
  }
View Full Code Here


    setupPersistenceBundle("file4", "");
   
    mgr.open();
   
    //Check the persistence.xml was looked for
    Skeleton.getSkeleton(persistenceBundle).assertCalled(new MethodCall(Bundle.class, "getEntry", "META-INF/persistence.xml"));
    //Check we didn't use getResource()
    Skeleton.getSkeleton(persistenceBundle).assertNotCalled(new MethodCall(Bundle.class, "getResource", String.class));
   
    testSuccessfulCreationEvent(ref, extenderContext, 1);
    testSuccessfulRegistrationEvent(ref, extenderContext, 1);
  }
View Full Code Here

    setupPersistenceBundle("file4", "");
   
    mgr.open();
   
    //Check the persistence.xml was looked for
    Skeleton.getSkeleton(persistenceBundle).assertCalled(new MethodCall(Bundle.class, "getEntry", "META-INF/persistence.xml"));
    //Check we didn't use getResource()
    Skeleton.getSkeleton(persistenceBundle).assertNotCalled(new MethodCall(Bundle.class, "getResource", String.class));
   
    BundleContextMock.assertNoServiceExists(EntityManagerFactory.class.getName());
    assertNotNull("We should have an EntityManagerFactoryManager", getTrackedObject());
   
    Hashtable<String,String> hash1 = new Hashtable<String, String>();
View Full Code Here

    setupPersistenceBundle("file4", "");
   
    mgr.open();
   
    //Check the persistence.xml was looked for
    Skeleton.getSkeleton(persistenceBundle).assertCalled(new MethodCall(Bundle.class, "getEntry", "META-INF/persistence.xml"));
    //Check we didn't use getResource()
    Skeleton.getSkeleton(persistenceBundle).assertNotCalled(new MethodCall(Bundle.class, "getResource", String.class));
   
    BundleContextMock.assertNoServiceExists(EntityManagerFactory.class.getName());
    assertNotNull("We should have an EntityManagerFactoryManager", getTrackedObject());
   
    Hashtable<String,String> hash1 = new Hashtable<String, String>();
View Full Code Here

  {
    testManager_OnePreExistingPersistenceBundle_OneExistingProvider();
   
    mgr.close();
   
    Skeleton.getSkeleton(pp).assertCalled(new MethodCall(EntityManagerFactory.class, "close"));
    BundleContextMock.assertNoServiceExists(EntityManagerFactory.class.getName());
  }
View Full Code Here

   
    setupPersistenceBundle("file4", "");
   
    //INSTALL the bundle
   
    Skeleton.getSkeleton(persistenceBundle).setReturnValue(new MethodCall(Bundle.class, "getState"), Bundle.INSTALLED);
   
    Object o = mgr.addingBundle(persistenceBundle, new BundleEvent(BundleEvent.INSTALLED, persistenceBundle));

    //Check the persistence.xml was looked for
    Skeleton.getSkeleton(persistenceBundle).assertCalled(new MethodCall(Bundle.class, "getEntry", "META-INF/persistence.xml"));
    //Check we didn't use getResource()
    Skeleton.getSkeleton(persistenceBundle).assertNotCalled(new MethodCall(Bundle.class, "getResource", String.class));
   
    //Check we didn't get the Provider, register a service or create an EMF
    Skeleton.getSkeleton(extenderContext).assertNotCalled(new MethodCall(BundleContext.class, "getService", ServiceReference.class));
    Skeleton.getSkeleton(persistenceBundleContext).assertNotCalled(new MethodCall(BundleContext.class, "registerService", EntityManagerFactory.class.getName(), EntityManagerFactory.class, Dictionary.class));
    Skeleton.getSkeleton(pp).assertNotCalled(new MethodCall(PersistenceProvider.class, "createContainerEntityManagerFactory", PersistenceUnitInfo.class, Map.class));
    BundleContextMock.assertNoServiceExists(EntityManagerFactory.class.getName());
   
   
    //Now try Resolving
    Skeleton.getSkeleton(persistenceBundle).setReturnValue(new MethodCall(Bundle.class, "getState"), Bundle.RESOLVED);
    mgr.modifiedBundle(persistenceBundle, new BundleEvent(BundleEvent.RESOLVED, persistenceBundle), o);
   
    testSuccessfulCreationEvent(ref, extenderContext, 1);
    BundleContextMock.assertNoServiceExists(EntityManagerFactory.class.getName());
   
   
    //Now try starting (This should not create again, so check we only called 1 time)
    Skeleton.getSkeleton(persistenceBundle).setReturnValue(new MethodCall(Bundle.class, "getState"), Bundle.STARTING);
    mgr.modifiedBundle(persistenceBundle, new BundleEvent(BundleEvent.STARTING, persistenceBundle), o);
   
    testSuccessfulCreationEvent(ref, extenderContext, 1);
    testSuccessfulRegistrationEvent(ref, extenderContext, 1);
   
    //Now try active (This should not create again, so check we only called 1 time)
    Skeleton.getSkeleton(persistenceBundle).setReturnValue(new MethodCall(Bundle.class, "getState"), Bundle.ACTIVE);
    mgr.modifiedBundle(persistenceBundle, new BundleEvent(BundleEvent.STARTED, persistenceBundle), o);
   
    testSuccessfulCreationEvent(ref, extenderContext, 1);
    testSuccessfulRegistrationEvent(ref, extenderContext, 1);
   
    //Now stop the bundle, check no extra calls, and the EMFs are still open
    Skeleton.getSkeleton(persistenceBundle).setReturnValue(new MethodCall(Bundle.class, "getState"), Bundle.STOPPING);
    mgr.modifiedBundle(persistenceBundle, new BundleEvent(BundleEvent.STOPPING, persistenceBundle), o);
   
    testSuccessfulCreationEvent(ref, extenderContext, 1);
    BundleContextMock.assertNoServiceExists(EntityManagerFactory.class.getName());
    Skeleton.getSkeleton(pp).assertNotCalled(new MethodCall(EntityManagerFactory.class, "close"));
   
    //Now Mark the bundle stopped, check no extra calls, and the EMFs are still open
    Skeleton.getSkeleton(persistenceBundle).setReturnValue(new MethodCall(Bundle.class, "getState"), Bundle.RESOLVED);
    mgr.modifiedBundle(persistenceBundle, new BundleEvent(BundleEvent.STOPPING, persistenceBundle), o);
   
    testSuccessfulCreationEvent(ref, extenderContext, 1);
    BundleContextMock.assertNoServiceExists(EntityManagerFactory.class.getName());
    Skeleton.getSkeleton(pp).assertNotCalled(new MethodCall(EntityManagerFactory.class, "close"));
   
    //Now Uninstall, check no extra calls, and the EMFs are closed
    Skeleton.getSkeleton(persistenceBundle).setReturnValue(new MethodCall(Bundle.class, "getState"), Bundle.UNINSTALLED);
    mgr.removedBundle(persistenceBundle, new BundleEvent(BundleEvent.UNINSTALLED, persistenceBundle), o);
   
    testSuccessfulCreationEvent(ref, extenderContext, 1);
    BundleContextMock.assertNoServiceExists(EntityManagerFactory.class.getName());
    Skeleton.getSkeleton(pp).assertCalled(new MethodCall(EntityManagerFactory.class, "close"));
  }
View Full Code Here

    //Clear the extender context to remove the previous get for the PersistenceProvider.
    Skeleton.getSkeleton(extenderContext).clearMethodCalls();
   
    System.out.println(getTrackedObject());
    //Update the bundle
    Skeleton.getSkeleton(persistenceBundle).setReturnValue(new MethodCall(Bundle.class, "getState"), Bundle.INSTALLED);
    mgr.modifiedBundle(persistenceBundle, new BundleEvent(BundleEvent.UPDATED, persistenceBundle), getTrackedObject());
   
    //Check the persistence.xml was looked for
    Skeleton.getSkeleton(persistenceBundle).assertCalled(new MethodCall(Bundle.class, "getEntry", "META-INF/persistence.xml"));
    //Check we didn't use getResource()
    Skeleton.getSkeleton(persistenceBundle).assertNotCalled(new MethodCall(Bundle.class, "getResource", String.class));
   
    //Check we didn't get the Provider, and there is no Service in the registry
    Skeleton.getSkeleton(extenderContext).assertNotCalled(new MethodCall(BundleContext.class, "getService", ServiceReference.class));
    Skeleton.getSkeleton(pp).assertCalled(new MethodCall(EntityManagerFactory.class, "close"));
    BundleContextMock.assertNoServiceExists(EntityManagerFactory.class.getName());
   
    //Now resolve the bundle again and check we get another EMF created
    Skeleton.getSkeleton(persistenceBundle).setReturnValue(new MethodCall(Bundle.class, "getState"), Bundle.RESOLVED);
    mgr.modifiedBundle(persistenceBundle, new BundleEvent(BundleEvent.RESOLVED, persistenceBundle), getTrackedObject());
   
    //We will have created the EMF a total of 2 times
    testSuccessfulCreationEvent(ref, extenderContext, 2);
    BundleContextMock.assertNoServiceExists(EntityManagerFactory.class.getName());
View Full Code Here

    testSuccessfulRegistrationEvent(ref, extenderContext, 1);
   
    Skeleton.getSkeleton(extenderContext).clearMethodCalls();
    Skeleton.getSkeleton(persistenceBundle).clearMethodCalls();
   
    Skeleton.getSkeleton(persistenceBundle).setReturnValue(new MethodCall(Bundle.class, "getState"), Bundle.INSTALLED);
    mgr.modifiedBundle(persistenceBundle, new BundleEvent(BundleEvent.UNRESOLVED, persistenceBundle), getTrackedObject());
   
    //Check we don't re-parse the xml
    Skeleton.getSkeleton(persistenceBundle).assertNotCalled(new MethodCall(Bundle.class, "getEntry", "META-INF/persistence.xml"));
    //Check we didn't use getResource()
    Skeleton.getSkeleton(persistenceBundle).assertNotCalled(new MethodCall(Bundle.class, "getResource", String.class));
   
    //Check we didn't get the Provider, and there is no Service in the registry
    Skeleton.getSkeleton(extenderContext).assertNotCalled(new MethodCall(BundleContext.class, "getService", ServiceReference.class));
    Skeleton.getSkeleton(pp).assertCalled(new MethodCall(EntityManagerFactory.class, "close"));
    BundleContextMock.assertNoServiceExists(EntityManagerFactory.class.getName());
  }
View Full Code Here

    testSuccessfulCreationEvent(ref, extenderContext, 1);
    testSuccessfulRegistrationEvent(ref, extenderContext, 1);
   
    mgr.removingProvider(ref);
   
    Skeleton.getSkeleton(pp).assertCalled(new MethodCall(EntityManagerFactory.class, "close"));
    BundleContextMock.assertNoServiceExists(EntityManagerFactory.class.getName());   
   
    mgr.modifiedBundle(persistenceBundle, null, getTrackedObject());
  }
View Full Code Here

   
    Object o = mgr.addingBundle(persistenceBundle, null);
   
    assertNull("We should not have received a manager", o);
    //Check we didn't get the Provider, and there is no Service in the registry
    Skeleton.getSkeleton(extenderContext).assertNotCalled(new MethodCall(BundleContext.class, "getService", ServiceReference.class));
    BundleContextMock.assertNoServiceExists(EntityManagerFactory.class.getName());
  }
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.