git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@482907 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -45,6 +45,13 @@ public abstract class ProjectComponent implements Cloneable { | |||||
| protected Location location = Location.UNKNOWN_LOCATION; | protected Location location = Location.UNKNOWN_LOCATION; | ||||
| // CheckStyle:VisibilityModifier ON | // CheckStyle:VisibilityModifier ON | ||||
| /** | |||||
| * Description of this component, if any. | |||||
| * @deprecated since 1.6.x. | |||||
| * You should not be accessing this variable directly. | |||||
| */ | |||||
| protected String description; | |||||
| /** Sole constructor. */ | /** Sole constructor. */ | ||||
| public ProjectComponent() { | public ProjectComponent() { | ||||
| } | } | ||||
| @@ -97,6 +104,29 @@ public abstract class ProjectComponent implements Cloneable { | |||||
| this.location = location; | this.location = location; | ||||
| } | } | ||||
| /** | |||||
| * Sets a description of the current action. This may be used for logging | |||||
| * purposes. | |||||
| * | |||||
| * @param desc Description of the current action. | |||||
| * May be <code>null</code>, indicating that no description is | |||||
| * available. | |||||
| * | |||||
| */ | |||||
| public void setDescription(String desc) { | |||||
| description = desc; | |||||
| } | |||||
| /** | |||||
| * Returns the description of the current action. | |||||
| * | |||||
| * @return the description of the current action, or <code>null</code> if | |||||
| * no description is available. | |||||
| */ | |||||
| public String getDescription() { | |||||
| return description; | |||||
| } | |||||
| /** | /** | ||||
| * Logs a message with the default (INFO) priority. | * Logs a message with the default (INFO) priority. | ||||
| * | * | ||||
| @@ -41,13 +41,6 @@ public abstract class Task extends ProjectComponent { | |||||
| */ | */ | ||||
| protected Target target; | protected Target target; | ||||
| /** | |||||
| * Description of this task, if any. | |||||
| * @deprecated since 1.6.x. | |||||
| * You should not be accessing this variable directly. | |||||
| */ | |||||
| protected String description; | |||||
| /** | /** | ||||
| * Name of this task to be used for logging purposes. | * Name of this task to be used for logging purposes. | ||||
| * This defaults to the same as the type, but may be | * This defaults to the same as the type, but may be | ||||
| @@ -141,29 +134,6 @@ public abstract class Task extends ProjectComponent { | |||||
| this.taskType = type; | this.taskType = type; | ||||
| } | } | ||||
| /** | |||||
| * Sets a description of the current action. This may be used for logging | |||||
| * purposes. | |||||
| * | |||||
| * @param desc Description of the current action. | |||||
| * May be <code>null</code>, indicating that no description is | |||||
| * available. | |||||
| * | |||||
| */ | |||||
| public void setDescription(String desc) { | |||||
| description = desc; | |||||
| } | |||||
| /** | |||||
| * Returns the description of the current action. | |||||
| * | |||||
| * @return the description of the current action, or <code>null</code> if | |||||
| * no description is available. | |||||
| */ | |||||
| public String getDescription() { | |||||
| return description; | |||||
| } | |||||
| /** | /** | ||||
| * Called by the project to let the task initialize properly. | * Called by the project to let the task initialize properly. | ||||
| * The default implementation is a no-op. | * The default implementation is a no-op. | ||||
| @@ -0,0 +1,47 @@ | |||||
| /* | |||||
| * 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; | |||||
| import junit.framework.TestCase; | |||||
| public class ProjectComponentTest extends TestCase { | |||||
| public ProjectComponentTest(String name) { | |||||
| super(name); | |||||
| } | |||||
| public void testClone() throws CloneNotSupportedException { | |||||
| Project expectedProject = new Project(); | |||||
| Location expectedLocation = new Location("foo"); | |||||
| String expectedDescription = "bar"; | |||||
| // use an anonymous subclass since ProjectComponent is abstract | |||||
| ProjectComponent pc = new ProjectComponent() { | |||||
| }; | |||||
| pc.setProject(expectedProject); | |||||
| pc.setLocation(expectedLocation); | |||||
| pc.setDescription(expectedDescription); | |||||
| ProjectComponent cloned = (ProjectComponent) pc.clone(); | |||||
| assertNotSame(pc, cloned); | |||||
| assertSame(cloned.getProject(), expectedProject); | |||||
| assertSame(cloned.getLocation(), expectedLocation); | |||||
| assertSame(cloned.getDescription(), expectedDescription); | |||||
| } | |||||
| } | |||||