textelementtest.java

来自「一个java工作流引擎」· Java 代码 · 共 62 行

JAVA
62
字号
package org.jbpm.web.formgen;

import java.io.IOException;

import javax.servlet.jsp.JspWriter;

import junit.framework.TestCase;

public class TextElementTest extends TestCase {
  
  private TextElement textElement = null;
  private String writtenText = null;
  
  protected void setUp() {
    textElement = new TextElement("test");
    writtenText = null;
  }
  
  public void testConstruction() {
    assertNotNull("1", textElement);
    assertEquals("2", textElement.getText(), "test");
  }
  
  public void testWrite() throws Exception {
    textElement.write(new TestJspWriter(), null);
    assertEquals("1", writtenText, "test");
  }
  
  class TestJspWriter extends JspWriter {
    protected TestJspWriter() {super(0, false);}
    public void newLine() throws IOException {}
    public void print(boolean arg0) throws IOException {}
    public void print(char arg0) throws IOException {}
    public void print(int arg0) throws IOException {}
    public void print(long arg0) throws IOException {}
    public void print(float arg0) throws IOException {}
    public void print(double arg0) throws IOException {}
    public void print(char[] arg0) throws IOException {}
    public void print(String arg0) throws IOException {}
    public void print(Object arg0) throws IOException {}
    public void println() throws IOException {}
    public void println(boolean arg0) throws IOException {}
    public void println(char arg0) throws IOException {}
    public void println(int arg0) throws IOException {}
    public void println(long arg0) throws IOException {}
    public void println(float arg0) throws IOException {}
    public void println(double arg0) throws IOException {}
    public void println(char[] arg0) throws IOException {}
    public void println(String arg0) throws IOException {}
    public void println(Object arg0) throws IOException {}
    public void clear() throws IOException {}
    public void clearBuffer() throws IOException {}
    public void flush() throws IOException {}
    public void close() throws IOException {}
    public int getRemaining() {return 0;}
    public void write(char[] cbuf, int off, int len) throws IOException {
      writtenText = new String(cbuf).trim();
    }
  }

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?