Package org.jboss.metatype.api.types

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


      MockCompositeValue[][] compData1 = new MockCompositeValue[][]
      {
         { cv, null }, { cv, cv }
      };

      ArrayMetaType compArrayType1 = new ArrayMetaType(2, compositeType);
      assertTrue("compData1 should be a value of array type", compArrayType1.isValue(compData1));

      ArrayMetaType compArrayType2 = new ArrayMetaType(1, compositeType);
      assertFalse("compData1 should not be a value of array type, wrong dimension", compArrayType2.isValue(compData1));

      CompositeMetaType compositeType2 = new ImmutableCompositeMetaType("typeName2", "description", itemNames, itemDescriptions, itemTypes);
      ArrayMetaType compArrayType3 = new ArrayMetaType(2, compositeType2);
      assertFalse("compData1 should not be a value of array type, wrong element type", compArrayType3.isValue(compData1));
   }
View Full Code Here


      TableValue[][] tabData1 = new TableValue[][]
      {
         { tv, null }, { tv, tv }
      };

      ArrayMetaType tabArrayType1 = new ArrayMetaType(2, tableType);
      assertTrue("tabData1 should be a value of array type", tabArrayType1.isValue(tabData1));

      ArrayMetaType tabArrayType2 = new ArrayMetaType(1, tableType);
      assertFalse("tabData1 should not be a value of array type, wrong number of dimensions", tabArrayType2.isValue(tabData1));

      TableMetaType tableType2 = new ImmutableTableMetaType("typeName2", "description", compositeType, new String[] { "name1" });
      ArrayMetaType tabArrayType3 = new ArrayMetaType(2, tableType2);
      assertFalse("tabData1 should not be a value of array type, wrong element type", tabArrayType3.isValue(tabData1));
   }
View Full Code Here

    * @throws Exception for any problem
    */
   @SuppressWarnings("unchecked")
   public void testEquals() throws Exception
   {
      ArrayMetaType arrayType = new ArrayMetaType(3, SimpleMetaType.STRING);

      assertNotSame("null is not an array type", null, arrayType);
      assertNotSame("object is not an array type", new Object(), arrayType);

      assertEquals("should be equal to itself", arrayType, arrayType);

      ArrayMetaType arrayType2 = new ArrayMetaType(3, SimpleMetaType.STRING);
      assertEquals("should be equal, even though different instances", arrayType, arrayType2);
      assertEquals("should be equal, even though different instances", arrayType2, arrayType);

      arrayType2 = new ArrayMetaType(2, SimpleMetaType.STRING);
      assertNotSame("should not be equal, wrong number of dimensions", arrayType, arrayType2);
      assertNotSame("should not be equal, wrong number of dimensions", arrayType2, arrayType);

      arrayType2 = new ArrayMetaType(3, SimpleMetaType.INTEGER);
      assertNotSame("should not be equal, wrong element type", arrayType, arrayType2);
      assertNotSame("should not be equal, wrong element type", arrayType2, arrayType);
   }
View Full Code Here

    * @throws Exception for any problem
    */
   @SuppressWarnings("unchecked")
   public void testHashCode() throws Exception
   {
      ArrayMetaType arrayType = new ArrayMetaType(3, SimpleMetaType.STRING);

      int myHashCode = 3 + SimpleMetaType.STRING.hashCode();
      assertTrue("Wrong hash code generated", myHashCode == arrayType.hashCode());
   }
View Full Code Here

    * @throws Exception for any problem
    */
   @SuppressWarnings("unchecked")
   public void testToString() throws Exception
   {
      ArrayMetaType arrayType = new ArrayMetaType(3, SimpleMetaType.STRING);

      String toString = arrayType.toString();

      assertTrue("toString() should contain the array type class name", toString.indexOf(ArrayMetaType.class.getSimpleName()) != -1);
      assertTrue("toString() should contain the dimension", toString.indexOf("3") != -1);
      assertTrue("toString() should contain the element type", toString.indexOf(SimpleMetaType.STRING.toString()) != -1);
   }
View Full Code Here

    * @throws Exception for any problem
    */
   @SuppressWarnings("unchecked")
   public void testSerialization() throws Exception
   {
      ArrayMetaType arrayType = new ArrayMetaType(3, SimpleMetaType.STRING);

      byte[] bytes = serialize(arrayType);
      Object result = deserialize(bytes);

      assertEquals(arrayType, result);
View Full Code Here

   @SuppressWarnings("unchecked")
   public void testErrors() throws Exception
   {
      try
      {
         new ArrayMetaType(-1, SimpleMetaType.STRING);
         fail("Excepted IllegalArgumentException for negative dimension");
      }
      catch (Throwable t)
      {
         checkThrowable(IllegalArgumentException.class, t);
      }

      try
      {
         new ArrayMetaType(1, new ArrayMetaType(2, SimpleMetaType.STRING));
         fail("Excepted IllegalArgumentException for ArrayMetaType element type");
      }
      catch (Throwable t)
      {
         checkThrowable(IllegalArgumentException.class, t);
      }
     
      try
      {
         new ArrayMetaType(1, null);
         fail("Excepted IllegalArgumentException for null element type");
      }
      catch (Throwable t)
      {
         checkThrowable(IllegalArgumentException.class, t);
View Full Code Here

    */
   @SuppressWarnings("unchecked")
   public void testSimpleArray() throws Exception
   {
      String[] array = { "Hello", "Goodbye" };
      ArrayMetaType arrayType = assertInstanceOf(resolve(array.getClass()), ArrayMetaType.class);
      MetaValue[] metaArray = { SimpleValueSupport.wrap("Hello"), SimpleValueSupport.wrap("Goodbye") };
      ArrayValueSupport expected = new ArrayValueSupport(arrayType, metaArray);
     
      MetaValue result = createMetaValue(array);
      ArrayValue actual = assertInstanceOf(result, ArrayValue.class);
View Full Code Here

   @SuppressWarnings("unchecked")
   public void testCharArray()
      throws Exception
   {
      char[] array = "Hello".toCharArray();
      ArrayMetaType arrayType = assertInstanceOf(resolve(array.getClass()), ArrayMetaType.class);
      MetaValue[] metaArray = { SimpleValueSupport.wrap('H'),
            SimpleValueSupport.wrap('e'),
            SimpleValueSupport.wrap('l'),
            SimpleValueSupport.wrap('l'),
            SimpleValueSupport.wrap('o')
View Full Code Here

  
   @SuppressWarnings("unchecked")
   public void test2DCharArray()
   {
      char[][] array = {"Hello".toCharArray(), "World".toCharArray()};
      ArrayMetaType arrayType = assertInstanceOf(resolve(array.getClass()), ArrayMetaType.class);
      MetaValue[][] metaArray = { {SimpleValueSupport.wrap('H'),
            SimpleValueSupport.wrap('e'),
            SimpleValueSupport.wrap('l'),
            SimpleValueSupport.wrap('l'),
            SimpleValueSupport.wrap('o')},
View Full Code Here

TOP

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

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.