diff --git a/README.md b/README.md index d40653a..08c8c2a 100644 --- a/README.md +++ b/README.md @@ -1 +1,34 @@ -# cicd-test-artifacts \ No newline at end of file +# cicd-test-artifacts + +This repository holds artifacts and scenario tests + + +#### Directory structure +``` +. +├── artifacts +│   └── repository +│   └── deployment +│   └── server +│   └── carbonapps +└── tests + └── sample-scenario-tests + ├── src +    └── test +    ├── java +    │   └── org +    │   └── wso2 +    └── resources +``` + +#### Quick Start Guide +* Place the car file in `artifacts/deployment/server/carbonapps/` directory. + +* A sample scenario test suite implemented using Testng is in `test/sample-scenario-tests` directory. Which run a +simple test to validate response code of a rest endpoint. Use following command to run the test, +``` +mvn test -Dendpoint= +``` +Implement a new scenario test for the new car + +* Configure this repository as the artifacts repository in the Jenkins CICD pipeline diff --git a/artifacts/repository/deployment/server/carbonapps/HelloWorldApp_1.0.0.car b/artifacts/repository/deployment/server/carbonapps/HelloWorldApp_1.0.0.car new file mode 100644 index 0000000..ffca023 Binary files /dev/null and b/artifacts/repository/deployment/server/carbonapps/HelloWorldApp_1.0.0.car differ diff --git a/tests/sample-scenario-tests/pom.xml b/tests/sample-scenario-tests/pom.xml new file mode 100644 index 0000000..3e1ca76 --- /dev/null +++ b/tests/sample-scenario-tests/pom.xml @@ -0,0 +1,65 @@ + + + + 4.0.0 + + org.wso2 + sample-scenario-tests + 1.0-SNAPSHOT + + + 6.9.8 + 3.1 + + + + + org.testng + testng + ${testng.version} + test + + + commons-httpclient + commons-httpclient + ${commons-httpclient.version} + test + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.1 + + + src/test/resources/testing.xml + + + + endpoint + + + + + + + diff --git a/tests/sample-scenario-tests/src/test/java/org/wso2/SimpleScenarioTest.java b/tests/sample-scenario-tests/src/test/java/org/wso2/SimpleScenarioTest.java new file mode 100644 index 0000000..e36f16a --- /dev/null +++ b/tests/sample-scenario-tests/src/test/java/org/wso2/SimpleScenarioTest.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.wso2; + +import org.apache.commons.httpclient.HttpClient; +import org.apache.commons.httpclient.HttpException; +import org.apache.commons.httpclient.HttpMethod; +import org.apache.commons.httpclient.HttpStatus; +import org.apache.commons.httpclient.methods.GetMethod; +import org.testng.Assert; +import org.testng.annotations.Test; + +import java.io.IOException; + +/** + * This class tests the HelloWorld Rest endpoint + */ + +public class SimpleScenarioTest { + @Test + public void testEndpoint() { + HttpClient client = new HttpClient(); + HttpMethod method = new GetMethod(System.getProperty("endpoint")); + try { + int statusCode = client.executeMethod(method); + Assert.assertEquals(statusCode, HttpStatus.SC_OK); + } catch (HttpException e) { + System.err.println("Fatal protocol violation: " + e.getMessage()); + e.printStackTrace(); + } catch (IOException e) { + System.err.println("Fatal transport error: " + e.getMessage()); + e.printStackTrace(); + } finally { + // Release the connection. + method.releaseConnection(); + } + } + +} diff --git a/tests/sample-scenario-tests/src/test/resources/testing.xml b/tests/sample-scenario-tests/src/test/resources/testing.xml new file mode 100644 index 0000000..8d8fefe --- /dev/null +++ b/tests/sample-scenario-tests/src/test/resources/testing.xml @@ -0,0 +1,26 @@ + + + + + + + + + +