Package org.jboss.forge.roaster.model.source

Examples of org.jboss.forge.roaster.model.source.JavaPackageInfoSource


{

   @Test
   public void testCanCreatePackageInfo() throws Exception
   {
      JavaPackageInfoSource packageInfo = Roaster.create(JavaPackageInfoSource.class);
      packageInfo.setPackage("org.jboss.forge.roaster");
      Assert.assertEquals("org.jboss.forge.roaster", packageInfo.getPackage());
      Assert.assertEquals("package-info", packageInfo.getName());
   }
View Full Code Here


   }

   @Test(expected = UnsupportedOperationException.class)
   public void testSetPackageInfoNameThrowsUnsupportedOperation() throws Exception
   {
      JavaPackageInfoSource packageInfo = Roaster.create(JavaPackageInfoSource.class);
      packageInfo.setName("anything");
   }
View Full Code Here

   @Test
   public void testCanParsePackageInfo() throws Exception
   {
      InputStream stream = JavaPackageInfoTest.class
               .getResourceAsStream("/org/jboss/forge/grammar/java/package-info.java");
      JavaPackageInfoSource javaPkg = Roaster.parse(JavaPackageInfoSource.class, stream);
      assertEquals("org.jboss.forge.test.roaster.model", javaPkg.getPackage());
      Assert.assertEquals("package-info", javaPkg.getName());
      Assert.assertNotNull(javaPkg.getImport("javax.xml.bind.annotation.XmlSchema"));
      Import XmlAccessTypeField = javaPkg.getImport("javax.xml.bind.annotation.XmlAccessType.FIELD");
      Assert.assertNotNull(XmlAccessTypeField);
      Assert.assertTrue(XmlAccessTypeField.isStatic());
      List<AnnotationSource<JavaPackageInfoSource>> annotations = javaPkg.getAnnotations();
      Assert.assertEquals(2, annotations.size());
      Annotation<JavaPackageInfoSource> annotation = javaPkg.getAnnotation("XmlSchema");
      List<ValuePair> values = annotation.getValues();
      Assert.assertEquals(3, values.size());
      String namespace = annotation.getLiteralValue("namespace");
      Assert.assertEquals(namespace, "\"http://forge.org/Test\"");

      AnnotationSource<JavaPackageInfoSource> annotationXmlOrder = javaPkg
               .addAnnotation("javax.xml.bind.annotation.XmlAccessorOrder");
      AnnotationSource<JavaPackageInfoSource> annotationXmlAccessorOrder = javaPkg.getAnnotation("XmlAccessorOrder");
      Assert.assertEquals(annotationXmlOrder.getName(), annotationXmlAccessorOrder.getName());
   }
View Full Code Here

{

   @Test
   public void testCanCreatePackageInfo() throws Exception
   {
      JavaPackageInfoSource packageInfo = Roaster.create(JavaPackageInfoSource.class);
      packageInfo.setPackage("org.jboss.forge.roaster");
      Assert.assertEquals("org.jboss.forge.roaster", packageInfo.getPackage());
      Assert.assertEquals("package-info", packageInfo.getName());
   }
View Full Code Here

   }

   @Test(expected = UnsupportedOperationException.class)
   public void testSetPackageInfoNameThrowsUnsupportedOperation() throws Exception
   {
      JavaPackageInfoSource packageInfo = Roaster.create(JavaPackageInfoSource.class);
      packageInfo.setName("anything");
   }
View Full Code Here

   @Test
   public void testCanParsePackageInfo() throws Exception
   {
      InputStream stream = JavaPackageInfoTest.class
               .getResourceAsStream("/org/jboss/forge/grammar/java/package-info.java");
      JavaPackageInfoSource javaPkg = Roaster.parse(JavaPackageInfoSource.class, stream);
      assertEquals("org.jboss.forge.test.roaster.model", javaPkg.getPackage());
      Assert.assertEquals("package-info", javaPkg.getName());
      Assert.assertNotNull(javaPkg.getImport("javax.xml.bind.annotation.XmlSchema"));
      Import XmlAccessTypeField = javaPkg.getImport("javax.xml.bind.annotation.XmlAccessType.FIELD");
      Assert.assertNotNull(XmlAccessTypeField);
      Assert.assertTrue(XmlAccessTypeField.isStatic());
      List<AnnotationSource<JavaPackageInfoSource>> annotations = javaPkg.getAnnotations();
      Assert.assertEquals(2, annotations.size());
      Annotation<JavaPackageInfoSource> annotation = javaPkg.getAnnotation("XmlSchema");
      List<ValuePair> values = annotation.getValues();
      Assert.assertEquals(3, values.size());
      String namespace = annotation.getLiteralValue("namespace");
      Assert.assertEquals(namespace, "\"http://forge.org/Test\"");

      AnnotationSource<JavaPackageInfoSource> annotationXmlOrder = javaPkg
               .addAnnotation("javax.xml.bind.annotation.XmlAccessorOrder");
      AnnotationSource<JavaPackageInfoSource> annotationXmlAccessorOrder = javaPkg.getAnnotation("XmlAccessorOrder");
      Assert.assertEquals(annotationXmlOrder.getName(), annotationXmlAccessorOrder.getName());
   }
View Full Code Here

TOP

Related Classes of org.jboss.forge.roaster.model.source.JavaPackageInfoSource

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.