Package etch.bindings.java.msg

Examples of etch.bindings.java.msg.Message


//    System.out.printf( "x.id() = %04x\n", x.getId() );
//    System.out.printf( "y.id() = %04x\n", y.getId() );
//    System.out.printf( "_mf__messageId.id() = %04x\n", _mf__messageId.getId() );
//    System.out.printf( "msgid = %08x\n", msgid );
   
    Message msg = new Message( add, vf );
    msg.put( x, 1 );
    msg.put( y, 2 );
    msg.put( _mf__messageId, msgid );
    testmsg2bytes( msg, null,  new byte[] { 3, -122, 39, -23, -73, -100, 3, -122, 21, 10, 44, -77, 1, -122, 99, 6, -76, 104, -121, 1, 2, 3, 4, 5, 6, 7, 8, -122, 21, 10, 44, -76, 2, -127 } );
    testmsg2bytes( msg, false, new byte[] { 3, -122, 39, -23, -73, -100, 3, -122, 21, 10, 44, -77, 1, -122, 99, 6, -76, 104, -121, 1, 2, 3, 4, 5, 6, 7, 8, -122, 21, 10, 44, -76, 2, -127 } );
    testmsg2bytes( msg, true,  new byte[] { 3, -109, 3, 97, 100, 100, 3, -109, 1, 120, 1, -109, 10, 95, 109, 101, 115, 115, 97, 103, 101, 73, 100, -121, 1, 2, 3, 4, 5, 6, 7, 8, -109, 1, 121, 2, -127 } );
   
    msg = new Message( add, vf );
    msg.put( x, 1000000000 );
    msg.put( y, 2000000000 );
    msg.put( _mf__messageId, msgid );
    testmsg2bytes( msg, null,  new byte[] { 3, -122, 39, -23, -73, -100, 3, -122, 21, 10, 44, -77, -122, 59, -102, -54, 0, -122, 99, 6, -76, 104, -121, 1, 2, 3, 4, 5, 6, 7, 8, -122, 21, 10, 44, -76, -122, 119, 53, -108, 0, -127 } );
    testmsg2bytes( msg, false, new byte[] { 3, -122, 39, -23, -73, -100, 3, -122, 21, 10, 44, -77, -122, 59, -102, -54, 0, -122, 99, 6, -76, 104, -121, 1, 2, 3, 4, 5, 6, 7, 8, -122, 21, 10, 44, -76, -122, 119, 53, -108, 0, -127 } );
    testmsg2bytes( msg, true,  new byte[] { 3, -109, 3, 97, 100, 100, 3, -109, 1, 120, -122, 59, -102, -54, 0, -109, 10, 95, 109, 101, 115, 115, 97, 103, 101, 73, 100, -121, 1, 2, 3, 4, 5, 6, 7, 8, -109, 1, 121, -122, 119, 53, -108, 0, -127 } );
  }
View Full Code Here


      -122, // INT (key)
      21, 10, 44, -77, // x
      1, // tiny int = 1 (value)
      -127 // NONE
    };
    Message msg = bytes2msg( buf );
    msg.checkType( add );
    Assert.assertEquals( 3, msg.size() );
    Assert.assertEquals( 1, msg.get( x ) );
    Assert.assertEquals( 2, msg.get( y ) );
    Assert.assertEquals( msgid, msg.get( _mf__messageId ) );
   
    buf = new byte[]
    {
      3, // version
      -122, // INT (type)
      39, -23, -73, -100, // add
      3, // length
      -122, // INT (key)
      99, 6, -76, 104,
      -121, // LONG (value)
      1, 35, 69, 103, -119, -85, -51, -17,
      -122, // INT (key)
      21, 10, 44, -76, // y
      -122, // INT (value)
      119, 53, -108, 0,
      -122, // INT (key)
      21, 10, 44, -77, // x
      -122, // INT (value)
      59, -102, -54, 0,
      -127 // NONE
    };
    msg = bytes2msg( buf );
    msg.checkType( add );
    Assert.assertEquals( 3, msg.size() );
    Assert.assertEquals( 1000000000, msg.get( x ) );
    Assert.assertEquals( 2000000000, msg.get( y ) );
    Assert.assertEquals( msgid, msg.get( _mf__messageId ) );
  }
View Full Code Here

//    System.out.printf( "x.id() = %04x\n", x.getId() );
//    System.out.printf( "y.id() = %04x\n", y.getId() );
//    System.out.printf( "_mf__messageId.id() = %04x\n", _mf__messageId.getId() );
//    System.out.printf( "msgid = %08x\n", msgid );
   
    Message msg = new Message( add, vf );
    msg.put( x, 123456789 );
    msg.put( y, 876543210 );
    msg.put( _mf__messageId, msgid );
//    System.out.println( "msg = "+msg );
   
    Resources res = new Resources();
    res.put( Transport.VALUE_FACTORY, vf );
    MyPacketSource ps = new MyPacketSource();
View Full Code Here

   
    int[] array = new int[2];
    for (int i = 0; i < array.length; i++)
      array[i] = 123456789;
   
    Message msg = new Message( sum, vf );
    msg.put( values, array );
    msg.put( _mf__messageId, msgid );
//    System.out.println( "msg = "+msg );
   
    Resources res = new Resources();
    res.put( Transport.VALUE_FACTORY, vf );
    MyPacketSource ps = new MyPacketSource();
View Full Code Here

 
  /** @throws Exception */
  @Test
  public void badtype() throws Exception
  {
    @SuppressWarnings("unused")
    Message msg = bytes2msg( new byte[] { 3, 1, 0, -127 } );
//    System.out.println( "msg = "+msg );
  }
View Full Code Here

 
  /** @throws Exception */
  @Test( expected = IllegalArgumentException.class )
  public void badmsglen1() throws Exception
  {
    @SuppressWarnings("unused")
    Message msg = bytes2msg( new byte[] { 3, 1, -1, -127 } );
//    System.out.println( "msg = "+msg );
  }
View Full Code Here

 
  /** @throws Exception */
  @Test( expected = IllegalArgumentException.class )
  public void badmsglen2() throws Exception
  {
    @SuppressWarnings("unused")
    Message msg = bytes2msg( new byte[] { 3, 1, 99, -127 } );
//    System.out.println( "msg = "+msg );
  }
View Full Code Here

 
  /** @throws Exception */
  @Test
  public void badfield() throws Exception
  {
    @SuppressWarnings("unused")
    Message msg = bytes2msg( new byte[] { 3, 1, 1, 2, 2, -127 }, Level.MISSING_OK );
//    System.out.println( "msg = "+msg );
  }
View Full Code Here

  {
    Type t = new Type( 1, "a" );
    Field f = new Field( 2, "b" );
    t.putValidator( f, Validator_object.get( 0 ) );
   
    Message msg = new Message( t, vf );
    msg.put( f, value );
//    System.out.println( "msg = "+msg );
   
    BinaryTaggedDataOutput btdo = new BinaryTaggedDataOutput( vf, "none:" );
    FlexBuffer buf = new FlexBuffer();
   
View Full Code Here

//    System.out.println( "-----------------------------------------" );
   
    mt_foo.clearValidator( mf_x );
    mt_foo.putValidator( mf_x, v );
   
    Message msg = new Message( mt_foo, vf );
    msg.put( mf_x, x );
//    System.out.println( "msg = "+msg );
   
    byte[] bufx = msg2bytes( msg, stringTypeAndField );
//    dump( bufx );
    Message msg2 = bytes2msg( bufx );
   
//    System.out.println( "msg2 = "+msg2 );
    msg2.checkType( mt_foo );
    Assert.assertEquals( 1, msg2.size() );
    Assert.assertTrue( msg.containsKey( mf_x ) );
    Object y = msg2.get( mf_x );
   
    assertEquals( x, y );
  }
View Full Code Here

TOP

Related Classes of etch.bindings.java.msg.Message

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.