Skip to content

Commit

Permalink
Merge pull request #472 from jenkinsci/bump-pom-4.47
Browse files Browse the repository at this point in the history
Bump plugin parent to 4.47
  • Loading branch information
rsandell committed Sep 26, 2022
2 parents 97d63f0 + 5599185 commit dd47352
Show file tree
Hide file tree
Showing 42 changed files with 1,374 additions and 1,212 deletions.
4 changes: 1 addition & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
buildPlugin(
platforms: ['linux'],
jenkinsVersions: [null],
jdkVersions: [8]
platforms: ['linux']
)
1 change: 1 addition & 0 deletions build-config/swe_checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
<module name="JavadocMethod">
<property name="logLoadErrors" value="true"/>
<property name="suppressLoadErrors" value="true"/>
<property name="allowedAnnotations" value="Override, Test, Before, BeforeClass, After, AfterClass"/>
</module>
<module name="JavadocStyle">
<property name="scope" value="protected"/>
Expand Down
104 changes: 54 additions & 50 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.25</version>
<version>4.47</version>
<relativePath />
</parent>

Expand Down Expand Up @@ -53,17 +53,15 @@
</developers>

<properties>
<jenkins.version>2.222.4</jenkins.version>
<jenkins.version>2.346.3</jenkins.version>
<revision>2.36.1</revision>
<changelist>-SNAPSHOT</changelist>
<gitHubRepo>jenkinsci/gerrit-trigger-plugin</gitHubRepo>
<java.level>8</java.level>
<!--<java.level>8</java.level>-->
<no-test-jar>false</no-test-jar>
<findbugs.failOnError>false</findbugs.failOnError>
<concurrency>0.5C</concurrency>
<powermock.version>1.6.2</powermock.version>
<!--<concurrency>0.5C</concurrency>-->
<checkstyle.version>2.16</checkstyle.version>
<mockito.version>1.10.19</mockito.version>
<surefire.rerunFailingTestsCount>3</surefire.rerunFailingTestsCount>
<reuseForks>false</reuseForks>
<forkCount>0.5C</forkCount>
Expand Down Expand Up @@ -116,7 +114,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>support-core</artifactId>
<version>2.75</version>
<!--<version>2.75</version>-->
<optional>true</optional>
</dependency>
<dependency>
Expand Down Expand Up @@ -187,20 +185,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<version>${powermock.version}</version>
<artifactId>mockito-inline</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -215,40 +200,59 @@
wiremock-jre8 introduces many dependencies that interferes with jth and core functionality
during testing, the standalone jar shades all those so it doesn't break other tests.
-->
<version>2.28.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.jenkins.plugins</groupId>
<artifactId>caffeine-api</artifactId>
</dependency>
<dependency>
<artifactId>configuration-as-code</artifactId>
<groupId>io.jenkins</groupId>
<optional>true</optional>
</dependency>
<dependency>
<artifactId>test-harness</artifactId>
<groupId>io.jenkins.configuration-as-code</groupId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>jackson2-api</artifactId>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>matrix-project</artifactId>
<scope>test</scope>
</dependency>

<version>2.28.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.jenkins.plugins</groupId>
<artifactId>caffeine-api</artifactId>
</dependency>
<dependency>
<artifactId>configuration-as-code</artifactId>
<groupId>io.jenkins</groupId>
<optional>true</optional>
</dependency>
<dependency>
<artifactId>test-harness</artifactId>
<groupId>io.jenkins.configuration-as-code</groupId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>jackson2-api</artifactId>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>matrix-project</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<!-- TODO move to plugin dependencies (no server module yet)-->
<groupId>org.apache.sshd</groupId>
<artifactId>sshd-core</artifactId>
<version>1.7.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sonyericsson.jenkins.plugins.bfa</groupId>
<artifactId>build-failure-analyzer</artifactId>
<version>2.4.0</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sonyericsson.jenkins.plugins.bfa</groupId>
<artifactId>build-failure-analyzer</artifactId>
<version>2.4.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-2.222.x</artifactId>
<version>887.vae9c8ac09ff7</version>
<artifactId>bom-2.346.x</artifactId>
<version>1595.v8c71c13cc3a_9</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,15 @@ public void start() {
s.start();
}
active = true;
}

/**
* Forces initialization of the Dispatchers.
*
* They need to register and listen to GerritEvents. Normally, it is lazy loaded when the first build is started.
*/
@Initializer(after = InitMilestone.SYSTEM_CONFIG_ADAPTED)
public static void initializeDispatchers() {
// Call the following method for force initialization of the Dispatchers because
// it needs to register and listen to GerritEvent. Normally, it is lazy loaded when the first build is started.
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,12 @@ public static ToGerritRunListener getInstance() {
logger.error("Jenkins instance is not available, are we not fully live yet?");
return null;
}
ExtensionList<ToGerritRunListener> listeners =
jenkins.getExtensionList(ToGerritRunListener.class);
if (listeners == null || listeners.isEmpty()) {
logger.error("INITIALIZATION ERROR? Could not find the registered instance.");
try {
return ExtensionList.lookupSingleton(ToGerritRunListener.class);
} catch (IllegalStateException e) {
logger.error("INITIALIZATION ERROR? Could not find the registered instance.", e);
return null;
}
return listeners.get(0);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,19 +259,19 @@ protected void schedule(GerritTrigger t, GerritCause cause, GerritTriggeredEvent
}
if (null != changeBasedEvent.getPatchSet()) {
logger.info("Project {} Build Scheduled: {} By event: {}",
new Object[]{project.getName(), (futureBuild != null),
changeBasedEvent.getChange().getNumber() + "/"
+ changeBasedEvent.getPatchSet().getNumber(), });
project.getName(), (futureBuild != null),
changeBasedEvent.getChange().getNumber() + "/"
+ changeBasedEvent.getPatchSet().getNumber());
} else {
logger.info("Project {} Build Scheduled: {} By event: {}",
new Object[]{project.getName(), (futureBuild != null),
changeBasedEvent.getChange().getNumber(), });
project.getName(), (futureBuild != null),
changeBasedEvent.getChange().getNumber());
}
} else if (event instanceof RefUpdated) {
RefUpdated refUpdated = (RefUpdated)event;
logger.info("Project {} Build Scheduled: {} By event: {}",
new Object[]{project.getName(), (futureBuild != null),
refUpdated.getRefUpdate().getRefName() + " " + refUpdated.getRefUpdate().getNewRev(), });
project.getName(), (futureBuild != null),
refUpdated.getRefUpdate().getRefName() + " " + refUpdated.getRefUpdate().getNewRev());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public String getDisplayName() {

@Override
public String getUrlName() {
return "/gerrit_manual_trigger";
return "gerrit_manual_trigger";
}

/**
Expand Down Expand Up @@ -464,7 +464,8 @@ public String generateTheId(JSONObject change, JSONObject patch) {
* @return an indexed map where the rowId is the key.
* @see #generateTheId(net.sf.json.JSONObject, net.sf.json.JSONObject)
*/
private HashMap<String, JSONObject> indexResult(List<JSONObject> result) {
@Restricted(NoExternalUse.class)
HashMap<String, JSONObject> indexResult(List<JSONObject> result) {
HashMap<String, JSONObject> map = new HashMap<String, JSONObject>();
for (JSONObject res : result) {
if (!res.has("type")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,33 +27,28 @@
import com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritConnectionListener;
import com.sonyericsson.hudson.plugins.gerrit.trigger.version.GerritVersionChecker;

import com.sonyericsson.jenkins.plugins.bfa.test.utils.Whitebox;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.jvnet.hudson.test.JenkinsRule;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.reflect.Whitebox;
import org.mockito.MockedStatic;

import java.util.LinkedList;
import java.util.List;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.eq;
import static org.powermock.api.mockito.PowerMockito.mock;
import static org.powermock.api.mockito.PowerMockito.mockStatic;
import static org.powermock.api.mockito.PowerMockito.when;
import static org.powermock.api.mockito.PowerMockito.spy;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockStatic;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;

/**
* Tests for {@link GerritServer}.
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest(PluginImpl.class)
@PowerMockIgnore({"javax.crypto.*" })
public class GerritServerTest {

/**
Expand All @@ -66,15 +61,16 @@ public class GerritServerTest {
private final String gerritServerOneName = "testServer1";
private GerritServer gerritServerOne;
private GerritConnectionListener listener;
private MockedStatic<PluginImpl> pluginMockedStatic;

/**
* Setup the mock'ed environment.
*/
@Before
public void setup() {
PluginImpl plugin = mock(PluginImpl.class);
mockStatic(PluginImpl.class);
when(PluginImpl.getInstance()).thenReturn(plugin);
pluginMockedStatic = mockStatic(PluginImpl.class);
pluginMockedStatic.when(PluginImpl::getInstance).thenReturn(plugin);
gerritServerOne = new GerritServer(gerritServerOneName);
listener = new GerritConnectionListener(gerritServerOne.getName());
listener.setConnected(true);
Expand All @@ -83,6 +79,11 @@ public void setup() {
when(plugin.getServer(eq(gerritServerOneName))).thenReturn(gerritServerOne);
}

@After
public void tearDown() throws Exception {
pluginMockedStatic.close();
}

/**
* Tests {@link GerritServer#isGerritSnapshotVersion()} is true when it should.
*
Expand Down

0 comments on commit dd47352

Please sign in to comment.