[Demonstration 1]

[Buggy Method]
@Test
public void testSetLed() throws ParticleException {
    button.setLed(1, Color.RED);
    Mockito.verify(api, Mockito.atLeastOnce()).callMethod("led", "01" + Integer.toString(Color.RED.getRGB()));
}

[Buggy Hunk]
Mockito.verify(api, Mockito.atLeastOnce()).callMethod("led", "01"+ Integer.toString(Color.RED.getRGB()));

[Patch]
Mockito.verify(api, Mockito.atLeastOnce()).callMethod("led", "01255000000");

[Demonstration 2]

[Buggy Method]
public void driver_output2(ByteBuffer header, ByteBuffer buf) throws Pausable {
    int status = task.status;
    if ((status & EDriverTask.ERTS_PORT_SFLG_CLOSING) != 0) {
        return;
    }
    header.flip();
    if (buf != null)
        buf.flip();
    if ((status & EDriverTask.ERTS_PORT_SFLG_DISTRIBUTION) != 0) {
        task.node().net_message(task.self_handle(), null, buf);
        return;
    }
    if ((status & EDriverTask.ERTS_PORT_SFLG_LINEBUF_IO) != 0) {
        throw new NotImplemented();
    }
    EObject tail = null;
    if (buf == null || !buf.hasRemaining()) {
        tail = ERT.NIL;
    } else if (task.send_binary_data) {
        tail = EBinary.make(buf);
    } else {
        tail = EString.make(buf);
    }
    EBinList out = new EBinList(header, tail);
    task.output_from_driver(out);
}

[Buggy Hunk]
EBinList out = new EBinList(header, tail);

[Patch]
EObject out = header.remaining()==0 ? tail : new EBinList(header, tail);

[Demonstration 3]

[Buggy Method]
public Cookie write(Session session) throws IOException {
    String callID = UUID.randomUUID().toString();
    String message = callID + "_" + new Integer(WRITE).toString() + session.extractInfo();
    DatagramSocket rpcSocket = new DatagramSocket();
    rpcSocket.setSoTimeout(3000);
    byte[] encodeInfo = convertToBytes(message);
    final int[] numOfwrite = new Random().ints(0, DataBrickManager.getServerNum()).distinct().limit(W).toArray();
    List<ServerID> serverList = DataBrickManager.getServerID();
    List<ServerID> repliedBricks = new ArrayList<ServerID>();
    for (int index : numOfwrite) {
        ServerID s = serverList.get(index);
        DatagramPacket sendPkt = new DatagramPacket(encodeInfo, encodeInfo.length, s.getIP(), s.getPort());
        rpcSocket.send(sendPkt);
    }
    session.clearLocation();
    byte[] inBuf = new byte[4096];
    while (repliedBricks.size() < WQ) {
        DatagramPacket recvPkt = new DatagramPacket(inBuf, inBuf.length);
        rpcSocket.receive(recvPkt);
        String response = (String) convertFromBytes(inBuf);
        String[] decodeInfo = response.split("_");
        String returnID = decodeInfo[0];
        if (returnID.equals(callID)) {
            int portNumber = Integer.parseInt(decodeInfo[2]);
            InetAddress ipAddress = InetAddress.getByName(decodeInfo[1]);
            ServerID locationInfo = new ServerID(ipAddress, portNumber);
            repliedBricks.add(locationInfo);
        }
    }
    session.updateLocationByOnce(serverList);
    rpcSocket.close();
    return null;
}

[Buggy Hunk]
public Cookie write(Session session) throws IOException {

[Patch]
public Cookie write(Session session) throws IOException, ClassNotFoundException {