@Test
 public void testMerging() {
   GenericBeanMetaData ebMetaData1 = new GenericBeanMetaData(EjbType.ENTITY);
   ebMetaData1.setName("Entity Bean 1");
   GenericBeanMetaData ebMetaData2 = new GenericBeanMetaData(EjbType.ENTITY);
   ebMetaData2.setName("Entity Bean 2");
   ebMetaData1.merge(ebMetaData1, ebMetaData2);
 }
Esempio n. 2
0
  /**
   * Test that {@link GenericBeanMetaData#merge(AbstractEnterpriseBeanMetaData,
   * AbstractEnterpriseBeanMetaData)} works as expected for timer metadata
   */
  @Test
  public void testSessionBeanTimerMerge2() {
    TimerMetaData persistentTimer = new TimerMetaData();
    persistentTimer.setPersistent(true);

    GenericBeanMetaData original = new GenericBeanMetaData(EjbType.SESSION);
    original.setEjbName("DummyBean");

    GenericBeanMetaData overriden = new GenericBeanMetaData(EjbType.SESSION);
    overriden.setEjbName("DummyBean");
    overriden.addTimer(persistentTimer);

    GenericBeanMetaData mergedBean = new GenericBeanMetaData(EjbType.SESSION);
    mergedBean.merge(overriden, original);

    List<TimerMetaData> mergedTimers = mergedBean.getTimers();
    Assert.assertNotNull("Merged timers is null", mergedTimers);
    Assert.assertEquals("Unexpected number of timers in merged metadata", 1, mergedTimers.size());
    Assert.assertTrue(
        "Timer in merged metadata is not persistent", mergedTimers.get(0).isPersistent());
  }
Esempio n. 3
0
  /**
   * Test that {@link GenericBeanMetaData#merge(AbstractEnterpriseBeanMetaData,
   * AbstractEnterpriseBeanMetaData)} works as expected for timer metadata
   */
  @Test
  public void testSessionBeanTimerMerge() {
    TimerMetaData nonPersistentTimer = new TimerMetaData();
    nonPersistentTimer.setPersistent(false);

    TimerMetaData persistentTimer = new TimerMetaData();
    persistentTimer.setPersistent(true);

    GenericBeanMetaData original = new GenericBeanMetaData(EjbType.SESSION);
    original.setEjbName("DummyBean");
    original.addTimer(nonPersistentTimer);

    GenericBeanMetaData overriden = new GenericBeanMetaData(EjbType.SESSION);
    overriden.setEjbName("DummyBean");
    overriden.addTimer(persistentTimer);

    GenericBeanMetaData mergedBean = new GenericBeanMetaData(EjbType.SESSION);
    mergedBean.merge(overriden, original);

    List<TimerMetaData> mergedTimers = mergedBean.getTimers();
    Assert.assertNotNull("Merged timers is null", mergedTimers);
    Assert.assertEquals("Unexpected number of timers in merged metadata", 2, mergedTimers.size());

    boolean foundPersistentTimer = false;
    boolean foundNonPersistentTimer = false;

    for (TimerMetaData timer : mergedTimers) {
      if (timer.isPersistent()) {
        foundPersistentTimer = true;
      } else {
        foundNonPersistentTimer = true;
      }
    }
    Assert.assertTrue("Persistent timer not found in merged metadata", foundPersistentTimer);
    Assert.assertTrue("Non-Persistent timer not found in merged metadata", foundNonPersistentTimer);
  }