Skip to content

Commit

Permalink
Added integration tests for SMSS
Browse files Browse the repository at this point in the history
Testing missing region, missing CICSplex and missing both in combination of SMSS and CPSM environments

Signed-off-by: Ledina Hido-Evans <[email protected]>
Signed-off-by: Dave Nice <[email protected]>
  • Loading branch information
ledina authored and davenice committed Feb 2, 2022
1 parent 8417a4a commit bc5a04b
Show file tree
Hide file tree
Showing 18 changed files with 261 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!--
#%L
CICS Bundle Maven Plugin
%%
Copyright (C) 2019 IBM Corp.
%%
This program and the accompanying materials are made
available under the terms of the Eclipse Public License 2.0
which is available at https://www.eclipse.org/legal/epl-2.0/
SPDX-License-Identifier: EPL-2.0
#L%
-->
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.ibm.cics.test-bundle-deploy-neither-smss</groupId>
<artifactId>test-bundle-deploy-neither-smss</artifactId>
<name>Example CICS bundle</name>
<version>0.0.1-SNAPSHOT</version>

<build>
<plugins>
<!-- Test the build succeeds when calling an SMSS endpoint (without a cicsplex or region specified) with a 200 response -->
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
<extensions>true</extensions>
<executions>
<execution>
<id>deploy</id>
<phase>verify</phase>
<goals>
<goal>deploy</goal>
</goals>
<configuration>
<serverId>neither</serverId>
<bunddef>bundle</bunddef>
<csdgroup>BAR</csdgroup>
<bundle>${basedir}/test-app-bundle-0.0.1-SNAPSHOT.zip</bundle>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
context.put("wireMockServer", com.ibm.cics.cbmp.DeployPreBuild.setupSMSSWiremock(Integer.parseInt(wiremockPort)));
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
###
# #%L
# CICS Bundle Maven Plugin
# %%
# Copyright (C) 2019 IBM Corp.
# %%
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
# #L%
###
# The expected result of the build, possible values are "success" (default) and "failure"
invoker.buildResult = failure
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<build>
<plugins>
<!-- Test the build succeeds when calling the endpoint with a 200 response -->
<!-- Test the build fails when calling a CPSM endpoint (without region or cicsplex specified) with a 400 response -->
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
Expand All @@ -35,10 +35,8 @@
<goal>deploy</goal>
</goals>
<configuration>
<serverId>serverId</serverId>
<serverId>neither</serverId>
<bunddef>bundle</bunddef>
<cicsplex>cicsplex</cicsplex>
<region>region</region>
<csdgroup>BAR</csdgroup>
<bundle>${basedir}/test-app-bundle-0.0.1-SNAPSHOT.zip</bundle>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*-
* #%L
* CICS Bundle Maven Plugin
* %%
* Copyright (C) 2019 IBM Corp.
* %%
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
* #L%
*/
import com.ibm.cics.cbmp.DeployPreBuild

context.get("wireMockServer").shutdownServer()

File buildLog = new File(basedir, 'build.log')

assert buildLog.exists()
assert buildLog.text.contains("[ERROR] Failed to execute goal com.ibm.cics:cics-bundle-maven-plugin:")
assert buildLog.text.contains("com.ibm.cics.bundle.deploy.BundleDeployException: Some of the supplied parameters were invalid")
assert buildLog.text.contains("- cicsplex: CICSplex could not be found")
Original file line number Diff line number Diff line change
@@ -1 +1 @@
context.put("wireMockServer", com.ibm.cics.cbmp.DeployPreBuild.setupWiremock(Integer.parseInt(wiremockPort)));
context.put("wireMockServer", com.ibm.cics.cbmp.DeployPreBuild.setupWiremockNoCICSplexRegion(Integer.parseInt(wiremockPort)));
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
###
# #%L
# CICS Bundle Maven Plugin
# %%
# Copyright (C) 2019 IBM Corp.
# %%
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
# #L%
###
# The expected result of the build, possible values are "success" (default) and "failure"
invoker.buildResult = failure
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@

<build>
<plugins>
<!-- Test the build succeeds when calling the endpoint with a 200 response -->
<!-- Test the build fails when calling the endpoint with just region but no CICSplex -->
<!-- This applies to both SMSS and CPSM so this tests CPSM, noRegion tests SMSS -->
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
Expand All @@ -35,8 +36,7 @@
<goal>deploy</goal>
</goals>
<configuration>
<cicsplex>cicsplex</cicsplex>
<serverId>serverId</serverId>
<serverId>noCICSplex</serverId>
<bunddef>bundle</bunddef>
<csdgroup>BAR</csdgroup>
<bundle>${basedir}/test-app-bundle-0.0.1-SNAPSHOT.zip</bundle>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*-
* #%L
* CICS Bundle Maven Plugin
* %%
* Copyright (C) 2019 IBM Corp.
* %%
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
* #L%
*/
import com.ibm.cics.cbmp.DeployPreBuild

context.get("wireMockServer").shutdownServer()

File buildLog = new File(basedir, 'build.log')

assert buildLog.exists()
assert buildLog.text.contains("[ERROR] Failed to execute goal com.ibm.cics:cics-bundle-maven-plugin:")
assert buildLog.text.contains("(deploy) on project test-bundle-deploy-noCICSplex: Specify both or neither of cicsplex and region in plugin configuration or server configuration")
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
###
# #%L
# CICS Bundle Maven Plugin
# %%
# Copyright (C) 2019 IBM Corp.
# %%
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
# #L%
###
# The expected result of the build, possible values are "success" (default) and "failure"
invoker.buildResult = failure
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@

<build>
<plugins>
<!-- Test the build succeeds when calling the endpoint with a 200 response -->
<!-- Test the build fails when calling the endpoint with just CICSplex but no region -->
<!-- This applies to both SMSS and CPSM so this tests SMSS, noRegion tests CPSM -->
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
Expand All @@ -34,9 +35,8 @@
<goal>deploy</goal>
</goals>
<configuration>
<serverId>serverId</serverId>
<serverId>noRegion</serverId>
<bunddef>bundle</bunddef>
<region>region</region>
<csdgroup>BAR</csdgroup>
<bundle>${basedir}/test-app-bundle-0.0.1-SNAPSHOT.zip</bundle>
</configuration>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*-
* #%L
* CICS Bundle Maven Plugin
* %%
* Copyright (C) 2019 IBM Corp.
* %%
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
* #L%
*/
import com.ibm.cics.cbmp.DeployPreBuild

context.get("wireMockServer").shutdownServer()

File buildLog = new File(basedir, 'build.log')

assert buildLog.exists()
assert buildLog.text.contains("[ERROR] Failed to execute goal com.ibm.cics:cics-bundle-maven-plugin:")
assert buildLog.text.contains("(deploy) on project test-bundle-deploy-noRegion: Specify both or neither of cicsplex and region in plugin configuration or server configuration")
Original file line number Diff line number Diff line change
@@ -1 +1 @@
context.put("wireMockServer", com.ibm.cics.cbmp.DeployPreBuild.setupWiremock(Integer.parseInt(wiremockPort)));
context.put("wireMockServer", com.ibm.cics.cbmp.DeployPreBuild.setupSMSSWiremock(Integer.parseInt(wiremockPort)));
Original file line number Diff line number Diff line change
Expand Up @@ -77,27 +77,106 @@ static WireMockServer setupWiremock(int port, Protocol protocol) {
.withName("region")
.withBody(equalTo("region")))
.withMultipartRequestBody(
aMultipart()
.withName("bunddef")
.withBody(equalTo("bundle")))
aMultipart()
.withName("bunddef")
.withBody(equalTo("bundle")))
.withMultipartRequestBody(
aMultipart()
.withName("csdgroup")
.withBody(equalTo("BAR")))
aMultipart()
.withName("csdgroup")
.withBody(equalTo("BAR")))
.withMultipartRequestBody(
aMultipart()
.withName("bundle")
.withBody(WireMock.binaryEqualTo(bundleBinary)))
aMultipart()
.withName("bundle")
.withBody(WireMock.binaryEqualTo(bundleBinary)))
.willReturn(
aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/plain")
.withBody("Some content")
)
);

return wireMockServer;
}


static WireMockServer setupWiremockNoCICSplexRegion(int port) {
ClassLoader ccl = Thread.currentThread().getContextClassLoader();

try {
Thread.currentThread().setContextClassLoader(WireMock.class.getClassLoader());
wireMockServer = new WireMockServer(WireMockConfiguration.options().port(port));
} finally {
Thread.currentThread().setContextClassLoader(ccl);
}

wireMockServer.start();

wireMockServer
.stubFor(
post(urlEqualTo("/managedcicsbundles"))
.withMultipartRequestBody(
aMultipart()
.withName("bunddef")
.withBody(equalTo("bundle")))
.withMultipartRequestBody(
aMultipart()
.withName("csdgroup")
.withBody(equalTo("BAR")))
.withMultipartRequestBody(
aMultipart()
.withName("bundle")
.withBody(WireMock.binaryEqualTo(bundleBinary)))
.willReturn(
aResponse()
.withStatus(400)
.withHeader("Content-Type", "text/plain")
.withBody("com.ibm.cics.bundle.deploy.BundleDeployException: Some of the supplied parameters were invalid:\n" +
" - cicsplex: CICSplex could not be found")
)
);

return wireMockServer;
}


static WireMockServer setupSMSSWiremock(int port) {
ClassLoader ccl = Thread.currentThread().getContextClassLoader();

try {
Thread.currentThread().setContextClassLoader(WireMock.class.getClassLoader());
wireMockServer = new WireMockServer(WireMockConfiguration.options().port(port));
} finally {
Thread.currentThread().setContextClassLoader(ccl);
}

wireMockServer.start();

wireMockServer
.stubFor(
post(urlEqualTo("/managedcicsbundles"))
.withMultipartRequestBody(
aMultipart()
.withName("bunddef")
.withBody(equalTo("bundle")))
.withMultipartRequestBody(
aMultipart()
.withName("csdgroup")
.withBody(equalTo("BAR")))
.withMultipartRequestBody(
aMultipart()
.withName("bundle")
.withBody(WireMock.binaryEqualTo(bundleBinary)))
.willReturn(
aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/plain")
.withBody("Some content")
)
);
return wireMockServer;
}


/*
* Used by test-reactor-war-deploy which builds the bundle and then tests deploying it, so we can't check for a specific binary for the bundle
*/
Expand Down

0 comments on commit bc5a04b

Please sign in to comment.