Package org.apache.etch.bindings.java.msg

Examples of org.apache.etch.bindings.java.msg.StructValue


    Type type = new Type( "date" );
    Class2TypeMap class2type = new Class2TypeMap();
    DateSerializer.init( type, class2type );
    ImportExportHelper helper = type.getImportExportHelper();
   
    StructValue sv = helper.exportValue( vf, date );
//    System.out.println( "sv = "+sv );
   
    assertEquals( sv.type(), type );
   
    Date date2 = (Date) helper.importValue( sv );
//    System.out.println( "date2 = "+date2 );
   
    assertEquals( date, date2 );
View Full Code Here


    testbadvalue( 0, 5.5f );
    testbadvalue( 0, 6.6 );
    testbadvalue( 0, "" );
    testbadvalue( 0, "abc" );
    testbadvalue( 0, new Object() );
    testbadvalue( 0, new StructValue( new Type( "abc" ), vf ) );
    testbadvalue( 0, new Date() );

    testbadvalue( 1, null );
    testbadvalue( 1, false );
    testbadvalue( 1, true );
    testbadvalue( 1, (byte) 1 );
    testbadvalue( 1, (short) 2222 );
    testbadvalue( 1, 33333333 );
    testbadvalue( 1, 4444444444444444L );
    testbadvalue( 1, 5.5f );
    testbadvalue( 1, 6.6 );
    testbadvalue( 1, "" );
    testbadvalue( 1, "abc" );
    testbadvalue( 1, new Object() );
    testbadvalue( 1, new StructValue( new Type( "abc" ), vf ) );
    testbadvalue( 1, new Date() );
  }
View Full Code Here

    Type type = new Type( "map" );
    Class2TypeMap class2type = new Class2TypeMap();
    StrStrHashMapSerializer.init( type, class2type );
    ImportExportHelper helper = type.getImportExportHelper();
   
    StructValue sv = helper.exportValue( vf, map );
//    System.out.println( "sv = "+sv );
   
    assertEquals( sv.type(), type );
   
    StrStrHashMap map2 = (StrStrHashMap) helper.importValue( sv );
//    System.out.println( "map2 = "+map2 );
   
    assertEquals( map, map2 );
View Full Code Here

    Type type = new Type( "url" );
    Class2TypeMap class2type = new Class2TypeMap();
    URLSerializer.init( type, class2type );
    ImportExportHelper helper = type.getImportExportHelper();
   
    StructValue sv = helper.exportValue( vf, url );
//    System.out.println( "sv = "+sv );
   
    assertEquals( sv.type(), type );
   
    URL url2 = (URL) helper.importValue( sv );
//    System.out.println( "url2 = "+url2 );
   
    assertEquals( url, url2 );
View Full Code Here

  /** @throws Exception */
  @Test
  public void exportCustomValue_RuntimeException() throws Exception
  {
    Exception value = new NullPointerException();
    StructValue sv = vf.exportCustomValue( value );
    sv.checkType( vf.getType( "_Etch_RuntimeException" ) );
    assertEquals( 1, sv.size() );
    assertEquals( "java.lang.NullPointerException",
      sv.get( DefaultValueFactory._mf_msg ) );
  }
View Full Code Here

  /** @throws Exception */
  @Test
  public void exportCustomValue_RuntimeException_msg() throws Exception
  {
    Exception value = new NullPointerException( "foo != null" );
    StructValue sv = vf.exportCustomValue( value );
    sv.checkType( vf.getType( "_Etch_RuntimeException" ) );
    assertEquals( 1, sv.size() );
    assertEquals( "java.lang.NullPointerException: foo != null",
      sv.get( DefaultValueFactory._mf_msg ) );
  }
View Full Code Here

 
  /** @throws Exception */
  @Test
  public void importCustomValue_Etch_RuntimeException() throws Exception
  {
    StructValue sv = new StructValue( vf.getType( "_Etch_RuntimeException" ), vf );
    _Etch_RuntimeException e = (_Etch_RuntimeException) vf.importCustomValue( sv );
    assertNotNull( e );
    assertNull( e.msg );
  }
View Full Code Here

 
  /** @throws Exception */
  @Test
  public void importCustomValue_Etch_RuntimeException_msg() throws Exception
  {
    StructValue sv = new StructValue( vf.getType( "_Etch_RuntimeException" ), vf );
    sv.put( DefaultValueFactory._mf_msg, "foo" );
    _Etch_RuntimeException e = (_Etch_RuntimeException) vf.importCustomValue( sv );
    assertNotNull( e );
    assertEquals( "foo", e.msg );
  }
View Full Code Here

 
  /** @throws Exception */
  @Test
  public void importCustomValue_Unknown() throws Exception
  {
    StructValue sv = new StructValue( vf.getType( "x" ), vf );
    assertNull( vf.importCustomValue( sv ) );
    // cannot import unsupported type
  }
View Full Code Here

    {
      keysAndValues[index++] = me.getKey();
      keysAndValues[index++] = me.getValue();
    }
   
    StructValue struct = new StructValue( type, vf );
    struct.put( field, keysAndValues );
    return struct;
  }
View Full Code Here

TOP

Related Classes of org.apache.etch.bindings.java.msg.StructValue

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.