Пример #1
0
  public void testByteArraytobyteArray() throws Exception {
    Byte[] input = new Byte[3];
    input[0] = new Byte((byte) 0);
    input[1] = new Byte((byte) 1);
    input[2] = new Byte((byte) 2);

    byte[] output = new byte[3];

    if (ConvertUtils.isConvertable(input, output.getClass())) {
      output = (byte[]) ConvertUtils.convert(input, output.getClass());
    }

    assertTrue(output.length == 3);
    assertTrue(output[0] == (byte) 0);
    assertTrue(output[1] == (byte) 1);
    assertTrue(output[2] == (byte) 2);
  }
Пример #2
0
  public void testBArraytoBList() throws Exception {

    B[] input = new B[3];
    input[0] = new B();
    input[0].setData(0);
    input[1] = new B();
    input[1].setData(1);
    input[2] = new B();
    input[2].setData(2);

    ArrayList<B> output = new ArrayList<B>();

    if (ConvertUtils.isConvertable(input, output.getClass())) {
      output = (ArrayList<B>) ConvertUtils.convert(input, output.getClass());
    }

    assertTrue(output.size() == 3);
    assertTrue(output.get(0).getData() == 0);
    assertTrue(output.get(1).getData() == 1);
    assertTrue(output.get(2).getData() == 2);
  }
Пример #3
0
  public void testBListtoBArray() throws Exception {
    ArrayList<B> input = new ArrayList<B>();
    B b = new B();
    b.setData(0);
    input.add(b);
    b = new B();
    b.setData(1);
    input.add(b);
    b = new B();
    b.setData(2);
    input.add(b);

    B[] output = new B[0];

    if (ConvertUtils.isConvertable(input, output.getClass())) {
      output = (B[]) ConvertUtils.convert(input, output.getClass());
    }

    assertTrue(output.length == 3);
    assertTrue(output[0].getData() == 0);
    assertTrue(output[1].getData() == 1);
    assertTrue(output[2].getData() == 2);
  }