You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

rmic-test.xml 4.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?xml version="1.0"?>
  2. <!--
  3. Licensed to the Apache Software Foundation (ASF) under one or more
  4. contributor license agreements. See the NOTICE file distributed with
  5. this work for additional information regarding copyright ownership.
  6. The ASF licenses this file to You under the Apache License, Version 2.0
  7. (the "License"); you may not use this file except in compliance with
  8. the License. You may obtain a copy of the License at
  9. https://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing, software
  11. distributed under the License is distributed on an "AS IS" BASIS,
  12. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. See the License for the specific language governing permissions and
  14. limitations under the License.
  15. -->
  16. <project default="antunit" xmlns:au="antlib:org.apache.ant.antunit">
  17. <import file="../antunit-base.xml" />
  18. <target name="-create-rmic-adapter">
  19. <mkdir dir="${input}/org/example"/>
  20. <echo file="${input}/org/example/Adapter.java"><![CDATA[
  21. package org.example;
  22. import org.apache.tools.ant.taskdefs.rmic.RmicAdapter;
  23. import org.apache.tools.ant.taskdefs.Rmic;
  24. import org.apache.tools.ant.types.Path;
  25. import org.apache.tools.ant.util.FileNameMapper;
  26. import org.apache.tools.ant.util.GlobPatternMapper;
  27. public class Adapter implements RmicAdapter {
  28. public void setRmic(Rmic attributes) {}
  29. public boolean execute() {
  30. System.err.println("adapter called");
  31. return true;
  32. }
  33. public FileNameMapper getMapper() {
  34. GlobPatternMapper m = new GlobPatternMapper();
  35. m.setFrom("*.class");
  36. m.setTo("*_foo.class");
  37. return m;
  38. }
  39. public Path getClasspath() {
  40. return new Path(null);
  41. }
  42. }]]></echo>
  43. <mkdir dir="${resources}"/>
  44. <javac srcdir="${input}" destdir="${resources}"/>
  45. </target>
  46. <target name="testCompilerNotFound" depends="-create-rmic-adapter" unless="build.sysclasspath.only">
  47. <au:expectfailure>
  48. <rmic base="${resources}" includes="**/*.class"
  49. compiler="org.example.Adapter"/>
  50. </au:expectfailure>
  51. <au:assertLogDoesntContain text="adapter called"/>
  52. </target>
  53. <target name="testCompilerClasspath" depends="-create-rmic-adapter"
  54. description="https://issues.apache.org/bugzilla/show_bug.cgi?id=11143">
  55. <rmic base="${resources}" includes="**/*.class"
  56. compiler="org.example.Adapter">
  57. <compilerclasspath location="${resources}"/>
  58. </rmic>
  59. <au:assertLogContains text="adapter called"/>
  60. </target>
  61. <target name="testCompilerAsNestedElement" depends="-create-rmic-adapter">
  62. <componentdef classname="org.example.Adapter" name="myjavac">
  63. <classpath location="${resources}"/>
  64. </componentdef>
  65. <rmic base="${resources}" includes="**/*.class">
  66. <myjavac/>
  67. </rmic>
  68. <au:assertLogContains text="adapter called"/>
  69. </target>
  70. <target name="-check-jdk">
  71. <condition property="java15+">
  72. <javaversion atleast="15"/>
  73. </condition>
  74. </target>
  75. <target name="-setup-real-test">
  76. <mkdir dir="${input}/org/example"/>
  77. <mkdir dir="${output}"/>
  78. <echo file="${input}/org/example/Foo.java"><![CDATA[
  79. package org.example;
  80. import java.rmi.Remote;
  81. import java.rmi.RemoteException;
  82. public interface Foo extends Remote {
  83. long bar() throws RemoteException ;
  84. }]]></echo>
  85. <echo file="${input}/org/example/FooImpl.java"><![CDATA[
  86. package org.example;
  87. import java.rmi.RemoteException;
  88. public class FooImpl implements Foo {
  89. public long bar() throws RemoteException {
  90. return 0;
  91. }
  92. }]]></echo>
  93. <javac srcdir="${input}" destdir="${output}"/>
  94. </target>
  95. <target name="testSourceBase" depends="-check-jdk, -setup-real-test" unless="java15+"
  96. description="https://issues.apache.org/bugzilla/show_bug.cgi?id=48970">
  97. <rmic sourcebase="${input}" base="${output}">
  98. <include name="**/*Impl.class"/>
  99. </rmic>
  100. <au:assertFileExists file="${input}/org/example/FooImpl_Stub.java"/>
  101. <au:assertFileDoesntExist file="${output}/org/example/FooImpl_Stub.java"/>
  102. </target>
  103. <target name="testSimpleCompileFailsOnJava15+" depends="-check-jdk, -setup-real-test"
  104. if="java15+">
  105. <au:expectfailure>
  106. <rmic sourcebase="${input}" base="${output}">
  107. <include name="**/*Impl.class"/>
  108. </rmic>
  109. </au:expectfailure>
  110. </target>
  111. </project>