コード例 #1
0
 protected void assertCreate(DefaultMuleSession session) {
   assertNotNull(session.getId());
   assertNull(session.getSecurityContext());
   assertNotNull(session.getPropertyNamesAsSet());
   assertTrue(session.getPropertyNamesAsSet().isEmpty());
   assertTrue(session.isValid());
 }
コード例 #2
0
  @Test
  public void merge() {
    DefaultMuleSession copy1 = new DefaultMuleSession();
    DefaultMuleSession copy2 = new DefaultMuleSession();

    Object nonSerializableValue2 = new Object();
    Object nonSerializableValue3 = new Object();

    copy1.setProperty("key1", "value1");
    copy1.setProperty("key2", nonSerializableValue2);
    copy1.setProperty("key3", nonSerializableValue3);
    copy1.setProperty("key4", "value4");
    copy1.setProperty("key5", "value5");
    copy1.setProperty("key6", "value6");

    copy2.setProperty("key1", "value1");
    copy2.setProperty("key2", "value2");
    copy2.setProperty("KEY4", "value4");
    copy2.setProperty("KEY5", "value5NEW");
    copy2.setProperty("key7", "value7");

    int copy2PropertiesHashCode = copy2.getPropertyNamesAsSet().hashCode();

    copy1.merge(copy2);

    assertEquals(6, copy1.getPropertyNamesAsSet().size());
    assertEquals("value1", copy1.getProperty("key1"));
    assertEquals("value2", copy1.getProperty("key2"));
    assertEquals(nonSerializableValue3, copy1.getProperty("key3"));
    assertEquals("value4", copy1.getProperty("key4"));
    assertEquals("value5NEW", copy1.getProperty("key5"));
    assertNull(copy1.getProperty("key6"));
    assertEquals("value7", copy1.getProperty("key7"));

    assertEquals(5, copy2.getPropertyNamesAsSet().size());
    assertEquals(copy2PropertiesHashCode, copy2.getPropertyNamesAsSet().hashCode());
  }