Examples of QuiesceParticipant


Examples of org.apache.aries.quiesce.participant.QuiesceParticipant

    BundleContext ctx = preExistingBundleSetup();
    mgr.start(ctx);
   
    QuiesceCallback cbk = Skeleton.newMock(QuiesceCallback.class);
   
    QuiesceParticipant p = (QuiesceParticipant) ctx.getService(ctx.getServiceReference(QuiesceParticipant.class.getName()));
 
    p.quiesce(cbk, Collections.singletonList(extenderBundle));
   
    Thread.sleep(100);
   
    Skeleton.getSkeleton(cbk).assertCalledExactNumberOfTimes(new MethodCall(QuiesceCallback.class,
        "bundleQuiesced", Bundle[].class), 1);
View Full Code Here

Examples of org.apache.aries.quiesce.participant.QuiesceParticipant

   
    assertCorrectPersistenceProviderUsed(ctx, providerP101, 2);
   
    QuiesceCallback cbk = Skeleton.newMock(QuiesceCallback.class);
   
    QuiesceParticipant p = (QuiesceParticipant) ctx.getService(ctx.getServiceReference(QuiesceParticipant.class.getName()));
 
    p.quiesce(cbk, Collections.singletonList(extenderBundle));
   
    Thread.sleep(100);
   
    Skeleton.getSkeleton(cbk).assertCalledExactNumberOfTimes(new MethodCall(QuiesceCallback.class,
        "bundleQuiesced", Bundle[].class), 1);
View Full Code Here

Examples of org.apache.aries.quiesce.participant.QuiesceParticipant

    EntityManager bravo = ((EntityManagerFactory) ctx.getService(ctx.getServiceReferences(
        EntityManagerFactory.class.getName(), "(osgi.unit.name=bravo)")[0])).createEntityManager();
   
    QuiesceCallback cbk = Skeleton.newMock(QuiesceCallback.class);
   
    QuiesceParticipant p = (QuiesceParticipant) ctx.getService(ctx.getServiceReference(QuiesceParticipant.class.getName()));
 
    p.quiesce(cbk, Collections.singletonList(extenderBundle));
   
    Thread.sleep(100);
   
    Skeleton.getSkeleton(cbk).assertNotCalled(new MethodCall(QuiesceCallback.class,
        "bundleQuiesced", Bundle[].class));
View Full Code Here

Examples of org.apache.aries.quiesce.participant.QuiesceParticipant

          + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true)" +
        "(" + PersistenceContextProvider.PROXY_FACTORY_EMF_ATTRIBUTE + "=*))", DEFAULT_TIMEOUT);
   
   
    //Quiesce it
    QuiesceParticipant participant = getParticipant("org.apache.aries.jpa.container.context");
   
    TestQuiesceCallback callback = new TestQuiesceCallback();
   
    participant.quiesce(callback, Collections.singletonList(getBundle(
        "org.apache.aries.jpa.org.apache.aries.jpa.container.itest.bundle")));
   
    Thread.sleep(1000);
   
    assertTrue("Quiesce not finished", callback.bundleClearedUp());
View Full Code Here

Examples of org.apache.aries.quiesce.participant.QuiesceParticipant

   
    tm.begin();
   
    emf.createEntityManager().getProperties();
   
    QuiesceParticipant participant = getParticipant("org.apache.aries.jpa.container.context");
   
    TestQuiesceCallback callback = new TestQuiesceCallback();
   
    participant.quiesce(callback, Collections.singletonList(getBundle(
        "org.apache.aries.jpa.org.apache.aries.jpa.container.itest.bundle")));
   
    Thread.sleep(1000);
   
    assertFalse("Quiesce finished", callback.bundleClearedUp());
   
    emf = getOsgiService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)("
        + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true)" +
      "(" + PersistenceContextProvider.PROXY_FACTORY_EMF_ATTRIBUTE + "=*))", DEFAULT_TIMEOUT);
   
    tm.commit();
   
    assertTrue("Quiesce not finished", callback.bundleClearedUp());
   
    ServiceReference[] refs = bundleContext.getAllServiceReferences(EntityManagerFactory.class.getName(), "(&(osgi.unit.name=test-unit)("
          + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true)" +
        "(" + PersistenceContextProvider.PROXY_FACTORY_EMF_ATTRIBUTE + "=*))");
   
    assertNull("No context should exist",refs);
   
   
    //Restart the bundle to check the context gets re-registered, then ensure it isn't
    //tidied up immediately again!
    Bundle b = getBundle("org.apache.aries.jpa.org.apache.aries.jpa.container.itest.bundle");
    b.stop();
    b.start();
   
    emf = getOsgiService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)("
        + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true)" +
      "(" + PersistenceContextProvider.PROXY_FACTORY_EMF_ATTRIBUTE + "=*))", DEFAULT_TIMEOUT);
   
    tm.begin();
   
    emf.createEntityManager().getProperties();
   
    tm.commit();
   
    Thread.sleep(1000);
   
    emf = getOsgiService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)("
        + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true)" +
      "(" + PersistenceContextProvider.PROXY_FACTORY_EMF_ATTRIBUTE + "=*))", 100);
   
    //Test again to make sure we don't hold state over
   
    tm.begin();
   
    emf.createEntityManager().getProperties();
   
    callback = new TestQuiesceCallback();
   
    participant.quiesce(callback, Collections.singletonList(getBundle(
        "org.apache.aries.jpa.org.apache.aries.jpa.container.itest.bundle")));
   
    Thread.sleep(1000);
   
    assertFalse("Quiesce finished", callback.bundleClearedUp());
View Full Code Here

Examples of org.apache.aries.quiesce.participant.QuiesceParticipant

   
    tm.begin();
   
    emf.createEntityManager().getProperties();
   
    QuiesceParticipant participant = getParticipant("org.apache.aries.jpa.container.context");
   
    TestQuiesceCallback callback = new TestQuiesceCallback();
   
    participant.quiesce(callback, Collections.singletonList(getBundle(
        "org.apache.aries.jpa.container.context")));
   
    Thread.sleep(1000);
   
    assertFalse("Quiesce not finished", callback.bundleClearedUp());
View Full Code Here

Examples of org.apache.aries.quiesce.participant.QuiesceParticipant

   
    EntityManagerFactory emf = getOsgiService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)("
          + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))", DEFAULT_TIMEOUT);
   
    QuiesceParticipant participant = getParticipant("org.apache.aries.jpa.container");
   
    TestQuiesceCallback callback = new TestQuiesceCallback();
   
    participant.quiesce(callback, Collections.singletonList(getBundle(
        "org.apache.aries.jpa.org.apache.aries.jpa.container.itest.bundle")));
   
    Thread.sleep(1000);
   
    assertTrue("Quiesce not finished", callback.bundleClearedUp());
View Full Code Here

Examples of org.apache.aries.quiesce.participant.QuiesceParticipant

    EntityManagerFactory emf = getOsgiService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)("
          + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))", DEFAULT_TIMEOUT);
   
    EntityManager em = emf.createEntityManager();
   
    QuiesceParticipant participant = getParticipant("org.apache.aries.jpa.container");
   
    TestQuiesceCallback callback = new TestQuiesceCallback();
   
    participant.quiesce(callback, Collections.singletonList(getBundle(
        "org.apache.aries.jpa.org.apache.aries.jpa.container.itest.bundle")));
   
    Thread.sleep(1000);
   
    assertFalse("Quiesce finished", callback.bundleClearedUp());
   
    emf = getOsgiService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)("
        + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))", DEFAULT_TIMEOUT);
   
    em.close();
   
    assertTrue("Quiesce not finished", callback.bundleClearedUp());
   
    ServiceReference[] refs = bundleContext.getAllServiceReferences(EntityManagerFactory.class.getName(), "(&(osgi.unit.name=test-unit)("
          + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))");
   
    assertNull("No context should exist",refs);
   
    //Restart the bundle to check the unit gets re-registered and is not immediately unregistered
    Bundle b = getBundle("org.apache.aries.jpa.org.apache.aries.jpa.container.itest.bundle");
    b.stop();
    b.start();
   
    emf = getOsgiService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)("
        + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))", DEFAULT_TIMEOUT);
   
    em = emf.createEntityManager();
    em.close();
   
    emf = getOsgiService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)("
        + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))", 100);
   
    //Test a second time to make sure state isn't held
   
    em = emf.createEntityManager();
   
    callback = new TestQuiesceCallback();
   
    participant.quiesce(callback, Collections.singletonList(getBundle(
        "org.apache.aries.jpa.org.apache.aries.jpa.container.itest.bundle")));
   
    Thread.sleep(1000);
   
    assertFalse("Quiesce finished", callback.bundleClearedUp());
View Full Code Here

Examples of org.apache.aries.quiesce.participant.QuiesceParticipant

          + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))", DEFAULT_TIMEOUT);
   
   
    EntityManager em = emf.createEntityManager();
   
    QuiesceParticipant participant = getParticipant("org.apache.aries.jpa.container");
   
    TestQuiesceCallback callback = new TestQuiesceCallback();
   
    participant.quiesce(callback, Collections.singletonList(getBundle(
        "org.apache.aries.jpa.container")));
   
    Thread.sleep(1000);
   
    assertFalse("Quiesce finished early", callback.bundleClearedUp());
View Full Code Here

Examples of org.apache.aries.quiesce.participant.QuiesceParticipant

    tm.begin();
   
    emf.createEntityManager().getProperties();
   
    //Quiesce the Unit, nothing should happen
    QuiesceParticipant participant = getParticipant("org.apache.aries.jpa.container");
   
    TestQuiesceCallback unitCallback = new TestQuiesceCallback();
   
    participant.quiesce(unitCallback, Collections.singletonList(getBundle(
        "org.apache.aries.jpa.org.apache.aries.jpa.container.itest.bundle")));
   
    Thread.sleep(1000);
   
    assertFalse("Quiesce finished", unitCallback.bundleClearedUp());
   
    emf = getOsgiService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)("
        + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true)" +
      "(" + PersistenceContextProvider.PROXY_FACTORY_EMF_ATTRIBUTE + "=*))", DEFAULT_TIMEOUT);
   
   
    //Quiesce the context, still nothing
   
    participant = getParticipant("org.apache.aries.jpa.container.context");
   
    TestQuiesceCallback contextCallback = new TestQuiesceCallback();
   
    participant.quiesce(contextCallback, Collections.singletonList(getBundle(
    "org.apache.aries.jpa.org.apache.aries.jpa.container.itest.bundle")));
   
    Thread.sleep(1000);
   
    assertFalse("Quiesce finished", unitCallback.bundleClearedUp());
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.