Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 67529 invoked from network); 10 Sep 2004 20:49:48 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 10 Sep 2004 20:49:48 -0000 Received: (qmail 48218 invoked by uid 500); 10 Sep 2004 20:49:42 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 48170 invoked by uid 500); 10 Sep 2004 20:49:42 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 48154 invoked by uid 500); 10 Sep 2004 20:49:42 -0000 Received: (qmail 48150 invoked by uid 99); 10 Sep 2004 20:49:41 -0000 X-ASF-Spam-Status: No, hits=-2.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Fri, 10 Sep 2004 13:49:39 -0700 Received: (qmail 67463 invoked by uid 1449); 10 Sep 2004 20:49:38 -0000 Date: 10 Sep 2004 20:49:38 -0000 Message-ID: <20040910204938.67462.qmail@minotaur.apache.org> From: leosutic@apache.org To: jakarta-commons-cvs@apache.org Subject: cvs commit: jakarta-commons/attributes/unittest/src/test/org/apache/commons/attributes/test AttributesTestCase.java InnerClassTestCase.java TargetTestCase.java X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N leosutic 2004/09/10 13:49:38 Modified: attributes build.xml attributes/api project.xml attributes/compiler project.xml attributes/compiler/src/java/org/apache/commons/attributes/compiler AttributeCompiler.java attributes/compiler/src/test/org/apache/commons/attributes/compiler/test AttributeExpressionParserTestCase.java attributes/plugin plugin.jelly project.xml attributes/site/etc/maven_demo project.xml attributes/site/xdocs ant_demo.xml changelog.xml index.xml attributes/unittest project.xml attributes/unittest/src/test/org/apache/commons/attributes/test AttributesTestCase.java InnerClassTestCase.java TargetTestCase.java Log: Ported to qDox 1.5 from xjavadoc. Revision Changes Path 1.9 +1 -3 jakarta-commons/attributes/build.xml Index: build.xml =================================================================== RCS file: /home/cvs/jakarta-commons/attributes/build.xml,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- build.xml 27 Aug 2004 21:30:10 -0000 1.8 +++ build.xml 10 Sep 2004 20:49:37 -0000 1.9 @@ -140,9 +140,7 @@ - - - + 1.2 +7 -0 jakarta-commons/attributes/api/project.xml Index: project.xml =================================================================== RCS file: /home/cvs/jakarta-commons/attributes/api/project.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- project.xml 6 Jul 2004 20:41:05 -0000 1.1 +++ project.xml 10 Sep 2004 20:49:38 -0000 1.2 @@ -41,6 +41,12 @@ + qdox + 1.5 + + + 1.6 +7 -0 jakarta-commons/attributes/compiler/project.xml Index: project.xml =================================================================== RCS file: /home/cvs/jakarta-commons/attributes/compiler/project.xml,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- project.xml 27 Aug 2004 21:30:11 -0000 1.5 +++ project.xml 10 Sep 2004 20:49:38 -0000 1.6 @@ -42,9 +42,16 @@ 1.5 + + + + qdox + 1.5 1.2 +132 -109 jakarta-commons/attributes/compiler/src/java/org/apache/commons/attributes/compiler/AttributeCompiler.java Index: AttributeCompiler.java =================================================================== RCS file: /home/cvs/jakarta-commons/attributes/compiler/src/java/org/apache/commons/attributes/compiler/AttributeCompiler.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- AttributeCompiler.java 6 Jul 2004 20:42:02 -0000 1.1 +++ AttributeCompiler.java 10 Sep 2004 20:49:38 -0000 1.2 @@ -27,22 +27,19 @@ import java.util.StringTokenizer; import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; import org.apache.tools.ant.types.FileSet; import org.apache.tools.ant.types.Path; -import xjavadoc.SourceClass; -import xjavadoc.XClass; -import xjavadoc.XConstructor; -import xjavadoc.XJavaDoc; -import xjavadoc.XField; -import xjavadoc.XMethod; -import xjavadoc.XParameter; -import xjavadoc.XProgramElement; -import xjavadoc.XTag; -import xjavadoc.ant.XJavadocTask; -import xjavadoc.filesystem.AbstractFile; +import com.thoughtworks.qdox.JavaDocBuilder; +import com.thoughtworks.qdox.model.JavaClass; +import com.thoughtworks.qdox.model.JavaField; +import com.thoughtworks.qdox.model.JavaMethod; +import com.thoughtworks.qdox.model.DocletTag; +import com.thoughtworks.qdox.model.JavaParameter; + /** * Ant task to compile attributes. Usage: @@ -64,7 +61,7 @@ * additional Java source files in the destination directory that should be compiled * along with the input source files. (See the overview for a diagram.) */ -public class AttributeCompiler extends XJavadocTask { +public class AttributeCompiler extends Task { private final ArrayList fileSets = new ArrayList (); private Path src; @@ -81,7 +78,6 @@ } public void addFileset (FileSet set) { - super.addFileset (set); fileSets.add (set); } @@ -115,18 +111,19 @@ } } - protected void addExpressions (Collection tags, PrintWriter pw, String collectionName, File sourceFile) { + protected void addExpressions (DocletTag[] tags, PrintWriter pw, String collectionName, File sourceFile) { addExpressions (tags, null, pw, collectionName, sourceFile); } - protected void addExpressions (Collection tags, String selector, PrintWriter pw, String collectionName, File sourceFile) { + protected void addExpressions (DocletTag[] tags, String selector, PrintWriter pw, String collectionName, File sourceFile) { String fileName = sourceFile != null ? sourceFile.getPath ().replace ('\\', '/') : ""; - Iterator iter = tags.iterator (); - while (iter.hasNext ()) { - XTag tag = (XTag) iter.next (); + for (int i = 0; i < tags.length; i++) { + DocletTag tag = tags[i]; if (isAttribute (tag)) { - String expression = tag.getName () + " " + tag.getValue (); + String tagName = tag.getName (); + String tagValue = tag.getValue (); + String expression = tagName + " " + tagValue; expression = expression.trim (); // Remove the second @-sign. @@ -195,11 +192,18 @@ } } - protected boolean elementHasAttributes (Collection xElements) { - Iterator iter = xElements.iterator (); - while (iter.hasNext ()) { - XProgramElement element = (XProgramElement) iter.next (); - if (tagHasAttributes (element.getDoc ().getTags ())) { + protected boolean elementHasAttributes (JavaField[] fields) { + for (int i = 0; i < fields.length; i++) { + if (tagHasAttributes (fields[i].getTags ())) { + return true; + } + } + return false; + } + + protected boolean elementHasAttributes (JavaMethod[] methods) { + for (int i = 0; i < methods.length; i++) { + if (tagHasAttributes (methods[i].getTags ())) { return true; } } @@ -209,56 +213,53 @@ /** * Encodes a class name to the internal Java name. * For example, an inner class Outer.Inner will be - * encoed as Outer$Inner. + * encoded as Outer$Inner. */ - private void getTransformedQualifiedName (XClass type, StringBuffer sb) { - - if (type.isInner ()) { - String packageName = type.getContainingPackage ().getName (); - sb.append (packageName); - if (packageName.length () > 0) { - sb.append ("."); - } - sb.append (type.getName ().replace ('.','$')); - } else { - sb.append (type.getQualifiedName ()); - } + private void getTransformedQualifiedName (JavaClass type, StringBuffer sb) { + sb.append (type.getFullyQualifiedName ()); } - protected String getParameterTypes (Collection parameters) { + protected String getParameterTypes (JavaParameter[] parameters) { StringBuffer sb = new StringBuffer (); - for (Iterator params = parameters.iterator (); params.hasNext ();) { - XParameter parameter = (XParameter) params.next (); - getTransformedQualifiedName (parameter.getType (), sb); - sb.append (parameter.getDimensionAsString ()); - - if (params.hasNext ()) { + for (int i = 0; i < parameters.length; i++) { + if (i > 0) { sb.append (","); } + + getTransformedQualifiedName (parameters[i].getType ().getJavaClass (), sb); + for (int j = 0; j < parameters[i].getType ().getDimensions (); j++) { + sb.append ("[]"); + } } return sb.toString (); } - protected void generateClass (XClass xClass) throws Exception { + protected void generateClass (JavaClass javaClass) throws Exception { String name = null; File sourceFile = null; File destFile = null; String packageName = null; String className = null; - packageName = xClass.getContainingPackage().getName (); + packageName = javaClass.getPackage (); + if (packageName == null) { + packageName = ""; + } - if (xClass.isInner ()) { - name = xClass.getQualifiedName ().substring (packageName.length ()); - - sourceFile = getSourceFile (xClass); + if (javaClass.isInner ()) { + sourceFile = getSourceFile (javaClass); - className = xClass.getName ().replace ('.', '$'); - name = packageName + (packageName.length () > 0 ? "." : "") + className; + String nonPackagePrefix = javaClass.getParent ().getClassNamePrefix (); + if (packageName.length () > 0) { + nonPackagePrefix = nonPackagePrefix.substring (packageName.length () + 1); + } + + className = nonPackagePrefix + javaClass.getName (); + name = javaClass.getParent ().getClassNamePrefix () + javaClass.getName (); } else { - name = xClass.getQualifiedName (); - sourceFile = getSourceFile (xClass); - className = xClass.getName (); + name = javaClass.getFullyQualifiedName (); + sourceFile = getSourceFile (javaClass); + className = javaClass.getName (); } if (sourceFile == null) { @@ -267,13 +268,13 @@ destFile = new File (destDir, name.replace ('.', '/') + "$__attributeRepository.java"); - if (xClass.isAnonymous ()) { - log (xClass.getName () + " is anonymous - ignoring.", Project.MSG_VERBOSE); - numIgnored++; - return; - } + /*if (javaClass.isAnonymous ()) { + log (javaClass.getName () + " is anonymous - ignoring.", Project.MSG_VERBOSE); + numIgnored++; + return; + }*/ - if (!hasAttributes (xClass)) { + if (!hasAttributes (javaClass)) { if (destFile.exists ()) { destFile.delete (); } @@ -326,7 +327,7 @@ pw.println (); pw.println (" private void initClassAttributes () {"); - addExpressions (xClass.getDoc ().getTags (), pw, "classAttributes", sourceFile); + addExpressions (javaClass.getTags (), pw, "classAttributes", sourceFile); pw.println (" }"); pw.println (); @@ -334,13 +335,14 @@ pw.println (" private void initFieldAttributes () {"); pw.println (" java.util.Set attrs = null;"); - for (Iterator iter = xClass.getFields ().iterator (); iter.hasNext ();) { - XField member = (XField) iter.next (); - if (member.getDoc ().getTags ().size () > 0) { + JavaField[] fields = javaClass.getFields (); + for (int i = 0; i < fields.length; i++) { + JavaField member = (JavaField) fields[i]; + if (member.getTags ().length > 0) { String key = member.getName (); pw.println (" attrs = new java.util.HashSet ();"); - addExpressions (member.getDoc ().getTags (), pw, "attrs", sourceFile); + addExpressions (member.getTags (), pw, "attrs", sourceFile); pw.println (" fieldAttributes.put (\"" + key + "\", attrs);"); pw.println (" attrs = null;"); pw.println (); @@ -353,9 +355,11 @@ pw.println (" private void initMethodAttributes () {"); pw.println (" java.util.Set attrs = null;"); pw.println (" java.util.List bundle = null;"); - for (Iterator iter = xClass.getMethods ().iterator (); iter.hasNext ();) { - XMethod member = (XMethod) iter.next (); - if (member.getDoc ().getTags ().size () > 0) { + JavaMethod[] methods = javaClass.getMethods (); + + for (int i = 0; i < methods.length; i++) { + JavaMethod member = (JavaMethod) methods[i]; + if (!member.isConstructor () && member.getTags ().length > 0) { StringBuffer sb = new StringBuffer (); sb.append (member.getName ()).append ("("); sb.append (getParameterTypes (member.getParameters ())); @@ -364,19 +368,20 @@ pw.println (" bundle = new java.util.ArrayList ();"); pw.println (" attrs = new java.util.HashSet ();"); - addExpressions (member.getDoc ().getTags (), null, pw, "attrs", sourceFile); + addExpressions (member.getTags (), null, pw, "attrs", sourceFile); pw.println (" bundle.add (attrs);"); pw.println (" attrs = null;"); pw.println (" attrs = new java.util.HashSet ();"); - addExpressions (member.getDoc ().getTags (), "return", pw, "attrs", sourceFile); + addExpressions (member.getTags (), "return", pw, "attrs", sourceFile); pw.println (" bundle.add (attrs);"); pw.println (" attrs = null;"); - for (Iterator parameters = member.getParameters ().iterator (); parameters.hasNext ();) { - XParameter parameter = (XParameter) parameters.next (); + JavaParameter[] parameters = member.getParameters (); + for (int j = 0; j < parameters.length; j++) { + JavaParameter parameter = (JavaParameter) parameters[j]; pw.println (" attrs = new java.util.HashSet ();"); - addExpressions (member.getDoc ().getTags (), parameter.getName (), pw, "attrs", sourceFile); + addExpressions (member.getTags (), parameter.getName (), pw, "attrs", sourceFile); pw.println (" bundle.add (attrs);"); pw.println (" attrs = null;"); } @@ -394,9 +399,11 @@ pw.println (" private void initConstructorAttributes () {"); pw.println (" java.util.Set attrs = null;"); pw.println (" java.util.List bundle = null;"); - for (Iterator iter = xClass.getConstructors ().iterator (); iter.hasNext ();) { - XConstructor member = (XConstructor) iter.next (); - if (member.getDoc ().getTags ().size () > 0) { + + JavaMethod[] constructors = javaClass.getMethods (); + for (int i = 0; i < constructors.length; i++) { + JavaMethod member = (JavaMethod) constructors[i]; + if (member.isConstructor () && member.getTags ().length > 0) { StringBuffer sb = new StringBuffer (); sb.append ("("); sb.append (getParameterTypes (member.getParameters ())); @@ -405,14 +412,15 @@ pw.println (" bundle = new java.util.ArrayList ();"); pw.println (" attrs = new java.util.HashSet ();"); - addExpressions (member.getDoc ().getTags (), null, pw, "attrs", sourceFile); + addExpressions (member.getTags (), null, pw, "attrs", sourceFile); pw.println (" bundle.add (attrs);"); pw.println (" attrs = null;"); - for (Iterator parameters = member.getParameters ().iterator (); parameters.hasNext ();) { - XParameter parameter = (XParameter) parameters.next (); + JavaParameter[] parameters = member.getParameters (); + for (int j = 0; j < parameters.length; j++) { + JavaParameter parameter = (JavaParameter) parameters[j]; pw.println (" attrs = new java.util.HashSet ();"); - addExpressions (member.getDoc ().getTags (), parameter.getName (), pw, "attrs", sourceFile); + addExpressions (member.getTags (), parameter.getName (), pw, "attrs", sourceFile); pw.println (" bundle.add (attrs);"); pw.println (" attrs = null;"); } @@ -441,23 +449,14 @@ * @return the file the class is defined in. * @throws BuildException if the file could not be found. */ - protected File getSourceFile (XClass xClass) throws BuildException { - while (xClass != null && xClass.isInner ()) { - xClass = xClass.getContainingClass (); - } - - if (xClass != null && xClass instanceof SourceClass) { - AbstractFile af = ((SourceClass) xClass).getFile (); - return new File (af.getPath ()); - } - return null; + protected File getSourceFile (JavaClass javaClass) throws BuildException { + return javaClass.getSource ().getFile (); } - protected boolean hasAttributes (XClass xClass) { - if (tagHasAttributes (xClass.getDoc ().getTags ()) || - elementHasAttributes (xClass.getFields ()) || - elementHasAttributes (xClass.getMethods ()) || - elementHasAttributes (xClass.getConstructors ()) ) { + protected boolean hasAttributes (JavaClass javaClass) { + if (tagHasAttributes (javaClass.getTags ()) || + elementHasAttributes (javaClass.getFields ()) || + elementHasAttributes (javaClass.getMethods ()) ) { return true; } return false; @@ -467,35 +466,59 @@ * Tests if a tag is an attribute. Currently the test is * only "check if it is defined with two @-signs". */ - protected boolean isAttribute (XTag tag) { + protected boolean isAttribute (DocletTag tag) { return tag.getName ().length () > 0 && tag.getName ().charAt (0) == '@'; } - protected void start() throws BuildException { + public void execute () throws BuildException { destDir.mkdirs (); numGenerated = 0; - XJavaDoc doc = getXJavaDoc (); - Iterator iter = doc.getSourceClasses ().iterator (); try { - while (iter.hasNext ()) { - XClass xClass = (XClass) iter.next (); - generateClass (xClass); + JavaDocBuilder builder = new JavaDocBuilder (); + for (int i = 0; i < fileSets.size (); i++) { + FileSet fs = (FileSet) fileSets.get (i); + DirectoryScanner ds = fs.getDirectoryScanner(project); + File fromDir = fs.getDir(project); + + String[] srcFiles = ds.getIncludedFiles(); + + for (int j = 0; j < srcFiles.length; j++) { + String srcName = srcFiles[j]; + + File sourceFile = new File (fromDir, srcName); + builder.addSource (sourceFile); + } } + + JavaClass[] classes = builder.getClasses (); + for (int i = 0; i < classes.length; i++) { + generateClassAndInners (classes[i]); + } + + log ("Generated attribute information for " + numGenerated + " classes. Ignored " + numIgnored + " classes."); + } catch (BuildException be) { + throw be; } catch (Exception e) { + e.printStackTrace (); throw new BuildException (e.toString (), e); + } + } + + public void generateClassAndInners (JavaClass clazz) throws Exception { + generateClass (clazz); + JavaClass[] classes = clazz.getInnerClasses (); + for (int i = 0; i < classes.length; i++) { + generateClassAndInners (classes[i]); } - log ("Generated attribute information for " + numGenerated + " classes. Ignored " + numIgnored + " classes."); } /** * Checks if a collection of XTags contain any tags specifying attributes. */ - protected boolean tagHasAttributes (Collection tags) { - Iterator iter = tags.iterator (); - while (iter.hasNext ()) { - XTag tag = (XTag) iter.next (); - if (isAttribute (tag)) { + protected boolean tagHasAttributes (DocletTag[] tags) { + for (int i = 0; i < tags.length; i++) { + if (isAttribute (tags[i])) { return true; } } 1.2 +16 -0 jakarta-commons/attributes/compiler/src/test/org/apache/commons/attributes/compiler/test/AttributeExpressionParserTestCase.java Index: AttributeExpressionParserTestCase.java =================================================================== RCS file: /home/cvs/jakarta-commons/attributes/compiler/src/test/org/apache/commons/attributes/compiler/test/AttributeExpressionParserTestCase.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- AttributeExpressionParserTestCase.java 6 Jul 2004 20:42:09 -0000 1.1 +++ AttributeExpressionParserTestCase.java 10 Sep 2004 20:49:38 -0000 1.2 @@ -68,6 +68,22 @@ new AttributeExpressionParser.Argument("alpha", "'\"'", 0), new AttributeExpressionParser.Argument("beta", "\"\\\'\"", 0) }); + + /* + singleTest ("my.package.AnAttribute( \"sometext,1,2\" , 'a' , ',' , alpha='\"', beta=\"\\\'\")", + "my.package.AnAttribute", new AttributeExpressionParser.Argument[] { + new AttributeExpressionParser.Argument(null, "\"sometext,1,2\" ", 0), + new AttributeExpressionParser.Argument(null, "'a'", 0), + new AttributeExpressionParser.Argument(null, "','", 0), + new AttributeExpressionParser.Argument("alpha", "'\"'", 0), + new AttributeExpressionParser.Argument("beta", "\"\\\'\"", 0) + }); + */ + + singleTest ("AnAttribute( \"sometext,1,2\" )", + "AnAttribute", new AttributeExpressionParser.Argument[] { + new AttributeExpressionParser.Argument(null, " \"sometext,1,2\" ", 0) + }); } } 1.3 +1 -4 jakarta-commons/attributes/plugin/plugin.jelly Index: plugin.jelly =================================================================== RCS file: /home/cvs/jakarta-commons/attributes/plugin/plugin.jelly,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- plugin.jelly 24 Jul 2004 13:51:10 -0000 1.2 +++ plugin.jelly 10 Sep 2004 20:49:38 -0000 1.3 @@ -26,10 +26,7 @@ - - - - + 1.5 - - - xml-apis - 1.0.b2 - http://xml.apache.org/xerces2-j/ - - - - xerces - 2.2.1 - http://xml.apache.org/xerces2-j/ - - - - - commons-collections - 2.1 - - - commons-logging - 1.0.1 - - - log4j - 1.1.3 - - - xdoclet+xjavadoc - 1.0 + qdox + 1.5 1.2 +2 -7 jakarta-commons/attributes/site/etc/maven_demo/project.xml Index: project.xml =================================================================== RCS file: /home/cvs/jakarta-commons/attributes/site/etc/maven_demo/project.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- project.xml 24 Jul 2004 13:50:17 -0000 1.1 +++ project.xml 10 Sep 2004 20:49:38 -0000 1.2 @@ -39,8 +39,8 @@ - xdoclet+xjavadoc - 1.0 + qdox + 1.5 @@ -52,11 +52,6 @@ commons-attributes commons-attributes-compiler - 2.1 - - - - commons-collections 2.1 1.3 +1 -4 jakarta-commons/attributes/site/xdocs/ant_demo.xml Index: ant_demo.xml =================================================================== RCS file: /home/cvs/jakarta-commons/attributes/site/xdocs/ant_demo.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ant_demo.xml 15 Aug 2004 16:28:15 -0000 1.2 +++ ant_demo.xml 10 Sep 2004 20:49:38 -0000 1.3 @@ -55,10 +55,7 @@

  • -

    Commons Collections 2.1: commons-collections-2.1.jar

    -
  • -
  • -

    Xjavadoc 1.0: xjavadoc-1.0.jar

    +

    qDox 1.5: qdox-1.5.jar

  • 1.7 +11 -0 jakarta-commons/attributes/site/xdocs/changelog.xml Index: changelog.xml =================================================================== RCS file: /home/cvs/jakarta-commons/attributes/site/xdocs/changelog.xml,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- changelog.xml 28 Aug 2004 21:12:46 -0000 1.6 +++ changelog.xml 10 Sep 2004 20:49:38 -0000 1.7 @@ -24,6 +24,17 @@ +
    +
      +
    • +

      + Ported the code to qDox. XJavadoc had an annoying bug where it would silently rewrite the value of + a JavaDoc tag, making the resulting expression unparseable by the attribute compiler. +

      +
    • +
    +
    +
    • 1.7 +1 -4 jakarta-commons/attributes/site/xdocs/index.xml Index: index.xml =================================================================== RCS file: /home/cvs/jakarta-commons/attributes/site/xdocs/index.xml,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- index.xml 15 Aug 2004 16:28:15 -0000 1.6 +++ index.xml 10 Sep 2004 20:49:38 -0000 1.7 @@ -65,10 +65,7 @@

      Ant task: commons-attributes-compiler-2.1.jar

    • -

      Commons Collections 2.1: commons-collections-2.1.jar

      -
    • -
    • -

      Xjavadoc 1.0: xjavadoc-1.0.jar

      +

      qDox 1.5: qdox-1.5.jar

    1.6 +7 -1 jakarta-commons/attributes/unittest/project.xml Index: project.xml =================================================================== RCS file: /home/cvs/jakarta-commons/attributes/unittest/project.xml,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- project.xml 27 Aug 2004 21:30:11 -0000 1.5 +++ project.xml 10 Sep 2004 20:49:38 -0000 1.6 @@ -41,6 +41,7 @@ 1.5 + + + + qdox + 1.5 + commons-attributes 1.2 +0 -67 jakarta-commons/attributes/unittest/src/test/org/apache/commons/attributes/test/AttributesTestCase.java Index: AttributesTestCase.java =================================================================== RCS file: /home/cvs/jakarta-commons/attributes/unittest/src/test/org/apache/commons/attributes/test/AttributesTestCase.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- AttributesTestCase.java 6 Jul 2004 20:43:35 -0000 1.1 +++ AttributesTestCase.java 10 Sep 2004 20:49:38 -0000 1.2 @@ -98,44 +98,6 @@ assertTrue (Attributes.hasParameterAttribute (c, 1, new ThreadSafe ())); } - public void testClassInheritance () throws Exception { - Class c = Sample.class; - assertEquals (5, Attributes.getAttributes (c).size ()); - assertEquals (4, Attributes.getAttributes (c, Dependency.class).size ()); - assertTrue (Attributes.hasAttributeType (c, Dependency.class)); - assertTrue (Attributes.hasAttributeType (c, ThreadSafe.class)); - assertTrue (Attributes.hasAttribute (c, new Dependency ( SampleService.class, "sample" ))); - assertTrue (Attributes.hasAttribute (c, new Dependency ( SampleService.class, "super-sample" ))); - assertTrue (Attributes.hasAttribute (c, new Dependency ( SampleService.class, "sample-if-1-c" ))); - assertTrue (Attributes.hasAttribute (c, new Dependency ( SampleService.class, "sample-if-2-c" ))); - assertTrue (Attributes.hasAttribute (c, new ThreadSafe ())); - } - - public void testMethodInheritance () throws Exception { - Method m = Sample.class.getMethod ("someMethod", new Class[]{ Integer.TYPE }); - assertEquals (4, Attributes.getAttributes (m).size ()); - assertEquals (4, Attributes.getAttributes (m, Dependency.class).size ()); - assertTrue (Attributes.hasAttributeType (m, Dependency.class)); - assertTrue (Attributes.hasAttribute (m, new Dependency ( SampleService.class, "super-some-method-sample" ))); - assertTrue (Attributes.hasAttribute (m, new Dependency ( SampleService.class, "sample-some-method2" ) )); - assertTrue (Attributes.hasAttribute (m, new Dependency ( SampleService.class, "sample-if-1" ) )); - assertTrue (Attributes.hasAttribute (m, new Dependency ( SampleService.class, "sample-if-2" ) )); - } - - public void testPrivateMethodNonInheritance () throws Exception { - Method m = Sample.class.getDeclaredMethod ("privateMethod", new Class[]{}); - assertEquals (1, Attributes.getAttributes (m).size ()); - assertEquals (1, Attributes.getAttributes (m, Dependency.class).size ()); - assertTrue (Attributes.hasAttributeType (m, Dependency.class)); - assertTrue (Attributes.hasAttribute (m, new Dependency ( SampleService.class, "sample-privateMethod" ) )); - - m = SuperSample.class.getDeclaredMethod ("privateMethod", new Class[]{}); - assertEquals (1, Attributes.getAttributes (m).size ()); - assertEquals (1, Attributes.getAttributes (m, Dependency.class).size ()); - assertTrue (Attributes.hasAttributeType (m, Dependency.class)); - assertTrue (Attributes.hasAttribute (m, new Dependency ( SampleService.class, "super-privateMethod" ) )); - } - public void testParameterAndReturnAttributes () throws Exception { Method m = Sample.class.getMethod ("methodWithAttributes", new Class[]{ Integer.TYPE, Integer.TYPE }); assertEquals (0, Attributes.getAttributes (m).size ()); @@ -147,35 +109,6 @@ assertEquals (2, Attributes.getParameterAttributes (m, 1).size ()); assertTrue (Attributes.hasParameterAttribute (m, 1, new Dependency ( SampleService.class, "sample-if-param-2" ) )); assertTrue (Attributes.hasParameterAttribute (m, 1, new ThreadSafe () )); - } - - public void testFieldNonInheritance () throws Exception { - Field f = SuperSample.class.getField ("field"); - assertEquals (2, Attributes.getAttributes (f).size ()); - assertEquals (1, Attributes.getAttributes (f, ThreadSafe.class).size ()); - assertEquals (1, Attributes.getAttributes (f, Dependency.class).size ()); - assertTrue (Attributes.hasAttributeType (f, ThreadSafe.class)); - assertTrue (Attributes.hasAttributeType (f, Dependency.class)); - assertTrue (Attributes.hasAttribute (f, new ThreadSafe ())); - assertTrue (Attributes.hasAttribute (f, new Dependency ( SampleService.class, "super-field" ))); - - f = Sample.class.getField ("field"); - assertEquals (1, Attributes.getAttributes (f).size ()); - assertEquals (1, Attributes.getAttributes (f, ThreadSafe.class).size ()); - assertTrue (Attributes.hasAttributeType (f, ThreadSafe.class)); - assertTrue (Attributes.hasAttribute (f, new ThreadSafe ())); - - f = SuperSample.class.getField ("noAttributesInSubClass"); - assertEquals (1, Attributes.getAttributes (f).size ()); - assertEquals (1, Attributes.getAttributes (f, Dependency.class).size ()); - assertTrue (Attributes.hasAttribute (f, new Dependency ( SampleService.class, "super-noattrs" ))); - assertTrue (Attributes.hasAttributeType (f, Dependency.class)); - - f = Sample.class.getField ("noAttributesInSubClass"); - assertEquals (0, Attributes.getAttributes (f).size ()); - assertEquals (0, Attributes.getAttributes (f, Dependency.class).size ()); - assertTrue (!Attributes.hasAttribute (f, new Dependency ( SampleService.class, "super-noattrs" ))); - assertTrue (!Attributes.hasAttributeType (f, Dependency.class)); } public void testNoAttributes () throws Exception { 1.2 +50 -4 jakarta-commons/attributes/unittest/src/test/org/apache/commons/attributes/test/InnerClassTestCase.java Index: InnerClassTestCase.java =================================================================== RCS file: /home/cvs/jakarta-commons/attributes/unittest/src/test/org/apache/commons/attributes/test/InnerClassTestCase.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- InnerClassTestCase.java 6 Jul 2004 20:43:38 -0000 1.1 +++ InnerClassTestCase.java 10 Sep 2004 20:49:38 -0000 1.2 @@ -24,16 +24,62 @@ import org.apache.commons.attributes.InvalidAttributeTargetError; public class InnerClassTestCase extends TestCase { + + public static class AnAttribute {} - public void testInnerClassAttributesOnMehtod () throws Exception { + public static class Internal { + } + + public static class InnerClassSample { + + public static class InternalOfSample { + } + + /** + * @@InnerClassTestCase.AnAttribute() + */ + public void method (Internal i) { + } + + /** + * @@InnerClassTestCase.AnAttribute() + */ + public void method2 (InternalOfSample i) { + } + + /** + * @@InnerClassTestCase.AnAttribute() + */ + public Internal field; + + /** + * @@InnerClassTestCase.AnAttribute() + */ + public InternalOfSample field2; + + } + + public void testInnerClassAttributesOnMethod () throws Exception { Class sample = InnerClassSample.class; - Method method = sample.getMethod ("method", new Class[]{ InnerClassSample.Internal.class }); - assertTrue (Attributes.getAttributes (method, ThreadSafe.class).size () > 0); + Method method = sample.getMethod ("method", new Class[]{ Internal.class }); + assertTrue (Attributes.getAttributes (method, AnAttribute.class).size () > 0); + } + + public void testInnerClassAttributesOnMethod2 () throws Exception { + Class sample = InnerClassSample.class; + Method method2 = sample.getMethod ("method2", new Class[]{ InnerClassSample.InternalOfSample.class }); + assertTrue (Attributes.getAttributes (method2, AnAttribute.class).size () > 0); } public void testInnerClassAttributesOnField () throws Exception { Class sample = InnerClassSample.class; Field field = sample.getField ("field"); - assertTrue (Attributes.getAttributes (field, ThreadSafe.class).size () > 0); + assertTrue (Attributes.getAttributes (field, AnAttribute.class).size () > 0); + } + + public void testInnerClassAttributesOnField2 () throws Exception { + Class sample = InnerClassSample.class; + Field field2 = sample.getField ("field2"); + assertTrue (Attributes.getAttributes (field2, AnAttribute.class).size () > 0); } } 1.3 +13 -2 jakarta-commons/attributes/unittest/src/test/org/apache/commons/attributes/test/TargetTestCase.java Index: TargetTestCase.java =================================================================== RCS file: /home/cvs/jakarta-commons/attributes/unittest/src/test/org/apache/commons/attributes/test/TargetTestCase.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- TargetTestCase.java 28 Aug 2004 21:12:19 -0000 1.2 +++ TargetTestCase.java 10 Sep 2004 20:49:38 -0000 1.3 @@ -18,10 +18,21 @@ import junit.framework.TestCase; import org.apache.commons.attributes.Attributes; +import org.apache.commons.attributes.Target; import org.apache.commons.attributes.InvalidAttributeTargetError; public class TargetTestCase extends TestCase { + /** + * @@TargetTestCase.AttributeWithTarget() + */ + public static class ClassWithInvalidDeclarations {} + + /** + * @@Target(Target.METHOD) + */ + public static class AttributeWithTarget {} + public void testMethodAttributeOnClass () throws Exception { Class clazz1 = ClassWithInvalidDeclarations.class; @@ -30,8 +41,8 @@ fail (); } catch (InvalidAttributeTargetError iate) { - assertEquals ("Attributes of type org.apache.commons.attributes.test.AttributeWithTarget " + - "can't be applied to org.apache.commons.attributes.test.ClassWithInvalidDeclarations. " + + assertEquals ("Attributes of type org.apache.commons.attributes.test.TargetTestCase$AttributeWithTarget " + + "can't be applied to org.apache.commons.attributes.test.TargetTestCase$ClassWithInvalidDeclarations. " + "They can only be applied to: METHOD", iate.getMessage ()); // OK. --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org