Package org.jboss.metatype.api.types

Examples of org.jboss.metatype.api.types.TableMetaType


    * @throws Exception for any problem
    */
   public void testHashCode() throws Exception
   {
      CompositeMetaType rowType = initRowType();
      TableMetaType tableType = initTableMetaType();

      int myHashCode = "typeName".hashCode() + rowType.hashCode() + "name1".hashCode() + "name2".hashCode();
      assertTrue("Wrong hash code generated", myHashCode == tableType.hashCode());
   }
View Full Code Here


    * @throws Exception for any problem
    */
   public void testToString() throws Exception
   {
      CompositeMetaType rowType = initRowType();
      TableMetaType tableType = initTableMetaType();

      String toString = tableType.toString();

      assertTrue("toString() should contain the tabular type class name", toString.indexOf(TableMetaType.class.getSimpleName()) != -1);
      assertTrue("toString() should contain the type name", toString.indexOf("typeName") != -1);
      assertTrue("toString() should contain the row type " + rowType, toString.indexOf(rowType.toString()) != -1);
      assertTrue("toString() should contain the index name1", toString.indexOf("name1") != -1);
View Full Code Here

    *
    * @throws Exception for any problem
    */
   public void testSerialization() throws Exception
   {
      TableMetaType tableType = initTableMetaType();
      byte[] bytes = serialize(tableType);
      Object result = deserialize(bytes);
      assertEquals(tableType, result);
   }
View Full Code Here

   protected TableMetaType initTableMetaType() throws Exception
   {
      CompositeMetaType rowType = initRowType();

      String[] indexNames = new String[] { "name1", "name2" };
      TableMetaType tableType = new ImmutableTableMetaType("typeName", "description", rowType, indexNames);
      return tableType;
   }
View Full Code Here

   protected TableMetaType initTableMetaTypeDifferentTypeName() throws Exception
   {
      CompositeMetaType rowType = initRowType();

      String[] indexNames = new String[] { "name1", "name2" };
      TableMetaType tableType = new ImmutableTableMetaType("typeName2", "description", rowType, indexNames);
      return tableType;
   }
View Full Code Here

   protected TableMetaType initTableMetaTypeDifferentRowTypes() throws Exception
   {
      CompositeMetaType rowType = initRowType2();

      String[] indexNames = new String[] { "name1", "name2" };
      TableMetaType tableType = new ImmutableTableMetaType("typeName", "description", rowType, indexNames);
      return tableType;
   }
View Full Code Here

   protected TableMetaType initTableMetaTypeDifferentIndexNames() throws Exception
   {
      CompositeMetaType rowType = initRowType();

      String[] indexNames = new String[] { "name2", "name1" };
      TableMetaType tableType = new ImmutableTableMetaType("typeName", "description", rowType, indexNames);
      return tableType;
   }
View Full Code Here

   public void testMapWithStringKeyErasure()
      throws Exception
   {
      Map<String,String> map = new HashMap<String,String>();
      Type mapSignature = map.getClass();
      TableMetaType result = assertInstanceOf(resolve(mapSignature), TableMetaType.class);

      MetaType keyType = resolve(Object.class);
      MetaType valueType = resolve(Object.class);
      MetaType[] itemTypes = { keyType, valueType };
      String entryName = Map.Entry.class.getName();
      CompositeMetaType entryType = new ImmutableCompositeMetaType(entryName, entryName, DefaultMetaTypeFactory.MAP_ITEM_NAMES, DefaultMetaTypeFactory.MAP_ITEM_NAMES, itemTypes);
      TableMetaType expected = new ImmutableTableMetaType(Map.class.getName(), Map.class.getName(), entryType, DefaultMetaTypeFactory.MAP_INDEX_NAMES);
     
      assertEquals(expected, result)
   }
View Full Code Here

   protected void testMap(String methodName, Type keyClass, Type valueClass) throws Exception
   {
      Method method = getClass().getMethod(methodName, (Class[]) null);
      Type collectionType = method.getGenericReturnType();
      MetaType result = resolve(collectionType);
      TableMetaType actual = assertInstanceOf(result, TableMetaType.class);
      MetaType keyType = resolve(keyClass);
      MetaType valueType = resolve(valueClass);
      MetaType[] itemTypes = { keyType, valueType };
      String entryName = Map.Entry.class.getName();
      CompositeMetaType entryType = new ImmutableCompositeMetaType(entryName, entryName, DefaultMetaTypeFactory.MAP_ITEM_NAMES, DefaultMetaTypeFactory.MAP_ITEM_NAMES, itemTypes);
      TableMetaType expected = new ImmutableTableMetaType(Map.class.getName(), Map.class.getName(), entryType, DefaultMetaTypeFactory.MAP_INDEX_NAMES);
      testTable(expected, actual);
   }
View Full Code Here

   @SuppressWarnings("unchecked")
   private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
   {
      ObjectInputStream.GetField getField = in.readFields();
      HashMap<List<MetaValue>, CompositeValue> dataMap = (HashMap<List<MetaValue>, CompositeValue>) getField.get("dataMap", null);
      TableMetaType tableType = (TableMetaType) getField.get("tableType", null);
      try
      {
         init(dataMap, tableType);
      }
      catch (Exception e)
View Full Code Here

TOP

Related Classes of org.jboss.metatype.api.types.TableMetaType

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.