Examples of Messenger


Examples of org.springframework.scripting.Messenger

  public void testStaticScriptImplementingInterface() throws Exception {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("bshContext.xml", getClass());
    assertTrue(Arrays.asList(ctx.getBeanNamesForType(Messenger.class)).contains("messengerImpl"));

    Messenger messenger = (Messenger) ctx.getBean("messengerImpl");
    String desiredMessage = "Hello World!";
    assertEquals("Message is incorrect", desiredMessage, messenger.getMessage());
    assertTrue(ctx.getBeansOfType(Messenger.class).values().contains(messenger));

    ctx.close();
    assertNull(messenger.getMessage());
  }
View Full Code Here

Examples of org.springframework.scripting.Messenger

    assertEquals("Byebye World!", messenger2.getMessage());
  }

  public void testNonStaticScript() throws Exception {
    ApplicationContext ctx = new ClassPathXmlApplicationContext("bshRefreshableContext.xml", getClass());
    Messenger messenger = (Messenger) ctx.getBean("messenger");

    assertTrue("Should be a proxy for refreshable scripts", AopUtils.isAopProxy(messenger));
    assertTrue("Should be an instance of Refreshable", messenger instanceof Refreshable);

    String desiredMessage = "Hello World!";
    assertEquals("Message is incorrect", desiredMessage, messenger.getMessage());

    Refreshable refreshable = (Refreshable) messenger;
    refreshable.refresh();

    assertEquals("Message is incorrect after refresh", desiredMessage, messenger.getMessage());
    assertEquals("Incorrect refresh count", 2, refreshable.getRefreshCount());
  }
View Full Code Here

Examples of org.springframework.scripting.Messenger

    given(script.getScriptAsString()).willReturn(badScript);
    given(script.isModified()).willReturn(true);
    BshScriptFactory factory = new BshScriptFactory(
        ScriptFactoryPostProcessor.INLINE_SCRIPT_PREFIX + badScript, Messenger.class);
    try {
      Messenger messenger = (Messenger) factory.getScriptedObject(script, Messenger.class);
      messenger.getMessage();
      fail("Must have thrown a BshScriptUtils.BshExecutionException.");
    }
    catch (BshScriptUtils.BshExecutionException expected) {
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.