Examples of IEncoderDecoder


Examples of org.serviceconnector.net.IEncoderDecoder

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

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

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

Examples of org.serviceconnector.net.IEncoderDecoder

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

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

    SCMPMessage message = null;
    try {
      message = (SCMPMessage) coder.decode(is);
    } catch (Exception e) {
      Assert.fail("Should not throw exception");
    }
    if (message.isFault() == false) {
      Assert.fail("scmp should be of type fault");
View Full Code Here

Examples of org.serviceconnector.net.IEncoderDecoder

    String requestString = "garbage /s=69&awd 1.0\n" + "bty=" + bodyType.getValue() + "\n" + "mid=" + msgSequenceNr + "\n"
        + "mty=" + msgType.getValue() + "\n\n" + body + "\n";

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

    try {
      coder.decode(is);
      Assert.fail("Should throw exception");
    } catch (Exception e) {
      Assert.assertEquals("wrong protocol in message not possible to decode", e.getMessage());
    }
  }
View Full Code Here

Examples of org.serviceconnector.net.IEncoderDecoder

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

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

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

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

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

    buffer = requestString.getBytes();
    is = new ByteArrayInputStream(buffer);
    coder = coderFactory.createEncoderDecoder(buffer);

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

Examples of org.serviceconnector.net.IEncoderDecoder

   * Description: Encode REQ test<br>
   * Expectation: passes
   */
  @Test
  public void t10_EncodeREQTest() {
    IEncoderDecoder coder = coderFactory.createEncoderDecoder(encodeScmp);

    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());
  }
View Full Code Here

Examples of org.serviceconnector.net.IEncoderDecoder

   * Description: Encode RES test<br>
   * Expectation: passes
   */
  @Test
  public void t11_EncodeRESTest() {
    IEncoderDecoder coder = coderFactory.createEncoderDecoder(encodeScmp);

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

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

    SCMPMessage encodeRes = new SCMPMessage();
    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

Examples of org.serviceconnector.net.IEncoderDecoder

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

    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

Examples of org.serviceconnector.net.IEncoderDecoder

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

    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

Examples of org.serviceconnector.net.IEncoderDecoder

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

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

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

Examples of org.serviceconnector.net.IEncoderDecoder

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

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

    SCMPMessage message = null;
    try {
      message = (SCMPMessage) coder.decode(is);
    } catch (Exception e) {
      Assert.fail("Should not throw exception");
    }
    verifySCMP(message);
  }
View Full Code Here
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.