Browse Source

adapting code and tests since Apt is not available under JKD1.8 PR 55922

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1553060 13f79535-47bb-0310-9956-ffa450edef68
master
Antoine Levy-Lambert 11 years ago
parent
commit
72e13d5ac8
8 changed files with 43 additions and 86 deletions
  1. +4
    -0
      WHATSNEW
  2. +3
    -0
      src/main/org/apache/tools/ant/taskdefs/Apt.java
  3. +36
    -9
      src/tests/antunit/taskdefs/apt-test.xml
  4. +0
    -0
      src/tests/antunit/taskdefs/apt/AptExample.java
  5. +0
    -0
      src/tests/antunit/taskdefs/apt/Distributed.java
  6. +0
    -0
      src/tests/antunit/taskdefs/apt/DistributedAnnotationFactory.java
  7. +0
    -0
      src/tests/antunit/taskdefs/apt/DistributedAnnotationProcessor.java
  8. +0
    -77
      src/tests/junit/org/apache/tools/ant/taskdefs/AptTest.java

+ 4
- 0
WHATSNEW View File

@@ -25,6 +25,10 @@ Fixed bugs:
* Ant 1.8 exec task changes have slowed exec to a crawl
Bugzilla Report 54128.

* Apt is not available under JDK 1.8
Bugzilla Report 55922.


Other changes:
--------------



+ 3
- 0
src/main/org/apache/tools/ant/taskdefs/Apt.java View File

@@ -262,6 +262,9 @@ public class Apt
*/
public void execute()
throws BuildException {
if (JavaEnvUtils.getJavaVersionNumber() >= 18) {
throw new BuildException("apt does not exist under Java 1.8 and higher");
}
super.execute();
}
}

src/etc/testcases/taskdefs/apt.xml → src/tests/antunit/taskdefs/apt-test.xml View File

@@ -15,7 +15,8 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<project basedir=".">
<project default="antunit" xmlns:au="antlib:org.apache.ant.antunit">
<import file="../antunit-base.xml" />
<!-- apt tests -->

<property name="build.dir" location="aptbuild" />
@@ -39,21 +40,29 @@
</sequential>
</macrodef>

<macrodef name="assertProcessed">
<sequential>
<au:assertLogContains text="DistributedAnnotationProcessor-is-go"/>
<au:assertLogContains text="[-Abuild.dir="/>
<au:assertLogContains text="visiting DistributedAnnotationFactory"/>
</sequential>
</macrodef>

<presetdef name="assertAptExampleCompiled">
<assertCompiled file="${AptExample.class}"/>
</presetdef>

<target name="clean">
<target name="tearDown" depends="antunit-base.tearDown">
<delete dir="${build.dir}"/>
</target>

<target name="init">
<target name="setUp">
<mkdir dir="${classes.dir}"/>
<mkdir dir="${classes2.dir}"/>
<mkdir dir="${preprocess.dir}"/>
</target>

<target name="testApt" depends="init">
<target name="testApt" depends="setUp" unless="jdk1.8+">
<apt srcdir="${src}"
destdir="${classes.dir}"
debug="on"
@@ -63,7 +72,7 @@
<assertAptExampleCompiled />
</target>

<target name="testAptFork" depends="init">
<target name="testAptFork" depends="setUp" unless="jdk1.8+">
<apt srcdir="${src}"
destdir="${classes.dir}"
debug="on"
@@ -74,7 +83,7 @@
<assertAptExampleCompiled />
</target>

<target name="testAptForkFalse" depends="init">
<target name="testAptForkFalse" depends="setUp" unless="jdk1.8+">
<apt srcdir="${src}"
destdir="${classes.dir}"
debug="on"
@@ -83,9 +92,11 @@
preprocessdir="${preprocess.dir}">
</apt>
<assertAptExampleCompiled />
<au:assertLogContains text="Apt only runs in its own JVM; fork=false option ignored"/>

</target>

<target name="testListAnnotationTypes" depends="init">
<target name="testListAnnotationTypes" depends="setUp" unless="jdk1.8+">
<apt srcdir="${src}"
destdir="${classes.dir}"
debug="on"
@@ -96,13 +107,15 @@
</apt>
<assertAptExampleCompiled />
<au:assertLogContains text="Set of annotations found:"/>
<au:assertLogContains text="Distributed"/>
</target>


<!-- use the factory we compiled. To avoid trouble
we deliver into a version in a new classpath, otherwise
the dependency logic will not run Apt-->
<target name="testAptNewFactory" depends="testApt">
<target name="testAptNewFactory" depends="testApt" unless="jdk1.8+">
<apt srcdir="${src}"
destdir="${classes2.dir}"
debug="on"
@@ -113,9 +126,10 @@
<option name="build.dir" value="${build.dir}" />
</apt>
<assertAptExampleCompiled />
<assertProcessed />
</target>

<target name="testAptNewFactoryFork" depends="testApt">
<target name="testAptNewFactoryFork" depends="testApt" unless="jdk1.8+">
<apt srcdir="${src}"
destdir="${classes2.dir}"
debug="on"
@@ -127,5 +141,18 @@
<option name="build.dir" value="${build.dir}" />
</apt>
<assertAptExampleCompiled />
<assertProcessed />
</target>

<target name="testAptUnderJDK18" if="jdk1.8+">
<au:expectfailure expectedMessage="apt does not exist under Java 1.8 and higher">
<apt srcdir="${src}"
destdir="${classes.dir}"
debug="on"
compile="true"
fork="true"
preprocessdir="${preprocess.dir}">
</apt>
</au:expectfailure>
</target>
</project>

src/etc/testcases/taskdefs/apt/AptExample.java → src/tests/antunit/taskdefs/apt/AptExample.java View File


src/etc/testcases/taskdefs/apt/Distributed.java → src/tests/antunit/taskdefs/apt/Distributed.java View File


src/etc/testcases/taskdefs/apt/DistributedAnnotationFactory.java → src/tests/antunit/taskdefs/apt/DistributedAnnotationFactory.java View File


src/etc/testcases/taskdefs/apt/DistributedAnnotationProcessor.java → src/tests/antunit/taskdefs/apt/DistributedAnnotationProcessor.java View File


+ 0
- 77
src/tests/junit/org/apache/tools/ant/taskdefs/AptTest.java View File

@@ -1,77 +0,0 @@
/*
* 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 org.apache.tools.ant.taskdefs;

import org.apache.tools.ant.BuildFileTest;

/**
*/
public class AptTest extends BuildFileTest {
public AptTest(String name) {
super(name);
}

public void setUp() {
configureProject("src/etc/testcases/taskdefs/apt.xml");
}

/**
* Tears down the fixture, for example, close a network connection. This
* method is called after a test is executed.
*/
protected void tearDown() throws Exception {
executeTarget("clean");
}

public void testApt() {
executeTarget("testApt");
}

public void testAptFork() {
executeTarget("testAptFork");
}
public void testAptForkFalse() {
executeTarget("testAptForkFalse");
assertLogContaining(Apt.WARNING_IGNORING_FORK);
}

public void testListAnnotationTypes() {
executeTarget("testListAnnotationTypes");
assertLogContaining("Set of annotations found:");
assertLogContaining("Distributed");
}

public void testAptNewFactory() {
executeTarget("testAptNewFactory");
assertProcessed();
}

public void testAptNewFactoryFork() {
executeTarget("testAptNewFactoryFork");
assertProcessed();
}
private void assertProcessed() {
assertLogContaining("DistributedAnnotationProcessor-is-go");
assertLogContaining("[-Abuild.dir=");
assertLogContaining("visiting DistributedAnnotationFactory");
}
}


Loading…
Cancel
Save