Package org.springframework.scripting

Examples of org.springframework.scripting.Calculator


    ApplicationContext ctx = new ClassPathXmlApplicationContext("groovyContext.xml", getClass());

    assertTrue(Arrays.asList(ctx.getBeanNamesForType(Calculator.class)).contains("calculator"));
    assertTrue(Arrays.asList(ctx.getBeanNamesForType(Messenger.class)).contains("messenger"));

    Calculator calc = (Calculator) ctx.getBean("calculator");
    Messenger messenger = (Messenger) ctx.getBean("messenger");

    assertFalse("Shouldn't get proxy when refresh is disabled", AopUtils.isAopProxy(calc));
    assertFalse("Shouldn't get proxy when refresh is disabled", AopUtils.isAopProxy(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));
    assertTrue(messenger.hashCode() != calc.hashCode());
    assertTrue(!messenger.toString().equals(calc.toString()));

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

    assertTrue(ctx.getBeansOfType(Calculator.class).values().contains(calc));
View Full Code Here


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

  public void testInlineScriptFromTag() throws Exception {
    ApplicationContext ctx = new ClassPathXmlApplicationContext("groovy-with-xsd.xml", getClass());
    Calculator calculator = (Calculator) ctx.getBean("calculator");
    assertNotNull(calculator);
    assertFalse(calculator instanceof Refreshable);
  }
View Full Code Here

    // expect the exception we threw in the custom metaclass to show it got invoked
    AssertThrows at = new AssertThrows(IllegalStateException.class) {
      public void test() throws Exception {
        ApplicationContext ctx =
            new ClassPathXmlApplicationContext(xmlFile);
        Calculator calc = (Calculator) ctx.getBean("delegatingCalculator");
        calc.add(1, 2);
      }
    };
    at.runTest();
    assertEquals("Gotcha", at.getActualException().getMessage());
  }
View Full Code Here

    ApplicationContext ctx = new ClassPathXmlApplicationContext("bshContext.xml", getClass());

    assertTrue(Arrays.asList(ctx.getBeanNamesForType(Calculator.class)).contains("calculator"));
    assertTrue(Arrays.asList(ctx.getBeanNamesForType(Messenger.class)).contains("messenger"));

    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));
    assertTrue(messenger.hashCode() != calc.hashCode());
    assertTrue(!messenger.toString().equals(calc.toString()));

    assertEquals(5, calc.add(2, 3));

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

    assertTrue(ctx.getBeansOfType(Calculator.class).values().contains(calc));
View Full Code Here

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

  public void testInlineScriptFromTag() throws Exception {
    ApplicationContext ctx = new ClassPathXmlApplicationContext("bsh-with-xsd.xml", getClass());
    Calculator calculator = (Calculator) ctx.getBean("calculator");
    assertNotNull(calculator);
    assertFalse(calculator instanceof Refreshable);
  }
View Full Code Here

          "RubyBar.new";


  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));
    assertTrue(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

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

  public void testInlineScriptFromTag() throws Exception {
    ApplicationContext ctx = new ClassPathXmlApplicationContext("jruby-with-xsd.xml", getClass());
    Calculator calculator = (Calculator) ctx.getBean("calculator");
    assertNotNull(calculator);
    assertFalse(calculator instanceof Refreshable);
  }
View Full Code Here

    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


  @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 testInlineScriptFromTag() throws Exception {
    ApplicationContext ctx = new ClassPathXmlApplicationContext("jruby-with-xsd.xml", getClass());
    Calculator calculator = (Calculator) ctx.getBean("calculator");
    assertNotNull(calculator);
    assertFalse(calculator instanceof Refreshable);
  }
View Full Code Here

TOP

Related Classes of org.springframework.scripting.Calculator

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.