{@link Assertions}
.
12 | */
13 | protected Assertions() {
14 | // empty
15 | }
16 | }
--------------------------------------------------------------------------------
/grab-latest-rc.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | set -eux
3 | curl -L https://get.jenkins.io/war-rc/latest/jenkins.war >jenkins.war
4 |
--------------------------------------------------------------------------------
/jut-server.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | DIR="$(cd "$(dirname "$0")" && pwd)"
3 | CMD="$DIR/target/appassembler/bin/jut-server"
4 | if [[ ! -s $CMD ]]; then
5 | mvn package -DskipTests -f "$DIR/pom.xml"
6 | fi
7 | sh "$CMD" "$@"
8 |
--------------------------------------------------------------------------------
/single-plugin.groovy:
--------------------------------------------------------------------------------
1 | // Run tests that requires plugins enumerated in TEST_ONLY_PLUGINS variable.
2 | //
3 | // 'TEST_ONLY_PLUGINS=git,envinject' run all tests that require git or envinject
4 | // using WithPlugins annotations
5 |
6 | import org.junit.runner.Description;
7 | import org.junit.runners.model.Statement;
8 |
9 | import org.jenkinsci.test.acceptance.junit.FilterRule.Filter;
10 | import org.jenkinsci.test.acceptance.junit.WithPlugins;
11 | import org.jenkinsci.test.acceptance.update_center.PluginSpec;
12 |
13 | import java.lang.annotation.Annotation;
14 |
15 | bind Filter toInstance new FilterImpl();
16 |
17 | class FilterImpl extends Filter {
18 | public String whySkip(Statement base, Description desc) {
19 | for (annot in getAnnotations(desc, WithPlugins.class)) {
20 | for (value in annot.value()) {
21 | if (testOnlyPlugins().contains(new PluginSpec(value).name)) {
22 | return null;
23 | }
24 | }
25 | }
26 |
27 | return "Running only tests for plugins: ${testOnlyPlugins()}";
28 | }
29 |
30 | private Collection15 | * User can select the factory by specifying its ID to the "TYPE" environment variable. 16 | */ 17 | String getId(); 18 | 19 | JenkinsController create(); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/org/jenkinsci/test/acceptance/docker/DockerModule.java: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.test.acceptance.docker; 2 | 3 | import com.cloudbees.sdk.extensibility.Extension; 4 | import com.cloudbees.sdk.extensibility.ExtensionModule; 5 | import com.google.inject.AbstractModule; 6 | 7 | /** 8 | * @author Kohsuke Kawaguchi 9 | */ 10 | @Extension 11 | public class DockerModule extends AbstractModule implements ExtensionModule { 12 | @Override 13 | protected void configure() { 14 | requestStaticInjection(Docker.class); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/org/jenkinsci/test/acceptance/docker/fixtures/ArtifactoryContainer.java: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.test.acceptance.docker.fixtures; 2 | 3 | import java.net.MalformedURLException; 4 | import java.net.URL; 5 | import org.jenkinsci.test.acceptance.docker.DockerContainer; 6 | import org.jenkinsci.test.acceptance.docker.DockerFixture; 7 | 8 | /** 9 | * Runs Artifactory OSS container 10 | */ 11 | @DockerFixture(id = "artifactory", ports = 8081) 12 | public class ArtifactoryContainer extends DockerContainer { 13 | 14 | public URL getURL() { 15 | try { 16 | return new URL("http://" + ipBound(8081) + ":" + port(8081) + "/artifactory"); 17 | } catch (MalformedURLException ex) { 18 | throw new AssertionError(ex); 19 | } 20 | } 21 | 22 | /** 23 | * Rest Api to verify Artifactory is up and running 24 | */ 25 | public URL getPingURL() throws MalformedURLException { 26 | return new URL("http://" + ipBound(8081) + ":" + port(8081) + "/artifactory/api/system/ping"); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/org/jenkinsci/test/acceptance/docker/fixtures/IPasswordDockerContainer.java: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.test.acceptance.docker.fixtures; 2 | 3 | /** 4 | * gets username and password for a service on a docker container 5 | * 6 | * @author Tobias Meyer 7 | */ 8 | public interface IPasswordDockerContainer { 9 | /** 10 | * Gets the passsword for a service on the docker server 11 | * 12 | * @return password 13 | */ 14 | String getPassword(); 15 | /** 16 | * Gets the username for a service on the docker server 17 | * 18 | * @return username 19 | */ 20 | String getUsername(); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/org/jenkinsci/test/acceptance/docker/fixtures/JavaGitContainer.java: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.test.acceptance.docker.fixtures; 2 | 3 | import org.jenkinsci.test.acceptance.docker.DockerFixture; 4 | 5 | @DockerFixture(id = "javagit", ports = 22) 6 | public class JavaGitContainer extends GitContainer { 7 | /** Local path. */ 8 | @Override 9 | public String getRepoUrl() { 10 | return "file:///" + REPO_DIR; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/org/jenkinsci/test/acceptance/docker/fixtures/SMBContainer.java: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.test.acceptance.docker.fixtures; 2 | 3 | import org.jenkinsci.test.acceptance.docker.DockerContainer; 4 | import org.jenkinsci.test.acceptance.docker.DockerFixture; 5 | 6 | /** 7 | * Represents a server with SMB. 8 | * 9 | * @author Tobias Meyer 10 | */ 11 | @DockerFixture( 12 | id = "smb", 13 | ports = {445, 139, 135}) 14 | public class SMBContainer extends DockerContainer implements IPasswordDockerContainer { 15 | private final String username = "test"; 16 | 17 | private final String password = "test"; 18 | 19 | /** 20 | * Gets the samba password of the samba user on the docker server 21 | * 22 | * @return Samba password 23 | */ 24 | @Override 25 | public String getPassword() { 26 | return password; 27 | } 28 | 29 | /** 30 | * Gets the username of the samba user on the docker server 31 | * 32 | * @return Samba username 33 | */ 34 | @Override 35 | public String getUsername() { 36 | return username; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/jenkinsci/test/acceptance/docker/fixtures/Tomcat10Container.java: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.test.acceptance.docker.fixtures; 2 | 3 | import java.io.IOException; 4 | import java.net.URL; 5 | import org.jenkinsci.test.acceptance.docker.DockerContainer; 6 | import org.jenkinsci.test.acceptance.docker.DockerFixture; 7 | 8 | /** 9 | * Runs stock Tomcat 7 container. 10 | * 11 | * @author Kohsuke Kawaguchi 12 | */ 13 | @DockerFixture(id = "tomcat10", ports = 8080) 14 | public class Tomcat10Container extends DockerContainer { 15 | /** 16 | * URL of Tomcat. 17 | */ 18 | public URL getUrl() throws IOException { 19 | return new URL("http://" + ipBound(8080) + ":" + port(8080)); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/org/jenkinsci/test/acceptance/guice/AutoCleaned.java: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.test.acceptance.guice; 2 | 3 | import java.io.Closeable; 4 | 5 | /** 6 | * Marks instances that want to run some shutdown action 7 | * at the end of their scope. 8 | *
9 | * When a test scope exits, all the existing instances that implement this interface 10 | * gets its {@link #close()} method invoked. 11 | * 12 | *
13 | * Currently this only works with {@link TestScope}. 14 | * 15 | * @see TestCleaner 16 | * @author Kohsuke Kawaguchi 17 | */ 18 | public interface AutoCleaned extends Closeable {} 19 | -------------------------------------------------------------------------------- /src/main/java/org/jenkinsci/test/acceptance/guice/SubWorld.java: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.test.acceptance.guice; 2 | 3 | import com.google.inject.Injector; 4 | import com.google.inject.Provider; 5 | 6 | /** 7 | * Represents a parallel Guice {@link Injector} inside {@link World} 8 | * so that components can be selectively bound to {@link World}. 9 | * 10 | *
11 | * See WIRING.md 12 | * 13 | * @author Kohsuke Kawaguchi 14 | */ 15 | public class SubWorld { 16 | /*package*/ Injector injector; 17 | /*package*/ String name; 18 | 19 | /*package*/ SubWorld() {} 20 | 21 | public String getName() { 22 | return name; 23 | } 24 | 25 | public Injector getInjector() { 26 | return injector; 27 | } 28 | 29 | /** 30 | * This is a part of the DSL construct that allows people to say: 31 | * 32 | *
33 | * subworld "masters" { 34 | * ... 35 | * bind Foo to ... 36 | * } 37 | * 38 | * bind Foo toProvider masters[Foo] // export Foo from the "masters" subworld to the parent 39 | *40 | */ 41 | public
9 | * Oftentimes marking your class with {@link AutoCleaned} gets the job done.
10 | *
11 | * @author Kohsuke Kawaguchi
12 | */
13 | @TestScope
14 | public class TestCleaner extends Cleaner {
15 | @Inject
16 | TestLifecycle lifecycle;
17 |
18 | @Override
19 | public List
14 | * {@link TestScope} is tied to a thread that executes a test, in anticipation of multi-threaded
15 | * concurrent test executions. See {@link World}
16 | *
17 | * @author Kohsuke Kawaguchi
18 | */
19 | @Retention(RetentionPolicy.RUNTIME)
20 | @Target({ElementType.TYPE, ElementType.METHOD})
21 | @Inherited
22 | @Documented
23 | @ScopeAnnotation
24 | public @interface TestScope {}
25 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/guice/TestScopeModule.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.guice;
2 |
3 | import com.cloudbees.sdk.extensibility.Extension;
4 | import com.cloudbees.sdk.extensibility.ExtensionModule;
5 | import com.google.inject.AbstractModule;
6 |
7 | /**
8 | * Defines {@link TestScope} and exposes {@link TestLifecycle} to clean-up test-scoped instances.
9 | *
10 | * @author Kohsuke Kawaguchi
11 | */
12 | @Extension
13 | public class TestScopeModule extends AbstractModule implements ExtensionModule {
14 | @Override
15 | protected void configure() {
16 | TestLifecycle tl = new TestLifecycle();
17 | bindScope(TestScope.class, tl);
18 | bind(TestLifecycle.class).toInstance(tl);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/guice/WorldCleaner.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.guice;
2 |
3 | import jakarta.inject.Singleton;
4 |
5 | /**
6 | * {@link Cleaner} at the end of {@link Singleton}.
7 | *
8 | * @author Kohsuke Kawaguchi
9 | */
10 | @Singleton
11 | public class WorldCleaner extends Cleaner {}
12 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/junit/DockerTest.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.junit;
2 |
3 | /**
4 | * Marker interface to identify a Docker test. Used to get categories working properly with {@link WithDocker}.
5 | *
6 | * @author Andrew Bayer
7 | */
8 | public interface DockerTest {
9 | // marker interface
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/junit/GlobalRule.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.junit;
2 |
3 | import java.lang.annotation.Documented;
4 | import java.lang.annotation.ElementType;
5 | import java.lang.annotation.Retention;
6 | import java.lang.annotation.RetentionPolicy;
7 | import java.lang.annotation.Target;
8 | import org.junit.rules.TestRule;
9 | import org.jvnet.hudson.annotation_indexer.Indexed;
10 |
11 | /**
12 | * {@link TestRule} to be applied on all tests globally.
13 | *
14 | * Annotate {@link TestRule} to have it run for every test.
15 | * See {@link RuleAnnotation} optional rule registration.
16 | *
17 | * @author ogondza
18 | */
19 | @Retention(RetentionPolicy.RUNTIME)
20 | @Target(ElementType.TYPE)
21 | @Documented
22 | @Indexed
23 | public @interface GlobalRule {
24 |
25 | /**
26 | * Optional ordering among rules.
27 | *
28 | * Annotation with {@code priority >= 0} are guaranteed to be run after
29 | * Jenkins is up. Negative priorities are run before startup on best effort
30 | * basis. (It might not happen before for ExistingJenkinsController,
31 | * PooledJenkinsController and possibly others).
32 | *
33 | * Annotations that skips execution are encouraged to run before Jenkins is
34 | * booted up to save time. Note, that these implementations can not inject
35 | * Jenkins for obvious reasons.
36 | */
37 | int priority() default 0;
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/junit/RuleFailedException.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.junit;
2 |
3 | import org.junit.rules.TestRule;
4 |
5 | /**
6 | * This is a service exception that wraps the TestRule failure to all traceability back to failing test rules.
7 | */
8 | public class RuleFailedException extends RuntimeException {
9 | private static final long serialVersionUID = 183080398115494371L;
10 |
11 | private final String failedRule;
12 |
13 | public RuleFailedException(Throwable throwable, TestRule failingRule) {
14 | super(throwable);
15 | failedRule = failingRule.getClass().getName();
16 | }
17 |
18 | @Override
19 | public String getMessage() {
20 | return "TestRule " + failedRule + " failed: " + super.getMessage();
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/junit/SmokeTest.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.junit;
2 |
3 | /**
4 | * Marker interface to identify a smoke test. A smoke test is a test that basically uses one important aspect of the
5 | * acceptance testing framework. Run these smoke tests in order to get a first impression if a framework change did not
6 | * break anything. The overall number of smoke tests should be less than 10.
7 | *
8 | * @author Ullrich Hafner
9 | */
10 | public interface SmokeTest {
11 | // marker interface
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/junit/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Glue to write acceptance tests in JUnit.
3 | */
4 | package org.jenkinsci.test.acceptance.junit;
5 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/log/LogListenable.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.log;
2 |
3 | import org.jenkinsci.test.acceptance.controller.JenkinsController;
4 |
5 | /**
6 | * Produces line-by-line log.
7 | *
8 | * Among other things, optionally implemented by {@link JenkinsController} that provides access
9 | * to the console output.
10 | *
11 | * @author Kohsuke Kawaguchi
12 | */
13 | public interface LogListenable {
14 | void addLogListener(LogListener l);
15 |
16 | void removeLogListener(LogListener l);
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/log/LogListener.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.log;
2 |
3 | import hudson.remoting.Asynchronous;
4 | import java.io.IOException;
5 |
6 | /**
7 | * Receives line-by-line logs from {@link LogListenable}.
8 | *
9 | * @see LogListenable
10 | * @author Kohsuke Kawaguchi
11 | */
12 | public interface LogListener {
13 | /**
14 | * Receives log output from Jenkins process one line at a time, in the order.
15 | */
16 | @Asynchronous
17 | void processLine(String line) throws IOException;
18 |
19 | /**
20 | * Indicates the EOF.
21 | *
22 | * @param t
23 | * if the termination of log source is unexpected, indicate the cause of the problem.
24 | */
25 | @Asynchronous
26 | void processClose(Exception t);
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/log/LogPrinter.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.log;
2 |
3 | import java.io.IOException;
4 |
5 | /**
6 | * Prints out the received log with a prefix.
7 | *
8 | * @author Kohsuke Kawaguchi
9 | */
10 | public class LogPrinter implements LogListener {
11 | private final String prefix;
12 |
13 | public LogPrinter(String id) {
14 | this.prefix = id == null ? "" : id + "|";
15 | }
16 |
17 | @Override
18 | public void processLine(String line) throws IOException {
19 | System.out.println(prefix + line);
20 | }
21 |
22 | @Override
23 | public void processClose(Exception t) {}
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/log/LogSplitter.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.log;
2 |
3 | import java.io.IOException;
4 | import java.util.List;
5 | import java.util.concurrent.CopyOnWriteArrayList;
6 |
7 | /**
8 | * Receives logs from {@link LogListener} and distributes them to other {@link LogListener}s.
9 | *
10 | * @author Kohsuke Kawaguchi
11 | */
12 | public class LogSplitter implements LogListenable, LogListener {
13 | private final List
25 | * Note that newly added trigger has one entry in there by default.
26 | */
27 | public TriggerConfig addTriggerConfig() {
28 | String path = createPageArea("configs", () -> clickButton("Add trigger..."));
29 | return new TriggerConfig(this, path);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/plugins/parameterized_trigger/TriggerCallBuildStep.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.plugins.parameterized_trigger;
2 |
3 | import org.jenkinsci.test.acceptance.po.AbstractStep;
4 | import org.jenkinsci.test.acceptance.po.BuildStep;
5 | import org.jenkinsci.test.acceptance.po.Describable;
6 | import org.jenkinsci.test.acceptance.po.Job;
7 |
8 | /**
9 | * Trigger/call build step of the parameterized trigger plug-in. Starts downstream projects.
10 | *
11 | * @author Ullrich Hafner
12 | */
13 | @Describable("Trigger/call builds on other projects")
14 | public class TriggerCallBuildStep extends AbstractStep implements BuildStep {
15 | public TriggerCallBuildStep(Job parent, String path) {
16 | super(parent, path);
17 | }
18 |
19 | public BuildTriggerConfig getBuildTriggerConfig(int index) {
20 | return new BuildTriggerConfig(this, getPath("configs", index));
21 | }
22 |
23 | /**
24 | * Adds a new trigger setting.
25 | *
26 | * Note that newly added trigger has one entry in there by default.
27 | */
28 | public BuildTriggerConfig addTriggerConfig() {
29 | String path = createPageArea("configs", () -> clickButton("Add trigger..."));
30 | return new BuildTriggerConfig(this, path);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/plugins/parameterized_trigger/TriggerConfig.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.plugins.parameterized_trigger;
2 |
3 | import org.jenkinsci.test.acceptance.po.Control;
4 | import org.jenkinsci.test.acceptance.po.PageAreaImpl;
5 |
6 | /**
7 | * @author Kohsuke Kawaguchi
8 | */
9 | public class TriggerConfig extends PageAreaImpl {
10 | public final Control projects = control("projects");
11 | public final Control block = control("block");
12 |
13 | public TriggerConfig(ParameterizedTrigger parent, String relativePath) {
14 | super(parent, relativePath);
15 | }
16 |
17 | public
13 | * It provides access to the particular web elements to configure the post build step.
14 | *
15 | * This post build step requires installation of the text-finder plugin.
16 | *
17 | * @author Martin Ende
18 | */
19 | @Describable("Jenkins Text Finder")
20 | public class TextFinderPublisher extends AbstractStep implements PostBuildStep {
21 |
22 | public final WebElement filePath = find(by.xpath("//input[@name='_.fileSet']"));
23 | public final WebElement regEx = find(by.xpath("//input[@name='_.regexp']"));
24 | public final WebElement succeedIfFound = find(by.xpath("//input[@name='_.succeedIfFound']"));
25 | public final WebElement unstableIfFound = find(by.xpath("//input[@name='_.unstableIfFound']"));
26 |
27 | public TextFinderPublisher(Job parent, String path) {
28 | super(parent, path);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/plugins/timestamper/TimstamperGlobalConfig.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.plugins.timestamper;
2 |
3 | import org.jenkinsci.test.acceptance.po.Control;
4 | import org.jenkinsci.test.acceptance.po.Jenkins;
5 | import org.jenkinsci.test.acceptance.po.PageAreaImpl;
6 |
7 | /**
8 | * @author Kohsuke Kawaguchi
9 | */
10 | public class TimstamperGlobalConfig extends PageAreaImpl {
11 | public final Control systemTimeFormat = control("systemTimeFormat");
12 | public final Control elapsedTimeFormat = control("elapsedTimeFormat");
13 |
14 | public TimstamperGlobalConfig(Jenkins jenkins) {
15 | super(jenkins, "/hudson-plugins-timestamper-TimestamperConfig");
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/plugins/workflow_multibranch/BranchSource.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.plugins.workflow_multibranch;
2 |
3 | import org.jenkinsci.test.acceptance.plugins.workflow_shared_library.WorkflowSharedLibrary;
4 | import org.jenkinsci.test.acceptance.po.PageAreaImpl;
5 | import org.jenkinsci.test.acceptance.po.WorkflowMultiBranchJob;
6 |
7 | /**
8 | * Base type for {@link PageAreaImpl} for Branch Source.
9 | */
10 | public class BranchSource extends PageAreaImpl {
11 |
12 | public BranchSource(WorkflowMultiBranchJob job, String path) {
13 | super(job, path);
14 | }
15 |
16 | public BranchSource(WorkflowSharedLibrary sharedLibrary, String path) {
17 | super(sharedLibrary, path);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/plugins/workflow_multibranch/GitBranchSource.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.plugins.workflow_multibranch;
2 |
3 | import org.jenkinsci.test.acceptance.po.Control;
4 | import org.jenkinsci.test.acceptance.po.Describable;
5 | import org.jenkinsci.test.acceptance.po.WorkflowMultiBranchJob;
6 | import org.openqa.selenium.By;
7 | import org.openqa.selenium.support.ui.Select;
8 |
9 | /**
10 | * Git Branch Source for the pipeline multi-branch plugin.
11 | *
12 | * @author Ullrich Hafner
13 | */
14 | @Describable("Git")
15 | // TODO: Remove duplicates with GitScm
16 | public class GitBranchSource extends BranchSource {
17 | private final Control remote = control("remote");
18 |
19 | public GitBranchSource(WorkflowMultiBranchJob job, String path) {
20 | super(job, path);
21 | }
22 |
23 | public GitBranchSource setRemote(final String remoteUrl) {
24 | this.remote.set(remoteUrl);
25 |
26 | return this;
27 | }
28 |
29 | public GitBranchSource setCredentials(final String name) {
30 | Select select = new Select(control(By.className("credentials-select")).resolve());
31 | select.selectByVisibleText(name);
32 |
33 | return this;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/plugins/workflow_shared_library/WorkflowGithubSharedLibrary.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.plugins.workflow_shared_library;
2 |
3 | import org.jenkinsci.test.acceptance.plugins.workflow_multibranch.GithubBranchSource;
4 | import org.jenkinsci.test.acceptance.po.Control;
5 | import org.jenkinsci.test.acceptance.po.PageAreaImpl;
6 |
7 | /**
8 | * Base type for {@link PageAreaImpl} for Pipeline Shared Library using Github as SCM.
9 | */
10 | public class WorkflowGithubSharedLibrary extends WorkflowSharedLibrary {
11 |
12 | public final Control modernScm = control("/");
13 | public final Control githubSourceCodeManagement = control("/retriever");
14 |
15 | public WorkflowGithubSharedLibrary(WorkflowSharedLibraryGlobalConfig config, String path) {
16 | super(config, path);
17 | }
18 |
19 | @Override
20 | public GithubBranchSource selectSCM() {
21 | modernScm.select("0");
22 | githubSourceCodeManagement.select("1");
23 |
24 | return new GithubBranchSource(this, this.getPath() + "/retriever/scm");
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/plugins/workflow_shared_library/WorkflowSharedLibrary.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.plugins.workflow_shared_library;
2 |
3 | import org.jenkinsci.test.acceptance.plugins.workflow_multibranch.BranchSource;
4 | import org.jenkinsci.test.acceptance.po.Control;
5 | import org.jenkinsci.test.acceptance.po.PageAreaImpl;
6 |
7 | /**
8 | * Base type for {@link PageAreaImpl} for Pipeline Shared Library.
9 | */
10 | public abstract class WorkflowSharedLibrary extends PageAreaImpl {
11 |
12 | public final Control name = control("name");
13 |
14 | public WorkflowSharedLibrary(WorkflowSharedLibraryGlobalConfig config, String path) {
15 | super(config, path);
16 | }
17 |
18 | public abstract
6 | * Use {@link Describable} annotation to register an implementation.
7 | *
8 | * @see GlobalSecurityConfig#useAuthorizationStrategy(Class)
9 | */
10 | public abstract class AuthorizationStrategy extends PageAreaImpl {
11 | protected AuthorizationStrategy(GlobalSecurityConfig context, String path) {
12 | super(context, path);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/po/Axis.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.po;
2 |
3 | /**
4 | * Page area for matrix axis.
5 | *
6 | * Use {@link Describable} annotation to register an implementation.
7 | *
8 | * @author Kohsuke Kawaguchi
9 | * @see MatrixProject#addAxis(Class)
10 | */
11 | public abstract class Axis extends PageAreaImpl {
12 | public final Control name = control("name");
13 |
14 | protected Axis(PageObject context, String path) {
15 | super(context, path);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/po/BatchCommandBuildStep.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.po;
2 |
3 | import org.openqa.selenium.NoSuchElementException;
4 |
5 | /**
6 | * BuildStep page object for a Windows Batch Command.
7 | */
8 | @Describable("Execute Windows batch command")
9 | public class BatchCommandBuildStep extends AbstractStep implements BuildStep {
10 |
11 | public BatchCommandBuildStep(Job parent, String path) {
12 | super(parent, path);
13 | }
14 |
15 | public void command(String command) {
16 | try {
17 | control("command").set(command);
18 | } catch (NoSuchElementException e) {
19 | new CodeMirror(this, "command").set(command);
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/po/BuildStep.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.po;
2 |
3 | /**
4 | * Job build step.
5 | *
6 | * Use {@link Describable} annotation to register an implementation.
7 | *
8 | * @author christian.fritz
9 | */
10 | public interface BuildStep extends Step {}
11 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/po/BuildTrigger.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.po;
2 |
3 | /**
4 | * Trigger other projects at the end of a build
5 | *
6 | * @author Kohsuke Kawaguchi
7 | */
8 | @Describable("Build other projects")
9 | public class BuildTrigger extends AbstractStep implements PostBuildStep {
10 | public final Control childProjects = control("childProjects");
11 |
12 | public final Control thresholdSuccess = control("threshold[SUCCESS]");
13 | public final Control thresholdFailure = control("threshold[FAILURE]");
14 |
15 | public BuildTrigger(Job parent, String path) {
16 | super(parent, path);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/po/BuildWrapper.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.po;
2 |
3 | /**
4 | * @author Kohsuke Kawaguchi
5 | */
6 | public abstract class BuildWrapper extends PageAreaImpl {
7 | /**
8 | * @param path p Each BuildWrapper occupies a unique path that is supplied by the subtype.
9 | */
10 | protected BuildWrapper(Job context, String path) {
11 | super(context, path);
12 | }
13 |
14 | /**
15 | * Checkbox that activates this build wrapper.
16 | */
17 | public final Control enable = control("");
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/po/Changes.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.po;
2 |
3 | import java.net.URL;
4 | import org.openqa.selenium.NoSuchElementException;
5 |
6 | /**
7 | * @author Matthias Karl
8 | */
9 | public class Changes extends PageObject {
10 |
11 | protected Changes(PageObject context, URL url) {
12 | super(context, url);
13 | }
14 |
15 | /**
16 | * Are there any changes in the current build.
17 | *
18 | * @return true if the build has changes.
19 | */
20 | public boolean hasChanges() {
21 | try {
22 | // TODO: improve test to be more failproove
23 | find(by.xpath("//h2[text()='%s']/following-sibling::ol/li", "Summary"));
24 | return true;
25 | } catch (NoSuchElementException e) {
26 | return false;
27 | }
28 | }
29 |
30 | /**
31 | * Is there a (diff) link for a specific file.
32 | * Links are present if there are changes in a file and a repository browser is specified.
33 | *
34 | * @param file name of the file with changes.
35 | * @return true if (diff) link for file is present.
36 | */
37 | public boolean hasDiffFileLink(String file) {
38 | try {
39 | // TODO: improve test to be more failproove
40 | find(by.xpath("//a[text()='/%s']/following-sibling::a[text()='(diff)']", file));
41 | return true;
42 | } catch (NoSuchElementException e) {
43 | return false;
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/po/Cloud.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.po;
2 |
3 | /**
4 | * Configuration fragment for cloud.
5 | *
6 | * @author Kohsuke Kawaguchi
7 | */
8 | public abstract class Cloud extends PageAreaImpl {
9 | protected Cloud(PageObject context, String path) {
10 | super(context, path);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/po/ComputerConnector.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.po;
2 |
3 | /**
4 | * Configuration fragment for computer launcher.
5 | *
6 | * Use {@link Describable} annotation to register an implementation.
7 | *
8 | * @author Kohsuke Kawaguchi
9 | */
10 | public abstract class ComputerConnector extends PageAreaImpl {
11 | protected ComputerConnector(PageObject context, String path) {
12 | super(context, path);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/po/ComputerLauncher.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.po;
2 |
3 | /**
4 | * Configuration fragment for computer launcher.
5 | *
6 | * Use {@link Describable} annotation to register an implementation.
7 | *
8 | * @author Kohsuke Kawaguchi
9 | * @see DumbSlave#setLauncher(Class)
10 | */
11 | public abstract class ComputerLauncher extends PageAreaImpl {
12 | protected ComputerLauncher(PageObject context, String path) {
13 | super(context, path);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/po/Container.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.po;
2 |
3 | /**
4 | * A container owns jobs and views. Known container implementations are {@link Jenkins} and {@link Folder}.
5 | *
6 | * @author Ullrich Hafner
7 | */
8 | public interface Container {
9 | /**
10 | * Returns the jobs in this container.
11 | *
12 | * @return the jobs
13 | */
14 | JobsMixIn getJobs();
15 |
16 | /**
17 | * Returns the views in this container.
18 | *
19 | * @return the views
20 | */
21 | ViewsMixIn getViews();
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/po/CopyArchivedArtifactsBuildStep.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.po;
2 |
3 | @Describable("Copy archived artifacts from remote/local job")
4 | public class CopyArchivedArtifactsBuildStep extends AbstractStep implements BuildStep {
5 |
6 | public final Control sourceJob = control("");
7 | public final Control timeout = control("timeout");
8 | public final Control includes = control("includes");
9 |
10 | public CopyArchivedArtifactsBuildStep(Job parent, String path) {
11 | super(parent, path);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/po/Describable.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.po;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 | import org.jvnet.hudson.annotation_indexer.Indexed;
8 |
9 | /**
10 | * Annotation used to register implementations to be discovered automatically.
11 | *
12 | * Note that different services creating an instances have different conventions concerning both the values of this
13 | * annotation as well as the class interface. In some cases, descriptions are visual labels used in UI, but it can as
14 | * well be an internal identifier such as Jenkins class name. Compare {@link Describable} annotations for {@link
15 | * MatrixProject} and {@link ShellBuildStep}. Unique constructor signature is often required for implementations of the
16 | * same abstraction.
17 | *
18 | * The details should be documented in particular superclass, such as {@link Job} or {@link BuildStep}.
19 | *
20 | * @author Kohsuke Kawaguchi
21 | * @see CapybaraPortingLayerImpl#findCaption(Class, CapybaraPortingLayerImpl.Finder)
22 | */
23 | @Retention(RetentionPolicy.RUNTIME)
24 | @Target(ElementType.TYPE)
25 | @Indexed
26 | public @interface Describable {
27 | /**
28 | * Descriptions.
29 | *
30 | * The annotation accepts several values as possible alternatives. First that exists will be used.
31 | */
32 | String[] value();
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/po/Fingerprint.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.po;
2 |
3 | @Describable("Record fingerprints of files to track usage")
4 | public class Fingerprint extends AbstractStep implements PostBuildStep {
5 | public final Control targets = control("targets");
6 |
7 | public Fingerprint(Job parent, String path) {
8 | super(parent, path);
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/po/FreeStyleJob.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.po;
2 |
3 | import com.google.inject.Injector;
4 | import java.net.URL;
5 |
6 | /**
7 | * @author Kohsuke Kawaguchi
8 | */
9 | @Describable("hudson.model.FreeStyleProject")
10 | public class FreeStyleJob extends Job {
11 | public FreeStyleJob(Injector injector, URL url, String name) {
12 | super(injector, url, name);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/po/FreeStyleMultiBranchJob.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.po;
2 |
3 | import com.google.inject.Injector;
4 | import java.net.URL;
5 | import org.openqa.selenium.WebElement;
6 |
7 | /**
8 | * A freestyle multi-branch job (requires installation of multi-branch-project-plugin).
9 | *
10 | * @author Ullrich Hafner
11 | */
12 | @Describable("com.github.mjdetullio.jenkins.plugins.multibranch.FreeStyleMultiBranchProject")
13 | public class FreeStyleMultiBranchJob extends Job {
14 | public FreeStyleMultiBranchJob(Injector injector, URL url, String name) {
15 | super(injector, url, name);
16 | }
17 |
18 | @Override
19 | public
10 | * These page areas do not get fixed path name, so we need to figure that out from the hidden "name" field.
11 | *
12 | * TODO: improve core to make this more robust
13 | *
14 | * @author Kohsuke Kawaguchi
15 | */
16 | public class GlobalPluginConfiguration extends PageAreaImpl {
17 | public GlobalPluginConfiguration(JenkinsConfig context, String pluginShortName) {
18 | super(context, toPathName(context.driver, pluginShortName));
19 | }
20 |
21 | private static String toPathName(WebDriver d, String pluginShortName) {
22 | for (int i = 0; ; i++) {
23 | String path = "/jenkins-model-GlobalPluginConfiguration/plugin";
24 | if (i > 0) {
25 | path += String.format("[%d]", i);
26 | }
27 |
28 | WebElement e = d.findElement(by.path("%s/name", path));
29 | if (e.getAttribute("value").equals(pluginShortName)) {
30 | return path;
31 | }
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/po/JUnitPublisher.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.po;
2 |
3 | /**
4 | * @author Kohsuke Kawaguchi
5 | */
6 | @Describable("Publish JUnit test result report")
7 | public class JUnitPublisher extends AbstractStep implements PostBuildStep {
8 | public final Control testResults = control("testResults");
9 |
10 | public JUnitPublisher(Job parent, String path) {
11 | super(parent, path);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/po/LabelAxis.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.po;
2 |
3 | import java.time.Duration;
4 | import org.openqa.selenium.WebElement;
5 |
6 | /**
7 | * @author Kohsuke Kawaguchi
8 | */
9 | @Describable({"Agents", "Slaves"}) // Agents for Matrix Project Plugin >= 1.15
10 | public class LabelAxis extends Axis {
11 | public LabelAxis(PageObject context, String path) {
12 | super(context, path);
13 | }
14 |
15 | public void select(String name) {
16 | WebElement checkBox =
17 | find(by.path(getPath())).findElement(by.xpath(".//input[@name='values' and @json='%s']", name));
18 | if (!checkBox.isDisplayed()) {
19 | // unfold the labels and slaves sub-nodes
20 | find(by.xpath("(//button[@class='jenkins-button mp-label-axis__button'])[1]"))
21 | .click();
22 | find(by.xpath("(//button[@class='jenkins-button mp-label-axis__button'])[2]"))
23 | .click();
24 |
25 | waitFor().withTimeout(Duration.ofSeconds(3)).until(checkBox::isDisplayed);
26 | }
27 | check(checkBox, true);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/po/LabelExpressionAxis.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.po;
2 |
3 | /**
4 | * @author Scott Hebert
5 | */
6 | @Describable("Label expression")
7 | public class LabelExpressionAxis extends Axis {
8 | public LabelExpressionAxis(PageObject context, String path) {
9 | super(context, path);
10 | }
11 |
12 | public final Control values = control("values");
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/po/ListViewColumn.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.po;
2 |
3 | /**
4 | * Marker Interface for {@link ListView} that corresponds to selectable columns.
5 | *
6 | * Subtypes should have {@link Describable} annotation on it.
7 | *
8 | * @author Fabian Trampusch
9 | */
10 | public interface ListViewColumn {}
11 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/po/LoggedInAuthorizationStrategy.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.po;
2 |
3 | /**
4 | * A logged in user can do everything. Anonymous may have read access.
5 | *
6 | * @author Ullrich Hafner
7 | */
8 | @Describable("Logged-in users can do anything")
9 | public class LoggedInAuthorizationStrategy extends AuthorizationStrategy {
10 | private final Control name = control("/");
11 | private final Control allowAnonymousRead = control("allowAnonymousRead");
12 |
13 | public LoggedInAuthorizationStrategy(GlobalSecurityConfig context, String path) {
14 | super(context, path);
15 | }
16 |
17 | /**
18 | * Enables READ access for anonymous.
19 | */
20 | public void enableAnonymousReadAccess() {
21 | setAnonymousAccess(true);
22 | }
23 |
24 | /**
25 | * Disables READ access for anonymous.
26 | */
27 | public void disableAnonymousReadAccess() {
28 | setAnonymousAccess(false);
29 | }
30 |
31 | private void setAnonymousAccess(final boolean state) {
32 | allowAnonymousRead.check(state);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/po/Logout.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.po;
2 |
3 | /**
4 | * Page object for logging out of Jenkins.
5 | * @author Marco.Miller@ericsson.com
6 | */
7 | public class Logout extends PageObject {
8 | public Logout(Jenkins jenkins) {
9 | super(jenkins.injector, jenkins.url("logout"));
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/po/MatrixBuild.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.po;
2 |
3 | import java.net.URL;
4 | import java.util.ArrayList;
5 | import java.util.List;
6 |
7 | /**
8 | * @author Kohsuke Kawaguchi
9 | */
10 | public class MatrixBuild extends Build {
11 | public MatrixBuild(Job job, URL url) {
12 | super(job.as(MatrixProject.class), url);
13 | }
14 |
15 | public MatrixProject getJob() {
16 | return (MatrixProject) job;
17 | }
18 |
19 | public List
8 | * This class is mostly a marker super-type for such mix-in types.
9 | *
10 | * @author Kohsuke Kawaguchi
11 | */
12 | public abstract class MixIn extends ContainerPageObject {
13 | protected MixIn(ContainerPageObject context) {
14 | super(context, context.url);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/po/OicAuthConfigurationMode.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.po;
2 |
3 | /**
4 | * Class representing the entry controls for the configuration mode when using the oic-auth plugin
5 | */
6 | public abstract class OicAuthConfigurationMode extends PageAreaImpl {
7 |
8 | protected OicAuthConfigurationMode(OicAuthSecurityRealm realm) {
9 | super(realm, "serverConfiguration");
10 | }
11 |
12 | /**
13 | * Class representing the entry controls for well-known endpoint when using the oic-auth plugin
14 | */
15 | @Describable("Discovery via well-known endpoint")
16 | public static class WellKnownEndpoint extends OicAuthConfigurationMode {
17 |
18 | public final Control wellKnownEndpoint = control("wellKnownOpenIDConfigurationUrl");
19 |
20 | public WellKnownEndpoint(OicAuthSecurityRealm realm) {
21 | super(realm);
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/po/PasswordParameter.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.po;
2 |
3 | @Describable("Password Parameter")
4 | public class PasswordParameter extends Parameter {
5 |
6 | public PasswordParameter(Job job, String path) {
7 | super(job, path);
8 | }
9 |
10 | @Override
11 | public void fillWith(Object v) {
12 | control("value").set(v.toString());
13 | }
14 |
15 | @Override
16 | public Parameter setDefault(String value) {
17 | control("defaultValueAsSecret").set(value);
18 | return this;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/po/PostBuildStep.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.po;
2 |
3 | /**
4 | * Marker Interface for {@link PageArea} that corresponds to 'Publisher' in the core.
5 | *
6 | * Subtypes should have {@link Describable} annotation on it.
7 | *
8 | * @author christian.fritz
9 | */
10 | public interface PostBuildStep extends Step {}
11 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/po/ShellBuildStep.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.po;
2 |
3 | import org.openqa.selenium.NoSuchElementException;
4 |
5 | /**
6 | * @author Kohsuke Kawaguchi
7 | */
8 | @Describable("Execute shell")
9 | public class ShellBuildStep extends AbstractStep implements BuildStep {
10 | public ShellBuildStep(Job parent, String path) {
11 | super(parent, path);
12 | }
13 |
14 | public void command(String command) {
15 | try {
16 | new CodeMirror(this, "command").set(command);
17 | } catch (NoSuchElementException e) {
18 | control("command").set(command);
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/po/SnippetGenerator.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.po;
2 |
3 | import org.apache.commons.lang3.StringUtils;
4 | import org.openqa.selenium.By;
5 | import org.openqa.selenium.WebElement;
6 |
7 | /**
8 | * {@link PageObject} for the snippet generator to create bits of code for individual steps.
9 | */
10 | public class SnippetGenerator extends PageObject {
11 | private static final String URI = "pipeline-syntax/";
12 |
13 | /**
14 | * Creates a new page object for the snippet generator.
15 | *
16 | * @param context
17 | * job context
18 | */
19 | public SnippetGenerator(final WorkflowJob context) {
20 | super(context, context.url(URI));
21 | }
22 |
23 | @Override
24 | protected WorkflowJob getContext() {
25 | return (WorkflowJob) super.getContext();
26 | }
27 |
28 | /**
29 | * Generates the sample pipeline script.
30 | *
31 | * @return the generated script
32 | */
33 | public String generateScript() {
34 | WebElement generateButton = find(By.id("generatePipelineScript"));
35 | generateButton.click();
36 |
37 | WebElement snippet = find(By.id("prototypeText"));
38 | waitFor().until(() -> StringUtils.isNotBlank(snippet.getAttribute("value")));
39 |
40 | return StringUtils.defaultString(snippet.getAttribute("value"));
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/po/Step.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.po;
2 |
3 | /**
4 | * @author christian.fritz
5 | */
6 | public interface Step extends PageArea {}
7 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/po/StringParameter.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.po;
2 |
3 | /**
4 | * @author Kohsuke Kawaguchi
5 | */
6 | @Describable("String Parameter")
7 | public class StringParameter extends Parameter {
8 | public StringParameter(Job job, String path) {
9 | super(job, path);
10 | }
11 |
12 | @Override
13 | public void fillWith(Object v) {
14 | control("value").set(v.toString());
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/po/TextAxis.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.po;
2 |
3 | /**
4 | * @author Kohsuke Kawaguchi
5 | */
6 | @Describable("User-defined Axis")
7 | public class TextAxis extends Axis {
8 | public TextAxis(PageObject context, String path) {
9 | super(context, path);
10 | }
11 |
12 | public final Control valueString = control("valueString");
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/po/TimerTrigger.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.po;
2 |
3 | /**
4 | * @author Kohsuke Kawaguchi
5 | */
6 | public class TimerTrigger extends Trigger {
7 | public final Control spec = control("spec");
8 |
9 | public TimerTrigger(Job parent) {
10 | super(parent, "/hudson-triggers-TimerTrigger");
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/po/Trigger.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.po;
2 |
3 | /**
4 | * Base type for {@link PageAreaImpl} for trigger.
5 | *
6 | * @see Job#addTrigger(Class)
7 | */
8 | public abstract class Trigger extends PageAreaImpl {
9 | public final Control enabled = control("");
10 |
11 | protected Trigger(Job parent, String path) {
12 | super(parent, path);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/po/UpstreamJobTrigger.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.po;
2 |
3 | import org.apache.commons.lang3.StringUtils;
4 |
5 | /**
6 | * Triggers a job, if another job has been finished.
7 | *
8 | * @author Ulli Hafner
9 | */
10 | public class UpstreamJobTrigger extends Trigger {
11 | private final Control upstreamProjects = control("upstreamProjects");
12 |
13 | public UpstreamJobTrigger(Job parent) {
14 | super(parent, "/jenkins-triggers-ReverseBuildTrigger");
15 | }
16 |
17 | public void setUpstreamProjects(final String... upstreamProjects) {
18 | this.upstreamProjects.set(StringUtils.join(upstreamProjects, ","));
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/po/WhoAmI.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.po;
2 |
3 | /**
4 | * Who Am I page in Jenkins
5 | */
6 | public class WhoAmI extends ContainerPageObject {
7 |
8 | public WhoAmI(ContainerPageObject parent) {
9 | super(parent, parent.url("whoAmI/"));
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/test/acceptance/slave/LocalSlaveController.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.test.acceptance.slave;
2 |
3 | import java.io.IOException;
4 | import java.util.concurrent.Future;
5 | import org.apache.http.concurrent.BasicFuture;
6 | import org.jenkinsci.test.acceptance.po.DumbSlave;
7 | import org.jenkinsci.test.acceptance.po.Jenkins;
8 | import org.jenkinsci.test.acceptance.po.Slave;
9 |
10 | /**
11 | * Launches slaves locally on the same box as the Jenkins master.
12 | *
13 | * @author Kohsuke Kawaguchi
14 | */
15 | public class LocalSlaveController extends SlaveController {
16 | @Override
17 | public Future hiddenPublished HTML
8 |