Beispiel #1
0
  @Test
  public void testSessionScope() throws Exception {
    MuleEvent e = getTestEvent("testing");
    e.getSession().setProperty("SESSION_PROP", "Value1");
    RequestContext.setEvent(e);

    MessagePropertiesContext mpc = new MessagePropertiesContext();

    assertEquals("Value1", mpc.getProperty("SESSION_PROP", PropertyScope.SESSION));
    // test case insensitivity
    assertEquals("Value1", mpc.getProperty("SESSION_prop", PropertyScope.SESSION));
    assertNull(mpc.getProperty("SESSION_X", PropertyScope.SESSION));
  }
Beispiel #2
0
  protected void doTest(MessagePropertiesContext mpc) {
    // Look in all scopes
    assertEquals("BAR", mpc.getProperty("foo"));
    assertEquals("DAR", mpc.getProperty("doo"));
    assertEquals("abc", mpc.getProperty("abc"));

    // Look in specific scope
    assertEquals("BAR", mpc.getProperty("foO", PropertyScope.OUTBOUND)); // default scope
    assertEquals("DAR", mpc.getProperty("doO", PropertyScope.INVOCATION));

    // Not found using other specific scopes
    assertNull(mpc.getProperty("doo", PropertyScope.INBOUND));
    assertNull(mpc.getProperty("doo", PropertyScope.OUTBOUND));
    assertNull(mpc.getProperty("doo", PropertyScope.SESSION));

    Set<String> keys = mpc.getPropertyNames();
    assertEquals(3, keys.size());

    for (String key : keys) {
      assertTrue(key.equals("FOO") || key.equals("DOO") || key.equals("ABC"));
      assertFalse(key.equals("foo") || key.equals("doo") || key.equals("abc"));
    }
  }
Beispiel #3
0
  @Test
  public void testPropertyScopeOrder() throws Exception {
    MuleEvent e = getTestEvent("testing");
    e.getSession().setProperty("Prop", "session");
    RequestContext.setEvent(e);

    MessagePropertiesContext mpc = new MessagePropertiesContext();
    // Note that we cannot write to the Inbound scope, its read only
    mpc.setProperty("Prop", "invocation", PropertyScope.INVOCATION);
    mpc.setProperty("Prop", "outbound", PropertyScope.OUTBOUND);

    assertEquals("outbound", mpc.getProperty("Prop"));
    mpc.removeProperty("Prop", PropertyScope.OUTBOUND);

    assertEquals("invocation", mpc.getProperty("Prop"));
    mpc.removeProperty("Prop", PropertyScope.INVOCATION);

    assertEquals("session", mpc.getProperty("Prop"));
    assertNull(mpc.getProperty("Prop", PropertyScope.INBOUND));
    assertNull(mpc.getProperty("Prop", PropertyScope.INVOCATION));
    assertNull(mpc.getProperty("Prop", PropertyScope.OUTBOUND));
  }