Here are the examples of the java api org.springframework.scripting.Messenger taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
84 Examples
19
Source : StandardScriptFactoryTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void testRefreshableJsr223FromTagWithInterface() throws Exception {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("jsr223-with-xsd.xml", getClreplaced());
replacedertTrue(Arrays.asList(ctx.getBeanNamesForType(Messenger.clreplaced)).contains("refreshableMessengerWithInterface"));
Messenger messenger = (Messenger) ctx.getBean("refreshableMessengerWithInterface");
replacedertTrue(AopUtils.isAopProxy(messenger));
replacedertTrue(messenger instanceof Refreshable);
replacedertEquals("Hello World!", messenger.getMessage());
}
19
Source : StandardScriptFactoryTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void testJsr223FromTagWithInterface() throws Exception {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("jsr223-with-xsd.xml", getClreplaced());
replacedertTrue(Arrays.asList(ctx.getBeanNamesForType(Messenger.clreplaced)).contains("messengerWithInterface"));
Messenger messenger = (Messenger) ctx.getBean("messengerWithInterface");
replacedertFalse(AopUtils.isAopProxy(messenger));
replacedertEquals("Hello World!", messenger.getMessage());
}
19
Source : StandardScriptFactoryTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void testInlineJsr223FromTagWithInterface() throws Exception {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("jsr223-with-xsd.xml", getClreplaced());
replacedertTrue(Arrays.asList(ctx.getBeanNamesForType(Messenger.clreplaced)).contains("inlineMessengerWithInterface"));
Messenger messenger = (Messenger) ctx.getBean("inlineMessengerWithInterface");
replacedertFalse(AopUtils.isAopProxy(messenger));
replacedertEquals("Hello World!", messenger.getMessage());
}
19
Source : BshScriptFactoryTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void applicationEventListener() {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("bsh-with-xsd.xml", getClreplaced());
Messenger eventListener = (Messenger) ctx.getBean("eventListener");
ctx.publishEvent(new MyEvent(ctx));
replacedertEquals("count=2", eventListener.getMessage());
}
19
Source : BshScriptFactoryTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void refreshableFromTag() {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("bsh-with-xsd.xml", getClreplaced());
Messenger messenger = (Messenger) ctx.getBean("refreshableMessenger");
replacedertEquals("Hello World!", messenger.getMessage());
replacedertTrue("Messenger should be Refreshable", messenger instanceof Refreshable);
}
19
Source : JRubyScriptFactoryTests.java
with Apache License 2.0
from langtianya
with Apache License 2.0
from langtianya
@Test
public void testThatMultipleScriptInterfacesAreSupported() throws Exception {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("jruby-with-xsd.xml", getClreplaced());
Messenger messenger = (Messenger) ctx.getBean("calculatingMessenger");
replacedertEquals("Hello World!", messenger.getMessage());
// cool, now check that the Calculator interface is also exposed
Calculator calc = (Calculator) messenger;
replacedertEquals(0, calc.add(2, -2));
}
19
Source : JRubyScriptFactoryTests.java
with Apache License 2.0
from langtianya
with Apache License 2.0
from langtianya
@Test
public void testRefreshableFromTagUsingJsr223() throws Exception {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("jruby-with-xsd-jsr223.xml", getClreplaced());
Messenger messenger = (Messenger) ctx.getBean("refreshableMessenger");
replacedertEquals("Hello World!", messenger.getMessage());
replacedertTrue("Messenger should be Refreshable", messenger instanceof Refreshable);
}
19
Source : JRubyScriptFactoryTests.java
with Apache License 2.0
from langtianya
with Apache License 2.0
from langtianya
@Test
public void testAop() throws Exception {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("jruby-aop.xml", getClreplaced());
Messenger messenger = (Messenger) ctx.getBean("messenger");
replacedertEquals(new StringBuffer("Hello World!").reverse().toString(), messenger.getMessage());
}
19
Source : JRubyScriptFactoryTests.java
with Apache License 2.0
from langtianya
with Apache License 2.0
from langtianya
@Test
public void testResourceScriptFromTagUsingJsr223() throws Exception {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("jruby-with-xsd-jsr223.xml", getClreplaced());
Messenger messenger = (Messenger) ctx.getBean("messenger");
replacedertEquals("Hello World!", messenger.getMessage());
replacedertFalse(messenger instanceof Refreshable);
}
19
Source : JRubyScriptFactoryTests.java
with Apache License 2.0
from langtianya
with Apache License 2.0
from langtianya
@Test
public void testRefreshableFromTag() throws Exception {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("jruby-with-xsd.xml", getClreplaced());
Messenger messenger = (Messenger) ctx.getBean("refreshableMessenger");
replacedertEquals("Hello World!", messenger.getMessage());
replacedertTrue("Messenger should be Refreshable", messenger instanceof Refreshable);
}
19
Source : BshScriptFactoryTests.java
with Apache License 2.0
from langtianya
with Apache License 2.0
from langtianya
@Test
public void refreshableFromTag() throws Exception {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("bsh-with-xsd.xml", getClreplaced());
Messenger messenger = (Messenger) ctx.getBean("refreshableMessenger");
replacedertEquals("Hello World!", messenger.getMessage());
replacedertTrue("Messenger should be Refreshable", messenger instanceof Refreshable);
}
19
Source : BshScriptFactoryTests.java
with Apache License 2.0
from langtianya
with Apache License 2.0
from langtianya
@Test
public void applicationEventListener() throws Exception {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("bsh-with-xsd.xml", getClreplaced());
Messenger eventListener = (Messenger) ctx.getBean("eventListener");
ctx.publishEvent(new MyEvent(ctx));
replacedertEquals("count=2", eventListener.getMessage());
}
18
Source : GroovyScriptFactoryTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void testRefreshableJsr223FromTag() throws Exception {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("groovy-with-xsd-jsr223.xml", getClreplaced());
replacedertTrue(Arrays.asList(ctx.getBeanNamesForType(Messenger.clreplaced)).contains("refreshableMessenger"));
Messenger messenger = (Messenger) ctx.getBean("refreshableMessenger");
replacedertTrue(AopUtils.isAopProxy(messenger));
replacedertTrue(messenger instanceof Refreshable);
replacedertEquals("Hello World!", messenger.getMessage());
}
18
Source : GroovyScriptFactoryTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void testWithTwoClreplacedesDefinedInTheOneGroovyFile_CorrectClreplacedFirst() throws Exception {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("twoClreplacedesCorrectOneFirst.xml", getClreplaced());
Messenger messenger = (Messenger) ctx.getBean("messenger");
replacedertNotNull(messenger);
replacedertEquals("Hello World!", messenger.getMessage());
// Check can cast to GroovyObject
GroovyObject goo = (GroovyObject) messenger;
replacedertNotNull(goo);
}
18
Source : GroovyScriptFactoryTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void testStaticScriptUsingJsr223() throws Exception {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("groovyContextWithJsr223.xml", getClreplaced());
replacedertTrue(Arrays.asList(ctx.getBeanNamesForType(Calculator.clreplaced)).contains("calculator"));
replacedertTrue(Arrays.asList(ctx.getBeanNamesForType(Messenger.clreplaced)).contains("messenger"));
Calculator calc = (Calculator) ctx.getBean("calculator");
Messenger messenger = (Messenger) ctx.getBean("messenger");
replacedertFalse("Shouldn't get proxy when refresh is disabled", AopUtils.isAopProxy(calc));
replacedertFalse("Shouldn't get proxy when refresh is disabled", AopUtils.isAopProxy(messenger));
replacedertFalse("Scripted object should not be instance of Refreshable", calc instanceof Refreshable);
replacedertFalse("Scripted object should not be instance of Refreshable", messenger instanceof Refreshable);
replacedertEquals(calc, calc);
replacedertEquals(messenger, messenger);
replacedertTrue(!messenger.equals(calc));
replacedertTrue(messenger.hashCode() != calc.hashCode());
replacedertTrue(!messenger.toString().equals(calc.toString()));
String desiredMessage = "Hello World!";
replacedertEquals("Message is incorrect", desiredMessage, messenger.getMessage());
replacedertTrue(ctx.getBeansOfType(Calculator.clreplaced).values().contains(calc));
replacedertTrue(ctx.getBeansOfType(Messenger.clreplaced).values().contains(messenger));
}
18
Source : GroovyScriptFactoryTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void testInlineJsr223FromTagWithInterface() throws Exception {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("groovy-with-xsd-jsr223.xml", getClreplaced());
replacedertTrue(Arrays.asList(ctx.getBeanNamesForType(Messenger.clreplaced)).contains("inlineMessengerWithInterface"));
Messenger messenger = (Messenger) ctx.getBean("inlineMessengerWithInterface");
replacedertFalse(AopUtils.isAopProxy(messenger));
}
18
Source : GroovyScriptFactoryTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void testInlineJsr223FromTag() throws Exception {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("groovy-with-xsd-jsr223.xml", getClreplaced());
replacedertTrue(Arrays.asList(ctx.getBeanNamesForType(Messenger.clreplaced)).contains("inlineMessenger"));
Messenger messenger = (Messenger) ctx.getBean("inlineMessenger");
replacedertFalse(AopUtils.isAopProxy(messenger));
}
18
Source : GroovyScriptFactoryTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void testJsr223FromTagWithInterface() throws Exception {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("groovy-with-xsd-jsr223.xml", getClreplaced());
replacedertTrue(Arrays.asList(ctx.getBeanNamesForType(Messenger.clreplaced)).contains("messengerWithInterface"));
Messenger messenger = (Messenger) ctx.getBean("messengerWithInterface");
replacedertFalse(AopUtils.isAopProxy(messenger));
}
18
Source : GroovyScriptFactoryTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void testStaticScriptWithInstance() throws Exception {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("groovyContext.xml", getClreplaced());
replacedertTrue(Arrays.asList(ctx.getBeanNamesForType(Messenger.clreplaced)).contains("messengerInstance"));
Messenger messenger = (Messenger) ctx.getBean("messengerInstance");
replacedertFalse("Shouldn't get proxy when refresh is disabled", AopUtils.isAopProxy(messenger));
replacedertFalse("Scripted object should not be instance of Refreshable", messenger instanceof Refreshable);
String desiredMessage = "Hello World!";
replacedertEquals("Message is incorrect", desiredMessage, messenger.getMessage());
replacedertTrue(ctx.getBeansOfType(Messenger.clreplaced).values().contains(messenger));
}
18
Source : GroovyScriptFactoryTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void testStaticScriptWithInstanceUsingJsr223() throws Exception {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("groovyContextWithJsr223.xml", getClreplaced());
replacedertTrue(Arrays.asList(ctx.getBeanNamesForType(Messenger.clreplaced)).contains("messengerInstance"));
Messenger messenger = (Messenger) ctx.getBean("messengerInstance");
replacedertFalse("Shouldn't get proxy when refresh is disabled", AopUtils.isAopProxy(messenger));
replacedertFalse("Scripted object should not be instance of Refreshable", messenger instanceof Refreshable);
String desiredMessage = "Hello World!";
replacedertEquals("Message is incorrect", desiredMessage, messenger.getMessage());
replacedertTrue(ctx.getBeansOfType(Messenger.clreplaced).values().contains(messenger));
}
18
Source : GroovyScriptFactoryTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void testStaticScript() throws Exception {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("groovyContext.xml", getClreplaced());
replacedertTrue(Arrays.asList(ctx.getBeanNamesForType(Calculator.clreplaced)).contains("calculator"));
replacedertTrue(Arrays.asList(ctx.getBeanNamesForType(Messenger.clreplaced)).contains("messenger"));
Calculator calc = (Calculator) ctx.getBean("calculator");
Messenger messenger = (Messenger) ctx.getBean("messenger");
replacedertFalse("Shouldn't get proxy when refresh is disabled", AopUtils.isAopProxy(calc));
replacedertFalse("Shouldn't get proxy when refresh is disabled", AopUtils.isAopProxy(messenger));
replacedertFalse("Scripted object should not be instance of Refreshable", calc instanceof Refreshable);
replacedertFalse("Scripted object should not be instance of Refreshable", messenger instanceof Refreshable);
replacedertEquals(calc, calc);
replacedertEquals(messenger, messenger);
replacedertTrue(!messenger.equals(calc));
replacedertTrue(messenger.hashCode() != calc.hashCode());
replacedertTrue(!messenger.toString().equals(calc.toString()));
String desiredMessage = "Hello World!";
replacedertEquals("Message is incorrect", desiredMessage, messenger.getMessage());
replacedertTrue(ctx.getBeansOfType(Calculator.clreplaced).values().contains(calc));
replacedertTrue(ctx.getBeansOfType(Messenger.clreplaced).values().contains(messenger));
}
18
Source : GroovyScriptFactoryTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void testStaticScriptWithInlineDefinedInstance() throws Exception {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("groovyContext.xml", getClreplaced());
replacedertTrue(Arrays.asList(ctx.getBeanNamesForType(Messenger.clreplaced)).contains("messengerInstanceInline"));
Messenger messenger = (Messenger) ctx.getBean("messengerInstanceInline");
replacedertFalse("Shouldn't get proxy when refresh is disabled", AopUtils.isAopProxy(messenger));
replacedertFalse("Scripted object should not be instance of Refreshable", messenger instanceof Refreshable);
String desiredMessage = "Hello World!";
replacedertEquals("Message is incorrect", desiredMessage, messenger.getMessage());
replacedertTrue(ctx.getBeansOfType(Messenger.clreplaced).values().contains(messenger));
}
18
Source : GroovyScriptFactoryTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void testStaticScriptWithInlineDefinedInstanceUsingJsr223() throws Exception {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("groovyContextWithJsr223.xml", getClreplaced());
replacedertTrue(Arrays.asList(ctx.getBeanNamesForType(Messenger.clreplaced)).contains("messengerInstanceInline"));
Messenger messenger = (Messenger) ctx.getBean("messengerInstanceInline");
replacedertFalse("Shouldn't get proxy when refresh is disabled", AopUtils.isAopProxy(messenger));
replacedertFalse("Scripted object should not be instance of Refreshable", messenger instanceof Refreshable);
String desiredMessage = "Hello World!";
replacedertEquals("Message is incorrect", desiredMessage, messenger.getMessage());
replacedertTrue(ctx.getBeansOfType(Messenger.clreplaced).values().contains(messenger));
}
18
Source : GroovyScriptFactoryTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void testResourceScriptFromTag() throws Exception {
ClreplacedPathXmlApplicationContext ctx = new ClreplacedPathXmlApplicationContext("groovy-with-xsd.xml", getClreplaced());
Messenger messenger = (Messenger) ctx.getBean("messenger");
CallCounter countingAspect = (CallCounter) ctx.getBean("getMessageAspect");
replacedertTrue(AopUtils.isAopProxy(messenger));
replacedertFalse(messenger instanceof Refreshable);
replacedertEquals(0, countingAspect.getCalls());
replacedertEquals("Hello World!", messenger.getMessage());
replacedertEquals(1, countingAspect.getCalls());
ctx.close();
replacedertEquals(-200, countingAspect.getCalls());
}
18
Source : GroovyScriptFactoryTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void testJsr223FromTag() throws Exception {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("groovy-with-xsd-jsr223.xml", getClreplaced());
replacedertTrue(Arrays.asList(ctx.getBeanNamesForType(Messenger.clreplaced)).contains("messenger"));
Messenger messenger = (Messenger) ctx.getBean("messenger");
replacedertFalse(AopUtils.isAopProxy(messenger));
replacedertEquals("Hello World!", messenger.getMessage());
}
18
Source : BshScriptFactoryTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void staticWithScriptReturningInstance() {
ClreplacedPathXmlApplicationContext ctx = new ClreplacedPathXmlApplicationContext("bshContext.xml", getClreplaced());
replacedertTrue(Arrays.asList(ctx.getBeanNamesForType(Messenger.clreplaced)).contains("messengerInstance"));
Messenger messenger = (Messenger) ctx.getBean("messengerInstance");
String desiredMessage = "Hello World!";
replacedertEquals("Message is incorrect", desiredMessage, messenger.getMessage());
replacedertTrue(ctx.getBeansOfType(Messenger.clreplaced).values().contains(messenger));
ctx.close();
replacedertNull(messenger.getMessage());
}
18
Source : BshScriptFactoryTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void staticScript() {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("bshContext.xml", getClreplaced());
replacedertTrue(Arrays.asList(ctx.getBeanNamesForType(Calculator.clreplaced)).contains("calculator"));
replacedertTrue(Arrays.asList(ctx.getBeanNamesForType(Messenger.clreplaced)).contains("messenger"));
Calculator calc = (Calculator) ctx.getBean("calculator");
Messenger messenger = (Messenger) ctx.getBean("messenger");
replacedertFalse("Scripted object should not be instance of Refreshable", calc instanceof Refreshable);
replacedertFalse("Scripted object should not be instance of Refreshable", messenger instanceof Refreshable);
replacedertEquals(calc, calc);
replacedertEquals(messenger, messenger);
replacedertTrue(!messenger.equals(calc));
replacedertTrue(messenger.hashCode() != calc.hashCode());
replacedertTrue(!messenger.toString().equals(calc.toString()));
replacedertEquals(5, calc.add(2, 3));
String desiredMessage = "Hello World!";
replacedertEquals("Message is incorrect", desiredMessage, messenger.getMessage());
replacedertTrue(ctx.getBeansOfType(Calculator.clreplaced).values().contains(calc));
replacedertTrue(ctx.getBeansOfType(Messenger.clreplaced).values().contains(messenger));
}
18
Source : BshScriptFactoryTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void scriptThatCompilesButIsJustPlainBad() throws IOException {
ScriptSource script = mock(ScriptSource.clreplaced);
final String badScript = "String getMessage() { throw new IllegalArgumentException(); }";
given(script.getScriptreplacedtring()).willReturn(badScript);
given(script.isModified()).willReturn(true);
BshScriptFactory factory = new BshScriptFactory(ScriptFactoryPostProcessor.INLINE_SCRIPT_PREFIX + badScript, Messenger.clreplaced);
try {
Messenger messenger = (Messenger) factory.getScriptedObject(script, Messenger.clreplaced);
messenger.getMessage();
fail("Must have thrown a BshScriptUtils.BshExecutionException.");
} catch (BshScriptUtils.BshExecutionException expected) {
}
}
18
Source : BshScriptFactoryTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void staticScriptImplementingInterface() {
ClreplacedPathXmlApplicationContext ctx = new ClreplacedPathXmlApplicationContext("bshContext.xml", getClreplaced());
replacedertTrue(Arrays.asList(ctx.getBeanNamesForType(Messenger.clreplaced)).contains("messengerImpl"));
Messenger messenger = (Messenger) ctx.getBean("messengerImpl");
String desiredMessage = "Hello World!";
replacedertEquals("Message is incorrect", desiredMessage, messenger.getMessage());
replacedertTrue(ctx.getBeansOfType(Messenger.clreplaced).values().contains(messenger));
ctx.close();
replacedertNull(messenger.getMessage());
}
18
Source : StandardScriptFactoryTests.java
with Apache License 2.0
from SourceHot
with Apache License 2.0
from SourceHot
@Test
public void testInlineJsr223FromTagWithInterface() throws Exception {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("jsr223-with-xsd.xml", getClreplaced());
replacedertThat(Arrays.asList(ctx.getBeanNamesForType(Messenger.clreplaced)).contains("inlineMessengerWithInterface")).isTrue();
Messenger messenger = (Messenger) ctx.getBean("inlineMessengerWithInterface");
replacedertThat(AopUtils.isAopProxy(messenger)).isFalse();
replacedertThat(messenger.getMessage()).isEqualTo("Hello World!");
}
18
Source : StandardScriptFactoryTests.java
with Apache License 2.0
from SourceHot
with Apache License 2.0
from SourceHot
@Test
public void testJsr223FromTagWithInterface() throws Exception {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("jsr223-with-xsd.xml", getClreplaced());
replacedertThat(Arrays.asList(ctx.getBeanNamesForType(Messenger.clreplaced)).contains("messengerWithInterface")).isTrue();
Messenger messenger = (Messenger) ctx.getBean("messengerWithInterface");
replacedertThat(AopUtils.isAopProxy(messenger)).isFalse();
replacedertThat(messenger.getMessage()).isEqualTo("Hello World!");
}
18
Source : StandardScriptFactoryTests.java
with Apache License 2.0
from SourceHot
with Apache License 2.0
from SourceHot
@Test
public void testRefreshableJsr223FromTagWithInterface() throws Exception {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("jsr223-with-xsd.xml", getClreplaced());
replacedertThat(Arrays.asList(ctx.getBeanNamesForType(Messenger.clreplaced)).contains("refreshableMessengerWithInterface")).isTrue();
Messenger messenger = (Messenger) ctx.getBean("refreshableMessengerWithInterface");
replacedertThat(AopUtils.isAopProxy(messenger)).isTrue();
boolean condition = messenger instanceof Refreshable;
replacedertThat(condition).isTrue();
replacedertThat(messenger.getMessage()).isEqualTo("Hello World!");
}
18
Source : BshScriptFactoryTests.java
with Apache License 2.0
from SourceHot
with Apache License 2.0
from SourceHot
@Test
public void refreshableFromTag() {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("bsh-with-xsd.xml", getClreplaced());
Messenger messenger = (Messenger) ctx.getBean("refreshableMessenger");
replacedertThat(messenger.getMessage()).isEqualTo("Hello World!");
boolean condition = messenger instanceof Refreshable;
replacedertThat(condition).as("Messenger should be Refreshable").isTrue();
}
18
Source : BshScriptFactoryTests.java
with Apache License 2.0
from SourceHot
with Apache License 2.0
from SourceHot
@Test
public void applicationEventListener() {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("bsh-with-xsd.xml", getClreplaced());
Messenger eventListener = (Messenger) ctx.getBean("eventListener");
ctx.publishEvent(new MyEvent(ctx));
replacedertThat(eventListener.getMessage()).isEqualTo("count=2");
}
18
Source : JRubyScriptFactoryTests.java
with Apache License 2.0
from langtianya
with Apache License 2.0
from langtianya
@Test
public void testResourceScriptFromTag() throws Exception {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("jruby-with-xsd.xml", getClreplaced());
TestBean testBean = (TestBean) ctx.getBean("testBean");
Messenger messenger = (Messenger) ctx.getBean("messenger");
replacedertEquals("Hello World!", messenger.getMessage());
replacedertFalse(messenger instanceof Refreshable);
TestBeanAwareMessenger messengerByType = (TestBeanAwareMessenger) ctx.getBean("messengerByType");
replacedertEquals(testBean, messengerByType.getTestBean());
TestBeanAwareMessenger messengerByName = (TestBeanAwareMessenger) ctx.getBean("messengerByName");
replacedertEquals(testBean, messengerByName.getTestBean());
}
18
Source : JRubyScriptFactoryTests.java
with Apache License 2.0
from langtianya
with Apache License 2.0
from langtianya
@Test
public void testStaticScriptUsingJsr223() throws Exception {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("jrubyContextWithJsr223.xml", getClreplaced());
Calculator calc = (Calculator) ctx.getBean("calculator");
Messenger messenger = (Messenger) ctx.getBean("messenger");
replacedertFalse("Scripted object should not be instance of Refreshable", calc instanceof Refreshable);
replacedertFalse("Scripted object should not be instance of Refreshable", messenger instanceof Refreshable);
replacedertEquals(calc, calc);
replacedertEquals(messenger, messenger);
replacedertTrue(!messenger.equals(calc));
replacedertNotSame(messenger.hashCode(), calc.hashCode());
replacedertTrue(!messenger.toString().equals(calc.toString()));
replacedertEquals(3, calc.add(1, 2));
String desiredMessage = "Hello World!";
replacedertEquals("Message is incorrect", desiredMessage, messenger.getMessage());
}
18
Source : JRubyScriptFactoryTests.java
with Apache License 2.0
from langtianya
with Apache License 2.0
from langtianya
@Test
public void testStaticScript() throws Exception {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("jrubyContext.xml", getClreplaced());
Calculator calc = (Calculator) ctx.getBean("calculator");
Messenger messenger = (Messenger) ctx.getBean("messenger");
replacedertFalse("Scripted object should not be instance of Refreshable", calc instanceof Refreshable);
replacedertFalse("Scripted object should not be instance of Refreshable", messenger instanceof Refreshable);
replacedertEquals(calc, calc);
replacedertEquals(messenger, messenger);
replacedertTrue(!messenger.equals(calc));
replacedertNotSame(messenger.hashCode(), calc.hashCode());
replacedertTrue(!messenger.toString().equals(calc.toString()));
replacedertEquals(3, calc.add(1, 2));
String desiredMessage = "Hello World!";
replacedertEquals("Message is incorrect", desiredMessage, messenger.getMessage());
}
18
Source : AdvisedJRubyScriptFactoryTests.java
with Apache License 2.0
from langtianya
with Apache License 2.0
from langtianya
@Test
public void testAdviseWithProxyFactoryBean() {
ClreplacedPathXmlApplicationContext ctx = new ClreplacedPathXmlApplicationContext(FACTORYBEAN_CONTEXT, CLreplaced);
try {
Messenger bean = (Messenger) ctx.getBean("messenger");
replacedertTrue("Bean is not a proxy", AopUtils.isAopProxy(bean));
replacedertTrue("Bean is not an Advised object", bean instanceof Advised);
CountingBeforeAdvice advice = (CountingBeforeAdvice) ctx.getBean("advice");
replacedertEquals(0, advice.getCalls());
bean.getMessage();
replacedertEquals(1, advice.getCalls());
} finally {
ctx.close();
}
}
18
Source : AdvisedJRubyScriptFactoryTests.java
with Apache License 2.0
from langtianya
with Apache License 2.0
from langtianya
@Test
public void testAdviseWithBeanNameAutoProxyCreator() {
ClreplacedPathXmlApplicationContext ctx = new ClreplacedPathXmlApplicationContext(APC_CONTEXT, CLreplaced);
try {
Messenger bean = (Messenger) ctx.getBean("messenger");
replacedertTrue("Bean is not a proxy", AopUtils.isAopProxy(bean));
replacedertTrue("Bean is not an Advised object", bean instanceof Advised);
CountingBeforeAdvice advice = (CountingBeforeAdvice) ctx.getBean("advice");
replacedertEquals(0, advice.getCalls());
bean.getMessage();
replacedertEquals(1, advice.getCalls());
} finally {
ctx.close();
}
}
18
Source : BshScriptFactoryTests.java
with Apache License 2.0
from langtianya
with Apache License 2.0
from langtianya
@Test
public void staticScript() throws Exception {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("bshContext.xml", getClreplaced());
replacedertTrue(Arrays.asList(ctx.getBeanNamesForType(Calculator.clreplaced)).contains("calculator"));
replacedertTrue(Arrays.asList(ctx.getBeanNamesForType(Messenger.clreplaced)).contains("messenger"));
Calculator calc = (Calculator) ctx.getBean("calculator");
Messenger messenger = (Messenger) ctx.getBean("messenger");
replacedertFalse("Scripted object should not be instance of Refreshable", calc instanceof Refreshable);
replacedertFalse("Scripted object should not be instance of Refreshable", messenger instanceof Refreshable);
replacedertEquals(calc, calc);
replacedertEquals(messenger, messenger);
replacedertTrue(!messenger.equals(calc));
replacedertTrue(messenger.hashCode() != calc.hashCode());
replacedertTrue(!messenger.toString().equals(calc.toString()));
replacedertEquals(5, calc.add(2, 3));
String desiredMessage = "Hello World!";
replacedertEquals("Message is incorrect", desiredMessage, messenger.getMessage());
replacedertTrue(ctx.getBeansOfType(Calculator.clreplaced).values().contains(calc));
replacedertTrue(ctx.getBeansOfType(Messenger.clreplaced).values().contains(messenger));
}
18
Source : BshScriptFactoryTests.java
with Apache License 2.0
from langtianya
with Apache License 2.0
from langtianya
@Test
public void staticWithScriptReturningInstance() throws Exception {
ClreplacedPathXmlApplicationContext ctx = new ClreplacedPathXmlApplicationContext("bshContext.xml", getClreplaced());
replacedertTrue(Arrays.asList(ctx.getBeanNamesForType(Messenger.clreplaced)).contains("messengerInstance"));
Messenger messenger = (Messenger) ctx.getBean("messengerInstance");
String desiredMessage = "Hello World!";
replacedertEquals("Message is incorrect", desiredMessage, messenger.getMessage());
replacedertTrue(ctx.getBeansOfType(Messenger.clreplaced).values().contains(messenger));
ctx.close();
replacedertNull(messenger.getMessage());
}
18
Source : BshScriptFactoryTests.java
with Apache License 2.0
from langtianya
with Apache License 2.0
from langtianya
@Test
public void staticScriptImplementingInterface() throws Exception {
ClreplacedPathXmlApplicationContext ctx = new ClreplacedPathXmlApplicationContext("bshContext.xml", getClreplaced());
replacedertTrue(Arrays.asList(ctx.getBeanNamesForType(Messenger.clreplaced)).contains("messengerImpl"));
Messenger messenger = (Messenger) ctx.getBean("messengerImpl");
String desiredMessage = "Hello World!";
replacedertEquals("Message is incorrect", desiredMessage, messenger.getMessage());
replacedertTrue(ctx.getBeansOfType(Messenger.clreplaced).values().contains(messenger));
ctx.close();
replacedertNull(messenger.getMessage());
}
18
Source : BshScriptFactoryTests.java
with Apache License 2.0
from langtianya
with Apache License 2.0
from langtianya
@Test
public void scriptThatCompilesButIsJustPlainBad() throws Exception {
ScriptSource script = mock(ScriptSource.clreplaced);
final String badScript = "String getMessage() { throw new IllegalArgumentException(); }";
given(script.getScriptreplacedtring()).willReturn(badScript);
given(script.isModified()).willReturn(true);
BshScriptFactory factory = new BshScriptFactory(ScriptFactoryPostProcessor.INLINE_SCRIPT_PREFIX + badScript, Messenger.clreplaced);
try {
Messenger messenger = (Messenger) factory.getScriptedObject(script, Messenger.clreplaced);
messenger.getMessage();
fail("Must have thrown a BshScriptUtils.BshExecutionException.");
} catch (BshScriptUtils.BshExecutionException expected) {
}
}
17
Source : GroovyScriptFactoryTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void testRefreshableFromTag() throws Exception {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("groovy-with-xsd.xml", getClreplaced());
replacedertTrue(Arrays.asList(ctx.getBeanNamesForType(Messenger.clreplaced)).contains("refreshableMessenger"));
Messenger messenger = (Messenger) ctx.getBean("refreshableMessenger");
CallCounter countingAspect = (CallCounter) ctx.getBean("getMessageAspect");
replacedertTrue(AopUtils.isAopProxy(messenger));
replacedertTrue(messenger instanceof Refreshable);
replacedertEquals(0, countingAspect.getCalls());
replacedertEquals("Hello World!", messenger.getMessage());
replacedertEquals(1, countingAspect.getCalls());
replacedertTrue(ctx.getBeansOfType(Messenger.clreplaced).values().contains(messenger));
}
17
Source : GroovyScriptFactoryTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void testNonStaticScript() throws Exception {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("groovyRefreshableContext.xml", getClreplaced());
Messenger messenger = (Messenger) ctx.getBean("messenger");
replacedertTrue("Should be a proxy for refreshable scripts", AopUtils.isAopProxy(messenger));
replacedertTrue("Should be an instance of Refreshable", messenger instanceof Refreshable);
String desiredMessage = "Hello World!";
replacedertEquals("Message is incorrect", desiredMessage, messenger.getMessage());
Refreshable refreshable = (Refreshable) messenger;
refreshable.refresh();
replacedertEquals("Message is incorrect after refresh.", desiredMessage, messenger.getMessage());
replacedertEquals("Incorrect refresh count", 2, refreshable.getRefreshCount());
}
17
Source : BshScriptFactoryTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void nonStaticScript() {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("bshRefreshableContext.xml", getClreplaced());
Messenger messenger = (Messenger) ctx.getBean("messenger");
replacedertTrue("Should be a proxy for refreshable scripts", AopUtils.isAopProxy(messenger));
replacedertTrue("Should be an instance of Refreshable", messenger instanceof Refreshable);
String desiredMessage = "Hello World!";
replacedertEquals("Message is incorrect", desiredMessage, messenger.getMessage());
Refreshable refreshable = (Refreshable) messenger;
refreshable.refresh();
replacedertEquals("Message is incorrect after refresh", desiredMessage, messenger.getMessage());
replacedertEquals("Incorrect refresh count", 2, refreshable.getRefreshCount());
}
17
Source : BshScriptFactoryTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void resourceScriptFromTag() {
ClreplacedPathXmlApplicationContext ctx = new ClreplacedPathXmlApplicationContext("bsh-with-xsd.xml", getClreplaced());
TestBean testBean = (TestBean) ctx.getBean("testBean");
Collection<String> beanNames = Arrays.asList(ctx.getBeanNamesForType(Messenger.clreplaced));
replacedertTrue(beanNames.contains("messenger"));
replacedertTrue(beanNames.contains("messengerImpl"));
replacedertTrue(beanNames.contains("messengerInstance"));
Messenger messenger = (Messenger) ctx.getBean("messenger");
replacedertEquals("Hello World!", messenger.getMessage());
replacedertFalse(messenger instanceof Refreshable);
Messenger messengerImpl = (Messenger) ctx.getBean("messengerImpl");
replacedertEquals("Hello World!", messengerImpl.getMessage());
Messenger messengerInstance = (Messenger) ctx.getBean("messengerInstance");
replacedertEquals("Hello World!", messengerInstance.getMessage());
TestBeanAwareMessenger messengerByType = (TestBeanAwareMessenger) ctx.getBean("messengerByType");
replacedertEquals(testBean, messengerByType.getTestBean());
TestBeanAwareMessenger messengerByName = (TestBeanAwareMessenger) ctx.getBean("messengerByName");
replacedertEquals(testBean, messengerByName.getTestBean());
Collection<Messenger> beans = ctx.getBeansOfType(Messenger.clreplaced).values();
replacedertTrue(beans.contains(messenger));
replacedertTrue(beans.contains(messengerImpl));
replacedertTrue(beans.contains(messengerInstance));
replacedertTrue(beans.contains(messengerByType));
replacedertTrue(beans.contains(messengerByName));
ctx.close();
replacedertNull(messenger.getMessage());
replacedertNull(messengerImpl.getMessage());
replacedertNull(messengerInstance.getMessage());
}
17
Source : GroovyScriptFactoryTests.java
with Apache License 2.0
from SourceHot
with Apache License 2.0
from SourceHot
@Test
public void testRefreshableJsr223FromTag() throws Exception {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("groovy-with-xsd-jsr223.xml", getClreplaced());
replacedertThat(Arrays.asList(ctx.getBeanNamesForType(Messenger.clreplaced)).contains("refreshableMessenger")).isTrue();
Messenger messenger = (Messenger) ctx.getBean("refreshableMessenger");
replacedertThat(AopUtils.isAopProxy(messenger)).isTrue();
boolean condition = messenger instanceof Refreshable;
replacedertThat(condition).isTrue();
replacedertThat(messenger.getMessage()).isEqualTo("Hello World!");
}
17
Source : GroovyScriptFactoryTests.java
with Apache License 2.0
from SourceHot
with Apache License 2.0
from SourceHot
@Test
public void testStaticScriptWithInlineDefinedInstanceUsingJsr223() throws Exception {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("groovyContextWithJsr223.xml", getClreplaced());
replacedertThat(Arrays.asList(ctx.getBeanNamesForType(Messenger.clreplaced)).contains("messengerInstanceInline")).isTrue();
Messenger messenger = (Messenger) ctx.getBean("messengerInstanceInline");
replacedertThat(AopUtils.isAopProxy(messenger)).as("Shouldn't get proxy when refresh is disabled").isFalse();
boolean condition = messenger instanceof Refreshable;
replacedertThat(condition).as("Scripted object should not be instance of Refreshable").isFalse();
String desiredMessage = "Hello World!";
replacedertThat(messenger.getMessage()).as("Message is incorrect").isEqualTo(desiredMessage);
replacedertThat(ctx.getBeansOfType(Messenger.clreplaced).values().contains(messenger)).isTrue();
}
17
Source : GroovyScriptFactoryTests.java
with Apache License 2.0
from SourceHot
with Apache License 2.0
from SourceHot
@Test
public void testInlineJsr223FromTagWithInterface() throws Exception {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("groovy-with-xsd-jsr223.xml", getClreplaced());
replacedertThat(Arrays.asList(ctx.getBeanNamesForType(Messenger.clreplaced)).contains("inlineMessengerWithInterface")).isTrue();
Messenger messenger = (Messenger) ctx.getBean("inlineMessengerWithInterface");
replacedertThat(AopUtils.isAopProxy(messenger)).isFalse();
}
See More Examples