Skip to content

Commit

Permalink
Add an IT
Browse files Browse the repository at this point in the history
  • Loading branch information
Vlatombe committed Jul 6, 2023
1 parent 7835622 commit b5daedb
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/it/cd-plugin/.mvn/extensions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<extensions xmlns="http://maven.apache.org/EXTENSIONS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/EXTENSIONS/1.0.0 http://maven.apache.org/xsd/core-extensions-1.0.0.xsd">
<extension>
<groupId>io.jenkins.tools.incrementals</groupId>
<artifactId>git-changelist-maven-extension</artifactId>
<version>1.6</version>
</extension>
</extensions>
3 changes: 3 additions & 0 deletions src/it/cd-plugin/.mvn/maven.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-Pconsume-incrementals
-Pmight-produce-incrementals
-Dchangelist.format=%d.v%s
2 changes: 2 additions & 0 deletions src/it/cd-plugin/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Same options as in https://github.com/jenkins-infra/jenkins-maven-cd-action/blob/master/run.sh
invoker.goals=-Dstyle.color=always -Dset.changelist -Dchangelist=1234.deadbeef5678 -ntp -P-consume-incrementals -Pquick-build clean install
47 changes: 47 additions & 0 deletions src/it/cd-plugin/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>@project.version@</version>
<relativePath />
</parent>
<groupId>org.jenkins-ci.plugins.its</groupId>
<artifactId>cd-plugin</artifactId>
<version>${changelist}</version>
<packaging>hpi</packaging>
<name>CD plugin</name>
<description>CD description</description>
<properties>
<changelist>999999-SNAPSHOT</changelist>
<spotless.check.skip>false</spotless.check.skip>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>structs</artifactId>
<version>1.5</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>structs</artifactId>
</dependency>
</dependencies>
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>
</project>
23 changes: 23 additions & 0 deletions src/it/cd-plugin/postbuild.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
assert new File(basedir, 'target/cd-plugin.hpi').file
assert new File(basedir, 'target/cd-plugin.jar').file

File installed = new File(basedir, '../../local-repo/org/jenkins-ci/plugins/its/cd-plugin/1234.deadbeef5678/')
assert new File(installed, 'cd-plugin-1234.deadbeef5678.hpi').file

def targetPom = new File(basedir, 'target/cd-plugin-1234.deadbeef5678.pom')
assert targetPom.file

def installedPom = new File(installed, 'cd-plugin-1234.deadbeef5678.pom')
assert installedPom.file

assert installedPom.text.contains("<name>")
assert installedPom.text.contains("<description>")
assert installedPom.text.contains("<dependencies>")
assert installedPom.text.contains("<build>")
assert installedPom.text.contains("<scm>")
assert !installedPom.text.contains("<properties>")
assert !installedPom.text.contains("<dependencyManagement>")
assert !installedPom.text.contains("<repositories>")
assert !installedPom.text.contains("<pluginRepositories>")

return true
28 changes: 28 additions & 0 deletions src/it/cd-plugin/src/main/java/test/SampleRootAction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package test;

import hudson.Extension;
import hudson.model.RootAction;
import org.kohsuke.stapler.HttpResponse;
import org.kohsuke.stapler.HttpResponses;

@Extension
public class SampleRootAction implements RootAction {
@Override
public String getUrlName() {
return "sample";
}

@Override
public String getIconFileName() {
return null;
}

@Override
public String getDisplayName() {
return null;
}

public HttpResponse doIndex() {
return HttpResponses.plainText("sample served");
}
}
2 changes: 2 additions & 0 deletions src/it/cd-plugin/src/main/resources/index.jelly
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?jelly escape-by-default='true'?>
<div/>
25 changes: 25 additions & 0 deletions src/it/cd-plugin/src/test/java/test/SampleRootActionTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package test;

import static org.junit.Assert.*;

import org.apache.commons.io.IOUtils;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.JenkinsRule;

public class SampleRootActionTest {

@Rule
public JenkinsRule r = new JenkinsRule();

@Test
public void smokes() throws Exception {
assertEquals(
IOUtils.toString(SampleRootActionTest.class.getResource("expected.txt")),
r.createWebClient()
.goTo("sample", "text/plain")
.getWebResponse()
.getContentAsString()
.trim());
}
}
1 change: 1 addition & 0 deletions src/it/cd-plugin/src/test/resources/test/expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sample served

0 comments on commit b5daedb

Please sign in to comment.