当前位置: 首页>>代码示例>>Java>>正文


Java ScriptFactoryPostProcessor.INLINE_SCRIPT_PREFIX属性代码示例

本文整理汇总了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));
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:16,代码来源:GroovyScriptFactoryTests.java

示例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));
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:16,代码来源:GroovyScriptFactoryTests.java

示例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) {
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:16,代码来源:BshScriptFactoryTests.java

示例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) {
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:16,代码来源:BshScriptFactoryTests.java


注:本文中的org.springframework.scripting.support.ScriptFactoryPostProcessor.INLINE_SCRIPT_PREFIX属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。