Package org.springframework.scripting

Examples of org.springframework.scripting.Messenger


    assertEquals("Message is incorrect", desiredMessage, messenger.getMessage());
  }

  public void testNonStaticScript() throws Exception {
    ApplicationContext ctx = new ClassPathXmlApplicationContext("jrubyRefreshableContext.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


  public void testResourceScriptFromTag() throws Exception {
    ApplicationContext ctx = new ClassPathXmlApplicationContext("jruby-with-xsd.xml", getClass());
    TestBean testBean = (TestBean) ctx.getBean("testBean");

    Messenger messenger = (Messenger) ctx.getBean("messenger");
    assertEquals("Hello World!", messenger.getMessage());
    assertFalse(messenger instanceof Refreshable);

    TestBeanAwareMessenger messengerByType = (TestBeanAwareMessenger) ctx.getBean("messengerByType");
    assertEquals(testBean, messengerByType.getTestBean());
View Full Code Here

    assertFalse(calculator instanceof Refreshable);
  }

  public void testRefreshableFromTag() throws Exception {
    ApplicationContext ctx = new ClassPathXmlApplicationContext("jruby-with-xsd.xml", getClass());
    Messenger messenger = (Messenger) ctx.getBean("refreshableMessenger");
    assertEquals("Hello World!", messenger.getMessage());
    assertTrue("Messenger should be Refreshable", messenger instanceof Refreshable);
  }
View Full Code Here

    assertTrue("Messenger should be Refreshable", messenger instanceof Refreshable);
  }

  public void testThatMultipleScriptInterfacesAreSupported() throws Exception {
    ApplicationContext ctx = new ClassPathXmlApplicationContext("jruby-with-xsd.xml", getClass());
    Messenger messenger = (Messenger) ctx.getBean("calculatingMessenger");
    assertEquals("Hello World!", messenger.getMessage());

    // cool, now check that the Calculator interface is also exposed
    Calculator calc = (Calculator) messenger;
    assertEquals(0, calc.add(2, -2));
  }
View Full Code Here

    }
  }

  public void testAOP() throws Exception {
    ApplicationContext ctx = new ClassPathXmlApplicationContext("jruby-aop.xml", getClass());
    Messenger messenger = (Messenger) ctx.getBean("messenger");
    assertEquals(new StringBuffer("Hello World!").reverse().toString(), messenger.getMessage());
  }
View Full Code Here

  public void testAdviseWithProxyFactoryBean() throws Exception {
    ApplicationContext context =
        new ClassPathXmlApplicationContext("advisedByProxyFactoryBean.xml", getClass());

    Messenger bean = (Messenger) context.getBean("messenger");
    assertTrue("Bean is not a proxy", AopUtils.isAopProxy(bean));
    assertTrue("Bean is not an Advised object", bean instanceof Advised);

    CountingBeforeAdvice advice = (CountingBeforeAdvice) context.getBean("advice");
    assertEquals(0, advice.getCalls());
    bean.getMessage();
    assertEquals(1, advice.getCalls());
  }
View Full Code Here

  public void testAdviseWithBeanNameAutoProxyCreator() throws Exception {
    ApplicationContext context =
        new ClassPathXmlApplicationContext("advisedByBeanNameAutoProxyCreator.xml", getClass());

    Messenger bean = (Messenger) context.getBean("messenger");
    assertTrue("Bean is not a proxy", AopUtils.isAopProxy(bean));
    assertTrue("Bean is not an Advised object", bean instanceof Advised);

    CountingBeforeAdvice advice = (CountingBeforeAdvice) context.getBean("advice");
    assertEquals(0, advice.getCalls());
    bean.getMessage();
    assertEquals(1, advice.getCalls());
  }
View Full Code Here

  @Test
  public void testStaticScript() throws Exception {
    ApplicationContext ctx = new ClassPathXmlApplicationContext("jrubyContext.xml", getClass());
    Calculator calc = (Calculator) ctx.getBean("calculator");
    Messenger messenger = (Messenger) ctx.getBean("messenger");

    assertFalse("Scripted object should not be instance of Refreshable", calc instanceof Refreshable);
    assertFalse("Scripted object should not be instance of Refreshable", messenger instanceof Refreshable);

    assertEquals(calc, calc);
    assertEquals(messenger, messenger);
    assertTrue(!messenger.equals(calc));
    assertNotSame(messenger.hashCode(), calc.hashCode());
    assertTrue(!messenger.toString().equals(calc.toString()));

    String desiredMessage = "Hello World!";
    assertEquals("Message is incorrect", desiredMessage, messenger.getMessage());
  }
View Full Code Here

  }

  @Test
  public void testNonStaticScript() throws Exception {
    ApplicationContext ctx = new ClassPathXmlApplicationContext("jrubyRefreshableContext.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

  @Test
  public void testResourceScriptFromTag() throws Exception {
    ApplicationContext ctx = new ClassPathXmlApplicationContext("jruby-with-xsd.xml", getClass());
    TestBean testBean = (TestBean) ctx.getBean("testBean");

    Messenger messenger = (Messenger) ctx.getBean("messenger");
    assertEquals("Hello World!", messenger.getMessage());
    assertFalse(messenger instanceof Refreshable);

    TestBeanAwareMessenger messengerByType = (TestBeanAwareMessenger) ctx.getBean("messengerByType");
    assertEquals(testBean, messengerByType.getTestBean());
View Full Code Here

TOP

Related Classes of org.springframework.scripting.Messenger

Copyright © 2018 www.massapicom. 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.