apt.sh revision 386
0N/A#!/bin/sh
3261N/A
0N/A#
0N/A# Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
0N/A# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A#
0N/A# This code is free software; you can redistribute it and/or modify it
0N/A# under the terms of the GNU General Public License version 2 only, as
0N/A# published by the Free Software Foundation.
0N/A#
0N/A# This code is distributed in the hope that it will be useful, but WITHOUT
0N/A# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A# version 2 for more details (a copy is included in the LICENSE file that
0N/A# accompanied this code).
0N/A#
0N/A# You should have received a copy of the GNU General Public License version
0N/A# 2 along with this work; if not, write to the Free Software Foundation,
2362N/A# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2362N/A#
2362N/A# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
0N/A# CA 95054 USA or visit www.sun.com if you need additional information or
0N/A# have any questions.
0N/A#
0N/A
0N/A# @test
0N/A# @bug 4908512 5024825 4957203 4993280 4996963 6174696 6177059
0N/A# @run shell ../verifyVariables.sh
0N/A# @build Milk MethodAnnotations NestedClassAnnotations StaticFieldAnnotations StaticMethodAnnotations ParameterAnnotations
0N/A# @run shell apt.sh
0N/A# @summary test consistency of annotation discovery
0N/A# @author Joseph D. Darcy
0N/A
0N/AOS=`uname -s`;
0N/Acase "${OS}" in
0N/A CYGWIN* )
0N/A DIFFOPTS="--strip-trailing-cr"
0N/A ;;
0N/A
0N/A * )
0N/A ;;
0N/Aesac
0N/A
0N/A# Construct path to apt executable
0N/AAPT="${TESTJAVA}/bin/apt ${TESTTOOLVMOPTS} -XDsuppress-tool-api-removal-message "
0N/A
0N/Aprintf "%s\n" "-classpath ${TESTCLASSES}" > options
0N/Aprintf "%s\n" "-factorypath ./nullap.jar" >> options
0N/Aprintf "%s\n" "-sourcepath ${TESTSRC} " >> options
0N/Aprintf "%s\n" "-nocompile" >> options
0N/Aprintf "%s\n" "-XListAnnotationTypes" >> options
0N/A
0N/Aprintf "%s\n" "-classpath ${TESTCLASSES}" > options1
0N/Aprintf "%s\n" "-factorypath ./nullap.jar" >> options1
0N/Aprintf "%s\n" "-sourcepath ${TESTSRC} " >> options1
0N/Aprintf "%s\n" "-nocompile" >> options1
0N/Aprintf "%s\n" "-XListAnnotationTypes" >> options1
0N/Aprintf "%s\n" "-XclassesAsDecls" >> options1
0N/A
0N/A
2612N/A# Construct path to javac executable
2612N/AJAVAC="${TESTJAVA}/bin/javac ${TESTTOOLVMOPTS} -source 1.5 -sourcepath ${TESTSRC} -classpath ${TESTJAVA}/lib/tools.jar -d . "
2612N/AJAR="${TESTJAVA}/bin/jar "
2612N/A
2612N/A$JAVAC ${TESTSRC}/NullAPF.java \
2612N/A${TESTSRC}/FreshnessApf.java \
2612N/A${TESTSRC}/TestGetTypeDeclarationApf.java \
2612N/A${TESTSRC}/TestGetPackageApf.java
0N/ARESULT=$?
0N/A
0N/Acase "${RESULT}" in
0N/A 0 )
0N/A ;;
0N/A
0N/A * )
0N/A echo "Compilation failed."
0N/A exit 1
0N/Aesac
0N/A
0N/Aecho "Making services directory and copying services information."
0N/Amkdir -p META-INF/services
2612N/Acp ${TESTSRC}/com.sun.mirror.apt.AnnotationProcessorFactory ./META-INF/services
2612N/A$JAR cvf0 nullap.jar NullAPF*.class META-INF
2612N/A
0N/AANNOTATION_FILES="${TESTSRC}/ClassAnnotations.java \
0N/A${TESTSRC}/MethodAnnotations.java \
0N/A${TESTSRC}/NestedClassAnnotations.java \
0N/A${TESTSRC}/StaticFieldAnnotations.java \
2612N/A${TESTSRC}/StaticMethodAnnotations.java \
2612N/A${TESTSRC}/ParameterAnnotations.java"
0N/A
0N/Afor i in ${ANNOTATION_FILES}
2612N/Ado
2612N/A printf "%s\n" "Testing annotations on source file ${i}"
0N/A ${APT} @options ${i} 2> result.txt
0N/A diff ${DIFFOPTS} ${TESTSRC}/golden.txt result.txt
2612N/A
2612N/A RESULT=$?
2612N/A case "$RESULT" in
2612N/A 0 )
2612N/A ;;
2612N/A
2612N/A * )
2612N/A echo "Unexpected set of annotations on source files found."
2612N/A exit 1
2612N/A esac
2612N/A
2612N/A CLASS=`basename ${i} .java`
2612N/A printf "%s\n" "Testing annotations on class file ${CLASS}"
2612N/A ${APT} @options1 ${CLASS} 2> result2.txt
2612N/A diff ${DIFFOPTS} ${TESTSRC}/golden.txt result2.txt
2612N/A
2612N/A RESULT=$?
2612N/A case "$RESULT" in
2612N/A 0 )
2612N/A ;;
2612N/A
2612N/A * )
2612N/A echo "Unexpected set of annotations on class files found."
0N/A exit 1
0N/A esac
0N/Adone
0N/A
0N/A# Verify source files are favored over class files
0N/A
0N/Aprintf "%s\n" "-factorypath ." > options2
0N/Aprintf "%s\n" "-factory FreshnessApf" >> options2
0N/Aprintf "%s\n" "-sourcepath ${TESTSRC}" >> options2
0N/Aprintf "%s\n" "-classpath ${TESTCLASSES}" >> options2
0N/Aprintf "%s\n" "-nocompile" >> options2
0N/A
0N/A${APT} @options2 ${TESTSRC}/Indirect.java
0N/A
0N/ARESULT=$?
2612N/Acase "$RESULT" in
2612N/A 0 )
2612N/A ;;
2612N/A
0N/A * )
0N/A exit 1
0N/Aesac
2612N/A
0N/A# Verify new classes can be loaded by getTypeDeclaration
0N/A
0N/Aprintf "%s\n" "-factorypath ." > options3
0N/Aprintf "%s\n" "-factory TestGetTypeDeclarationApf" >> options3
0N/Aprintf "%s\n" "-sourcepath ${TESTSRC}" >> options3
2612N/A
0N/A# ${APT} @options3
0N/A
0N/ARESULT=$?
0N/Acase "$RESULT" in
0N/A 0 )
0N/A ;;
0N/A
0N/A * )
0N/A exit 1
0N/Aesac
0N/A
0N/A# Verify packages can be loaded by getPackage
0N/A
0N/Aprintf "%s\n" "-factorypath ." > options4
0N/Aprintf "%s\n" "-factory TestGetPackageApf" >> options4
0N/Aprintf "%s\n" "-sourcepath ${TESTSRC}" >> options4
0N/A
0N/A${APT} @options4
0N/A
0N/ARESULT=$?
0N/Acase "$RESULT" in
0N/A 0 )
0N/A ;;
0N/A
0N/A * )
0N/A exit 1
0N/Aesac
0N/Aexit 0
0N/A