Package it.polito.appeal.traci.protocol

Examples of it.polito.appeal.traci.protocol.Command


    assertEquals(AN_INTEGER, cmd.content().readInt());
  }

  @Test
  public void testWriteRawTo() {
    Command cmd = new Command(sampleStorage());
    Storage s = new Storage();
    cmd.writeRawTo(s);
    Iterator<Byte> bytes = s.getStorageList().iterator();
    assertEquals(0, (int)bytes.next());
    assertEquals(0, (int)bytes.next());
    assertEquals(0, (int)bytes.next());
    assertEquals(0, (int)bytes.next());
View Full Code Here


  List<Command> getRequests() {
    if (time == -1)
      throw new IllegalStateException("time must be set first");
   
    List<Command> reqs = super.getRequests();
    Command req = reqs.iterator().next();
    req.content().writeByte(Constants.TYPE_INTEGER);
    req.content().writeInt(time);
    return reqs;
  }
View Full Code Here

  }
 
  @Test
  public void testGetVersionHighLevel() throws IOException {
    RequestMessage reqm = new RequestMessage();
    reqm.append(new Command(Constants.CMD_GETVERSION));
    reqm.writeTo(outStream);
   
    ResponseMessage respm = new ResponseMessage(inStream);
    assertEquals(1, respm.responses().size());
   
    ResponseContainer pair = respm.responses().get(0);
    assertEquals(Constants.CMD_GETVERSION, pair.getStatus().id());
   
    Command resp = pair.getResponse();
    assertEquals(Constants.CMD_GETVERSION, resp.id());
    assertEquals(1, resp.content().readInt());
    System.out.println(resp.content().readStringASCII());
  }
View Full Code Here

  }
 
  @Test
  public void testCloseHighLevel() throws IOException {
    RequestMessage reqm = new RequestMessage();
    reqm.append(new Command(Constants.CMD_CLOSE));
    reqm.writeTo(outStream);
   
    ResponseMessage respm = new ResponseMessage(inStream);
    assertEquals(1, respm.responses().size());
   
View Full Code Here

  }

  @Test
  public void testAppend() {
    RequestMessage m = new RequestMessage();
    Command cmd = new Command(0xAA);
    m.append(cmd);
    assertEquals(cmd, m.commands().iterator().next());
  }
View Full Code Here

  }

  @Test
  public void testWriteTo() throws IOException {
    RequestMessage m = new RequestMessage();
    Command cmd = new Command(0xAA);
    m.append(cmd);

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(baos);
    m.writeTo(dos);
View Full Code Here

  }
 
  @Test
  public void testGetVersionHighLevel() throws IOException {
    RequestMessage reqm = new RequestMessage();
    reqm.append(new Command(Constants.CMD_GETVERSION));
    reqm.writeTo(outStream);
   
    ResponseMessage respm = new ResponseMessage(inStream);
    assertEquals(1, respm.responses().size());
   
    ResponseContainer pair = respm.responses().get(0);
    assertEquals(Constants.CMD_GETVERSION, pair.getStatus().id());
   
    Command resp = pair.getResponse();
    assertEquals(Constants.CMD_GETVERSION, resp.id());
    assertEquals(API_VERSION, resp.content().readInt());
    log.info(resp.content().readStringASCII());
  }
View Full Code Here

  }
 
  @Test
  public void testCloseHighLevel() throws IOException {
    RequestMessage reqm = new RequestMessage();
    reqm.append(new Command(Constants.CMD_CLOSE));
    reqm.writeTo(outStream);
   
    ResponseMessage respm = new ResponseMessage(inStream);
    assertEquals(1, respm.responses().size());
   
View Full Code Here

  }

  @Test
  public void testCommandStorage() {
    Storage s = sampleStorage();
    new Command(s);
  }
View Full Code Here

    return new Storage(buf);
  }

  @Test
  public void testCommandInt() {
    new Command(A_COMMAND_ID);
  }
View Full Code Here

TOP

Related Classes of it.polito.appeal.traci.protocol.Command

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.