Package fpdu

Examples of fpdu.FPDU


  @Test
  public void testFPDUReception() {
    ConnectionWS cws = new ConnectionWS();
    FPDUParameter parameter = new FPDUParameter("Bob", "Local");
    parameter.setLocalConnectionId(1);
    FPDU fpdu = new FPDU(EnumFPDU.CONNECT, parameter);
   
    // Case 1
    System.out.println("testFPDUReception : Case 1/6");
    OutputConnectionWS ocws;
    try {
      ocws = cws.FPDUReception(fpdu);
      assertEquals(EnumFPDU.ACONNECT, ocws.getFpdu().getType())
      assertEquals("Bob", ocws.getFpdu().getParameter().getReceiver());
      assertEquals("Local", ocws.getFpdu().getParameter().getSender());
    } catch (Exception e) {
      fail("testFPDUReception : No exception " +
      "should have been raised");
    }
   
    // Case 2
    System.out.println("testFPDUReception : Case 2/6");
    try {
      ocws = cws.FPDUReception(fpdu);
      fail("testFPDUReception : ConnectionException " +
      "should have been raised");
    } catch (ConnectionException e) {
    } catch (Exception e) {
      e.printStackTrace();
    }
   
    // Case 3
    System.out.println("testFPDUReception : Case 3/6");
    parameter = new FPDUParameter("Alice", "Local");
    fpdu = new FPDU(EnumFPDU.ACONNECT, parameter);
    try {
      ocws = cws.FPDUReception(fpdu);
      fail("testFPDUReception : WrongFPDUException " +
      "should have been raised");
    } catch (WrongFPDUException e) {
    } catch (Exception e) {
      e.printStackTrace();
    }
    // Case 4
    System.out.println("testFPDUReception : Case 4/6");
    try {
      fpdu.setType(EnumFPDU.RCONNECT);
      cws.FPDUReception(fpdu);
      fail("testFPDUReception : WrongFPDUException " +
      "should have been raised");
    } catch (WrongFPDUException e) {
    } catch (Exception e) {
      e.printStackTrace();
    }
    // Case 5
    System.out.println("testFPDUReception : Case 5/6");
    try {
      fpdu.setType(EnumFPDU.RELCONF);
      cws.FPDUReception(fpdu);
      fail("testFPDUReception : WrongFPDUException " +
      "should have been raised");
    } catch (WrongFPDUException e) {
    } catch (Exception e) {
      e.printStackTrace();
    }
    // Case 6
    System.out.println("testFPDUReception : Case 6/6");
    try {
      fpdu.setType(EnumFPDU.RELEASE);
      cws.FPDUReception(fpdu);
      fail("testFPDUReception : WrongFPDUException " +
      "should have been raised");
    } catch (WrongFPDUException e) {
    } catch (Exception e) {
View Full Code Here


   *     We ask Bob for a connection. Waiting for ACONNECT.
   */
  public void testLogLocalNominalConnect() {
    FPDUParameter param = new FPDUParameter("Alice", "Bob");

    FPDU fpdu = new FPDU(param);
    fpdu.setType(EnumFPDU.CONNECT);
   
    String result = PeSITLog.logLocal(fpdu);
    assertThat(result, containsString("Sent: " +
        "FPDU CONNECT   to Bob. We ask Bob for a connection. "
        + "Waiting for ACONNECT."));
View Full Code Here

   *     We will close the connection with Bob. Waiting for RELCONF.
   */
  public void testLogLocalNominalRelease() {
    FPDUParameter param = new FPDUParameter("Alice", "Bob");

    FPDU fpdu = new FPDU(param);
    fpdu.setType(EnumFPDU.RELEASE);
   
    String result = PeSITLog.logLocal(fpdu);
    assertThat(result, containsString("Sent: " +
        "FPDU RELEASE   to Bob. " +
        "We will close the connection with Bob. Waiting for RELCONF."));
View Full Code Here

   * *Date* Sent: FPDU RELCONF   to Bob. We are now disconnected.
   */
  public void testLogLocalNominalRelconf() {
    FPDUParameter param = new FPDUParameter("Alice", "Bob");

    FPDU fpdu = new FPDU(param);
    fpdu.setType(EnumFPDU.RELCONF);
   
    String result = PeSITLog.logLocal(fpdu);
    assertThat(result, containsString("Sent: " +
        "FPDU RELCONF   to Bob. We are now disconnected."));
  }
View Full Code Here

   * *Date* Sent: FPDU DTF   to Bob. Sending data to Bob.
   */
  public void testLogLocalNominalDTF() {
    FPDUParameter param = new FPDUParameter("Alice", "Bob");

    FPDU fpdu = new FPDU(param);
    fpdu.setType(EnumFPDU.DTF);
   
    String result = PeSITLog.logLocal(fpdu);
    assertThat(result, containsString("Sent: " +
        "FPDU DTF   to Bob. Sending data to Bob."));
  }
View Full Code Here

  /**
   * Test of logLocal with a null FPDU
   * Expected return: Error null FPDU
   */
  public void testLogLocalNullFPDU() {
    FPDU fpdu = null;
   
    String result = PeSITLog.logLocal(fpdu);
    assertEquals("failure - should be equal", "Error null FPDU", result);
  }
View Full Code Here

   * its type, the type is DTF (0).
   */
  public void testLogLocalNullType() {
    FPDUParameter param = new FPDUParameter("Alice", "Bob");

    FPDU fpdu = new FPDU();
    fpdu.setParameter(param);
   
    System.out.println("\n\n\n!!!!! " + fpdu.getType() + " !!!!!\n\n\n");
   
    String result = PeSITLog.logLocal(fpdu);
    assertEquals("failure - should be equal", "Error null FPDU", result);
  }
View Full Code Here

   * Test of logLocal with a FPDU that has null parameters.
   * (this should never happen)
   * No specific return is expected has this case is not handled
   */
  public void testLogLocalNullParameters() {
    FPDU fpdu = new FPDU();
   
    fpdu.setType(EnumFPDU.CONNECT);
   
    String result = PeSITLog.logLocal(fpdu);
    assertThat(result, containsString("Sent: " +
        "FPDU CONNECT  . We ask null for a connection."));
    //assertEquals("failure - should be equal", "Error null FPDU", result);
View Full Code Here

   * *Date* Received: FPDU CONNECT   from Bob. Bob wants to connect.
   */
  public void testLogRemoteNominalConnect() {
    FPDUParameter param = new FPDUParameter("Bob", "Alice");

    FPDU fpdu = new FPDU(param);
    fpdu.setType(EnumFPDU.CONNECT);
   
    String result = PeSITLog.logRemote(fpdu);
    assertThat(result, containsString("Received: " +
        "FPDU CONNECT   from Bob. Bob wants to connect."));
  }
View Full Code Here

   *     Connection accepted. We are now connected to Bob.
   */
  public void testLogRemoteNominalAConnect() {
    FPDUParameter param = new FPDUParameter("Bob", "Alice");

    FPDU fpdu = new FPDU(param);
    fpdu.setType(EnumFPDU.ACONNECT);
   
    String result = PeSITLog.logRemote(fpdu);
    assertThat(result, containsString("Received: " +
        "FPDU ACONNECT   from Bob. Connection accepted. " +
        "We are now connected to Bob."));
View Full Code Here

TOP

Related Classes of fpdu.FPDU

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.