forbiddenapis-3.8.src.test.antunit.TestInlineSignatures.xml Maven / Gradle / Ivy
<?xml version="1.0" encoding="UTF-8"?> <!-- * (C) Copyright Uwe Schindler (Generics Policeman) and others. * * 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. --> <project xmlns:au="antlib:org.apache.ant.antunit"> <fileset id="main.classes" dir="${antunit.main.classes}"/> <target name="testForbiddenClassWithMessage"> <au:expectfailure expectedMessage="Check for forbidden API calls failed, see log"> <forbiddenapis classpathref="path.all"> <fileset refid="main.classes"/> java.awt.Color @ Color is disallowed, thats not bad, because ANT has no colors... java.lang.String @ You are crazy that you disallow strings </forbiddenapis> </au:expectfailure> <au:assertLogContains level="error" text="java.lang.String [You are crazy that you disallow strings]"/> </target> <target name="testForbiddenClassPatternWithMessage"> <au:expectfailure expectedMessage="Check for forbidden API calls failed, see log"> <forbiddenapis classpathref="path.all"> <fileset refid="main.classes"/> java.util.Array* @ You are crazy that you disallow all Array* java.lang.** @ You are crazy that you disallow all java.lang </forbiddenapis> </au:expectfailure> <au:assertLogContains level="error" text="java.util.ArrayList [You are crazy that you disallow all Array*]"/> <au:assertLogContains level="error" text="java.lang.String [You are crazy that you disallow all java.lang]"/> <au:assertLogContains level="error" text="java.lang.StringBuilder [You are crazy that you disallow all java.lang]"/> <au:assertLogContains level="error" text="java.lang.Object [You are crazy that you disallow all java.lang]"/> </target> <target name="testForbiddenClassWithDefaultMessage"> <au:expectfailure expectedMessage="Check for forbidden API calls failed, see log"> <forbiddenapis classpathref="path.all"> <fileset refid="main.classes"/> @defaultMessage Let's disable some of AWT java.awt.BorderLayout @defaultMessage but it is even more crazy to have the same log message everywhere java.awt.Color java.lang.String </forbiddenapis> </au:expectfailure> <au:assertLogContains level="error" text="java.lang.String [but it is even more crazy to have the same log message everywhere]"/> </target> <target name="testForbiddenMethodWithMessage"> <au:expectfailure expectedMessage="Check for forbidden API calls failed, see log"> <forbiddenapis classpathref="path.all"> <fileset refid="main.classes"/> java.lang.String#substring(int,int) @ You are crazy that you disallow substrings </forbiddenapis> </au:expectfailure> <au:assertLogContains level="error" text="java.lang.String#substring(int,int) [You are crazy that you disallow substrings]"/> </target> <target name="testForbiddenWildcardMethodWithMessage"> <au:expectfailure expectedMessage="Check for forbidden API calls failed, see log"> <forbiddenapis classpathref="path.all"> <fileset refid="main.classes"/> java.lang.String#substring(**) @ You are crazy that you disallow all substrings </forbiddenapis> </au:expectfailure> <au:assertLogContains level="error" text="java.lang.String#substring(**) [You are crazy that you disallow all substrings]"/> </target> <target name="testForbiddenFieldWithMessage"> <au:expectfailure expectedMessage="Check for forbidden API calls failed, see log"> <forbiddenapis classpathref="path.all"> <fileset refid="main.classes"/> java.util.Locale#ENGLISH @ We are speaking chinese here! </forbiddenapis> </au:expectfailure> <au:assertLogContains level="error" text="java.util.Locale#ENGLISH [We are speaking chinese here!]"/> </target> <target name="testFailOnMissing"> <au:expectfailure expectedMessage="Parsing signatures failed: Class 'foo.bar.ForbiddenApis' not found on classpath while parsing signature: foo.bar.ForbiddenApis#testMethod()"> <forbiddenapis classpathref="path.all"> <fileset refid="main.classes"/> foo.bar.ForbiddenApis#testMethod() @ should fail here java.lang.String#forbiddenFoobarMethod() @ should also fail java.lang.String#forbiddenFoobarField @ should also fail </forbiddenapis> </au:expectfailure> </target> <target name="testDontFailOnMissing"> <forbiddenapis classpathref="path.all"> <fileset refid="main.classes"/> @ignoreUnresolvable foo.bar.ForbiddenApis#testMethod() @ should be ignored java.lang.String#forbiddenFoobarMethod() @ should be ignored java.lang.String#forbiddenFoobarField @ should be ignored </forbiddenapis> <au:assertLogContains level="warning" text="'@ignoreUnresolvable' inside signatures files is deprecated, prefer using '@ignoreMissingClasses' to ignore signatures where the class is missing."/> <au:assertLogContains level="warning" text="Some signatures were ignored because the following classes were not found on classpath:"/> <au:assertLogContains level="warning" text=" foo.bar.ForbiddenApis"/> <au:assertLogContains level="warning" text="Method not found while parsing signature: java.lang.String#forbiddenFoobarMethod() [signature ignored]"/> <au:assertLogContains level="warning" text="Field not found while parsing signature: java.lang.String#forbiddenFoobarField [signature ignored]"/> </target> <target name="testDontFailOnMissingWithAttribute"> <forbiddenapis classpathref="path.all" failOnUnresolvableSignatures="false"> <fileset refid="main.classes"/> foo.bar.ForbiddenApis#testMethod() @ should be ignored java.lang.String#forbiddenFoobarMethod() @ should be ignored java.lang.String#forbiddenFoobarField @ should be ignored </forbiddenapis> <au:assertLogContains level="warning" text="The setting 'failOnUnresolvableSignatures' was deprecated and will be removed in next version. Use 'ignoreSignaturesOfMissingClasses' instead."/> <au:assertLogContains level="warning" text="Some signatures were ignored because the following classes were not found on classpath:"/> <au:assertLogContains level="warning" text=" foo.bar.ForbiddenApis"/> <au:assertLogContains level="warning" text="Method not found while parsing signature: java.lang.String#forbiddenFoobarMethod() [signature ignored]"/> <au:assertLogContains level="warning" text="Field not found while parsing signature: java.lang.String#forbiddenFoobarField [signature ignored]"/> </target> <target name="testIgnoreSignaturesOfMissingClasses"> <forbiddenapis classpathref="path.all"> <fileset refid="main.classes"/> @ignoreMissingClasses foo.bar.ForbiddenApis#testMethod() @ should be ignored foo.bar.ForbiddenApis#field @ should be ignored foo.bar.ForbiddenApis @ should be ignored </forbiddenapis> <au:assertLogContains level="info" text="Skipping execution because no API signatures are available."/> </target> <target name="testIgnoreSignaturesOfMissingClassesAttribute"> <forbiddenapis classpathref="path.all" ignoreSignaturesOfMissingClasses="true"> <fileset refid="main.classes"/> foo.bar.ForbiddenApis#testMethod() @ should be ignored foo.bar.ForbiddenApis#field @ should be ignored foo.bar.ForbiddenApis @ should be ignored </forbiddenapis> <au:assertLogContains level="info" text="Skipping execution because no API signatures are available."/> </target> <target name="testIgnoreSignaturesOfMissingClassesAttributeButFailOnMissingMethod"> <au:expectfailure expectedMessage="Method not found while parsing signature: java.lang.String#forbiddenFoobarMethod()"> <forbiddenapis classpathref="path.all" ignoreSignaturesOfMissingClasses="true"> <fileset refid="main.classes"/> foo.bar.ForbiddenApis#testMethod() @ should be ignored java.lang.String#forbiddenFoobarMethod() @ should not be ignored java.lang.String#forbiddenFoobarField @ should not be ignored </forbiddenapis> </au:expectfailure> </target> <target name="testIgnoreSignaturesOfMissingClassesInSeparateResources"> <au:expectfailure expectedMessage="Parsing signatures failed: Class 'foo.bar.ForbiddenApis2' not found on classpath while parsing signature: foo.bar.ForbiddenApis2#testMethod()"> <forbiddenapis classpathref="path.all"> <fileset refid="main.classes"/> <signatures> <string> @ignoreMissingClasses foo.bar.ForbiddenApis#testMethod() @ should be ignored foo.bar.ForbiddenApis#field @ should be ignored foo.bar.ForbiddenApis @ should be ignored </string> <string> foo.bar.ForbiddenApis2#testMethod() @ should fail foo.bar.ForbiddenApis2#field @ should fail foo.bar.ForbiddenApis2 @ should fail </string> </signatures> </forbiddenapis> </au:expectfailure> </target> </project>
© 2015 - 2025 Weber Informatics LLC | Privacy Policy