本文整理汇总了Java中org.springframework.scripting.support.ScriptFactoryPostProcessor.INLINE_SCRIPT_PREFIX属性的典型用法代码示例。如果您正苦于以下问题:Java ScriptFactoryPostProcessor.INLINE_SCRIPT_PREFIX属性的具体用法?Java ScriptFactoryPostProcessor.INLINE_SCRIPT_PREFIX怎么用?Java ScriptFactoryPostProcessor.INLINE_SCRIPT_PREFIX使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.springframework.scripting.support.ScriptFactoryPostProcessor
的用法示例。
在下文中一共展示了ScriptFactoryPostProcessor.INLINE_SCRIPT_PREFIX属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testScriptedClassThatDoesNotHaveANoArgCtor
@Test
public void testScriptedClassThatDoesNotHaveANoArgCtor() throws Exception {
ScriptSource script = mock(ScriptSource.class);
final String badScript = "class Foo { public Foo(String foo) {}}";
given(script.getScriptAsString()).willReturn(badScript);
given(script.suggestedClassName()).willReturn("someName");
GroovyScriptFactory factory = new GroovyScriptFactory(ScriptFactoryPostProcessor.INLINE_SCRIPT_PREFIX
+ badScript);
try {
factory.getScriptedObject(script);
fail("Must have thrown a ScriptCompilationException (no public no-arg ctor in scripted class).");
}
catch (ScriptCompilationException expected) {
assertTrue(expected.contains(InstantiationException.class));
}
}
示例2: testScriptedClassThatHasNoPublicNoArgCtor
@Test
public void testScriptedClassThatHasNoPublicNoArgCtor() throws Exception {
ScriptSource script = mock(ScriptSource.class);
final String badScript = "class Foo { protected Foo() {}}";
given(script.getScriptAsString()).willReturn(badScript);
given(script.suggestedClassName()).willReturn("someName");
GroovyScriptFactory factory = new GroovyScriptFactory(ScriptFactoryPostProcessor.INLINE_SCRIPT_PREFIX
+ badScript);
try {
factory.getScriptedObject(script);
fail("Must have thrown a ScriptCompilationException (no oublic no-arg ctor in scripted class).");
}
catch (ScriptCompilationException expected) {
assertTrue(expected.contains(IllegalAccessException.class));
}
}
示例3: scriptThatCompilesButIsJustPlainBad
@Test
public void scriptThatCompilesButIsJustPlainBad() throws Exception {
ScriptSource script = mock(ScriptSource.class);
final String badScript = "String getMessage() { throw new IllegalArgumentException(); }";
given(script.getScriptAsString()).willReturn(badScript);
given(script.isModified()).willReturn(true);
BshScriptFactory factory = new BshScriptFactory(
ScriptFactoryPostProcessor.INLINE_SCRIPT_PREFIX + badScript, Messenger.class);
try {
Messenger messenger = (Messenger) factory.getScriptedObject(script, Messenger.class);
messenger.getMessage();
fail("Must have thrown a BshScriptUtils.BshExecutionException.");
}
catch (BshScriptUtils.BshExecutionException expected) {
}
}
示例4: testScriptThatCompilesButIsJustPlainBad
public void testScriptThatCompilesButIsJustPlainBad() throws Exception {
ScriptSource script = mock(ScriptSource.class);
final String badScript = "String getMessage() { throw new IllegalArgumentException(); }";
given(script.getScriptAsString()).willReturn(badScript);
given(script.isModified()).willReturn(true);
BshScriptFactory factory = new BshScriptFactory(
ScriptFactoryPostProcessor.INLINE_SCRIPT_PREFIX + badScript,
new Class<?>[] {Messenger.class});
try {
Messenger messenger = (Messenger) factory.getScriptedObject(script, new Class<?>[]{Messenger.class});
messenger.getMessage();
fail("Must have thrown a BshScriptUtils.BshExecutionException.");
}
catch (BshScriptUtils.BshExecutionException expected) {
}
}