Package org.cipango.diameter.node

Examples of org.cipango.diameter.node.DiameterAnswer


  }
 
  @Test
  public void testEncodeCEA() throws Exception
  {
    DiameterAnswer answer = new DiameterAnswer();
    answer.setCommand(Common.CEA);
    AVPList l = new AVPList();
    answer.setAVPList(l);
    answer.setResultCode(Common.DIAMETER_SUCCESS);

    Buffer buffer = new ByteArrayBuffer(512);
    buffer = Codecs.__message.encode(buffer, answer);
    DiameterMessage message = Codecs.__message.decode(buffer);
    assertFalse(message.isRequest());
View Full Code Here


  }
 
  @Test
  public void testEncodeSmallBuffer() throws Exception
  {
    DiameterAnswer answer = new DiameterAnswer();
    answer.setCommand(Sh.UDA);
    AVPList l = new AVPList();
    answer.setAVPList(l);
    answer.setResultCode(Common.DIAMETER_SUCCESS);
    answer.setEndToEndId(33);
    answer.setHopByHopId(51648);
    l.add(Common.DIAMETER_SUCCESS.getAVP());
    l.add(new AVP<String>(Common.ORIGIN_HOST, "cipango.org"));
    l.add(new AVP<InetAddress>(Common.HOST_IP_ADDRESS, InetAddress.getLocalHost()));
    l.add(new AVP<Integer>(Common.FIRMWARE_REVISION, 2));
    l.add(new AVP<byte[]>(Sh.USER_DATA, "<shData>dasaiTag<shData>".getBytes()));

    for (int i = 24; i < 256; i++)
    {
      Buffer buffer = new ByteArrayBuffer(i);
      buffer = Codecs.__message.encode(buffer, answer);
      // System.out.println(buffer.putIndex() + " / " + i);
      DiameterMessage message = Codecs.__message.decode(buffer);
      // System.out.println(message);
      assertFalse(message.isRequest());
      assertEquals(answer.getEndToEndId(), message.getEndToEndId());
      assertEquals(answer.getHopByHopId(), message.getHopByHopId());
      assertEquals(Sh.UDA, message.getCommand());
      assertEquals(Common.DIAMETER_SUCCESS.getCode(), message.get(Common.RESULT_CODE).intValue());
      assertEquals(InetAddress.getLocalHost(), message.get(Common.HOST_IP_ADDRESS));
      assertEquals("<shData>dasaiTag<shData>", new String(message.get(Sh.USER_DATA)));
    }
View Full Code Here

   
    DiameterCommand command = isRequest ? dictionary.getRequest(code) : dictionary.getAnswer(code);
    if (command == null)
      command = isRequest ? Factory.newRequest(code, "Unknown") : Factory.newAnswer(code, "Unknown");
   
    DiameterMessage message = isRequest ? new DiameterRequest() : new DiameterAnswer();
   
    message.setApplicationId(getInt(buffer));
    message.setHopByHopId(getInt(buffer));
    message.setEndToEndId(getInt(buffer));
    message.setCommand(command);
View Full Code Here

TOP

Related Classes of org.cipango.diameter.node.DiameterAnswer

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.