parameterelementtest.java

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

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

import java.io.IOException;
import java.util.HashMap;

import javax.servlet.jsp.JspWriter;

import junit.framework.TestCase;

public class ParameterElementTest extends TestCase {
  
  private ParameterElement parameterElement = null;
  private HashMap parameterMap = null;
  private String writtenText = null;
  
  protected void setUp() {
    parameterMap = new HashMap();
    parameterMap.put("existingKey", "existingValue");
    writtenText = null;
  }
  
  public void testWriteExisting() throws Exception {
    parameterElement = new ParameterElement("existingKey");
    parameterElement.write(new TestJspWriter(), parameterMap);
    assertEquals("1", writtenText, "existingValue");
  }
  
  public void testWriteUnexisting() throws Exception {
    parameterElement = new ParameterElement("unexistingKey");
    parameterElement.write(new TestJspWriter(), parameterMap);
    assertNull("1", writtenText);
  }

  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 + -
显示快捷键?