Package org.springframework.scripting

Examples of org.springframework.scripting.ConfigurableMessenger


    assertTrue(ctx.getBeansOfType(Messenger.class).values().contains(messenger));
  }

  public void testStaticPrototypeScript() throws Exception {
    ApplicationContext ctx = new ClassPathXmlApplicationContext("groovyContext.xml", getClass());
    ConfigurableMessenger messenger = (ConfigurableMessenger) ctx.getBean("messengerPrototype");
    ConfigurableMessenger messenger2 = (ConfigurableMessenger) ctx.getBean("messengerPrototype");

    assertFalse("Shouldn't get proxy when refresh is disabled", AopUtils.isAopProxy(messenger));
    assertFalse("Scripted object should not be instance of Refreshable", messenger instanceof Refreshable);

    assertNotSame(messenger, messenger2);
    assertSame(messenger.getClass(), messenger2.getClass());
    assertEquals("Hello World!", messenger.getMessage());
    assertEquals("Hello World!", messenger2.getMessage());
    messenger.setMessage("Bye World!");
    messenger2.setMessage("Byebye World!");
    assertEquals("Bye World!", messenger.getMessage());
    assertEquals("Byebye World!", messenger2.getMessage());
  }
View Full Code Here


    assertEquals("Incorrect refresh count", 2, refreshable.getRefreshCount());
  }

  public void testNonStaticPrototypeScript() throws Exception {
    ApplicationContext ctx = new ClassPathXmlApplicationContext("groovyRefreshableContext.xml", getClass());
    ConfigurableMessenger messenger = (ConfigurableMessenger) ctx.getBean("messengerPrototype");
    ConfigurableMessenger messenger2 = (ConfigurableMessenger) ctx.getBean("messengerPrototype");

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

    assertEquals("Hello World!", messenger.getMessage());
    assertEquals("Hello World!", messenger2.getMessage());
    messenger.setMessage("Bye World!");
    messenger2.setMessage("Byebye World!");
    assertEquals("Bye World!", messenger.getMessage());
    assertEquals("Byebye World!", messenger2.getMessage());

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

    assertEquals("Hello World!", messenger.getMessage());
    assertEquals("Byebye World!", messenger2.getMessage());
    assertEquals("Incorrect refresh count", 2, refreshable.getRefreshCount());
  }
View Full Code Here

    assertEquals(-200, countingAspect.getCalls());
  }

  public void testPrototypeScriptFromTag() throws Exception {
    ApplicationContext ctx = new ClassPathXmlApplicationContext("groovy-with-xsd.xml", getClass());
    ConfigurableMessenger messenger = (ConfigurableMessenger) ctx.getBean("messengerPrototype");
    ConfigurableMessenger messenger2 = (ConfigurableMessenger) ctx.getBean("messengerPrototype");

    assertNotSame(messenger, messenger2);
    assertSame(messenger.getClass(), messenger2.getClass());
    assertEquals("Hello World!", messenger.getMessage());
    assertEquals("Hello World!", messenger2.getMessage());
    messenger.setMessage("Bye World!");
    messenger2.setMessage("Byebye World!");
    assertEquals("Bye World!", messenger.getMessage());
    assertEquals("Byebye World!", messenger2.getMessage());
  }
View Full Code Here

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

    ConfigurableMessenger messenger = (ConfigurableMessenger) ctx.getBean("messengerWithConfig");
    messenger.setMessage(null);
    assertNull(messenger.getMessage());
    assertTrue(ctx.getBeansOfType(Messenger.class).values().contains(messenger));
  }
View Full Code Here

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

    ConfigurableMessenger messenger = (ConfigurableMessenger) ctx.getBean("messengerWithConfigExtra");
    messenger.setMessage(null);
    assertNull(messenger.getMessage());
    assertTrue(ctx.getBeansOfType(Messenger.class).values().contains(messenger));

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

    assertNull(messenger.getMessage());
  }

  public void testStaticPrototypeScript() throws Exception {
    ApplicationContext ctx = new ClassPathXmlApplicationContext("bshContext.xml", getClass());
    ConfigurableMessenger messenger = (ConfigurableMessenger) ctx.getBean("messengerPrototype");
    ConfigurableMessenger messenger2 = (ConfigurableMessenger) ctx.getBean("messengerPrototype");

    assertFalse("Shouldn't get proxy when refresh is disabled", AopUtils.isAopProxy(messenger));
    assertFalse("Scripted object should not be instance of Refreshable", messenger instanceof Refreshable);

    assertNotSame(messenger, messenger2);
    assertSame(messenger.getClass(), messenger2.getClass());
    assertEquals("Hello World!", messenger.getMessage());
    assertEquals("Hello World!", messenger2.getMessage());
    messenger.setMessage("Bye World!");
    messenger2.setMessage("Byebye World!");
    assertEquals("Bye World!", messenger.getMessage());
    assertEquals("Byebye World!", messenger2.getMessage());
  }
View Full Code Here

    assertEquals("Incorrect refresh count", 2, refreshable.getRefreshCount());
  }

  public void testNonStaticPrototypeScript() throws Exception {
    ApplicationContext ctx = new ClassPathXmlApplicationContext("bshRefreshableContext.xml", getClass());
    ConfigurableMessenger messenger = (ConfigurableMessenger) ctx.getBean("messengerPrototype");
    ConfigurableMessenger messenger2 = (ConfigurableMessenger) ctx.getBean("messengerPrototype");

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

    assertEquals("Hello World!", messenger.getMessage());
    assertEquals("Hello World!", messenger2.getMessage());
    messenger.setMessage("Bye World!");
    messenger2.setMessage("Byebye World!");
    assertEquals("Bye World!", messenger.getMessage());
    assertEquals("Byebye World!", messenger2.getMessage());

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

    assertEquals("Hello World!", messenger.getMessage());
    assertEquals("Byebye World!", messenger2.getMessage());
    assertEquals("Incorrect refresh count", 2, refreshable.getRefreshCount());
  }
View Full Code Here

    assertNull(messengerInstance.getMessage());
  }

  public void testPrototypeScriptFromTag() throws Exception {
    ApplicationContext ctx = new ClassPathXmlApplicationContext("bsh-with-xsd.xml", getClass());
    ConfigurableMessenger messenger = (ConfigurableMessenger) ctx.getBean("messengerPrototype");
    ConfigurableMessenger messenger2 = (ConfigurableMessenger) ctx.getBean("messengerPrototype");

    assertNotSame(messenger, messenger2);
    assertSame(messenger.getClass(), messenger2.getClass());
    assertEquals("Hello World!", messenger.getMessage());
    assertEquals("Hello World!", messenger2.getMessage());
    messenger.setMessage("Bye World!");
    messenger2.setMessage("Byebye World!");
    assertEquals("Bye World!", messenger.getMessage());
    assertEquals("Byebye World!", messenger2.getMessage());
  }
View Full Code Here

    assertEquals(testBean, messengerByName.getTestBean());
  }

  public void testPrototypeScriptFromTag() throws Exception {
    ApplicationContext ctx = new ClassPathXmlApplicationContext("jruby-with-xsd.xml", getClass());
    ConfigurableMessenger messenger = (ConfigurableMessenger) ctx.getBean("messengerPrototype");
    ConfigurableMessenger messenger2 = (ConfigurableMessenger) ctx.getBean("messengerPrototype");

    assertNotSame(messenger, messenger2);
    assertSame(messenger.getClass(), messenger2.getClass());
    assertEquals("Hello World!", messenger.getMessage());
    assertEquals("Hello World!", messenger2.getMessage());
    messenger.setMessage("Bye World!");
    messenger2.setMessage("Byebye World!");
    assertEquals("Bye World!", messenger.getMessage());
    assertEquals("Byebye World!", messenger2.getMessage());
  }
View Full Code Here

  }

  @Test
  public void testPrototypeScriptFromTag() throws Exception {
    ApplicationContext ctx = new ClassPathXmlApplicationContext("jruby-with-xsd.xml", getClass());
    ConfigurableMessenger messenger = (ConfigurableMessenger) ctx.getBean("messengerPrototype");
    ConfigurableMessenger messenger2 = (ConfigurableMessenger) ctx.getBean("messengerPrototype");

    assertNotSame(messenger, messenger2);
    assertSame(messenger.getClass(), messenger2.getClass());
    assertEquals("Hello World!", messenger.getMessage());
    assertEquals("Hello World!", messenger2.getMessage());
    messenger.setMessage("Bye World!");
    messenger2.setMessage("Byebye World!");
    assertEquals("Bye World!", messenger.getMessage());
    assertEquals("Byebye World!", messenger2.getMessage());
  }
View Full Code Here

TOP

Related Classes of org.springframework.scripting.ConfigurableMessenger

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.