Пример #1
0
  @Test
  public void testSerialization() throws IOException, QException {
    final QExpressions qe = new QExpressions("src/test/resources/QExpressions.out");

    for (final String expr : qe.getExpressions()) {
      serializeObject(qe.getReferenceObject(expr), qe, expr);

      if (qe.hasReferenceObjectAlt(expr)) {
        serializeObject(qe.getReferenceObjectAlt(expr), qe, expr);
      }
    }
  }
Пример #2
0
  protected void serializeObject(
      final Object referenceObject, final QExpressions qe, final String expr)
      throws IOException, QException, ArrayComparisonFailure {
    final ByteArrayOutputStream stream = new ByteArrayOutputStream();
    final QWriter writer = new QWriter(stream, "ISO-8859-1", 3);
    writer.write(referenceObject, QConnection.MessageType.SYNC);

    final byte[] out = stream.toByteArray();

    assertArrayEquals(
        "Serialization failed for q expression: " + expr,
        qe.getBinaryExpression(expr),
        copyOfRange(out, 8, out.length));
  }