summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakozak2011-11-22 02:22:40 (EST)
committer Winston Prakash2011-12-01 20:46:54 (EST)
commit227a4ba622ba77e3585050e516d70e2e7274812d (patch)
treec92bb0a7d9db5a1fdc529440460c2f1d31e1cacf
parent7fecc99e740cc36b4725899b6edaf5bb03af1bff (diff)
downloadorg.eclipse.hudson.core-227a4ba622ba77e3585050e516d70e2e7274812d.zip
org.eclipse.hudson.core-227a4ba622ba77e3585050e516d70e2e7274812d.tar.gz
org.eclipse.hudson.core-227a4ba622ba77e3585050e516d70e2e7274812d.tar.bz2
Fix code formatting. Implement unit test for isCustomWorkspaceInherited method. Interfaces relocated to org.hudsonci.api package.
Signed-off-by: Winston Prakash <winston.prakash@gmail.com>
-rw-r--r--hudson-core/pom.xml1
-rw-r--r--hudson-core/src/main/java/hudson/matrix/MatrixProject.java5
-rw-r--r--hudson-core/src/main/java/hudson/model/AbstractProject.java8
-rw-r--r--hudson-core/src/main/java/hudson/model/FreeStyleProject.java18
-rw-r--r--hudson-core/src/main/java/hudson/model/Job.java3
-rw-r--r--hudson-core/src/main/java/hudson/model/Project.java4
-rw-r--r--hudson-core/src/main/java/org/hudsonci/api/matrix/IMatrixProject.java (renamed from hudson-core/src/main/java/hudson/matrix/IMatrixProject.java)10
-rw-r--r--hudson-core/src/main/java/org/hudsonci/api/model/IAbstractProject.java (renamed from hudson-core/src/main/java/hudson/model/IAbstractProject.java)7
-rw-r--r--hudson-core/src/main/java/org/hudsonci/api/model/IFreeStyleProject.java (renamed from hudson-core/src/main/java/hudson/model/IFreeStyleProject.java)2
-rw-r--r--hudson-core/src/main/java/org/hudsonci/api/model/IJob.java (renamed from hudson-core/src/main/java/hudson/model/IJob.java)4
-rw-r--r--hudson-core/src/main/java/org/hudsonci/api/model/IProject.java (renamed from hudson-core/src/main/java/hudson/model/IProject.java)3
-rw-r--r--hudson-core/src/test/java/hudson/model/FreeStyleProjectTest.java21
-rw-r--r--pom.xml1
13 files changed, 56 insertions, 31 deletions
diff --git a/hudson-core/pom.xml b/hudson-core/pom.xml
index 3596aec..805e00c 100644
--- a/hudson-core/pom.xml
+++ b/hudson-core/pom.xml
@@ -76,7 +76,6 @@
<bridge-method-injector.version>1.4</bridge-method-injector.version>
<access-modifier-checker.version>1.0</access-modifier-checker.version>
<antlr-maven-plugin.version>2.1</antlr-maven-plugin.version>
- <cobertura-maven-plugin.version>2.5.1</cobertura-maven-plugin.version>
<apt-maven-plugin.version>1.0-alpha-2</apt-maven-plugin.version>
<maven-project-info-reports-plugin.version>2.1</maven-project-info-reports-plugin.version>
</properties>
diff --git a/hudson-core/src/main/java/hudson/matrix/MatrixProject.java b/hudson-core/src/main/java/hudson/matrix/MatrixProject.java
index f186d65..a6e6f09 100644
--- a/hudson-core/src/main/java/hudson/matrix/MatrixProject.java
+++ b/hudson-core/src/main/java/hudson/matrix/MatrixProject.java
@@ -33,9 +33,7 @@ import hudson.model.Items;
import hudson.model.JDK;
import hudson.model.Job;
import hudson.model.Label;
-import hudson.model.Node;
import hudson.model.Queue.FlyweightTask;
-import hudson.model.ResourceController;
import hudson.model.Result;
import hudson.model.SCMedItem;
import hudson.model.Saveable;
@@ -53,6 +51,7 @@ import hudson.util.FormValidation;
import hudson.util.FormValidation.Kind;
import net.sf.json.JSONObject;
import org.apache.commons.lang3.ObjectUtils;
+import org.hudsonci.api.matrix.IMatrixProject;
import org.kohsuke.stapler.HttpResponse;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
@@ -75,8 +74,6 @@ import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
-import static hudson.Util.*;
-
/**
* {@link Job} that allows you to run multiple different configurations
* from a single setting.
diff --git a/hudson-core/src/main/java/hudson/model/AbstractProject.java b/hudson-core/src/main/java/hudson/model/AbstractProject.java
index 5baedcd..99af94e 100644
--- a/hudson-core/src/main/java/hudson/model/AbstractProject.java
+++ b/hudson-core/src/main/java/hudson/model/AbstractProject.java
@@ -21,9 +21,7 @@ import hudson.AbortException;
import hudson.CopyOnWrite;
import hudson.FeedAdapter;
import hudson.FilePath;
-import hudson.Functions;
import hudson.Launcher;
-import hudson.RestrictedSince;
import hudson.Util;
import hudson.cli.declarative.CLIMethod;
import hudson.cli.declarative.CLIResolver;
@@ -93,8 +91,7 @@ import net.sf.json.JSONObject;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
-import org.kohsuke.accmod.Restricted;
-import org.kohsuke.accmod.restrictions.NoExternalUse;
+import org.hudsonci.api.model.IAbstractProject;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.stapler.ForwardToView;
@@ -118,7 +115,8 @@ import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
* @author Kohsuke Kawaguchi
* @see AbstractBuild
*/
-public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends AbstractBuild<P,R>> extends Job<P,R> implements BuildableItem, IAbstractProject {
+public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends AbstractBuild<P,R>> extends Job<P,R> implements BuildableItem,
+ IAbstractProject {
/**
* {@link SCM} associated with the project.
diff --git a/hudson-core/src/main/java/hudson/model/FreeStyleProject.java b/hudson-core/src/main/java/hudson/model/FreeStyleProject.java
index a0ee2d3..887c29a 100644
--- a/hudson-core/src/main/java/hudson/model/FreeStyleProject.java
+++ b/hudson-core/src/main/java/hudson/model/FreeStyleProject.java
@@ -22,6 +22,7 @@ import java.io.File;
import java.io.IOException;
import org.apache.commons.lang3.StringUtils;
+import org.hudsonci.api.model.IFreeStyleProject;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
@@ -32,7 +33,8 @@ import javax.servlet.ServletException;
*
* @author Kohsuke Kawaguchi
*/
-public class FreeStyleProject extends Project<FreeStyleProject,FreeStyleBuild> implements TopLevelItem, IFreeStyleProject {
+public class FreeStyleProject extends Project<FreeStyleProject,FreeStyleBuild> implements TopLevelItem,
+ IFreeStyleProject {
private static final String DEFAULT_CUSTOM_WORKSPACE = "default_workspace";
@@ -59,14 +61,14 @@ public class FreeStyleProject extends Project<FreeStyleProject,FreeStyleBuild> i
return FreeStyleBuild.class;
}
-
public String getCustomWorkspace(boolean useParentValue) {
- if (!useParentValue || !isCustomWorkspaceInherited()) {
- return DEFAULT_CUSTOM_WORKSPACE.equals(customWorkspace)? null : StringUtils.trimToNull(customWorkspace);
- } else if (StringUtils.isNotBlank(customWorkspace)) {
- return customWorkspace;
- }
- return hasCascadingProject()? getCascadingProject().getCustomWorkspace() : null;
+ if (!useParentValue || !isCustomWorkspaceInherited()) {
+ return DEFAULT_CUSTOM_WORKSPACE.equals(customWorkspace) ? null : StringUtils.trimToNull(customWorkspace);
+ }
+ if (StringUtils.isNotBlank(customWorkspace)) {
+ return customWorkspace;
+ }
+ return hasCascadingProject() ? getCascadingProject().getCustomWorkspace() : null;
}
public boolean isCustomWorkspaceInherited() {
diff --git a/hudson-core/src/main/java/hudson/model/Job.java b/hudson-core/src/main/java/hudson/model/Job.java
index 7568d66..24fdf3d 100644
--- a/hudson-core/src/main/java/hudson/model/Job.java
+++ b/hudson-core/src/main/java/hudson/model/Job.java
@@ -79,7 +79,8 @@ import javax.servlet.ServletException;
import net.sf.json.JSONException;
import net.sf.json.JSONObject;
-
+
+import org.hudsonci.api.model.IJob;
import org.jvnet.localizer.Localizable;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.CmdLineException;
diff --git a/hudson-core/src/main/java/hudson/model/Project.java b/hudson-core/src/main/java/hudson/model/Project.java
index 7133c8b..42a6be8 100644
--- a/hudson-core/src/main/java/hudson/model/Project.java
+++ b/hudson-core/src/main/java/hudson/model/Project.java
@@ -32,6 +32,7 @@ import hudson.tasks.Maven.MavenInstallation;
import hudson.triggers.Trigger;
import hudson.util.DescribableList;
import net.sf.json.JSONObject;
+import org.hudsonci.api.model.IProject;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
@@ -48,7 +49,8 @@ import java.util.Set;
* @author Kohsuke Kawaguchi
*/
public abstract class Project<P extends Project<P,B>,B extends Build<P,B>>
- extends AbstractProject<P,B> implements SCMedItem, Saveable, ProjectWithMaven, BuildableItemWithBuildWrappers, IProject {
+ extends AbstractProject<P,B> implements SCMedItem, Saveable, ProjectWithMaven, BuildableItemWithBuildWrappers,
+ IProject {
/**
* List of active {@link Builder}s configured for this project.
diff --git a/hudson-core/src/main/java/hudson/matrix/IMatrixProject.java b/hudson-core/src/main/java/org/hudsonci/api/matrix/IMatrixProject.java
index 8367382..c390a8f 100644
--- a/hudson-core/src/main/java/hudson/matrix/IMatrixProject.java
+++ b/hudson-core/src/main/java/org/hudsonci/api/matrix/IMatrixProject.java
@@ -12,15 +12,15 @@
* Anton Kozak
*
*******************************************************************************/
-package hudson.matrix;
+package org.hudsonci.api.matrix;
+import hudson.matrix.AxisList;
import hudson.model.Descriptor;
-import hudson.model.IAbstractProject;
+import org.hudsonci.api.model.IAbstractProject;
import hudson.model.Result;
import hudson.tasks.BuildWrapper;
import hudson.tasks.Builder;
import hudson.tasks.Publisher;
-import hudson.util.DescribableList;
import java.io.IOException;
import java.util.List;
import java.util.Map;
@@ -33,9 +33,9 @@ import java.util.Map;
public interface IMatrixProject extends IAbstractProject {
/**
- * Returns {@link AxisList} of configured axes.
+ * Returns {@link hudson.matrix.AxisList} of configured axes.
*
- * @return {@link AxisList} of configured axes.
+ * @return {@link hudson.matrix.AxisList} of configured axes.
*/
public AxisList getAxes();
diff --git a/hudson-core/src/main/java/hudson/model/IAbstractProject.java b/hudson-core/src/main/java/org/hudsonci/api/model/IAbstractProject.java
index 01d4ea3..8bf6405 100644
--- a/hudson-core/src/main/java/hudson/model/IAbstractProject.java
+++ b/hudson-core/src/main/java/org/hudsonci/api/model/IAbstractProject.java
@@ -12,8 +12,9 @@
* Nikita Levyankov
*
*******************************************************************************/
-package hudson.model;
+package org.hudsonci.api.model;
+import hudson.model.Label;
import hudson.scm.SCM;
import hudson.triggers.Trigger;
import hudson.triggers.TriggerDescriptor;
@@ -94,9 +95,9 @@ public interface IAbstractProject extends IJob {
/**
* If this project is configured to be always built on this node,
- * return that {@link Node}. Otherwise null.
+ * return that {@link hudson.model.Node}. Otherwise null.
*
- * @return {@link Label} instance.
+ * @return {@link hudson.model.Label} instance.
*/
Label getAssignedLabel();
diff --git a/hudson-core/src/main/java/hudson/model/IFreeStyleProject.java b/hudson-core/src/main/java/org/hudsonci/api/model/IFreeStyleProject.java
index fcf6dd0..a735d49 100644
--- a/hudson-core/src/main/java/hudson/model/IFreeStyleProject.java
+++ b/hudson-core/src/main/java/org/hudsonci/api/model/IFreeStyleProject.java
@@ -12,7 +12,7 @@
* Nikita Levyankov
*
*******************************************************************************/
-package hudson.model;
+package org.hudsonci.api.model;
/**
* FreeStyle project interface.
diff --git a/hudson-core/src/main/java/hudson/model/IJob.java b/hudson-core/src/main/java/org/hudsonci/api/model/IJob.java
index 5493a36..0d1a712 100644
--- a/hudson-core/src/main/java/hudson/model/IJob.java
+++ b/hudson-core/src/main/java/org/hudsonci/api/model/IJob.java
@@ -12,8 +12,10 @@
* Nikita Levyankov
*
*******************************************************************************/
-package hudson.model;
+package org.hudsonci.api.model;
+import hudson.model.JobProperty;
+import hudson.model.JobPropertyDescriptor;
import hudson.tasks.LogRotator;
import java.util.Map;
diff --git a/hudson-core/src/main/java/hudson/model/IProject.java b/hudson-core/src/main/java/org/hudsonci/api/model/IProject.java
index 79f3f8b..5f19bc3 100644
--- a/hudson-core/src/main/java/hudson/model/IProject.java
+++ b/hudson-core/src/main/java/org/hudsonci/api/model/IProject.java
@@ -12,8 +12,9 @@
* Nikita Levyankov
*
*******************************************************************************/
-package hudson.model;
+package org.hudsonci.api.model;
+import hudson.model.Descriptor;
import hudson.tasks.BuildWrapper;
import hudson.tasks.Builder;
import hudson.tasks.Publisher;
diff --git a/hudson-core/src/test/java/hudson/model/FreeStyleProjectTest.java b/hudson-core/src/test/java/hudson/model/FreeStyleProjectTest.java
index dcfebc9..2fcf241 100644
--- a/hudson-core/src/test/java/hudson/model/FreeStyleProjectTest.java
+++ b/hudson-core/src/test/java/hudson/model/FreeStyleProjectTest.java
@@ -34,6 +34,7 @@ import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.assertTrue;
import static org.easymock.EasyMock.expect;
+import static org.junit.Assert.assertFalse;
import static org.powermock.api.easymock.PowerMock.createMock;
import static org.powermock.api.easymock.PowerMock.mockStatic;
import static org.powermock.api.easymock.PowerMock.replayAll;
@@ -761,6 +762,26 @@ public class FreeStyleProjectTest {
assertEquals(childConcurrentBuild, (Boolean) childProject.isConcurrentBuild());
}
+ @Test
+ public void testIsCustomWorkspaceInherited() throws IOException{
+ FreeStyleProject parentProject = new FreeStyleProjectMock("parent");
+ parentProject.allowSave.set(false);
+ assertFalse(parentProject.isCustomWorkspaceInherited());
+ String temp = "/temp";
+ parentProject.setCustomWorkspace(temp);
+ assertFalse(parentProject.isCustomWorkspaceInherited());
+ FreeStyleProject childProject = new FreeStyleProjectMock("child");
+ childProject.allowSave.set(false);
+ childProject.setCascadingProject(parentProject);
+ assertTrue(childProject.isCustomWorkspaceInherited());
+ childProject.setCustomWorkspace("/temp1");
+ assertFalse(childProject.isCustomWorkspaceInherited());
+ childProject.setCustomWorkspace(null);
+ assertFalse(childProject.isCustomWorkspaceInherited());
+ childProject.setCustomWorkspace(temp);
+ assertTrue(childProject.isCustomWorkspaceInherited());
+ }
+
private class FreeStyleProjectMock extends FreeStyleProject {
private FreeStyleProjectMock(String name) {
diff --git a/pom.xml b/pom.xml
index 7547d3e..b78695d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -104,6 +104,7 @@
<maven-jaxb2-plugin.version>0.7.4</maven-jaxb2-plugin.version>
<!--TODO migrate to 2.6 to resolve issue with compilation on JDK7 (https://jira.codehaus.org/browse/ENUNCIATE-603) -->
<maven-enunciate-plugin.version>1.24</maven-enunciate-plugin.version>
+ <cobertura-maven-plugin.version>2.5.1</cobertura-maven-plugin.version>
</properties>
<modules>