Package com.google.gwt.dev.javac.typemodel.test

Examples of com.google.gwt.dev.javac.typemodel.test.TestAnnotation


    JClassType[] intf = enumType.getImplementedInterfaces();
    assertEquals(1, intf.length);
    assertEquals(EnumInterface.class.getName(),
        intf[0].getQualifiedSourceName());
    JMethod getExtra = intf[0].getMethod("getExtra", TypeOracle.NO_JTYPES);
    TestAnnotation annotation = getExtra.getAnnotation(TestAnnotation.class);
    assertNotNull(annotation);
    assertEquals("EnumInterface getExtra", annotation.value());
    JEnumConstant[] constants = enumType.getEnumConstants();
    assertEquals(2, constants.length);
    assertEquals("A", constants[0].getName());
    annotation = constants[0].getAnnotation(TestAnnotation.class);
    assertNotNull(annotation);
    assertEquals("A", annotation.value());
    JClassType aClass = (JClassType) constants[0].getType().isClass();
    {
      JMethod[] methods = aClass.getInheritableMethods();
      assertEquals(10, methods.length);
      boolean found = false;
View Full Code Here


      TestAnnotation realAnnotation) {
    assertNotNull(annotatedElement);

    assertNull(annotatedElement.getAnnotation(SourceRetentionAnnotation.class));

    TestAnnotation testAnnotation = annotatedElement.getAnnotation(TestAnnotation.class);
    assertNotNull(testAnnotation);

    // Check our proxy objects against the real thing.
    assertEquals(realAnnotation, testAnnotation);
    assertEquals(realAnnotation.hashCode(), testAnnotation.hashCode());

    // tobyr doesn't like this.
    // assertEquals(realAnnotation.toString(), testAnnotation.toString());

    // checks default value
    assertEquals(testAnnotationValue, testAnnotation.value());
    assertEquals(nestedAnnotationValue,
        testAnnotation.nestedAnnotation().value());

    // Tests default values using conditional statements.
    assertEquals(realAnnotation.longValue(), testAnnotation.longValue());

    // Tests default value of array type.
    assertEquals(realAnnotation.intArrayValue().length,
        testAnnotation.intArrayValue().length);

    // Tests default value which is a field reference.
    assertEquals(realAnnotation.stringValue(), testAnnotation.stringValue());

    // Tests default value that is a class literal.
    assertEquals(realAnnotation.classLiteral(), testAnnotation.classLiteral());

    // Tests implicit array initializers
    Class<?>[] expectedArrayValue = realAnnotation.arrayWithImplicitArrayInitializer();
    Class<?>[] actualArrayValue = testAnnotation.arrayWithImplicitArrayInitializer();
    assertTrue(expectedArrayValue.length > 0);
    assertEquals(expectedArrayValue.length, actualArrayValue.length);
    assertEquals(expectedArrayValue[0], actualArrayValue[0]);

    // Tests that empty array initializers are also handled correctly.
    assertEquals(realAnnotation.emptyArray().length,
        testAnnotation.emptyArray().length);
  }
View Full Code Here

   * Test that a class can be annotated.
   */
  public void testAnnotatedClass() throws NotFoundException {
    JClassType annotatedClass = typeOracle.getType(AnnotatedClass.class.getName());

    TestAnnotation realAnnotation = AnnotatedClass.class.getAnnotation(TestAnnotation.class);
    validateAnnotation(annotatedClass, "Class", "Foo", realAnnotation);

    ClassLiteralReferenceAnnotation classReferenceAnnotation = annotatedClass.getAnnotation(ClassLiteralReferenceAnnotation.class);
    assertEquals(ClassLiteralReferenceAnnotation.Foo.class,
        classReferenceAnnotation.value());
View Full Code Here

      SecurityException, NoSuchMethodException {
    JClassType annotatedClass = typeOracle.getType(AnnotatedClass.class.getName());
    JConstructor ctor = annotatedClass.getConstructor(TypeOracle.NO_JTYPES);

    Constructor<AnnotatedClass> constructor = AnnotatedClass.class.getConstructor();
    TestAnnotation realAnnotation = constructor.getAnnotation(TestAnnotation.class);

    validateAnnotation(ctor, "Constructor", "Not assigned", realAnnotation);
  }
View Full Code Here

      NoSuchFieldException {
    JClassType annotatedClass = typeOracle.getType(AnnotatedClass.class.getName());
    JField annotatedField = annotatedClass.getField("annotatedField");

    Field field = AnnotatedClass.class.getDeclaredField("annotatedField");
    TestAnnotation realAnnotation = field.getAnnotation(TestAnnotation.class);

    validateAnnotation(annotatedField, "Field", "Not assigned", realAnnotation);
  }
View Full Code Here

    JClassType annotatedClass = typeOracle.getType(AnnotatedClass.class.getName());
    JMethod annotatedMethod = annotatedClass.getMethod("annotatedMethod",
        TypeOracle.NO_JTYPES);

    Method method = AnnotatedClass.class.getDeclaredMethod("annotatedMethod");
    TestAnnotation realAnnotation = method.getAnnotation(TestAnnotation.class);

    validateAnnotation(annotatedMethod, "Method", "Not assigned",
        realAnnotation);
  }
View Full Code Here

  public void testAnnotatedPackage() throws NotFoundException,
      ClassNotFoundException {
    JPackage annotatedPackage = typeOracle.getPackage("com.google.gwt.dev.javac.typemodel.test");
    assertNotNull(annotatedPackage);

    TestAnnotation realAnnotation = Class.forName(
        "com.google.gwt.dev.javac.typemodel.test.package-info", false,
        TypeOracleAnnotationSupportTest.class.getClassLoader()).getAnnotation(
        TestAnnotation.class);

    validateAnnotation(annotatedPackage, "Package", "Not assigned",
View Full Code Here

    JParameter parameter = jmethod.getParameters()[0];

    Method method = AnnotatedClass.class.getDeclaredMethod(
        "methodWithAnnotatedParameter", int.class);
    Annotation[][] paramAnnotations = method.getParameterAnnotations();
    TestAnnotation realAnnotation = (TestAnnotation) paramAnnotations[0][0];

    validateAnnotation(parameter, "Parameter", "Not assigned", realAnnotation);
  }
View Full Code Here

    JClassType annotatedClass = typeOracle.getType(AnnotatedClass.class.getName());
    JMethod annotatedMethod = annotatedClass.getMethod(
        "annotatedWithArrayOfClasses", TypeOracle.NO_JTYPES);

    Method method = AnnotatedClass.class.getDeclaredMethod("annotatedWithArrayOfClasses");
    TestAnnotation realAnnotation = method.getAnnotation(TestAnnotation.class);

    validateAnnotation(annotatedMethod, "Method", "Not assigned",
        realAnnotation);
  }
View Full Code Here

TOP

Related Classes of com.google.gwt.dev.javac.typemodel.test.TestAnnotation

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.