Java 类org.junit.jupiter.api.Tag 实例源码

项目:incubator-plc4x    文件:PlcConnectionAdapterTest.java   
@SuppressWarnings("unchecked")
@Test
@Tag("fast")
public void testNewSupplierNeg() throws Exception {
  String addressStr = "MyReadWriteAddress/0";
  MockAddress address = new MockAddress(addressStr);
  PlcConnectionAdapter adapter = new PlcConnectionAdapter(getMockConnection());
  MockConnection connection = (MockConnection) adapter.getConnection();

  Supplier<?> supplier;

  supplier = adapter.newSupplier(String.class, addressStr);
  checkSupplier(2, connection, address, (Supplier<String>)supplier, "one", "two", "three");

  adapter.close();
}
项目:incubator-plc4x    文件:PlcConnectionAdapterTest.java   
@SuppressWarnings("unchecked")
@Test
@Tag("fast")
public void testNewConsumer1Neg() throws Exception {
  String addressStr = "MyReadWriteAddress/0";
  MockAddress address = new MockAddress(addressStr);
  PlcConnectionAdapter adapter = new PlcConnectionAdapter(getMockConnection());
  MockConnection connection = (MockConnection) adapter.getConnection();

  Consumer<?> consumer;

  consumer = adapter.newConsumer(String.class, addressStr);
  checkConsumer(2, connection, address, (Consumer<String>)consumer, "one", "two", "three");

  adapter.close();
}
项目:incubator-plc4x    文件:PlcConnectionAdapterTest.java   
@Test
@Tag("fast")
public void testNewConsumer2Neg() throws Exception {
  String addressStr = "MyReadWriteAddress/0";
  MockAddress address = new MockAddress(addressStr);
  PlcConnectionAdapter adapter = new PlcConnectionAdapter(getMockConnection());
  MockConnection connection = (MockConnection) adapter.getConnection();

  Consumer<JsonObject> consumer;

  Function<JsonObject,String> addressFn = t -> t.get("address").getAsString(); 

  consumer = adapter.newConsumer(String.class, addressFn, t -> t.get("value").getAsString());
  checkConsumerJson(2, connection, address, consumer, "one", "two", "three");

  adapter.close();
}
项目:incubator-plc4x    文件:IsoTPProtocolTest.java   
@Test
@Tag("fast")
public void encodeConnectionRequest() throws Exception {
    ChannelHandlerContext ctx = new MockChannelHandlerContext();
    ByteBuf buf = Unpooled.buffer();
    ConnectionRequestTpdu tpdu = new ConnectionRequestTpdu((short)0x1, (short)(0x2), ProtocolClass.CLASS_0, Collections.emptyList(), buf);
    ArrayList<Object> out = new ArrayList<>();

    isoTPProtocol.encode(ctx, tpdu, out);

    assertTrue(out.size() == 1, "Message not decoded");

    ByteBuf userData = ((IsoOnTcpMessage)out.get(0)).getUserData();

    assertTrue(userData.writerIndex() == 7, "Incorrect message length");
    assertTrue(userData.readByte() == (byte)0x6, "Incorrect header length");
    assertTrue(userData.readByte() == TpduCode.CONNECTION_REQUEST.getCode(), "Incorrect Tpdu code");
    assertTrue(userData.readShort() == (short)0x1, "Incorrect destination reference code");
    assertTrue(userData.readShort() == (short)0x2, "Incorrect source reference code");
    assertTrue(userData.readByte() == ProtocolClass.CLASS_0.getCode(), "Incorrect protocol class");
}
项目:incubator-plc4x    文件:IsoTPProtocolTest.java   
@Test
@Tag("fast")
public void decodeConnectionRequest() throws Exception {
    ChannelHandlerContext ctx = new MockChannelHandlerContext();
    ByteBuf buf = Unpooled.buffer();
    ArrayList<Object> out = new ArrayList<>();

    buf.writeByte(0x6); // header length
    buf.writeByte(TpduCode.CONNECTION_REQUEST.getCode());
    buf.writeShort(0x01); // destination reference
    buf.writeShort(0x02); // source reference
    buf.writeByte(ProtocolClass.CLASS_0.getCode());
    IsoOnTcpMessage in = new IsoOnTcpMessage(buf);

    isoTPProtocol.decode(ctx, in, out);

    assertTrue(out.size() == 1, "Message not decoded");

    ConnectionRequestTpdu requestTpdu = (ConnectionRequestTpdu) ((IsoTPMessage)out.get(0)).getTpdu();

    assertTrue(requestTpdu.getTpduCode() == TpduCode.CONNECTION_REQUEST, "Message code not correct");
    assertTrue(requestTpdu.getDestinationReference() == (short) 0x1, "Message destination reference not correct");
    assertTrue(requestTpdu.getSourceReference() == (short) 0x2, "Message source reference not correct");
    assertTrue(requestTpdu.getProtocolClass() == ProtocolClass.CLASS_0, "Message protocol class reference not correct");
    assertTrue(requestTpdu.getParameters().isEmpty(), "Message contains paramaters");
}
项目:incubator-plc4x    文件:IsoTPProtocolTest.java   
@Test
@Tag("fast")
public void encodeDisconnectionRequest() throws Exception {
    ChannelHandlerContext ctx = new MockChannelHandlerContext();
    ByteBuf buf = Unpooled.buffer();
    DisconnectRequestTpdu tpdu = new DisconnectRequestTpdu((short)0x1, (short)(0x2), DisconnectReason.NORMAL, Collections.emptyList(), buf);
    ArrayList<Object> out = new ArrayList<>();

    isoTPProtocol.encode(ctx, tpdu, out);

    assertTrue(out.size() == 1, "Message not decoded");
    ByteBuf userData = ((IsoOnTcpMessage)out.get(0)).getUserData();

    assertTrue(userData.writerIndex() == 7, "Incorrect message length");
    assertTrue(userData.readByte() == (byte)0x6, "Incorrect header length");
    assertTrue(userData.readByte() == TpduCode.DISCONNECT_REQUEST.getCode(), "Incorrect Tpdu code");
    assertTrue(userData.readShort() == (short)0x1, "Incorrect destination reference code");
    assertTrue(userData.readShort() == (short)0x2, "Incorrect source reference code");
    assertTrue(userData.readByte() == DisconnectReason.NORMAL.getCode(), "Incorrect disconnect reason");
}
项目:incubator-plc4x    文件:IsoTPProtocolTest.java   
@Test
@Tag("fast")
public void decodeDisconnectionRequest() throws Exception {
    ChannelHandlerContext ctx = new MockChannelHandlerContext();
    ByteBuf buf = Unpooled.buffer();
    ArrayList<Object> out = new ArrayList<>();

    buf.writeByte(0x6); // header length
    buf.writeByte(TpduCode.DISCONNECT_REQUEST.getCode());
    buf.writeShort(0x01); // destination reference
    buf.writeShort(0x02); // source reference
    buf.writeByte(DisconnectReason.NORMAL.getCode());
    IsoOnTcpMessage in = new IsoOnTcpMessage(buf);

    isoTPProtocol.decode(ctx, in, out);

    assertTrue(out.size() == 1, "Message not decoded");

    DisconnectRequestTpdu requestTpdu = (DisconnectRequestTpdu) ((IsoTPMessage)out.get(0)).getTpdu();

    assertTrue(requestTpdu.getTpduCode() == TpduCode.DISCONNECT_REQUEST, "Message code not correct");
    assertTrue(requestTpdu.getDestinationReference() == (short) 0x1, "Message destination reference not correct");
    assertTrue(requestTpdu.getSourceReference() == (short) 0x2, "Message source reference not correct");
    assertTrue(requestTpdu.getDisconnectReason() == DisconnectReason.NORMAL, "Message disconnect reason not correct");
    assertTrue(requestTpdu.getParameters().isEmpty(), "Message contains paramaters");
}
项目:incubator-plc4x    文件:IsoTPProtocolTest.java   
@Test
@Tag("fast")
public void decodeData() throws Exception {
  ChannelHandlerContext ctx = new MockChannelHandlerContext();
  ByteBuf buf = Unpooled.buffer();
  ArrayList<Object> out = new ArrayList<>();

  buf.writeByte(0x3); // header length
  buf.writeByte(TpduCode.DATA.getCode());
  buf.writeByte((byte) 0x1); // Tpdu code
  IsoOnTcpMessage in = new IsoOnTcpMessage(buf);

  isoTPProtocol.decode(ctx, in, out);

  assertTrue(out.size() == 1, "Message not decoded");

  DataTpdu requestTpdu = (DataTpdu) ((IsoTPMessage)out.get(0)).getTpdu();

  assertTrue(requestTpdu.getTpduCode() == TpduCode.DATA, "Message code not correct");
  assertTrue(requestTpdu.getTpduRef() == (short) 0x1, "Message Tpdu reference not correct");
  assertTrue(!requestTpdu.isEot(), "Message EOT not correct");
  assertTrue(requestTpdu.getParameters().isEmpty(), "Message contains paramaters");
}
项目:incubator-plc4x    文件:IsoTPProtocolTest.java   
@Test
@Tag("fast")
public void encodeConnectionConfirm() throws Exception {
    ChannelHandlerContext ctx = new MockChannelHandlerContext();
    ByteBuf buf = Unpooled.buffer();
    ConnectionConfirmTpdu tpdu = new ConnectionConfirmTpdu((short)0x1, (short)(0x2), ProtocolClass.CLASS_1, Collections.emptyList(), buf);
    ArrayList<Object> out = new ArrayList<>();

    isoTPProtocol.encode(ctx, tpdu, out);

    assertTrue(out.size() == 1, "Message not decoded");

    ByteBuf userData = ((IsoOnTcpMessage)out.get(0)).getUserData();

    assertTrue(userData.writerIndex() == 7, "Incorrect message length");
    assertTrue(userData.readByte() == (byte)0x6, "Incorrect header length");
    assertTrue(userData.readByte() == TpduCode.CONNECTION_CONFIRM.getCode(), "Incorrect Tpdu code");
    assertTrue(userData.readShort() == (short)0x1, "Incorrect destination reference code");
    assertTrue(userData.readShort() == (short)0x2, "Incorrect source reference code");
    assertTrue(userData.readByte() == ProtocolClass.CLASS_1.getCode(), "Incorrect protocol class");
}
项目:incubator-plc4x    文件:IsoTPProtocolTest.java   
@Test
@Tag("fast")
public void decodeConnectionConfirm() throws Exception {
    ChannelHandlerContext ctx = new MockChannelHandlerContext();
    ByteBuf buf = Unpooled.buffer();
    ArrayList<Object> out = new ArrayList<>();

    buf.writeByte(0x6); // header length
    buf.writeByte(TpduCode.CONNECTION_CONFIRM.getCode());
    buf.writeShort(0x01); // destination reference
    buf.writeShort(0x02); // source reference
    buf.writeByte(ProtocolClass.CLASS_0.getCode());
    IsoOnTcpMessage in = new IsoOnTcpMessage(buf);

    isoTPProtocol.decode(ctx, in, out);

    assertTrue(out.size() == 1, "Message not decoded");

    ConnectionConfirmTpdu requestTpdu = (ConnectionConfirmTpdu) ((IsoTPMessage)out.get(0)).getTpdu();

    assertTrue(requestTpdu.getTpduCode() == TpduCode.CONNECTION_CONFIRM, "Message code not correct");
    assertTrue(requestTpdu.getDestinationReference() == (short) 0x1, "Message destination reference not correct");
    assertTrue(requestTpdu.getSourceReference() == (short) 0x2, "Message source reference not correct");
    assertTrue(requestTpdu.getProtocolClass() == ProtocolClass.CLASS_0, "Message protocol class reference not correct");
    assertTrue(requestTpdu.getParameters().isEmpty(), "Message contains paramaters");
}
项目:incubator-plc4x    文件:IsoTPProtocolTest.java   
@Test
@Tag("fast")
public void encodeDisconnectionConfirm() throws Exception {
    ChannelHandlerContext ctx = new MockChannelHandlerContext();
    ByteBuf buf = Unpooled.buffer();
    DisconnectConfirmTpdu tpdu = new DisconnectConfirmTpdu((short)0x1, (short)(0x2), Collections.emptyList(), buf);
    ArrayList<Object> out = new ArrayList<>();

    isoTPProtocol.encode(ctx, tpdu, out);

    assertTrue(out.size() == 1, "Message not decoded");

    ByteBuf userData = ((IsoOnTcpMessage)out.get(0)).getUserData();

    assertTrue(userData.writerIndex() == 6, "Incorrect message length");
    assertTrue(userData.readByte() == (byte)0x5, "Incorrect header length");
    assertTrue(userData.readByte() == TpduCode.DISCONNECT_CONFIRM.getCode(), "Incorrect Tpdu code");
    assertTrue(userData.readShort() == (short)0x1, "Incorrect destination reference code");
    assertTrue(userData.readShort() == (short)0x2, "Incorrect source reference code");
}
项目:incubator-plc4x    文件:IsoTPProtocolTest.java   
@Test
@Tag("fast")
public void encodeError() throws Exception {
    ChannelHandlerContext ctx = new MockChannelHandlerContext();
    ByteBuf buf = Unpooled.buffer();
    ErrorTpdu tpdu = new ErrorTpdu((short)0x1, RejectCause.REASON_NOT_SPECIFIED, Collections.emptyList(), buf);
    ArrayList<Object> out = new ArrayList<>();

    isoTPProtocol.encode(ctx, tpdu, out);

    assertTrue(out.size() == 1, "Message not decoded");

    ByteBuf userData = ((IsoOnTcpMessage)out.get(0)).getUserData();

    assertTrue(userData.writerIndex() == 5, "Incorrect message length");
    assertTrue(userData.readByte() == (byte)0x4, "Incorrect header length");
    assertTrue(userData.readByte() == TpduCode.TPDU_ERROR.getCode(), "Incorrect Tpdu code");
    assertTrue(userData.readShort() == (short)0x1, "Incorrect destination reference code");
    assertTrue(userData.readByte() == RejectCause.REASON_NOT_SPECIFIED.getCode(), "Incorrect reject cause code");
}
项目:incubator-plc4x    文件:IsoTPProtocolTest.java   
@Test
@Tag("fast")
public void encodeChecksumParameter() throws Exception {
    ChannelHandlerContext ctx = new MockChannelHandlerContext();
    ByteBuf buf = Unpooled.buffer();
    ArrayList<Parameter> parmameters = new ArrayList<>();
    ChecksumParameter checksumParameter = new ChecksumParameter((byte)0x77);
    parmameters.add(checksumParameter);
    ErrorTpdu tpdu = new ErrorTpdu((short)0x1, RejectCause.REASON_NOT_SPECIFIED, parmameters, buf);
    ArrayList<Object> out = new ArrayList<>();

    isoTPProtocol.encode(ctx, tpdu, out);

    assertTrue(out.size() == 1, "Message not decoded");

    ByteBuf userData = ((IsoOnTcpMessage)out.get(0)).getUserData();

    assertTrue(userData.writerIndex() == 8, "Incorrect message length");
    assertTrue(userData.readByte() == (byte)0x7, "Incorrect header length");
    assertTrue(userData.readByte() == TpduCode.TPDU_ERROR.getCode(), "Incorrect Tpdu code");
    assertTrue(userData.readShort() == (short)0x1, "Incorrect destination reference code");
    assertTrue(userData.readByte() == RejectCause.REASON_NOT_SPECIFIED.getCode(), "Incorrect reject cause code");
    assertTrue(userData.readByte() == ParameterCode.CHECKSUM.getCode(), "Incorrect parameter code");
    assertTrue(userData.readByte() == (byte)0x1, "Incorrect parameter length");
    assertTrue(userData.readByte() == 0x77, "Incorrect checksum");
}
项目:incubator-plc4x    文件:IsoTPProtocolTest.java   
@Test
@Tag("fast")
public void encodeSizeParameter() throws Exception {
    ChannelHandlerContext ctx = new MockChannelHandlerContext();
    ByteBuf buf = Unpooled.buffer();
    ArrayList<Parameter> parmameters = new ArrayList<>();
    TpduSizeParameter sizeParameter = new TpduSizeParameter(TpduSize.SIZE_512);
    parmameters.add(sizeParameter);
    ErrorTpdu tpdu = new ErrorTpdu((short)0x1, RejectCause.REASON_NOT_SPECIFIED, parmameters, buf);
    ArrayList<Object> out = new ArrayList<>();

    isoTPProtocol.encode(ctx, tpdu, out);

    assertTrue(out.size() == 1, "Message not decoded");

    ByteBuf userData = ((IsoOnTcpMessage)out.get(0)).getUserData();

    assertTrue(userData.writerIndex() == 8, "Incorrect message length");
    assertTrue(userData.readByte() == (byte)0x7, "Incorrect header length");
    assertTrue(userData.readByte() == TpduCode.TPDU_ERROR.getCode(), "Incorrect Tpdu code");
    assertTrue(userData.readShort() == (short)0x1, "Incorrect destination reference code");
    assertTrue(userData.readByte() == RejectCause.REASON_NOT_SPECIFIED.getCode(), "Incorrect reject cause code");
    assertTrue(userData.readByte() == ParameterCode.TPDU_SIZE.getCode(), "Incorrect parameter code");
    assertTrue(userData.readByte() == (byte)0x1, "Incorrect parameter length");
    assertTrue(userData.readByte() == TpduSize.SIZE_512.getCode(), "Incorrect tdpu size");
}
项目:incubator-plc4x    文件:IsoTPProtocolTest.java   
@Test
@Tag("fast")
public void decodeError() throws Exception {
    ChannelHandlerContext ctx = new MockChannelHandlerContext();
    ByteBuf buf = Unpooled.buffer();
    ArrayList<Object> out = new ArrayList<>();

    buf.writeByte(0x4); // header length
    buf.writeByte(TpduCode.TPDU_ERROR.getCode());
    buf.writeShort(0x01); // destination reference
    buf.writeByte(RejectCause.REASON_NOT_SPECIFIED.getCode());
    IsoOnTcpMessage in = new IsoOnTcpMessage(buf);

    isoTPProtocol.decode(ctx, in, out);

    assertTrue(out.size() == 1, "Message not decoded");

    ErrorTpdu errorTpdu = (ErrorTpdu) ((IsoTPMessage)out.get(0)).getTpdu();

    assertTrue(errorTpdu.getTpduCode() == TpduCode.TPDU_ERROR, "Message code not correct");
    assertTrue(errorTpdu.getDestinationReference() == (short) 0x1, "Message destination reference not correct");
    assertTrue(errorTpdu.getRejectCause() == RejectCause.REASON_NOT_SPECIFIED, "Message reject cause not correct");
    assertTrue(errorTpdu.getParameters().isEmpty(), "Message contains paramaters");
}
项目:incubator-plc4x    文件:IsoTPMessageTests.java   
@Test
@Tag("fast")
void isoTPMessage() {
    short destinationReference = 0x1;
    RejectCause rejectCause = RejectCause.REASON_NOT_SPECIFIED;
    List<Parameter> parameters = Collections.emptyList();
    ByteBuf errorData = Unpooled.buffer();
    ErrorTpdu tpdu = new ErrorTpdu(destinationReference, rejectCause, parameters, errorData);
    ByteBuf userData = Unpooled.buffer();
    IsoTPMessage isoTpMessage = new IsoTPMessage(tpdu, userData);

    errorData.writeByte(0x72);
    userData.writeByte(0x32);

    assertTrue(isoTpMessage.getTpdu().getTpduCode() == TpduCode.TPDU_ERROR, "Unexpected Tpdu");
    // Question: do we need two user data fields?
    assertTrue(tpdu.getUserData().readByte() == (byte) 0x72, "Unexpected user data");
    assertTrue(isoTpMessage.getUserData().readByte() == (byte) 0x32, "Unexpected user data");
}
项目:incubator-plc4x    文件:IsotpModelTests.java   
@Test
@Tag("Fast")
void errorTpdu() {
    short destinationReference = 0x1;
    RejectCause rejectCause = RejectCause.REASON_NOT_SPECIFIED;
    List<Parameter> parameters = Collections.emptyList();
    ByteBuf userData = Unpooled.buffer();

    userData.writeByte(0x7F);

    ErrorTpdu tpdu = new ErrorTpdu(destinationReference, rejectCause, parameters, userData);

    assertTrue(tpdu.getTpduCode() == TpduCode.TPDU_ERROR);
    assertTrue(tpdu.getDestinationReference() == 0x1, "Unexpected destination reference");
    assertTrue(tpdu.getRejectCause() == RejectCause.REASON_NOT_SPECIFIED);
    assertTrue(tpdu.getParameters().isEmpty(), "Unexpected parameters");
    assertTrue(tpdu.getUserData().readByte() == (byte) 0x7F, "Unexpected user data");
}
项目:incubator-plc4x    文件:IsotpModelTests.java   
@Test
@Tag("Fast")
void errorTpduParameter() {
    short destinationReference = 0x1;
    RejectCause rejectCause = RejectCause.REASON_NOT_SPECIFIED;
    ArrayList<Parameter> parameters = new ArrayList<>();
    ByteBuf userData = Unpooled.buffer();

    userData.writeByte(0x7F);

    ErrorTpdu tpdu = new ErrorTpdu(destinationReference, rejectCause, parameters, userData);

    parameters.add(new TpduSizeParameter(TpduSize.SIZE_1024));
    parameters.add(new ChecksumParameter((byte)0xFF));

    assertTrue(tpdu.getParameters().size() == 2, "Unexpected number of parameters");
    assertTrue(tpdu.getParameters().containsAll(parameters), "Unexpected parameter");
    assertTrue(tpdu.getParameter(ChecksumParameter.class) != null, "Checksum parameter should exist");
    assertTrue(tpdu.getParameter(CallingTsapParameter.class) == null, "CallingTsapParameter parameter should not exist");
}
项目:incubator-plc4x    文件:IsotpModelTests.java   
@Test
@Tag("Fast")
void connectionRequestTpdu() {
    short destinationReference = 0x1;
    short sourceReference = 0x2;
    ProtocolClass protocolClass = ProtocolClass.CLASS_0;
    List<Parameter> parameters = Collections.emptyList();
    ByteBuf userData = Unpooled.buffer();

    userData.writeByte(0x33);

    ConnectionRequestTpdu tpdu = new ConnectionRequestTpdu(destinationReference, sourceReference, protocolClass, parameters, userData);

    assertTrue(tpdu.getTpduCode() == TpduCode.CONNECTION_REQUEST);
    assertTrue(tpdu.getDestinationReference() == 0x1, "Unexpected destination reference");
    assertTrue(tpdu.getSourceReference() == 0x2, "Unexpected source reference");
    assertTrue(tpdu.getProtocolClass() == ProtocolClass.CLASS_0);
    assertTrue(tpdu.getParameters().isEmpty(), "Unexpected parameters");
    assertTrue(tpdu.getUserData().readByte() == (byte) 0x33, "Unexpected user data");
}
项目:incubator-plc4x    文件:IsotpModelTests.java   
@Test
@Tag("Fast")
void connectionConfirmTpdu() {
    short destinationReference = 0x3;
    short sourceReference = 0x4;
    ProtocolClass protocolClass = ProtocolClass.CLASS_1;
    List<Parameter> parameters = Collections.emptyList();
    ByteBuf userData = Unpooled.buffer();

    userData.writeByte(0x44);

    ConnectionConfirmTpdu tpdu = new ConnectionConfirmTpdu(destinationReference, sourceReference, protocolClass, parameters, userData);

    assertTrue(tpdu.getTpduCode() == TpduCode.CONNECTION_CONFIRM);
    assertTrue(tpdu.getDestinationReference() == 0x3, "Unexpected destination reference");
    assertTrue(tpdu.getSourceReference() == 0x4, "Unexpected source reference");
    assertTrue(tpdu.getProtocolClass() == ProtocolClass.CLASS_1);
    assertTrue(tpdu.getParameters().isEmpty(), "Unexpected parameters");
    assertTrue(tpdu.getUserData().readByte() == (byte) 0x44, "Unexpected user data");
}
项目:incubator-plc4x    文件:IsotpModelTests.java   
@Test
@Tag("Fast")
void disconnectionRequestTpdu() {
    short destinationReference = 0x1;
    short sourceReference = 0x2;
    DisconnectReason disconnectReason = DisconnectReason.ADDRESS_UNKNOWN;
    List<Parameter> parameters = Collections.emptyList();
    ByteBuf userData = Unpooled.buffer();

    userData.writeByte(0x22);

    DisconnectRequestTpdu tpdu = new DisconnectRequestTpdu(destinationReference, sourceReference, disconnectReason, parameters, userData);

    assertTrue(tpdu.getTpduCode() == TpduCode.DISCONNECT_REQUEST);
    assertTrue(tpdu.getDestinationReference() == 0x1, "Unexpected destination reference");
    assertTrue(tpdu.getSourceReference() == 0x2, "Unexpected source reference");
    assertTrue(tpdu.getDisconnectReason() == DisconnectReason.ADDRESS_UNKNOWN);
    assertTrue(tpdu.getParameters().isEmpty(), "Unexpected parameters");
    assertTrue(tpdu.getUserData().readByte() == (byte) 0x22, "Unexpected user data");
}
项目:incubator-plc4x    文件:S7MessageTests.java   
@Test
@Tag("fast")
void s7MessagePayload() {
    MessageType messageType = MessageType.USER_DATA;
    short tpduReference = 1;
    ArrayList<S7Parameter> s7Parameters = new ArrayList<>();
    ArrayList<S7Payload> s7Payloads = new ArrayList<>();
    ParameterType parameterType = ParameterType.WRITE_VAR;
    ArrayList<VarPayloadItem> payloadItems = new ArrayList<>();
    byte[] data = {(byte)0x79};
    VarPayload varPayload;

    payloadItems.add(new VarPayloadItem(DataTransportErrorCode.OK, DataTransportSize.BIT, data));
    varPayload = new VarPayload(parameterType, payloadItems);
    s7Payloads.add(varPayload);

    S7RequestMessage message = new S7RequestMessage(messageType, tpduReference, s7Parameters, s7Payloads);

    assertTrue(message.getTpduReference() == tpduReference, "Unexpected tpdu value");
    assertTrue(message.getMessageType() == MessageType.USER_DATA, "Unexpected message type");
    assertTrue(message.getPayloads().size() == 1, "Unexpected number of payloads");
    assertTrue(message.getPayloads().containsAll(s7Payloads), "Unexpected payloads");
    assertTrue(message.getPayload(VarPayload.class).equals(varPayload), "Payload missing");
    assertTrue(message.getPayload(VarParameter.class) == null, "Contains unexpected payload"); // No other parameter classes
    assertTrue(message.getParameters().size() == 0, "Unexpected number of parameters");
}
项目:incubator-plc4x    文件:IsoOnTcpProtocolTest.java   
@Test
@Tag("fast")
public void encode() {
    IsoOnTcpMessage isoOnTcpMessage = new IsoOnTcpMessage(
        Unpooled.wrappedBuffer(new byte[]{(byte)0x01,(byte)0x02,(byte)0x03}));
    EmbeddedChannel channel = new EmbeddedChannel(new IsoOnTcpProtocol());
    channel.writeOutbound(isoOnTcpMessage);
    channel.checkException();
    Object obj = channel.readOutbound();
    assertThat(obj).isInstanceOf(ByteBuf.class);
    ByteBuf byteBuf = (ByteBuf) obj;
    assertEquals(4 + 3, byteBuf.readableBytes(),
        "The TCP on ISO Header should add 4 bytes to the data sent");
    assertEquals(IsoOnTcpProtocol.ISO_ON_TCP_MAGIC_NUMBER, byteBuf.getByte(0));
    assertEquals(4 + 3, byteBuf.getShort(2),
        "The length value in the packet should reflect the size of the entire data being sent");
}
项目:incubator-plc4x    文件:IsoOnTcpProtocolTest.java   
/**
 * Happy path test.
 */
@Test
@Tag("fast")
public void decode() {
    EmbeddedChannel channel = new EmbeddedChannel(new IsoOnTcpProtocol());
    channel.writeInbound(Unpooled.wrappedBuffer(new byte[]{IsoOnTcpProtocol.ISO_ON_TCP_MAGIC_NUMBER,
        (byte)0x00,(byte)0x00,(byte)0x0D,
        (byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09}));
    channel.checkException();
    Object obj = channel.readInbound();
    assertThat(obj).isInstanceOf(IsoOnTcpMessage.class);
    IsoOnTcpMessage isoOnTcpMessage = (IsoOnTcpMessage) obj;
    assertNotNull(isoOnTcpMessage.getUserData());
    assertEquals(9, isoOnTcpMessage.getUserData().readableBytes());
}
项目:incubator-plc4x    文件:S7ProtocolTest.java   
@Test
@Tag("fast")
public void encode() throws Exception {
    //TODO: finish me
    LinkedList<Object> out = new LinkedList<>();
    SUT.encode(null, new S7RequestMessage(
        MessageType.ACK,
        (short) 1,
        singletonList(new VarParameter(ParameterType.WRITE_VAR, singletonList(new S7AnyVarParameterItem(
            SpecificationType.VARIABLE_SPECIFICATION, MemoryArea.DATA_BLOCKS, TransportSize.BIT, (short) 1, (short) 1, (short) 1, (byte) 1
        )))),
        singletonList(new VarPayload(
            ParameterType.WRITE_VAR,
            singletonList(new VarPayloadItem(
                DataTransportErrorCode.OK,
                DataTransportSize.BYTE_WORD_DWORD, new byte[]{0})
            ))
        )), out);
    assertThat(out).hasSize(1);
}
项目:incubator-plc4x    文件:S7ProtocolTest.java   
@Test
@Tag("fast")
public void decode() throws Exception {
    //TODO: finish me
    LinkedList<Object> out = new LinkedList<>();
    ByteBuf buffer = Unpooled.buffer();
    // Magic Number
    buffer.writeByte(0x32);
    buffer.writeByte(MessageType.JOB.getCode());
    // Reserved magic value
    buffer.writeShort(0x0000);
    // tpduReference
    buffer.writeShort(0x0000);
    // headerParametersLength
    buffer.writeShort(0x0000);
    // userDataLength
    buffer.writeShort(0x0000);
    SUT.decode(null, new IsoTPMessage(mock(Tpdu.class), buffer), out);
    assertThat(out).hasSize(1);
}
项目:incubator-plc4x    文件:S7MessageTests.java   
@Test
@Tag("fast")
void s7ResponseMessage() {
    MessageType messageType = MessageType.USER_DATA;
    short tpduReference = 1;
    ArrayList<S7Parameter> s7Parameters = null;
    ArrayList<S7Payload> s7Payloads = null;
    byte errorClass = 0x1;
    byte errorCode = 0x23;

    S7ResponseMessage message = new S7ResponseMessage(messageType, tpduReference, s7Parameters, s7Payloads, errorClass, errorCode);

    assertTrue(message.getTpduReference() == tpduReference, "Unexpected tpdu value");
    assertTrue(message.getMessageType() == MessageType.USER_DATA, "Unexpected message type");
    assertTrue(message.getErrorClass() == 0x1, "Unexpected error class");
    assertTrue(message.getErrorCode() == 0x23, "Unexpected error code");
    assertTrue(message.getPayloads() == null, "Unexpected payloads");
    assertTrue(message.getParameters() == null, "Unexpected parameters");
}
项目:mastering-junit5    文件:TestInfoTest.java   
@Test
@DisplayName("My test")
@Tag("my-tag")
void testOne(TestInfo testInfo) {
    System.out.println(testInfo.getDisplayName());
    System.out.println(testInfo.getTags());
    System.out.println(testInfo.getTestClass());
    System.out.println(testInfo.getTestMethod());
}
项目:incubator-plc4x    文件:S7PlcDriverTest.java   
/**
 * In this test case the 's7' driver should report an invalid url format.
 *
 * @throws PlcException something went wrong
 */
@Test
@Tag("fast")
void getConnectionInvalidUrl() throws PlcException {
    Assertions.assertThrows(PlcConnectionException.class,
        () -> new PlcDriverManager().getConnection("s7://localhost/hurz/2"));
}
项目:pandemie    文件:CarteInfectionTest.java   
@Tag("Test lien verso de la carte") 
@Test
public void testLinkVerso() {
    String tmp = path.concat("/Verso.jpg");
    assertTrue(maCarteBleu.linkImgVerso().equals(tmp));
    assertTrue(maCarteNoir.linkImgVerso().equals(tmp));
    assertTrue(maCarteRouge.linkImgVerso().equals(tmp));
    assertTrue(maCarteJaune.linkImgVerso().equals(tmp));
}
项目:pandemie    文件:CarteReferenceTest.java   
@Tag("Test lien verso de la carte") 
@Test
public void testLinkVerso() {
    String tmp = path.concat("/Rev_Verso_1.jpg");
    assertTrue(maCarte.linkImgVerso().equals(tmp));

}
项目:pandemie    文件:CarteRoleTest.java   
@Tag("Test lien verso de la carte") 
@Test
public void testLinkVerso() {
    String tmp = path.concat("/Verso.jpg");
    assertTrue(maCarte.linkImgVerso().equals(tmp));

}
项目:pandemie    文件:CarteRoleTest.java   
@Tag("Test lien recto de la carte") 
@Test
public void testLinkRecto() {
    String tmp = path.concat("/"+role.name()+".jpg");
    assertTrue(maCarte.linkImg().equals(tmp));

}
项目:incubator-plc4x    文件:PlcFunctionsTest.java   
@SuppressWarnings("unchecked")
@Test
@Tag("fast")
public void testSupplier() throws Exception {
  String addressStr = "MyReadWriteAddress/0";
  MockAddress address = new MockAddress(addressStr);
  PlcConnectionAdapter adapter = new PlcConnectionAdapter(getMockConnection());
  MockConnection connection = (MockConnection) adapter.getConnection();

  Supplier<?> supplier;

  supplier = PlcFunctions.booleanSupplier(adapter, addressStr);
  PlcConnectionAdapterTest.checkSupplier(connection, address, (Supplier<Boolean>)supplier, true, false);

  supplier = PlcFunctions.byteSupplier(adapter, addressStr);
  PlcConnectionAdapterTest.checkSupplier(connection, address, (Supplier<Byte>)supplier, (byte)0x1, (byte)0x2, (byte)0x3);

  supplier = PlcFunctions.shortSupplier(adapter, addressStr);
  PlcConnectionAdapterTest.checkSupplier(connection, address, (Supplier<Short>)supplier, (short)1, (short)2, (short)3);

  supplier = PlcFunctions.integerSupplier(adapter, addressStr);
  PlcConnectionAdapterTest.checkSupplier(connection, address, (Supplier<Integer>)supplier, 1000, 1001, 1002);

  supplier = PlcFunctions.floatSupplier(adapter, addressStr);
  PlcConnectionAdapterTest.checkSupplier(connection, address, (Supplier<Float>)supplier, 1000.5f, 1001.5f, 1002.5f);

  supplier = PlcFunctions.stringSupplier(adapter, addressStr);
  PlcConnectionAdapterTest.checkSupplier(connection, address, (Supplier<String>)supplier, "one", "two", "three");

  adapter.close();
}
项目:incubator-plc4x    文件:PlcFunctionsTest.java   
@SuppressWarnings("unchecked")
@Test
@Tag("fast")
public void testNewConsumer1() throws Exception {
  String addressStr = "MyReadWriteAddress/0";
  MockAddress address = new MockAddress(addressStr);
  PlcConnectionAdapter adapter = new PlcConnectionAdapter(getMockConnection());
  MockConnection connection = (MockConnection) adapter.getConnection();

  Consumer<?> consumer;

  consumer = PlcFunctions.booleanConsumer(adapter, addressStr);
  PlcConnectionAdapterTest.checkConsumer(connection, address, (Consumer<Boolean>)consumer, true, false);

  consumer = PlcFunctions.byteConsumer(adapter, addressStr);
  PlcConnectionAdapterTest.checkConsumer(connection, address, (Consumer<Byte>)consumer, (byte)0x1, (byte)0x2, (byte)0x3);

  consumer = PlcFunctions.shortConsumer(adapter, addressStr);
  PlcConnectionAdapterTest.checkConsumer(connection, address, (Consumer<Short>)consumer, (short)1, (short)2, (short)3);

  consumer = PlcFunctions.integerConsumer(adapter, addressStr);
  PlcConnectionAdapterTest.checkConsumer(connection, address, (Consumer<Integer>)consumer, 1000, 1001, 1002);

  consumer = PlcFunctions.floatConsumer(adapter, addressStr);
  PlcConnectionAdapterTest.checkConsumer(connection, address, (Consumer<Float>)consumer, 1000.5f, 1001.5f, 1002.5f);

  consumer = PlcFunctions.stringConsumer(adapter, addressStr);
  PlcConnectionAdapterTest.checkConsumer(connection, address, (Consumer<String>)consumer, "one", "two", "three");

  adapter.close();
}
项目:incubator-plc4x    文件:PlcFunctionsTest.java   
@Test
@Tag("fast")
public void testNewConsumer2() throws Exception {
  String addressStr = "MyReadWriteAddress/0";
  MockAddress address = new MockAddress(addressStr);
  PlcConnectionAdapter adapter = new PlcConnectionAdapter(getMockConnection());
  MockConnection connection = (MockConnection) adapter.getConnection();

  Consumer<JsonObject> consumer;

  Function<JsonObject,String> addressFn = t -> t.get("address").getAsString(); 

  consumer = PlcFunctions.booleanConsumer(adapter, addressFn, t -> t.get("value").getAsBoolean());
  PlcConnectionAdapterTest.checkConsumerJson(connection, address, consumer, true, false);

  consumer = PlcFunctions.byteConsumer(adapter, addressFn, t -> t.get("value").getAsByte());
  PlcConnectionAdapterTest.checkConsumerJson(connection, address, consumer, (byte)0x1, (byte)0x2, (byte)0x3);

  consumer = PlcFunctions.shortConsumer(adapter, addressFn, t -> t.get("value").getAsShort());
  PlcConnectionAdapterTest.checkConsumerJson(connection, address, consumer, (short)1, (short)2, (short)3);

  consumer = PlcFunctions.integerConsumer(adapter, addressFn, t -> t.get("value").getAsInt());
  PlcConnectionAdapterTest.checkConsumerJson(connection, address, consumer, 1000, 1001, 1002);

  consumer = PlcFunctions.floatConsumer(adapter, addressFn, t -> t.get("value").getAsFloat());
  PlcConnectionAdapterTest.checkConsumerJson(connection, address, consumer, 1000.5f, 1001.5f, 1002.5f);

  consumer = PlcFunctions.stringConsumer(adapter, addressFn, t -> t.get("value").getAsString());
  PlcConnectionAdapterTest.checkConsumerJson(connection, address, consumer, "one", "two", "three");

  adapter.close();
}
项目:incubator-plc4x    文件:PlcConnectionAdapterTest.java   
@Test
@Tag("fast")
public void testCtor2() throws Exception {
  MockConnection mockConnection = getMockConnection();
  PlcConnectionAdapter adapter = new PlcConnectionAdapter(mockConnection.getUrl());
  MockConnection mockConnection2 = (MockConnection) adapter.getConnection();
  Assertions.assertNotSame(mockConnection, mockConnection2);
  Assertions.assertSame(mockConnection.getUrl(), mockConnection2.getUrl());
  // and again... multiple adapter.getConnection() returns the same
  Assertions.assertSame(mockConnection2, adapter.getConnection());
  adapter.close();
}
项目:incubator-plc4x    文件:S7TypeTests.java   
@Test
@Tag("fast")
void unknownDataTransportErrorCode() {
    DataTransportErrorCode dataTransportErrorCode = DataTransportErrorCode.INVALID_ADDRESS;

    assertTrue(DataTransportErrorCode.valueOf((byte)0xFE) == null, "Unexpected value mapped");
}
项目:incubator-plc4x    文件:PlcConnectionAdapterTest.java   
@Test
@Tag("fast")
public void testNewConsumer1() throws Exception {
  String addressStr = "MyReadWriteAddress/0";
  MockAddress address = new MockAddress(addressStr);
  PlcConnectionAdapter adapter = new PlcConnectionAdapter(getMockConnection());
  MockConnection connection = (MockConnection) adapter.getConnection();

  Consumer<?> consumer;

  consumer = adapter.newConsumer(Boolean.class, addressStr);
  Assertions.assertNotSame(consumer, adapter.newConsumer(Boolean.class, addressStr));
  checkConsumer(connection, address, consumer, true, false);

  consumer = adapter.newConsumer(Byte.class, addressStr);
  checkConsumer(connection, address, consumer, (byte)0x1, (byte)0x2, (byte)0x3);

  consumer = adapter.newConsumer(Short.class, addressStr);
  checkConsumer(connection, address, consumer, (short)1, (short)2, (short)3);

  consumer = adapter.newConsumer(Integer.class, addressStr);
  checkConsumer(connection, address, consumer, 1000, 1001, 1002);

  consumer = adapter.newConsumer(Float.class, addressStr);
  checkConsumer(connection, address, consumer, 1000.5f, 1001.5f, 1002.5f);

  consumer = adapter.newConsumer(String.class, addressStr);
  checkConsumer(connection, address, consumer, "one", "two", "three");

  adapter.close();
}
项目:incubator-plc4x    文件:PlcConnectionAdapterTest.java   
@Test
@Tag("fast")
public void testNewConsumer2() throws Exception {
  String addressStr = "MyReadWriteAddress/0";
  MockAddress address = new MockAddress(addressStr);
  PlcConnectionAdapter adapter = new PlcConnectionAdapter(getMockConnection());
  MockConnection connection = (MockConnection) adapter.getConnection();

  Consumer<JsonObject> consumer;

  Function<JsonObject,String> addressFn = t -> t.get("address").getAsString(); 

  consumer = adapter.newConsumer(Boolean.class, addressFn, t -> t.get("value").getAsBoolean());
  checkConsumerJson(connection, address, consumer, true, false);

  consumer = adapter.newConsumer(Byte.class, addressFn, t -> t.get("value").getAsByte());
  checkConsumerJson(connection, address, consumer, (byte)0x1, (byte)0x2, (byte)0x3);

  consumer = adapter.newConsumer(Short.class, addressFn, t -> t.get("value").getAsShort());
  checkConsumerJson(connection, address, consumer, (short)1, (short)2, (short)3);

  consumer = adapter.newConsumer(Integer.class, addressFn, t -> t.get("value").getAsInt());
  checkConsumerJson(connection, address, consumer, 1000, 1001, 1002);

  consumer = adapter.newConsumer(Float.class, addressFn, t -> t.get("value").getAsFloat());
  checkConsumerJson(connection, address, consumer, 1000.5f, 1001.5f, 1002.5f);

  consumer = adapter.newConsumer(String.class, addressFn, t -> t.get("value").getAsString());
  checkConsumerJson(connection, address, consumer, "one", "two", "three");

  adapter.close();
}