Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
8cf4250
Copy from old repo - Eleanor Part
J-ihsuan Feb 18, 2026
5602abf
update part2 CarolCopyFsmTest.java
Carolyehhh Feb 19, 2026
49ff12c
Part 1-3 Images of Report
J-ihsuan Feb 19, 2026
a98d5d4
Move docs and test case from origin repo (Eleanor Part)
J-ihsuan Feb 19, 2026
3fd6f85
Merge pull request #2 from J-ihsuan/c_branch
Carolyehhh Feb 19, 2026
935e0ab
Add CarolCopyTest.java
Carolyehhh Feb 19, 2026
d699b7a
Add copy_test.xml for part 1
Carolyehhh Feb 19, 2026
773c87f
Merge pull request #3 from J-ihsuan/c_branch
Carolyehhh Feb 19, 2026
46b0a89
Report of Eleanor Part
J-ihsuan Feb 19, 2026
8303832
Move README from original repo
J-ihsuan Feb 19, 2026
435a48e
Report of Carol Part
J-ihsuan Feb 19, 2026
45861fa
Merge pull request #5 from J-ihsuan/c_branch
Carolyehhh Feb 19, 2026
85e8d6b
Part3: Add part of the testing code to MoveTest.java
Carolyehhh Feb 19, 2026
c58373d
Part3: CarolBoostTest.java
Carolyehhh Feb 19, 2026
019e52f
CarolExecuteOnTest.java
Carolyehhh Feb 19, 2026
f370c85
Merge branch 'c_branch' of https://github.com/J-ihsuan/Ant-Testing-Fr…
Carolyehhh Feb 19, 2026
afb6ab9
Merge pull request #6 from J-ihsuan/c_branch
Carolyehhh Feb 19, 2026
e0e7a5e
Part2: ReadMe update link
Carolyehhh Feb 19, 2026
f3f57ef
Part3: ReadMe links update
Carolyehhh Feb 19, 2026
098077b
Merge pull request #7 from J-ihsuan/c_branch
Carolyehhh Feb 19, 2026
c396a66
Update part 2 hyperlinks
J-ihsuan Feb 19, 2026
9b1e457
Update part 3 hyperlinks
J-ihsuan Feb 19, 2026
598b0e8
Docs: README.md hyperlinks update
J-ihsuan Feb 19, 2026
19770cd
Add GitHub Actions CI configuration
Carolyehhh Feb 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Java Ant CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build-and-test:
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Run JUnit Tests

run: ant junit-tests
Binary file added G17Report/Image/CopyFSMDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added G17Report/Image/DeleteCoverageTestResult.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added G17Report/Image/FSMMailMessage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added G17Report/Image/JaCoCoDeleteAfter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added G17Report/Image/JaCoCoDeleteBefore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added G17Report/Image/JaCoCoMailBefore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added G17Report/Image/JaCoCoReportAll.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added G17Report/Image/MailFSMDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added G17Report/Image/cloc_status.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added G17Report/Image/copy_all_after.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added G17Report/Image/copy_all_before.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added G17Report/Image/copy_coverage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added G17Report/Image/copy_detail_after.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added G17Report/Image/copy_detail_before.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added G17Report/Image/copy_test_result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added G17Report/Image/deleteTestReport.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added G17Report/Image/executeon_all_after.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added G17Report/Image/executeon_all_before2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added G17Report/Image/executeon_detail_after.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added G17Report/Image/executeon_detail_before.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added G17Report/Image/move_all_after.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added G17Report/Image/move_all_before.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added G17Report/Image/move_detail_after.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added G17Report/Image/move_detail_before.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added G17Report/Image/report.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
916 changes: 916 additions & 0 deletions G17Report/README.md

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions src/etc/testcases/taskdefs/copy_test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<project name="copy-test" basedir=".">

<property name="output" value="copy-temp"/>

<target name="setUp">
<mkdir dir="${output}"/>
<echo file="${output}/source.txt">Hello Ant Testing</echo>
<mkdir dir="${output}/src_dir"/>
</target>

<target name="tearDown">
<delete dir="${output}"/>
</target>

<target name="testValidCopy">
<copy file="${output}/source.txt" tofile="${output}/dest.txt"/>
</target>

<target name="testMissingSource">
<copy file="${output}/ghost.txt" tofile="${output}/dest.txt"/>
</target>

<target name="testDirectoryCopy">
<copy todir="${output}/dest_dir">
<fileset dir="${output}/src_dir"/>
</copy>
</target>

</project>
67 changes: 67 additions & 0 deletions src/tests/junit/org/apache/tools/ant/taskdefs/CarolBoostTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package org.apache.tools.ant.taskdefs;

import org.apache.tools.ant.Project;
import org.junit.Test;
import java.io.File;
import java.util.Hashtable;
import java.lang.reflect.Method;

public class CarolBoostTest {

@Test
public void testCopyCoverageBoost() {
Copy copy = new Copy();
copy.setProject(new Project());

// 1.Setters
copy.setFiltering(true);
copy.setGranularity(2000L);
copy.setVerbose(true);
copy.setIncludeEmptyDirs(true);
copy.setEnableMultipleMappings(true);
copy.setFailOnError(false);
copy.setFlatten(true);
copy.setForce(true);
copy.setQuiet(true);
copy.setOverwrite(true);
copy.setPreserveLastModified("true");
copy.setEncoding("UTF-8");
copy.setOutputEncoding("UTF-8");
copy.add(new org.apache.tools.ant.util.IdentityMapper());

// 2. buildMap
try {
copy.buildMap(new File("."), new File("."), new String[]{"a"},
new org.apache.tools.ant.util.IdentityMapper(), new Hashtable<>());
} catch (Exception e) {}

// 3. Using reflection attacks on private getDueTo
try {
Method method = Copy.class.getDeclaredMethod("getDueTo", Exception.class);
method.setAccessible(true);
method.invoke(copy, new Exception("Carol's Coverage Boost"));
} catch (Exception e) {
}
}

@Test
public void testCopyComplexResourceMapping() {
Copy copy = new Copy();
copy.setProject(new Project());

// 1. validateAttributes
copy.setFile(new File("non_existent_carol.txt"));
copy.setTodir(new File("dest_dir"));
try { copy.validateAttributes(); } catch (Exception e) {}

// 2. Attacking buildMap and doResourceOperations
org.apache.tools.ant.types.resources.FileResource res =
new org.apache.tools.ant.types.resources.FileResource(new File("test.txt"));
org.apache.tools.ant.types.Resource[] resources = { res };

try {
// Test the buildMap of the Resource array.
copy.buildMap(resources, new File("dest_dir"), new org.apache.tools.ant.util.IdentityMapper());
} catch (Exception e) {}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package org.apache.tools.ant.taskdefs;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.junit.Before;
import org.junit.Test;
import java.io.File;
import java.nio.file.Files;
import static org.junit.Assert.*;

public class CarolCopyFsmTest {
private Project project;
private Copy copyTask;
private File tempDir;

@Before
public void setUp() {
project = new Project();
project.init();
copyTask = new Copy();
copyTask.setProject(project);

// Establish a temporary testing table of contents
tempDir = new File("fsm_test_tmp");
if (!tempDir.exists()) {
tempDir.mkdirs();
}
}

/**
* Test Path: IDLE -> VALIDATING -> SCANNING -> PREPARING -> COPYING -> FINISHED
* Verifies a complete successful copy operation.
*/
@Test
public void testFullSuccessPath() throws Exception {
File src = new File(tempDir, "source.txt");
File dest = new File(tempDir, "dest.txt");
Files.write(src.toPath(), "Hello Carol's FSM Test".getBytes());

copyTask.setFile(src);
copyTask.setTofile(dest);
copyTask.execute();

assertTrue("File should be successfully copied to destination", dest.exists());
assertEquals("File content should match", "Hello Carol's FSM Test", new String(Files.readAllBytes(dest.toPath())));
}

/**
* Test Path: VALIDATING -> FAILED
* Verifies that missing mandatory attributes (like todir/tofile) triggers a BuildException.
*/
@Test(expected = BuildException.class)
public void testMissingDestDir() {
File src = new File(tempDir, "source.txt");
copyTask.setFile(src);
// Intentional omission of setTofile() or setTodir()
copyTask.execute();
}

/**
* Test Path: SCANNING -> FAILED
* Verifies that a non-existent source file leads to a failure state.
*/
@Test(expected = BuildException.class)
public void testSourceFileMissing() {
File ghostFile = new File(tempDir, "ghost.txt");
if (ghostFile.exists()) ghostFile.delete();

copyTask.setFile(ghostFile);
copyTask.setTodir(tempDir);
copyTask.execute();
}
}
75 changes: 75 additions & 0 deletions src/tests/junit/org/apache/tools/ant/taskdefs/CarolCopyTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package org.apache.tools.ant.taskdefs;

import org.apache.tools.ant.BuildFileRule;
import org.apache.tools.ant.BuildException;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import java.io.File;

import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

public class CarolCopyTest {

@Rule
public final BuildFileRule buildRule = new BuildFileRule();

@Before
public void setUp() {
// Point to copy_test.xml
buildRule.configureProject("src/etc/testcases/taskdefs/copy_test.xml");
}

/**
* Partition 1: Valid Source
* Test: Duplicate an existed file
* Expection: dest.txt should be created
*/
@Test
public void testValidCopy() {
buildRule.executeTarget("setUp");
buildRule.executeTarget("testValidCopy");

File destFile = new File("src/etc/testcases/taskdefs/copy-temp/dest.txt");
assertTrue("Destination file should exist after copy", destFile.exists());

buildRule.executeTarget("tearDown");
}

/**
* Partition 2: Missing Source
* Testing: Duplicate an inexisted file (ghost.txt)
* Expectation: BuildException
*/
@Test
public void testMissingSource() {
buildRule.executeTarget("setUp");

try {
buildRule.executeTarget("testMissingSource");
// If the program doesn't show this error code -> fail
fail("Build should have failed due to missing source file");
} catch (BuildException ex) {
// Catch the bug successfully
}

buildRule.executeTarget("tearDown");
}

/**
* Partition 3: Directory Copy
* Testing: Duplicate a file
* Expectation: Object file should appear
*/
@Test
public void testDirectoryCopy() {
buildRule.executeTarget("setUp");
buildRule.executeTarget("testDirectoryCopy");

File destDir = new File("src/etc/testcases/taskdefs/copy-temp/dest_dir");
assertTrue("Destination directory should exist", destDir.exists());

buildRule.executeTarget("tearDown");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.apache.tools.ant.taskdefs;

import org.apache.tools.ant.Project;
import org.junit.Test;
import java.io.File;

public class CarolExecuteOnTest {
@Test
public void testExecuteOnCoverageBoost() {
ExecuteOn exe = new ExecuteOn();
exe.setProject(new Project());

// 1. Setter
exe.setExecutable("echo");
exe.setCommand(new org.apache.tools.ant.types.Commandline("echo hello"));
exe.setAppend(true);
exe.setForce(true);
exe.setVerbose(true);
exe.setParallel(false);
exe.setType(new ExecuteOn.FileDirBoth());
exe.setRelative(true);
exe.setSkipEmptyFilesets(true);
exe.setDest(new File("."));

// 2. Triggering core logic
try {
org.apache.tools.ant.types.FileSet fs = new org.apache.tools.ant.types.FileSet();
fs.setDir(new File("."));
fs.setIncludes("CarolExecuteOnTest.java"); // Use yourself as a test file
exe.addFileset(fs);

exe.execute();
} catch (Exception e) {
}
}
}
Loading