Package com.google.code.hs4j.command.text

Source Code of com.google.code.hs4j.command.text.AbstractCommandUnitTest

package com.google.code.hs4j.command.text;

import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

import com.google.code.hs4j.command.text.AbstractCommand.ParseState;
import com.google.code.hs4j.network.buffer.IoBuffer;

public abstract class AbstractCommandUnitTest {

  protected AbstractCommand cmd;

  @Before
  public void setUp() {
    this.cmd = this.createCommand();
  }

  public abstract AbstractCommand createCommand();

  @Test
  public void testDecodeErrorMessage() {
    IoBuffer buffer = IoBuffer.wrap("1\t1\terror message\n".getBytes());

    assertEquals(1, this.cmd.getLatch().getCount());
    assertTrue(this.cmd.decode(null, buffer));
    assertEquals(1, this.cmd.getResponseStatus());
    assertEquals(1, this.cmd.getNumColumns());

    assertEquals(ParseState.DONE, this.cmd.getCurrentState());
    assertEquals(0, this.cmd.getLatch().getCount());
    assertEquals("Error message from server:error message", this.cmd
        .getExceptionMessage());

  }
}
TOP

Related Classes of com.google.code.hs4j.command.text.AbstractCommandUnitTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.