[hibernate-commits] Hibernate SVN: r15909 - in validator/trunk: hibernate-validator and 5 other directories.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Fri Feb 6 05:26:41 EST 2009


Author: hardy.ferentschik
Date: 2009-02-06 05:26:41 -0500 (Fri, 06 Feb 2009)
New Revision: 15909

Added:
   validator/trunk/tck-utils/src/main/java/org/hibernate/tck/annotations/SpecAssertions.java
Modified:
   validator/trunk/hibernate-validator/pom.xml
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorImplTest.java
   validator/trunk/pom.xml
   validator/trunk/tck-utils/src/main/java/org/hibernate/tck/TCKAnnotationProcessor.java
   validator/trunk/tck-utils/src/main/java/org/hibernate/tck/annotations/SpecAssertion.java
   validator/trunk/tck-utils/src/main/java/org/hibernate/tck/report/CoverageProcessor.java
   validator/trunk/tck-utils/src/main/java/org/hibernate/tck/report/CoverageProcessorFactory.java
   validator/trunk/tck-utils/src/main/resources/META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory
Log:
Changes to tck-utils in order to get it compile. Changed to jvm target 1.6 in pom.

Modified: validator/trunk/hibernate-validator/pom.xml
===================================================================
--- validator/trunk/hibernate-validator/pom.xml	2009-02-05 18:18:05 UTC (rev 15908)
+++ validator/trunk/hibernate-validator/pom.xml	2009-02-06 10:26:41 UTC (rev 15909)
@@ -41,6 +41,7 @@
         <dependency>
             <groupId>org.hibernate</groupId>
             <artifactId>tck-utils</artifactId>
+            <version>0.9-SNAPSHOT</version>
             <scope>test</scope>
         </dependency>
     </dependencies>
@@ -149,24 +150,6 @@
                             <report>javadoc</report>
                         </reports>
                     </reportSet>
-                    <reportSet>
-                        <id>specCheck</id>
-                        <configuration>
-                            <doclet>org.hibernate.javadoc.JSRDoclet</doclet>
-                            <docletPath>${basedir}/target/test-classes</docletPath>
-                            <additionalparam>
-                                -d ${project.build.directory}/site
-                            </additionalparam>
-                            <!--Other dir than apidocs-->
-                            <destDir>tck</destDir>
-                            <!--For the project-reports page-->
-                            <name>JSR Tests</name>
-                            <description>Cross references unit tests to JSR 303 specification.</description>
-                        </configuration>
-                        <reports>
-                            <report>test-javadoc</report>
-                        </reports>
-                    </reportSet>
                 </reportSets>
             </plugin>
         </plugins>

Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorImplTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorImplTest.java	2009-02-05 18:18:05 UTC (rev 15908)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorImplTest.java	2009-02-06 10:26:41 UTC (rev 15909)
@@ -55,7 +55,7 @@
  */
 public class ValidatorImplTest {
 
-	@SpecAssertion( section = {"3.1"} )
+	@SpecAssertion( section = "3.1" )
 	@Test
 	public void testWrongMethodName() {
 		try {
@@ -324,7 +324,7 @@
 	}
 
 	@Test
-	@SpecAssertion( section = {"2.2"} )
+	@SpecAssertion( section = "2.2" )
 	public void testMultiValueConstraint() {
 		Validator validator = TestUtil.getValidator();
 
@@ -343,7 +343,7 @@
 	}
 
 	@Test
-	@SpecAssertion( section = {"3.5.1"} )
+	@SpecAssertion( section = "3.5.1" )
 	public void testGraphValidation() {
 		Validator validator = TestUtil.getValidator();
 

Modified: validator/trunk/pom.xml
===================================================================
--- validator/trunk/pom.xml	2009-02-05 18:18:05 UTC (rev 15908)
+++ validator/trunk/pom.xml	2009-02-06 10:26:41 UTC (rev 15909)
@@ -79,11 +79,6 @@
                 <artifactId>junit</artifactId>
                 <version>4.4</version>
             </dependency>
-            <dependency>
-                <groupId>org.hibernate</groupId>
-                <artifactId>tck-utils</artifactId>
-                <version>${version}</version>
-            </dependency>
         </dependencies>
     </dependencyManagement>
 
@@ -119,8 +114,8 @@
                     <artifactId>maven-compiler-plugin</artifactId>
                     <version>2.0.2</version>
                     <configuration>
-                        <source>1.5</source>
-                        <target>1.5</target>
+                        <source>1.6</source>
+                        <target>1.6</target>
                     </configuration>
                 </plugin>
                 <plugin>

Modified: validator/trunk/tck-utils/src/main/java/org/hibernate/tck/TCKAnnotationProcessor.java
===================================================================
--- validator/trunk/tck-utils/src/main/java/org/hibernate/tck/TCKAnnotationProcessor.java	2009-02-05 18:18:05 UTC (rev 15908)
+++ validator/trunk/tck-utils/src/main/java/org/hibernate/tck/TCKAnnotationProcessor.java	2009-02-06 10:26:41 UTC (rev 15909)
@@ -94,7 +94,7 @@
 		public void visitMethodDeclaration(MethodDeclaration d) {
 			SpecAssertion annotation = d.getAnnotation( SpecAssertion.class );
 			JSRReference ref = new JSRReference(
-					annotation.section()[0], d.getDeclaringType().getQualifiedName(), d.getSimpleName()
+					annotation.section(), d.getDeclaringType().getQualifiedName(), d.getSimpleName()
 			);
 			if ( annotation.note().length() > 0 ) {
 				ref.note = annotation.note();

Modified: validator/trunk/tck-utils/src/main/java/org/hibernate/tck/annotations/SpecAssertion.java
===================================================================
--- validator/trunk/tck-utils/src/main/java/org/hibernate/tck/annotations/SpecAssertion.java	2009-02-05 18:18:05 UTC (rev 15908)
+++ validator/trunk/tck-utils/src/main/java/org/hibernate/tck/annotations/SpecAssertion.java	2009-02-06 10:26:41 UTC (rev 15909)
@@ -25,8 +25,10 @@
 @Documented
 public @interface SpecAssertion {
 
-	public String[] section();
+	public String section();
 
+	public String id() default "";
+
 	public String note() default "";
 
 }

Added: validator/trunk/tck-utils/src/main/java/org/hibernate/tck/annotations/SpecAssertions.java
===================================================================
--- validator/trunk/tck-utils/src/main/java/org/hibernate/tck/annotations/SpecAssertions.java	                        (rev 0)
+++ validator/trunk/tck-utils/src/main/java/org/hibernate/tck/annotations/SpecAssertions.java	2009-02-06 10:26:41 UTC (rev 15909)
@@ -0,0 +1,30 @@
+// $Id: SpecAssertion.java 15705 2008-12-18 16:21:24Z hardy.ferentschik $
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.tck.annotations;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+
+ at Target(ElementType.METHOD)
+ at Documented
+public @interface SpecAssertions {
+
+	SpecAssertion[] value();
+
+}
\ No newline at end of file

Modified: validator/trunk/tck-utils/src/main/java/org/hibernate/tck/report/CoverageProcessor.java
===================================================================
--- validator/trunk/tck-utils/src/main/java/org/hibernate/tck/report/CoverageProcessor.java	2009-02-05 18:18:05 UTC (rev 15908)
+++ validator/trunk/tck-utils/src/main/java/org/hibernate/tck/report/CoverageProcessor.java	2009-02-06 10:26:41 UTC (rev 15909)
@@ -2,11 +2,11 @@
 
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.hibernate.tck.annotations.SpecAssertion;
-
 import com.sun.mirror.apt.AnnotationProcessor;
 import com.sun.mirror.apt.AnnotationProcessorEnvironment;
 import com.sun.mirror.declaration.AnnotationTypeDeclaration;
@@ -15,91 +15,125 @@
 import com.sun.mirror.util.DeclarationVisitors;
 import com.sun.mirror.util.SimpleDeclarationVisitor;
 
+import org.hibernate.tck.annotations.SpecAssertion;
+import org.hibernate.tck.annotations.SpecAssertions;
+
 /**
  * Annotation processor for generating TCK coverage report
- * 
+ *
  * @author Shane Bryzak
  */
-public class CoverageProcessor implements AnnotationProcessor
-{
-   private static final String OUTDIR_OPTION_NAME = "-s";
-   private static final String REPORT_FILE_NAME = "coverage.html"; 
-   
-   private static final String AUDIT_FILE_NAME = "tck-audit.xml";
-      
-   private final AnnotationProcessorEnvironment env;
-   private final File baseDir;
-   
-   private final List<SpecReference> references = new ArrayList<SpecReference>();
-   
-   private AuditParser auditParser;
-   
-   public CoverageProcessor(AnnotationProcessorEnvironment env)
-   {
-      this.env = env;
-      String baseDirName = env.getOptions().get( OUTDIR_OPTION_NAME );
-      baseDir = new File( baseDirName );
-      baseDir.mkdirs();
-      
-      try
-      {
-         auditParser = new AuditParser(new FileInputStream(AUDIT_FILE_NAME));
-         auditParser.parse();
-      }
-      catch (Exception ex)
-      {
-         throw new RuntimeException("Error parsing tck-audit.xml: " + 
-               ex.getClass().getName() + " - " + ex.getMessage(), ex);
-      }
-   }
+public class CoverageProcessor implements AnnotationProcessor {
+	private static final String OUTDIR_OPTION_FLAG = "-s";
+	private static final String AUDITFILE_OPTION_FLAG = "-a";
+	private static final String REPORT_FILE_NAME = "coverage.html";
 
-   public void process()
-   {
-      AnnotationTypeDeclaration annotationType = (AnnotationTypeDeclaration) 
-         env.getTypeDeclaration(SpecAssertion.class.getCanonicalName());
-      
-      for (Declaration d : env.getDeclarationsAnnotatedWith(annotationType))
-      {
-         d.accept(DeclarationVisitors.getDeclarationScanner(
-               new CreateReferenceVisitor(), DeclarationVisitors.NO_OP));
-      }
-      
-      annotationType = (AnnotationTypeDeclaration) 
-      env.getTypeDeclaration(SpecAssertions.class.getCanonicalName());
-      for (Declaration d : env.getDeclarationsAnnotatedWith(annotationType))
-      {
-         d.accept(DeclarationVisitors.getDeclarationScanner(
-               new CreateReferenceVisitor(), DeclarationVisitors.NO_OP));
-      }      
-      
-      
-      new CoverageReport(references, auditParser).writeToFile(new File(baseDir, REPORT_FILE_NAME));
-   }     
-   
-   private class CreateReferenceVisitor extends SimpleDeclarationVisitor 
-   {
-      public void visitMethodDeclaration(MethodDeclaration d) 
-      {
-         SpecAssertions assertions = d.getAnnotation ( SpecAssertions.class );
-         if (assertions != null)
-         {
-            for (SpecAssertion assertion : assertions.value())
-            {
-               SpecReference ref = new SpecReference(
-                     assertion.section(), assertion.id(), 
-                     d.getDeclaringType().getSimpleName(), d.getSimpleName()); 
-               references.add( ref );               
-            }
-         }
-         
-         SpecAssertion assertion = d.getAnnotation( SpecAssertion.class );
-         if (assertion != null)
-         {
-            SpecReference ref = new SpecReference(
-                  assertion.section(), assertion.id(), 
-                  d.getDeclaringType().getSimpleName(), d.getSimpleName()); 
-            references.add( ref );
-         }
-      }
-   }   
+	private static final String DEFAULT_AUDIT_FILE_NAME = "tck-audit.xml";
+
+	private final AnnotationProcessorEnvironment env;
+
+	private final List<SpecReference> references = new ArrayList<SpecReference>();
+
+	private AuditParser auditParser;
+
+	private File baseDir;
+
+	public CoverageProcessor(AnnotationProcessorEnvironment env) {
+		this.env = env;
+
+		createOutputDir( env );
+		InputStream in = getAuditFileInputStream( env );
+
+		if ( in == null ) {
+			return;
+		}
+
+		try {
+			auditParser = new AuditParser( in );
+			auditParser.parse();
+		}
+		catch ( Exception e ) {
+			throw new RuntimeException( "Unable to parse audit file." );
+		}
+	}
+
+	private InputStream getAuditFileInputStream(AnnotationProcessorEnvironment env) {
+		InputStream in;
+		String auditFileName = env.getOptions().get( AUDITFILE_OPTION_FLAG );
+		if ( auditFileName == null || auditFileName.length() == 0 ) {
+			env.getMessager()
+					.printNotice( "No audit file specified on the command line. Trying default: " + DEFAULT_AUDIT_FILE_NAME );
+			auditFileName = DEFAULT_AUDIT_FILE_NAME;
+		}
+		try {
+			in = new FileInputStream( auditFileName );
+		}
+		catch ( IOException ex ) {
+			env.getMessager().printWarning( "Unable to open audit file - " + auditFileName );
+			env.getMessager().printWarning( "No report generated" );
+			return null;
+		}
+		return in;
+	}
+
+	private void createOutputDir(AnnotationProcessorEnvironment env) {
+		String baseDirName = env.getOptions().get( OUTDIR_OPTION_FLAG );
+		baseDir = new File( baseDirName );
+		baseDir.mkdirs();
+	}
+
+	public void process() {
+		if ( auditParser == null ) {
+			return;
+		}
+
+		AnnotationTypeDeclaration annotationType = ( AnnotationTypeDeclaration )
+				env.getTypeDeclaration( SpecAssertion.class.getCanonicalName() );
+
+
+		for ( Declaration d : env.getDeclarationsAnnotatedWith( annotationType ) ) {
+			d.accept(
+					DeclarationVisitors.getDeclarationScanner(
+							new CreateReferenceVisitor(), DeclarationVisitors.NO_OP
+					)
+			);
+		}
+
+		annotationType = ( AnnotationTypeDeclaration )
+				env.getTypeDeclaration( SpecAssertions.class.getCanonicalName() );
+		for ( Declaration d : env.getDeclarationsAnnotatedWith( annotationType ) ) {
+			d.accept(
+					DeclarationVisitors.getDeclarationScanner(
+							new CreateReferenceVisitor(), DeclarationVisitors.NO_OP
+					)
+			);
+		}
+
+
+		new CoverageReport( references, auditParser ).writeToFile( new File( baseDir, REPORT_FILE_NAME ) );
+	}
+
+	private class CreateReferenceVisitor extends SimpleDeclarationVisitor {
+		public void visitMethodDeclaration(MethodDeclaration d) {
+			SpecAssertions assertions = d.getAnnotation( SpecAssertions.class );
+			if ( assertions != null ) {
+				for ( SpecAssertion assertion : assertions.value() ) {
+					SpecReference ref = new SpecReference(
+							assertion.section(), assertion.id(),
+							d.getDeclaringType().getSimpleName(), d.getSimpleName()
+					);
+					references.add( ref );
+				}
+			}
+
+			SpecAssertion assertion = d.getAnnotation( SpecAssertion.class );
+			if ( assertion != null ) {
+				SpecReference ref = new SpecReference(
+						assertion.section(), assertion.id(),
+						d.getDeclaringType().getSimpleName(), d.getSimpleName()
+				);
+				references.add( ref );
+			}
+		}
+	}
 }
Modified: validator/trunk/tck-utils/src/main/java/org/hibernate/tck/report/CoverageProcessorFactory.java
===================================================================
--- validator/trunk/tck-utils/src/main/java/org/hibernate/tck/report/CoverageProcessorFactory.java	2009-02-05 18:18:05 UTC (rev 15908)
+++ validator/trunk/tck-utils/src/main/java/org/hibernate/tck/report/CoverageProcessorFactory.java	2009-02-06 10:26:41 UTC (rev 15909)
@@ -6,6 +6,7 @@
 import java.util.Set;
 
 import org.hibernate.tck.annotations.SpecAssertion;
+import org.hibernate.tck.annotations.SpecAssertions;
 
 import com.sun.mirror.apt.AnnotationProcessor;
 import com.sun.mirror.apt.AnnotationProcessorEnvironment;
Modified: validator/trunk/tck-utils/src/main/resources/META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory
===================================================================
--- validator/trunk/tck-utils/src/main/resources/META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory	2009-02-05 18:18:05 UTC (rev 15908)
+++ validator/trunk/tck-utils/src/main/resources/META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory	2009-02-06 10:26:41 UTC (rev 15909)
@@ -1 +1 @@
-org.hibernate.tck.TCKAnnotationProcessorFactory
\ No newline at end of file
+org.hibernate.tck.report.CoverageProcessorFactory
\ No newline at end of file




More information about the hibernate-commits mailing list