org.red5.io.object.Deserializer Java Examples

The following examples show how to use org.red5.io.object.Deserializer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractIOTest.java    From red5-io with Apache License 2.0 6 votes vote down vote up
@Test
public void testLongString() {
    log.debug("\ntestLongString");
    byte[] rndStr = new byte[AMF.LONG_STRING_LENGTH];
    Arrays.fill(rndStr, (byte) 0x65);
    //Random rnd = new Random();
    //rnd.nextBytes(rndStr);
    String inStr = new String(rndStr, StandardCharsets.UTF_8);
    //String inStr = RandomStringUtils.random(AMF.LONG_STRING_LENGTH);
    //log.trace(inStr);
    Serializer.serialize(out, inStr);
    dumpOutput();
    String outStr = Deserializer.deserialize(in, String.class);
    assertEquals(inStr, outStr);
    resetOutput();
}
 
Example #2
Source File: AMF3IOTest.java    From red5-io with Apache License 2.0 6 votes vote down vote up
@Test
public void testVectorMixedInput() {
    log.debug("\n Testing Vector<Object>");
    //100700010607666f6f010a13256f72672e726564352e74673742e466f6f33000403
    //[foo, null, org.red5.test.Foo3[foo=0]] // Foo3 is a class instance
    byte[] v2 = new byte[] { (byte) 0x10, (byte) 0x07, (byte) 0x00, (byte) 0x01, (byte) 0x06, (byte) 0x07, (byte) 0x66, (byte) 0x6f, (byte) 0x6f, (byte) 0x01, (byte) 0x0a, (byte) 0x13, (byte) 0x25, (byte) 0x6f, (byte) 0x72, (byte) 0x67, (byte) 0x2e, (byte) 0x72, (byte) 0x65, (byte) 0x64, (byte) 0x35, (byte) 0x2e, (byte) 0x74, (byte) 0x65, (byte) 0x73, (byte) 0x74, (byte) 0x2e, (byte) 0x46, (byte) 0x6f,
            (byte) 0x6f, (byte) 0x33, (byte) 0x00, (byte) 0x04, (byte) 0x03 };

    in = new Input(IoBuffer.wrap(v2));
    List<Object> vectorOut = Deserializer.deserialize(in, null);
    assertNotNull(vectorOut);
    assertEquals(vectorOut.size(), 3);
    for (int i = 0; i < vectorOut.size(); i++) {
        System.err.println("Vector: " + vectorOut.get(i));
    }
    resetOutput();
}
 
Example #3
Source File: RTMPProtocolDecoder.java    From red5-server-common with Apache License 2.0 6 votes vote down vote up
/**
 * Sets incoming connection parameters and / or returns encoded parameters for use in a call.
 * 
 * @param in
 * @param notify
 * @param input
 * @return parameters array
 */
private Object[] handleParameters(IoBuffer in, Notify notify, Input input) {
    Object[] params = new Object[] {};
    List<Object> paramList = new ArrayList<>();
    final Object obj = Deserializer.deserialize(input, Object.class);
    if (obj instanceof Map) {
        // Before the actual parameters we sometimes (connect) get a map of parameters, this is usually null, but if set should be
        // passed to the connection object.
        @SuppressWarnings("unchecked")
        final Map<String, Object> connParams = (Map<String, Object>) obj;
        notify.setConnectionParams(connParams);
    } else if (obj != null) {
        paramList.add(obj);
    }
    while (in.hasRemaining()) {
        paramList.add(Deserializer.deserialize(input, Object.class));
    }
    params = paramList.toArray();
    if (log.isDebugEnabled()) {
        log.debug("Num params: {}", paramList.size());
        for (int i = 0; i < params.length; i++) {
            log.debug(" > {}: {}", i, params[i]);
        }
    }
    return params;
}
 
Example #4
Source File: AMF3IOTest.java    From red5-io with Apache License 2.0 6 votes vote down vote up
@Test
public void testVectorNumberInput() {
    log.debug("\n Testing Vector<Number>");
    //0F0F003FF199999999999ABFF199999999999A7FEFFFFFFFFFFFFF0000000000000001FFF8000000000000FFF00000000000007FF0000000000000
    byte[] v = new byte[] { (byte) 0x0F, (byte) 0x0F, (byte) 0x00, (byte) 0x3F, (byte) 0xF1, (byte) 0x99, (byte) 0x99, (byte) 0x99, (byte) 0x99, (byte) 0x99, (byte) 0x9A, (byte) 0xBF, (byte) 0xF1, (byte) 0x99, (byte) 0x99, (byte) 0x99, (byte) 0x99, (byte) 0x99, (byte) 0x9A, (byte) 0x7F, (byte) 0xEF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0x00, (byte) 0x00,
            (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0xFF, (byte) 0xF8, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0xFF, (byte) 0xF0, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x7F, (byte) 0xF0, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 };

    in = new Input(IoBuffer.wrap(v));
    List<Double> vectorOut = Deserializer.deserialize(in, null);
    //[1.1, -1.1, 1.7976931348623157E308, 4.9E-324, NaN, -Infinity, Infinity]
    assertNotNull(vectorOut);
    assertEquals(vectorOut.size(), 7);
    for (int i = 0; i < vectorOut.size(); i++) {
        System.err.println("Vector: " + vectorOut.get(i));
    }
    resetOutput();
}
 
Example #5
Source File: RemotingClient.java    From red5-server-common with Apache License 2.0 6 votes vote down vote up
/**
 * Decode response received from remoting server.
 * 
 * @param data
 *            Result data to decode
 * @return Object deserialized from byte buffer data
 */
private Object decodeResult(IoBuffer data) {
    log.debug("decodeResult - data limit: {}", (data != null ? data.limit() : 0));
    processHeaders(data);
    int count = data.getUnsignedShort();
    if (count != 1) {
        throw new RuntimeException("Expected exactly one result but got " + count);
    }
    Input input = new Input(data);
    String target = input.getString(); // expect "/onResult"
    log.debug("Target: {}", target);
    String nullString = input.getString(); // expect "null"
    log.debug("Null string: {}", nullString);
    // Read return value
    return Deserializer.deserialize(input, Object.class);
}
 
Example #6
Source File: AMF3IOTest.java    From red5-io with Apache License 2.0 6 votes vote down vote up
@Test
public void testVectorIntInput() {
    log.debug("\n Testing Vector<int>");
    //0D090000000002000007D07FFFFFFF80000000
    byte[] v = new byte[] { (byte) 0x0D, (byte) 0x09, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x02, (byte) 0x00, (byte) 0x00, (byte) 0x07, (byte) 0xD0, (byte) 0x7F, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0x80, (byte) 0x00, (byte) 0x00, (byte) 0x00 };

    in = new Input(IoBuffer.wrap(v));
    List<Object> vectorOut = Deserializer.deserialize(in, null);
    //[2, 2000, 2147483647, -2147483648]
    assertNotNull(vectorOut);
    assertEquals(vectorOut.size(), 4);
    for (int i = 0; i < vectorOut.size(); i++) {
        System.err.println("Vector: " + vectorOut.get(i));
    }
    resetOutput();
}
 
Example #7
Source File: Input.java    From red5-io with Apache License 2.0 6 votes vote down vote up
@Override
public Object readArray(Type target) {
    log.debug("readArray - target: {}", target);
    Object result = null;
    int count = buf.getInt();
    log.debug("Count: {}", count);
    // To conform to the Input API, we should convert the output into an Array if the Type asks us to.
    Class<?> collection = Collection.class;
    if (target instanceof Class<?>) {
        collection = (Class<?>) target;
    }
    List<Object> resultCollection = new ArrayList<>(count);
    if (collection.isArray()) {
        result = ArrayUtils.getArray(collection.getComponentType(), count);
    } else {
        result = resultCollection;
    }
    storeReference(result); // reference should be stored before reading of objects to get correct refIds
    for (int i = 0; i < count; i++) {
        resultCollection.add(Deserializer.deserialize(this, Object.class));
    }
    if (collection.isArray()) {
        ArrayUtils.fillArray(collection.getComponentType(), result, resultCollection);
    }
    return result;
}
 
Example #8
Source File: AMF3IOTest.java    From red5-io with Apache License 2.0 6 votes vote down vote up
@Test
public void testByteArray() {
    log.debug("\n Testing ByteArray");
    // just some ones and such
    ByteArray baIn = new ByteArray();
    baIn.writeBytes(new byte[] { (byte) 0, (byte) 0x1, (byte) 0x42, (byte) 0x1, (byte) 0x42, (byte) 0x1, (byte) 0x42, (byte) 0x1, (byte) 0x42, (byte) 0x1, (byte) 0x42, (byte) 0x1, (byte) 0x42, (byte) 0x1, (byte) 0x42, (byte) 0x1, (byte) 0x42, (byte) 0x99 });
    Serializer.serialize(out, baIn);
    dumpOutput();
    ByteArray baOut = Deserializer.deserialize(in, ByteArray.class);
    assertNotNull(baOut);
    assertEquals(baIn.length(), baOut.length());
    for (int i = 0; i < baOut.length(); i++) {
        System.err.println("Byte: " + baOut.readByte());
    }
    resetOutput();
}
 
Example #9
Source File: AbstractIOTest.java    From red5-io with Apache License 2.0 6 votes vote down vote up
@Test
public void testMap() {
    log.debug("\ntestMap");
    Map<String, Object> mapIn = new HashMap<>();
    mapIn.put("testNumber", 34d); //numbers are stored as double
    mapIn.put("testString", "wicked awesome");
    mapIn.put("testBean", new SimpleJavaBean());
    mapIn.put("21.0.1", "version");
    mapIn.put("2.1", "version2");
    Serializer.serialize(out, mapIn);
    dumpOutput();
    Map<?, ?> mapOut = Deserializer.deserialize(in, Map.class);
    log.info("mapOut: {}", mapOut);
    assertNotNull(mapOut);
    assertEquals(mapIn.size(), mapOut.size());
    for (Map.Entry<String, Object> entry : mapIn.entrySet()) {
        String key = entry.getKey();
        Object iVal = entry.getValue();
        Object oVal = mapOut.get(key);
        assertNotNull(oVal);
        assertEquals(iVal, oVal);
    }
    resetOutput();
}
 
Example #10
Source File: AMFIOTest.java    From red5-io with Apache License 2.0 6 votes vote down vote up
@Test
public void testAMF0Connect() {
    log.debug("\ntestAMF0Connect");
    IoBuffer data = IoBuffer.wrap(IOUtils.hexStringToByteArray(
            "020007636f6e6e656374003ff00000000000000300036170700200086f666c6144656d6f0008666c61736856657202000e4c4e582032302c302c302c323836000673776655726c020029687474703a2f2f6c6f63616c686f73743a353038302f64656d6f732f6f666c615f64656d6f2e7377660005746355726c02001972746d703a2f2f6c6f63616c686f73742f6f666c6144656d6f0004667061640100000c6361706162696c697469657300406de00000000000000b617564696f436f646563730040abee0000000000000b766964656f436f6465637300406f800000000000000d766964656f46756e6374696f6e003ff000000000000000077061676555726c02002a687474703a2f2f6c6f63616c686f73743a353038302f64656d6f732f6f666c615f64656d6f2e68746d6c000009"));
    Input in0 = new Input(data);
    // action string
    Assert.assertEquals(DataTypes.CORE_STRING, in0.readDataType());
    String action = in0.readString();
    Assert.assertEquals("connect", action);
    // invoke trasaction id
    log.trace("Before reading number type: {}", data.position());
    byte type = in0.readDataType();
    log.trace("After reading number type({}): {}", type, data.position());
    Assert.assertEquals(DataTypes.CORE_NUMBER, type);
    Number transactionId = in0.readNumber();
    System.out.printf("Number - i: %d d: %f%n", transactionId.intValue(), transactionId.doubleValue());
    Map<String, Object> obj1 = Deserializer.deserialize(in0, Map.class);
    assertNotNull("Connection parameters should be valid", obj1);
    log.debug("Parameters: {}", obj1.toString());
    assertEquals("Application does not match", "oflaDemo", obj1.get("app"));
}
 
Example #11
Source File: AbstractIOTest.java    From red5-io with Apache License 2.0 5 votes vote down vote up
@Test
public void testNumberInteger() {
    log.debug("\ntestNumberInteger");
    for (Number n : new Number[] { Integer.MIN_VALUE, Integer.MAX_VALUE, 1024, rnd.nextInt(Integer.MAX_VALUE) }) {
        Serializer.serialize(out, n);
        dumpOutput();
        Number rn = Deserializer.deserialize(in, Number.class);
        assertEquals("Deserialized Integer should be the same", n, rn.intValue());
        resetOutput();
    }
}
 
Example #12
Source File: AbstractIOTest.java    From red5-io with Apache License 2.0 5 votes vote down vote up
@Test
public void testBoolean() {
    log.debug("\ntestBoolean");
    Serializer.serialize(out, Boolean.TRUE);
    dumpOutput();
    Boolean val = Deserializer.deserialize(in, Boolean.class);
    assertEquals(Boolean.TRUE, val);
    resetOutput();
    Serializer.serialize(out, Boolean.FALSE);
    dumpOutput();
    val = Deserializer.deserialize(in, Boolean.class);
    assertEquals(Boolean.FALSE, val);
    resetOutput();
}
 
Example #13
Source File: AbstractIOTest.java    From red5-io with Apache License 2.0 5 votes vote down vote up
@Test
public void testCircularReference() {
    log.debug("\ntestCircularReference");
    CircularRefBean beanIn = new CircularRefBean();
    beanIn.setRefToSelf(beanIn);
    Serializer.serialize(out, beanIn);

    dumpOutput();
    CircularRefBean beanOut = Deserializer.deserialize(in, CircularRefBean.class);
    assertNotNull(beanOut);
    assertEquals(beanOut, beanOut.getRefToSelf());
    assertEquals(beanIn.getNameOfBean(), beanOut.getNameOfBean());
    resetOutput();
}
 
Example #14
Source File: AbstractIOTest.java    From red5-io with Apache License 2.0 5 votes vote down vote up
@Test
public void testDate() {
    log.debug("\ntestDate");
    Date dateIn = new Date();
    Serializer.serialize(out, dateIn);
    dumpOutput();
    Date dateOut = Deserializer.deserialize(in, Date.class);
    assertEquals(dateIn, dateOut);
    resetOutput();
}
 
Example #15
Source File: AbstractIOTest.java    From red5-io with Apache License 2.0 5 votes vote down vote up
@Test
@SuppressWarnings({ "rawtypes" })
public void testJavaBean() {
    log.debug("\ntestJavaBean");
    TestJavaBean beanIn = new TestJavaBean();
    beanIn.setTestString("test string here");
    beanIn.setTestBoolean((System.currentTimeMillis() % 2 == 0) ? true : false);
    beanIn.setTestBooleanObject((System.currentTimeMillis() % 2 == 0) ? Boolean.TRUE : Boolean.FALSE);
    beanIn.setTestNumberObject(Integer.valueOf((int) System.currentTimeMillis() / 1000));
    Serializer.serialize(out, beanIn);
    dumpOutput();
    Object mapOrBean = Deserializer.deserialize(in, Object.class);
    assertEquals(beanIn.getClass().getName(), mapOrBean.getClass().getName());
    Map<?, ?> map = (mapOrBean instanceof Map) ? (Map<?, ?>) mapOrBean : new BeanMap(mapOrBean);
    Set<?> entrySet = map.entrySet();
    Iterator<?> it = entrySet.iterator();
    Map beanInMap = new BeanMap(beanIn);
    assertEquals(beanInMap.size(), map.size());
    while (it.hasNext()) {
        Map.Entry entry = (Map.Entry) it.next();
        String propOut = (String) entry.getKey();
        Object valueOut = entry.getValue();
        assertTrue(beanInMap.containsKey(propOut));
        assertEquals(valueOut, beanInMap.get(propOut));
    }
    resetOutput();
}
 
Example #16
Source File: AbstractIOTest.java    From red5-io with Apache License 2.0 5 votes vote down vote up
@Test
public void testNull() {
    log.debug("\ntestNull");
    Serializer.serialize(out, null);
    dumpOutput();
    Object val = Deserializer.deserialize(in, Object.class);
    assertEquals(val, null);
    resetOutput();
}
 
Example #17
Source File: AbstractIOTest.java    From red5-io with Apache License 2.0 5 votes vote down vote up
public void testNumberLong() {
    log.debug("\ntestNumberLong");
    for (Number n : new Number[] { Long.MIN_VALUE, rnd.nextLong(), -666L, 0L, 666L, Long.MAX_VALUE }) {
        Serializer.serialize(out, n);
        dumpOutput();
        Number rn = Deserializer.deserialize(in, Number.class);
        assertEquals("Deserialized Long should be the same", n, rn.longValue());
        resetOutput();
    }
}
 
Example #18
Source File: SharedObject.java    From red5-server-common with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@SuppressWarnings({ "unchecked", "rawtypes" })
public void deserialize(Input input) throws IOException {
    log.debug("deserialize");
    name = Deserializer.deserialize(input, String.class);
    log.trace("Name: {}", name);
    persistent = true;
    Map<String, Object> map = Deserializer.<Map> deserialize(input, Map.class);
    if (log.isTraceEnabled()) {
        log.trace("Attributes: {}", map);
    }
    super.setAttributes(map);
    ownerMessage.setName(name);
    ownerMessage.setPersistent(persistent);
}
 
Example #19
Source File: AbstractIOTest.java    From red5-io with Apache License 2.0 5 votes vote down vote up
@Test
public void testNumberFloat() {
    log.debug("\ntestNumberFloat");
    for (Number n : new Number[] { Float.MIN_VALUE, Float.MIN_NORMAL, Float.MAX_VALUE, rnd.nextFloat(), 666.6666f }) {
        Serializer.serialize(out, n);
        dumpOutput();
        Number rn = Deserializer.deserialize(in, Number.class);
        assertEquals("Deserialized Float should be the same", (Float) n, (Float) rn.floatValue());
        resetOutput();
    }
}
 
Example #20
Source File: AbstractIOTest.java    From red5-io with Apache License 2.0 5 votes vote down vote up
@Test
public void testNumberDouble() {
    log.debug("\ntestNumberDouble");
    for (Number n : new Number[] { 1.056d, Double.MIN_VALUE, Double.MAX_VALUE, Double.valueOf(899.45678d), rnd.nextDouble() }) {
        Serializer.serialize(out, n);
        dumpOutput();
        Number rn = Deserializer.deserialize(in, Number.class);
        assertEquals("Deserialized number should be the same", n, rn.doubleValue());
        resetOutput();
    }
}
 
Example #21
Source File: AbstractIOTest.java    From red5-io with Apache License 2.0 5 votes vote down vote up
@Test
public void testNumber() {
    log.debug("\ntestNumber");
    int num = 1000;
    Serializer.serialize(out, Integer.valueOf(num));
    dumpOutput();
    Number n = Deserializer.deserialize(in, Number.class);
    assertEquals(n.intValue(), num);
    resetOutput();
}
 
Example #22
Source File: AbstractIOTest.java    From red5-io with Apache License 2.0 5 votes vote down vote up
@Test
public void testInteger() {
    log.debug("\ntestInteger");
    int num = 129;
    Serializer.serialize(out, Integer.valueOf(num));
    dumpOutput();
    int n = ((Number) Deserializer.deserialize(in, Number.class)).intValue();
    assertEquals(n, num);
    resetOutput();
}
 
Example #23
Source File: AbstractIOTest.java    From red5-io with Apache License 2.0 5 votes vote down vote up
@Test
public void testNegativeInteger() {
    log.debug("\ntestNegativeInteger");
    int num = -129;
    Serializer.serialize(out, Integer.valueOf(num));
    dumpOutput();
    int n = ((Number) Deserializer.deserialize(in, Number.class)).intValue();
    log.debug("Integer: {} {}", n, num);
    assertEquals(n, num);
    resetOutput();
}
 
Example #24
Source File: AbstractIOTest.java    From red5-io with Apache License 2.0 5 votes vote down vote up
@Test
@SuppressWarnings({})
public void testSimpleReference() {
    log.debug("\ntestSimpleReference");
    Map<String, Object> mapIn = new HashMap<String, Object>();
    Object bean = new SimpleJavaBean();
    mapIn.put("thebean", bean);
    mapIn.put("thesamebeanagain", bean);
    // mapIn.put("thismap",mapIn);
    Serializer.serialize(out, mapIn);

    dumpOutput();
    Map<?, ?> mapOut = Deserializer.deserialize(in, Map.class);
    assertNotNull(mapOut);
    assertEquals(mapIn.size(), mapOut.size());

    Set<?> entrySet = mapOut.entrySet();
    Iterator<?> it = entrySet.iterator();
    while (it.hasNext()) {
        Map.Entry<?, ?> entry = (Map.Entry<?, ?>) it.next();
        String propOut = (String) entry.getKey();
        SimpleJavaBean valueOut = (SimpleJavaBean) entry.getValue();
        assertNotNull("couldn't get output bean", valueOut);
        assertTrue(mapIn.containsKey(propOut));
        SimpleJavaBean valueIn = (SimpleJavaBean) mapIn.get(propOut);
        assertNotNull("couldn't get input bean", valueIn);
        assertEquals(valueOut.getNameOfBean(), valueIn.getNameOfBean());
    }
    resetOutput();
}
 
Example #25
Source File: AbstractIOTest.java    From red5-io with Apache License 2.0 5 votes vote down vote up
@Test
public void testString() {
    log.debug("\ntestString");
    String inStr = "hello world \u00A3";
    Serializer.serialize(out, inStr);
    dumpOutput();
    String outStr = Deserializer.deserialize(in, String.class);
    assertEquals(inStr, outStr);
    resetOutput();
}
 
Example #26
Source File: AbstractIOTest.java    From red5-io with Apache License 2.0 5 votes vote down vote up
@Test
public void testLongString1() {
    log.debug("\ntestLongString1");
    String inStr = RandomStringUtils.random(rnd.nextInt(AMF.LONG_STRING_LENGTH));
    log.trace(inStr);
    Serializer.serialize(out, inStr);
    dumpOutput();
    String outStr = Deserializer.deserialize(in, String.class);
    assertEquals(inStr, outStr);
    resetOutput();
}
 
Example #27
Source File: AbstractIOTest.java    From red5-io with Apache License 2.0 5 votes vote down vote up
@Test
public void testArray() {
    log.debug("\ntestArray");
    String[] strArrIn = new String[] { "This", "Is", "An", "Array", "Of", "Strings" };
    Serializer.serialize(out, strArrIn);
    dumpOutput();
    Object[] objArrayOut = Deserializer.deserialize(in, Object[].class);
    for (int i = 0; i < strArrIn.length; i++) {
        assertEquals(strArrIn[i], objArrayOut[i]);
    }
    resetOutput();
}
 
Example #28
Source File: AMF3IOTest.java    From red5-io with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unused")
@Test
public void testVectorStringInput() {
    log.debug("\n Testing Vector<String>");
    //[Paul, ]
    byte[] v = new byte[] { (byte) 0x10, (byte) 0x05, (byte) 0x00, (byte) 0x01, (byte) 0x06, (byte) 0x09, (byte) 0x50, (byte) 0x61, (byte) 0x75, (byte) 0x6c, (byte) 0x06, (byte) 0x01 };
    //[Paul, Paul]
    byte[] v1 = new byte[] { (byte) 0x10, (byte) 0x05, (byte) 0x00, (byte) 0x01, (byte) 0x06, (byte) 0x09, (byte) 0x50, (byte) 0x61, (byte) 0x75, (byte) 0x6c, (byte) 0x06, (byte) 0x00 };
    //[Paul, Paul, Paul]
    byte[] v2 = new byte[] { (byte) 0x10, (byte) 0x07, (byte) 0x00, (byte) 0x01, (byte) 0x06, (byte) 0x09, (byte) 0x50, (byte) 0x61, (byte) 0x75, (byte) 0x6c, (byte) 0x06, (byte) 0x00, (byte) 0x06, (byte) 0x00 };
    //[Paul, Tawnya]
    byte[] v3 = new byte[] { (byte) 0x10, (byte) 0x05, (byte) 0x00, (byte) 0x01, (byte) 0x06, (byte) 0x09, (byte) 0x50, (byte) 0x61, (byte) 0x75, (byte) 0x6c, (byte) 0x06, (byte) 0x0d, (byte) 0x54, (byte) 0x61, (byte) 0x77, (byte) 0x6e, (byte) 0x79, (byte) 0x61 };

    //[1.0, 3.0, aaa, 5.0, aaa, aaa, 5.0, bb, bb]
    byte[] v4 = new byte[] { (byte) 0x10, (byte) 0x13, (byte) 0x00, (byte) 0x01, (byte) 0x04, (byte) 0x01, (byte) 0x04, (byte) 0x03, (byte) 0x06, (byte) 0x07, (byte) 0x61, (byte) 0x61, (byte) 0x61, (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x00, (byte) 0x06, (byte) 0x00, (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x05, (byte) 0x62, (byte) 0x62, (byte) 0x06, (byte) 0x02 };
    //[1.0, 3.0, aaa, [1, 2]]
    byte[] v5 = new byte[] { (byte) 0x10, (byte) 0x09, (byte) 0x00, (byte) 0x01, (byte) 0x04, (byte) 0x01, (byte) 0x04, (byte) 0x03, (byte) 0x06, (byte) 0x07, (byte) 0x61, (byte) 0x61, (byte) 0x61, (byte) 0x0d, (byte) 0x05, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x02 };

    in = new Input(IoBuffer.wrap(v5));
    List<Object> vectorOut = Deserializer.deserialize(in, null);
    //[Paul, ]
    assertNotNull(vectorOut);
    //assertEquals(vectorOut.size(), 4);
    for (int i = 0; i < vectorOut.size(); i++) {
        System.err.println("Vector: " + vectorOut.get(i));
    }
    resetOutput();
}
 
Example #29
Source File: AMF3IOTest.java    From red5-io with Apache License 2.0 5 votes vote down vote up
@Test
public void testVectorUIntInput() {
    log.debug("\n Testing Vector<uint>");
    //0E090000000002000007D0FFFFFFFF00000000
    byte[] v = new byte[] { (byte) 0x0E, (byte) 0x09, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x02, (byte) 0x00, (byte) 0x00, (byte) 0x07, (byte) 0xD0, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 };
    in = new Input(IoBuffer.wrap(v));
    List<Object> vectorOut = Deserializer.deserialize(in, null);
    //[2, 2000, 4294967295, 0]
    assertNotNull(vectorOut);
    assertEquals(vectorOut.size(), 4);
    for (int i = 0; i < vectorOut.size(); i++) {
        System.err.println("Vector: " + vectorOut.get(i));
    }
    resetOutput();
}
 
Example #30
Source File: AMF3IOTest.java    From red5-io with Apache License 2.0 5 votes vote down vote up
@Test
public void testVectorRoundTrip() {
    log.debug("\n Testing Vector on a round trip");
    Vector<String> vIn = new Vector<String>();
    vIn.add("This is my vector and her name is Sally");
    Serializer.serialize(out, vIn);
    dumpOutput();
    Vector<String> vOut = Deserializer.deserialize(in, Vector.class);
    assertNotNull(vOut);
    assertEquals(vIn.size(), vOut.size());
    for (int i = 0; i < vOut.size(); i++) {
        System.err.println("Element: " + vOut.elementAt(i));
    }
    resetOutput();
}