Esempio n. 1
0
  public void testSharedFields() throws Exception {
    beanN1C1.setField("newVal1");
    beanN2C2.setField("newVal2");

    assertEquals("Failed to share", "newVal1", beanN2C1.getField());
    assertEquals("Failed to share", "newVal2", beanN1C2.getField());
  }
Esempio n. 2
0
  public void testScopeId() throws Exception {
    String id11 = beanN1C1.getConversationId();
    String id12 = beanN1C2.getConversationId();

    String id21 = beanN2C1.getConversationId();
    String id22 = beanN2C2.getConversationId();

    assertEquals("Unexpected scope", id11, id21);
    assertEquals("Unexpected scope", id12, id22);
  }
Esempio n. 3
0
  public void testTransientFields() throws Exception {
    assertEquals(
        "Failed to initialize transient field", "transient-val", beanN1C1.getTransientField());
    assertEquals(
        "Failed to initialize transient field", "transient-val", beanN1C2.getTransientField());
    assertEquals(
        "Failed to initialize transient field", "transient-val", beanN2C1.getTransientField());
    assertEquals(
        "Failed to initialize transient field", "transient-val", beanN2C2.getTransientField());

    beanN1C1.setTransientField("newVal11");
    beanN1C2.setTransientField("newVal12");
    beanN2C1.setTransientField("newVal21");
    beanN2C2.setTransientField("newVal22");

    assertEquals("Unexpected sharing", "newVal11", beanN1C1.getTransientField());
    assertEquals("Unexpected sharing", "newVal12", beanN1C2.getTransientField());
    assertEquals("Unexpected sharing", "newVal21", beanN2C1.getTransientField());
    assertEquals("Unexpected sharing", "newVal22", beanN2C2.getTransientField());
  }
Esempio n. 4
0
  public void testDestructionCallbacks() throws Exception {
    String conversationId11 = beanN1C1.getConversationId();
    String conversationId21 = beanN1C2.getConversationId();
    String conversationId12 = beanN2C1.getConversationId();
    String conversationId22 = beanN2C2.getConversationId();

    beanN1C1.setField("newVal11");
    beanN1C2.setField("newVal12");
    beanN2C1.setField("newVal21");
    beanN2C2.setField("newVal22");

    assertTrue(
        "Failed to create scoped bean", beanN1C1.isInClusteredSingletonCache(conversationId11));
    assertTrue(
        "Failed to create scoped bean", beanN1C2.isInClusteredSingletonCache(conversationId12));
    assertTrue(
        "Failed to create scoped bean", beanN2C1.isInClusteredSingletonCache(conversationId21));
    assertTrue(
        "Failed to create scoped bean", beanN2C2.isInClusteredSingletonCache(conversationId22));

    beanN1C1.invokeDestructionCallback();
    beanN2C2.invokeDestructionCallback();

    assertFalse(
        "Failed to destruct scoped bean", beanN1C1.isInClusteredSingletonCache(conversationId11));
    assertFalse(
        "Failed to destruct scoped bean", beanN1C2.isInClusteredSingletonCache(conversationId12));
    assertFalse(
        "Failed to destruct scoped bean", beanN2C1.isInClusteredSingletonCache(conversationId21));
    assertFalse(
        "Failed to destruct scoped bean", beanN2C2.isInClusteredSingletonCache(conversationId22));
  }