You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2018/08/19 13:23:40 UTC
groovy git commit: test for GROOVY-8669
Repository: groovy
Updated Branches:
refs/heads/master cff3aed0c -> 1b83d1f5f
test for GROOVY-8669
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/1b83d1f5
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/1b83d1f5
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/1b83d1f5
Branch: refs/heads/master
Commit: 1b83d1f5f19e348574d9ec36e0839dbde90a9afe
Parents: cff3aed
Author: Paul King <pa...@asert.com.au>
Authored: Sun Aug 19 23:23:29 2018 +1000
Committer: Paul King <pa...@asert.com.au>
Committed: Sun Aug 19 23:23:29 2018 +1000
----------------------------------------------------------------------
.../groovy/groovy/ant/Groovy8669Test.groovy | 88 ++++++++++++++++++++
1 file changed, 88 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/1b83d1f5/subprojects/groovy-ant/src/test/groovy/groovy/ant/Groovy8669Test.groovy
----------------------------------------------------------------------
diff --git a/subprojects/groovy-ant/src/test/groovy/groovy/ant/Groovy8669Test.groovy b/subprojects/groovy-ant/src/test/groovy/groovy/ant/Groovy8669Test.groovy
new file mode 100644
index 0000000..1cd46e7
--- /dev/null
+++ b/subprojects/groovy-ant/src/test/groovy/groovy/ant/Groovy8669Test.groovy
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 groovy.ant
+
+class Groovy8669Test extends AntTestCase {
+ private scriptAllOnPath = '''
+ def anno = AnnotatedClass.annotations[0]
+ def type = anno.annotationType()
+ assert type.name == 'MyAnnotation'
+ assert type.getDeclaredMethod('value').invoke(anno).name == 'ValueClass'
+ '''
+
+ private scriptNoValueClass = '''
+ // using annotations will cause ValueClass not to be found
+ // but should still be able to use the class otherwise
+ assert AnnotatedClass.name.size() == 14
+ '''
+
+ private scriptNoAnnotationOnPath = '''
+ // class should be usable but won't have annotations
+ assert !AnnotatedClass.annotations
+ '''
+
+ void testCreateZip() {
+// def debugLogger = new org.apache.tools.ant.DefaultLogger()
+// debugLogger.setMessageOutputLevel(4)
+// debugLogger.setOutputPrintStream(System.out)
+// debugLogger.setErrorPrintStream(System.err)
+
+ doInTmpDir { ant, baseDir ->
+ baseDir.src {
+ 'ValueClass.java'('''
+ public class ValueClass{ }
+ ''')
+ 'MyAnnotation.java'('''
+ import java.lang.annotation.*;
+
+ @Target(ElementType.TYPE)
+ @Retention(RetentionPolicy.RUNTIME)
+ public @interface MyAnnotation {
+ Class<ValueClass> value();
+ }
+ ''')
+ 'AnnotatedClass.java'('''
+ @MyAnnotation(ValueClass.class)
+ class AnnotatedClass { }
+ ''')
+ }
+// ant.project.addBuildListener(debugLogger)
+ ant.mkdir(dir: 'build')
+ ant.javac(classpath: '.', destdir: 'build', srcdir: 'src',
+ includes: '*.java', includeantruntime: 'false', fork: 'true')
+ ['ValueClass', 'MyAnnotation', 'AnnotatedClass'].each { name ->
+ ant.mkdir(dir: "build$name")
+ ant.copy(file: "build/${name}.class", todir: "build$name")
+ }
+ ant.taskdef(name: 'groovy', classname: 'org.codehaus.groovy.ant.Groovy')
+ ant.groovy(scriptAllOnPath) {
+ classpath { pathelement(path: 'buildValueClass') }
+ classpath { pathelement(path: 'buildMyAnnotation') }
+ classpath { pathelement(path: 'buildAnnotatedClass') }
+ }
+ ant.groovy(scriptNoValueClass) {
+ classpath { pathelement(path: 'buildMyAnnotation') }
+ classpath { pathelement(path: 'buildAnnotatedClass') }
+ }
+ ant.groovy(scriptNoAnnotationOnPath) {
+ classpath { pathelement(path: 'buildAnnotatedClass') }
+ }
+ }
+ }
+}