Package org.serviceconnector.net

Examples of org.serviceconnector.net.IEncoderDecoder


   * Description: Encode EXC test<br>
   * Expectation: passes
   */
  @Test
  public void t22_encodeEXCTest() {
    IEncoderDecoder coder = coderFactory.createEncoderDecoder(new SCMPPart());

    this.headKey = SCMPHeaderKey.EXC;
    String header = "msn=" + msgSequenceNr + "\n" + "bty=" + bodyType.getValue() + "\n" + "mty=" + msgType.getValue() + "\n";

    String expectedString = TestUtil.getSCMPString(headKey, header, body);

    SCMPMessage encodeExc = new SCMPMessageFault();
    encodeExc.setHeader(encodeScmp);
    encodeExc.setBody(body.getBytes());

    OutputStream os = new ByteArrayOutputStream();
    try {
      coder.encode(os, encodeExc);
    } catch (Exception e) {
      Assert.fail("Should not throw exception");
    }
    Assert.assertEquals(expectedString, os.toString());
  }
View Full Code Here


   * Description: Encode PRQ test<br>
   * Expectation: passes
   */
  @Test
  public void t23_EncodePRQTest() {
    IEncoderDecoder coder = coderFactory.createEncoderDecoder(new SCMPPart());

    this.headKey = SCMPHeaderKey.PRQ;
    String header = "msn=" + msgSequenceNr + "\n" + "bty=" + bodyType.getValue() + "\n" + "mty=" + msgType.getValue() + "\n";

    String expectedString = TestUtil.getSCMPString(headKey, header, body);

    SCMPMessage encodeRes = new SCMPPart();
    encodeRes.setHeader(encodeScmp);
    encodeRes.setBody(body.getBytes());

    OutputStream os = new ByteArrayOutputStream();
    try {
      coder.encode(os, encodeRes);
    } catch (Exception e) {
      Assert.fail("Should not throw exception");
    }
    Assert.assertEquals(expectedString, os.toString());
  }
View Full Code Here

   * Description: Encode PRS test<br>
   * Expectation: passes
   */
  @Test
  public void t24_EncodePRSTest() {
    IEncoderDecoder coder = coderFactory.createEncoderDecoder(new SCMPPart());

    this.headKey = SCMPHeaderKey.PRS;
    String header = "msn=" + msgSequenceNr + "\n" + "bty=" + bodyType.getValue() + "\n" + "mty=" + msgType.getValue() + "\n";

    String expectedString = TestUtil.getSCMPString(headKey, header, body);

    SCMPMessage encodeRes = new SCMPPart();
    encodeRes.setIsReply(true);
    encodeRes.setHeader(encodeScmp);
    encodeRes.setBody(body.getBytes());

    OutputStream os = new ByteArrayOutputStream();
    try {
      coder.encode(os, encodeRes);
    } catch (Exception e) {
      Assert.fail("Should not throw exception");
    }
    Assert.assertEquals(expectedString, os.toString());
  }
View Full Code Here

   * Description: Encode body types test<br>
   * Expectation: passes
   */
  @Test
  public void t25_EncodeBodyTypesTest() {
    IEncoderDecoder coder = coderFactory.createEncoderDecoder(new SCMPPart());

    String header = "msn=" + msgSequenceNr + "\n" + "bty=" + bodyType.getValue() + "\n" + "mty=" + msgType.getValue() + "\n";

    String expectedString = TestUtil.getSCMPString(headKey, header, body);

    OutputStream os = new ByteArrayOutputStream();
    try {
      coder.encode(os, encodeScmp);
    } catch (Exception e) {
      Assert.fail("Should not throw exception");
    }
    Assert.assertEquals(expectedString, os.toString());

    coder = coderFactory.createEncoderDecoder(encodeScmp);
    bodyType = SCMPBodyType.TEXT;
    encodeScmp.setHeader(SCMPHeaderAttributeKey.BODY_TYPE, bodyType.getValue());

    header = "msn=" + msgSequenceNr + "\n" + "bty=" + bodyType.getValue() + "\n" + "mty=" + msgType.getValue() + "\n";

    expectedString = TestUtil.getSCMPString(headKey, header, body);

    os = new ByteArrayOutputStream();
    try {
      coder.encode(os, encodeScmp);
    } catch (Exception e) {
      Assert.fail("Should not throw exception");
    }
    Assert.assertEquals(expectedString, os.toString());
  }
View Full Code Here

    Statistics.getInstance().incrementTotalMessages(buffer.length);
    if (ConnectionLogger.isEnabledFull()) {
      ConnectionLogger.logReadBuffer(this.getClass().getSimpleName(), this.getRemoteSocketAddress().getHostName(), this
          .getRemoteSocketAddress().getPort(), buffer, 0, buffer.length);
    }
    IEncoderDecoder encoderDecoder = AppContext.getEncoderDecoderFactory().createEncoderDecoder(buffer);
    ByteArrayInputStream bais = new ByteArrayInputStream(buffer);
    SCMPMessage message = (SCMPMessage) encoderDecoder.decode(bais);
    this.setMessage(message);
  }
View Full Code Here

    Statistics.getInstance().incrementTotalMessages(buffer.length);
    if (ConnectionLogger.isEnabledFull()) {
      ConnectionLogger.logReadBuffer(this.getClass().getSimpleName(), this.getRemoteSocketAddress().getHostName(), this
          .getRemoteSocketAddress().getPort(), buffer, 0, buffer.length);
    }
    IEncoderDecoder encoderDecoder = AppContext.getEncoderDecoderFactory().createEncoderDecoder(buffer);
    ByteArrayInputStream bais = new ByteArrayInputStream(buffer);
    SCMPMessage message = (SCMPMessage) encoderDecoder.decode(bais);
    this.setMessage(message);
  }
View Full Code Here

    String requestString = TestUtil.getSCMPString(headKey, null, null);

    byte[] buffer = requestString.getBytes();
    InputStream is = new ByteArrayInputStream(buffer);
    IEncoderDecoder coder = coderFactory.createEncoderDecoder(new SCMPKeepAlive());

    SCMPMessage message = null;
    try {
      message = (SCMPMessage) coder.decode(is);
    } catch (Exception e) {
      Assert.fail("Should not throw exception");
    }
    verifySCMP(message);
  }
View Full Code Here

    this.headKey = SCMPHeaderKey.KRS;
    String requestString = headKey.name() + " 0000000 00000 1.0\n";

    byte[] buffer = requestString.getBytes();
    InputStream is = new ByteArrayInputStream(buffer);
    IEncoderDecoder coder = coderFactory.createEncoderDecoder(new SCMPKeepAlive());

    SCMPMessage message = null;
    try {
      message = (SCMPMessage) coder.decode(is);
    } catch (Exception e) {
      Assert.fail("Should not throw exception");
    }
    verifySCMP(message);
  }
View Full Code Here

   */
  @Test
  public void t10_EncodeKRQTest() {
    this.headKey = SCMPHeaderKey.KRQ;
    this.encodeScmp = new SCMPKeepAlive();
    IEncoderDecoder coder = coderFactory.createEncoderDecoder(new SCMPKeepAlive());

    String expectedString = this.headKey.name() + " 0000000 00000 " + SCMPVersion.CURRENT + "\n";

    OutputStream os = new ByteArrayOutputStream();
    try {
      coder.encode(os, encodeScmp);
    } catch (Exception e) {
      Assert.fail("Should not throw exception");
    }
    Assert.assertEquals(expectedString, os.toString());
  }
View Full Code Here

   */
  @Test
  public void t11_EncodeKRSTest() {
    this.headKey = SCMPHeaderKey.KRS;
    this.encodeScmp = new SCMPKeepAlive();
    IEncoderDecoder coder = coderFactory.createEncoderDecoder(new SCMPKeepAlive());

    String expectedString = this.headKey.name() + " 0000000 00000 " + SCMPVersion.CURRENT + "\n";

    OutputStream os = new ByteArrayOutputStream();
    try {
      encodeScmp.setIsReply(true);
      coder.encode(os, encodeScmp);
    } catch (Exception e) {
      Assert.fail("Should not throw exception");
    }
    Assert.assertEquals(expectedString, os.toString());
  }
View Full Code Here

TOP

Related Classes of org.serviceconnector.net.IEncoderDecoder

Copyright © 2018 www.massapicom. 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.