?? counterplugintest.java
字號:
package com.ecyrd.jspwiki.plugin;import com.ecyrd.jspwiki.*;import junit.framework.*;import java.io.*;import java.util.*;import javax.servlet.ServletException;public class CounterPluginTest extends TestCase{ Properties props = new Properties(); TestEngine testEngine; WikiContext context; PluginManager manager; public CounterPluginTest( String s ) { super( s ); } public void setUp() throws Exception { props.load( TestEngine.findTestProperties() ); testEngine = new TestEngine(props); } public void tearDown() { } private String translate( String src ) throws IOException, NoRequiredPropertyException, ServletException { WikiContext context = new WikiContext( testEngine, new WikiPage("TestPage") ); Reader r = new TranslatorReader( context, new BufferedReader( new StringReader(src)) ); StringWriter out = new StringWriter(); int c; while( ( c=r.read()) != -1 ) { out.write( c ); } return out.toString(); } public void testSimpleCount() throws Exception { String src = "[{Counter}], [{Counter}]"; assertEquals( "1, 2", translate(src) ); } public void testSimpleVar() throws Exception { String src = "[{Counter}], [{Counter}], [{$counter}]"; assertEquals( "1, 2, 2", translate(src) ); } public void testTwinVar() throws Exception { String src = "[{Counter}], [{Counter name=aa}], [{$counter-aa}]"; assertEquals( "1, 1, 1", translate(src) ); } public static Test suite() { return new TestSuite( CounterPluginTest.class ); }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -