Package br.gov.frameworkdemoiselle.util

Examples of br.gov.frameworkdemoiselle.util.NameQualifier


  @Test
  public void produceOneEntityManagerPerView() {
    ViewContext ctx = Beans.getReference(ViewContext.class);
    ctx.activate();
   
    EntityManager m1 = Beans.getReference(EntityManager.class, new NameQualifier("pu"));

    assertNotNull(m1);
    assertEquals(EntityManagerProxy.class, m1.getClass());

    EntityManager m2 = Beans.getReference(EntityManager.class, new NameQualifier("pu"));

    assertNotNull(m2);
    assertEquals(EntityManagerProxy.class, m2.getClass());

    MyEntity entity = new MyEntity();
View Full Code Here


    ViewContext ctx = Beans.getReference(ViewContext.class);
    if (ctx.isActive()){
      ctx.deactivate();
    }
   
    EntityManager m1 = Beans.getReference(EntityManager.class, new NameQualifier("pu"));

    assertNotNull(m1);
    assertEquals(EntityManagerProxy.class, m1.getClass());

    MyEntity entity = new MyEntity();
View Full Code Here

  }

  @Test
  public void produceNamedOneEntityManagerFactory() {
    EntityManagerFactory emf = Beans.getReference(EntityManagerFactory.class, new NameQualifier("pu"));
    assertNotNull(emf);
    assertTrue(emf.getMetamodel().getEntities().toString().contains(DummyEntityDefault.class.getSimpleName()));
   
    EntityManager em = emf.createEntityManager();
View Full Code Here

    assertTrue(listAll.size() == 0);
  }

  @Test
  public void produceNamedTwoEntityManagerFactory() {
    EntityManagerFactory emf = Beans.getReference(EntityManagerFactory.class, new NameQualifier("pu2"));
    assertNotNull(emf);
    assertTrue(emf.getMetamodel().getEntities().toString().contains(DummyEntityNamed.class.getSimpleName()));
   
    EntityManager em = emf.createEntityManager();
View Full Code Here

  }

  @SuppressWarnings("unused")
  @Test(expected = PersistenceException.class)
  public void produceNamedInexistentEntityManagerFactory() {
    EntityManagerFactory emf = Beans.getReference(EntityManagerFactory.class, new NameQualifier("pu3"));
  }
View Full Code Here

  }
 
  @SuppressWarnings("unused")
  @Test(expected=PersistenceException.class)
  public void produceNamedInexistentEntityManagerFactory() {
    EntityManagerFactory emf = Beans.getReference(EntityManagerFactory.class, new NameQualifier("pu2"));
  }
View Full Code Here

    assertEquals(EntityManagerProxy.class, manager.getClass());
  }

  @Test
  public void produceMultipleEntityManagers() {
    EntityManager m1 = Beans.getReference(EntityManager.class, new NameQualifier("pu"));

    assertNotNull(m1);
    assertEquals(EntityManagerProxy.class, m1.getClass());

    EntityManager m2 = Beans.getReference(EntityManager.class, new NameQualifier("pu2"));

    assertNotNull(m2);
    assertEquals(EntityManagerProxy.class, m2.getClass());
  }
View Full Code Here

    assertEquals(EntityManagerProxy.class, m2.getClass());
  }

  @Test
  public void produceOneEntityManagerPerRequest() {
    EntityManager m1 = Beans.getReference(EntityManager.class, new NameQualifier("pu"));

    assertNotNull(m1);
    assertEquals(EntityManagerProxy.class, m1.getClass());

    EntityManager m2 = Beans.getReference(EntityManager.class, new NameQualifier("pu"));

    assertNotNull(m2);
    assertEquals(EntityManagerProxy.class, m2.getClass());

    MyEntity entity = new MyEntity();
View Full Code Here

    if (!weldContext.isActive()){
      wasNotActive = true;
      weldContext.activate();
    }
   
    EntityManager m1 = Beans.getReference(EntityManager.class, new NameQualifier("pu"));
    assertNotNull(m1);
    assertEquals(EntityManagerProxy.class, m1.getClass());
   
    MyEntity entity = new MyEntity();
    entity.setId(createId("testID"));
   
    m1.persist(entity);
    assertTrue(m1.contains(entity));
   
    weldContext.invalidate();
    weldContext.deactivate();
   
    if (!weldContext.isActive()){
      weldContext.activate();
    }
   
    EntityManager m2 = Beans.getReference(EntityManager.class, new NameQualifier("pu"));
   
    assertTrue( m2.isOpen() );
    assertTrue( !m2.contains(entity));
   
    if (wasNotActive && weldContext.isActive()){
View Full Code Here

  private transient ResourceBundle bundle;

  private ResourceBundle getBundle() {
    if (bundle == null) {
      bundle = Beans.getReference(ResourceBundle.class, new NameQualifier("demoiselle-jdbc-bundle"));
    }

    return bundle;
  }
View Full Code Here

TOP

Related Classes of br.gov.frameworkdemoiselle.util.NameQualifier

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.