企业级 JavaBeans 3.1 技术深入剖析
1. 拦截器与 TV 频道服务示例
在 TV 频道服务示例中,涉及到了对频道访问的测试和拦截器的模拟实现。以下是相关代码示例:
{
bean.getChannel(2);
}
// Expected
catch (final UndeclaredThrowableException ute)
{
throw ute.getCause();
}
// Fail if we reach here
TestCase.fail("Request should have been blocked");
}
/**
* Ensures that requests to obtain Channel 2 while open succeed
*/
@Test
public void testChannel2Allowed() throws NamingException, IOException
{
// Set the policy to block channel 2
Channel2AccessPolicy.setChannel2Permitted(true);
// Invoke
final int channel = 2;
final InputStream stream = bean.getChannel(channel);
// Test
TestCase.assertEquals("Unexpected content obtained from channel " + channel, channel, strea
超级会员免费看
订阅专栏 解锁全文
1197

被折叠的 条评论
为什么被折叠?



