org.springframework.scripting.Calculator Java Examples
The following examples show how to use
org.springframework.scripting.Calculator.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JRubyScriptFactoryTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void testStaticScriptUsingJsr223() throws Exception { ApplicationContext ctx = new ClassPathXmlApplicationContext("jrubyContextWithJsr223.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())); assertEquals(3, calc.add(1, 2)); String desiredMessage = "Hello World!"; assertEquals("Message is incorrect", desiredMessage, messenger.getMessage()); }
Example #2
Source File: JRubyScriptFactoryTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@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())); assertEquals(3, calc.add(1, 2)); String desiredMessage = "Hello World!"; assertEquals("Message is incorrect", desiredMessage, messenger.getMessage()); }
Example #3
Source File: BshScriptFactoryTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void inlineScriptFromTag() { ApplicationContext ctx = new ClassPathXmlApplicationContext("bsh-with-xsd.xml", getClass()); Calculator calculator = (Calculator) ctx.getBean("calculator"); assertNotNull(calculator); assertFalse(calculator instanceof Refreshable); }
Example #4
Source File: BshScriptFactoryTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void inlineScriptFromTag() throws Exception { ApplicationContext ctx = new ClassPathXmlApplicationContext("bsh-with-xsd.xml", getClass()); Calculator calculator = (Calculator) ctx.getBean("calculator"); assertNotNull(calculator); assertFalse(calculator instanceof Refreshable); }
Example #5
Source File: BshScriptFactoryTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void staticScript() throws Exception { 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)); assertTrue(ctx.getBeansOfType(Messenger.class).values().contains(messenger)); }
Example #6
Source File: GroovyScriptFactoryTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
private void testMetaClass(final String xmlFile) { // expect the exception we threw in the custom metaclass to show it got invoked try { ApplicationContext ctx = new ClassPathXmlApplicationContext(xmlFile); Calculator calc = (Calculator) ctx.getBean("delegatingCalculator"); calc.add(1, 2); fail("expected IllegalStateException"); } catch (IllegalStateException ex) { assertEquals("Gotcha", ex.getMessage()); } }
Example #7
Source File: GroovyScriptFactoryTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testInlineScriptFromTag() throws Exception { ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("groovy-with-xsd.xml", getClass()); BeanDefinition bd = ctx.getBeanFactory().getBeanDefinition("calculator"); assertTrue(ObjectUtils.containsElement(bd.getDependsOn(), "messenger")); Calculator calculator = (Calculator) ctx.getBean("calculator"); assertNotNull(calculator); assertFalse(calculator instanceof Refreshable); }
Example #8
Source File: GroovyScriptFactoryTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testStaticScriptUsingJsr223() throws Exception { ApplicationContext ctx = new ClassPathXmlApplicationContext("groovyContextWithJsr223.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)); assertTrue(ctx.getBeansOfType(Messenger.class).values().contains(messenger)); }
Example #9
Source File: GroovyScriptFactoryTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testStaticScript() throws Exception { 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)); assertTrue(ctx.getBeansOfType(Messenger.class).values().contains(messenger)); }
Example #10
Source File: JRubyScriptFactoryTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test 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)); }
Example #11
Source File: JRubyScriptFactoryTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testInlineScriptFromTagUsingJsr223() throws Exception { ApplicationContext ctx = new ClassPathXmlApplicationContext("jruby-with-xsd-jsr223.xml", getClass()); Calculator calculator = (Calculator) ctx.getBean("calculator"); assertNotNull(calculator); assertFalse(calculator instanceof Refreshable); assertEquals(3, calculator.add(1, 2)); }
Example #12
Source File: JRubyScriptFactoryTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@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); assertEquals(3, calculator.add(1, 2)); }
Example #13
Source File: GroovyScriptFactoryTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testStaticScript() throws Exception { 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)); assertTrue(ctx.getBeansOfType(Messenger.class).values().contains(messenger)); }
Example #14
Source File: BshScriptFactoryTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void staticScript() { 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)); assertTrue(ctx.getBeansOfType(Messenger.class).values().contains(messenger)); }
Example #15
Source File: GroovyScriptFactoryTests.java From java-technology-stack with MIT License | 5 votes |
private void testMetaClass(String xmlFile) { // expect the exception we threw in the custom metaclass to show it got invoked try { ApplicationContext ctx = new ClassPathXmlApplicationContext(xmlFile); Calculator calc = (Calculator) ctx.getBean("delegatingCalculator"); calc.add(1, 2); fail("expected IllegalStateException"); } catch (IllegalStateException ex) { assertEquals("Gotcha", ex.getMessage()); } }
Example #16
Source File: GroovyScriptFactoryTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testInlineScriptFromTag() throws Exception { ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("groovy-with-xsd.xml", getClass()); BeanDefinition bd = ctx.getBeanFactory().getBeanDefinition("calculator"); assertTrue(ObjectUtils.containsElement(bd.getDependsOn(), "messenger")); Calculator calculator = (Calculator) ctx.getBean("calculator"); assertNotNull(calculator); assertFalse(calculator instanceof Refreshable); }
Example #17
Source File: GroovyScriptFactoryTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testStaticScriptUsingJsr223() throws Exception { ApplicationContext ctx = new ClassPathXmlApplicationContext("groovyContextWithJsr223.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)); assertTrue(ctx.getBeansOfType(Messenger.class).values().contains(messenger)); }
Example #18
Source File: GroovyScriptFactoryTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testStaticScript() throws Exception { 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)); assertTrue(ctx.getBeansOfType(Messenger.class).values().contains(messenger)); }
Example #19
Source File: BshScriptFactoryTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void inlineScriptFromTag() { ApplicationContext ctx = new ClassPathXmlApplicationContext("bsh-with-xsd.xml", getClass()); Calculator calculator = (Calculator) ctx.getBean("calculator"); assertNotNull(calculator); assertFalse(calculator instanceof Refreshable); }
Example #20
Source File: BshScriptFactoryTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void staticScript() { 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)); assertTrue(ctx.getBeansOfType(Messenger.class).values().contains(messenger)); }
Example #21
Source File: GroovyScriptFactoryTests.java From spring-analysis-note with MIT License | 5 votes |
private void testMetaClass(String xmlFile) { // expect the exception we threw in the custom metaclass to show it got invoked try { ApplicationContext ctx = new ClassPathXmlApplicationContext(xmlFile); Calculator calc = (Calculator) ctx.getBean("delegatingCalculator"); calc.add(1, 2); fail("expected IllegalStateException"); } catch (IllegalStateException ex) { assertEquals("Gotcha", ex.getMessage()); } }
Example #22
Source File: GroovyScriptFactoryTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testInlineScriptFromTag() throws Exception { ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("groovy-with-xsd.xml", getClass()); BeanDefinition bd = ctx.getBeanFactory().getBeanDefinition("calculator"); assertTrue(ObjectUtils.containsElement(bd.getDependsOn(), "messenger")); Calculator calculator = (Calculator) ctx.getBean("calculator"); assertNotNull(calculator); assertFalse(calculator instanceof Refreshable); }
Example #23
Source File: GroovyScriptFactoryTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testStaticScriptUsingJsr223() throws Exception { ApplicationContext ctx = new ClassPathXmlApplicationContext("groovyContextWithJsr223.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)); assertTrue(ctx.getBeansOfType(Messenger.class).values().contains(messenger)); }