-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #206 from malshaniS/testFramework
[Test Framework] - Adding Base Test Framework to public repo
- Loading branch information
Showing
32 changed files
with
5,086 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Integration Test Framework (integration-test-framework) | ||
|
||
The Integration Test Framework is built as a common test framework for the BFSI domain. We have used layered architecture | ||
in order to archive this extensibility. Basically, the integration test framework consists of four main layers as follows. | ||
|
||
- Level 1 - Configuration of the system under test | ||
- Level 2 - Common function layer | ||
- Level 3 - Domain Specific Capabilities layer | ||
- Level 4 - Test Layer | ||
|
||
Level 3 and Level 4 can be implemented by the user by using the Integration Test Framework to write specific test scenarios. | ||
This framework is used to write test cases for the all the specifications such as UK, CDS, NextGenPSD2 (Berlin), etc. | ||
|
||
The test framework contains 2 modules which are as follows: | ||
- [bfsi-test-framework](bfsi-test-framework) - Implementation of the common functional layer of the test framework | ||
architecture. It contains supportive features for the Open-Banking, Financial Services and Insurance domains. | ||
This module is placed in the “Financial-Open-Banking” repository, under the Integration test framework module. | ||
|
||
- [open-banking-test-framework](open-banking-test-framework) - This layer is implemented as the lower section of the | ||
Domain specific capabilities layer. This module contains commonly used features for every Open-banking specification | ||
and “BFSI Test Framework” module is added to this module as a dependency. | ||
|
||
# How to use integration-test-framework to write test cases. | ||
1. Build the integration-test-framework module and install the jar. | ||
2. Create a new maven project for your test scenarios and add the integration-test-framework jar as a dependency. | ||
3. Create a new class and extend the BaseTest class. | ||
4. Write your test scenarios in the new class. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). | ||
~ | ||
~ WSO2 LLC. 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. | ||
--> | ||
<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>org.wso2</groupId> | ||
<artifactId>bfsi-test-framework</artifactId> | ||
<version>4.0.0-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
|
||
<parent> | ||
<groupId>org.wso2</groupId> | ||
<artifactId>integration-test-framework</artifactId> | ||
<version>4.0.0-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.groovy</groupId> | ||
<artifactId>groovy-all</artifactId> | ||
<version>${org.apache.groovy.version}</version> | ||
<type>pom</type> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.osgi</groupId> | ||
<artifactId>org.osgi.core</artifactId> | ||
<version>6.0.0</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.codehaus.gmavenplus</groupId> | ||
<artifactId>gmavenplus-plugin</artifactId> | ||
<version>${org.codehaus.gmavenplus.version}</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>compile</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.groovy</groupId> | ||
<artifactId>groovy</artifactId> | ||
<version>${org.apache.groovy.version}</version> | ||
<scope>runtime</scope> | ||
</dependency> | ||
</dependencies> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<source>${maven.compiler.source}</source> | ||
<target>${maven.compiler.target}</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-resources-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> | ||
|
68 changes: 68 additions & 0 deletions
68
...mework/bfsi-test-framework/src/main/groovy/org/wso2/bfsi/test/framework/CommonTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/** | ||
* Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). | ||
* <p> | ||
* WSO2 LLC. 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 | ||
* <p> | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* 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.bfsi.test.framework | ||
|
||
import org.wso2.bfsi.test.framework.util.TestContext | ||
|
||
/** | ||
* Class that can keeps common functions for test cases | ||
* Should be extended from any product common test class | ||
* All bfsi layer common functions that directly required for test classes are implemented in here | ||
*/ | ||
class CommonTest { | ||
|
||
private TestContext context = TestContext.getInstance() | ||
|
||
/** | ||
* Save data in Context class | ||
* @param key | ||
* @param object | ||
*/ | ||
void addToContext(String key, Object object) { | ||
context.addContext(key, object) | ||
} | ||
|
||
/** | ||
* Retrieve data from Context class | ||
* @param key | ||
* @return | ||
*/ | ||
Object getFromContext(String key) { | ||
return context.getContext(key) | ||
} | ||
|
||
/** | ||
* Retrive data from Context class as String | ||
* @param key | ||
* @return | ||
*/ | ||
String getStrFromContext(String key) { | ||
return context.getContext(key) as String | ||
} | ||
|
||
/** | ||
* Retrieve context Map from Context class | ||
* @return | ||
*/ | ||
Map getContextMap() { | ||
return context.getContextMap() | ||
} | ||
|
||
} | ||
|
35 changes: 35 additions & 0 deletions
35
...work/src/main/groovy/org/wso2/bfsi/test/framework/exception/TestFrameworkException.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). | ||
* <p> | ||
* WSO2 LLC. 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 | ||
* <p> | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* 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.bfsi.test.framework.exception | ||
|
||
/** | ||
* Exception class for TestFramework | ||
*/ | ||
class TestFrameworkException extends Exception { | ||
|
||
public TestFrameworkException(String message) { | ||
super(message); | ||
} | ||
|
||
public TestFrameworkException(String message, Throwable e) { | ||
super(message, e); | ||
} | ||
|
||
} | ||
|
48 changes: 48 additions & 0 deletions
48
...c/main/groovy/org/wso2/bfsi/test/framework/exception/TestFrameworkRuntimeException.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). | ||
* <p> | ||
* WSO2 LLC. 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 | ||
* <p> | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* 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.bfsi.test.framework.exception | ||
|
||
/** | ||
* Class handles Runtime exceptions in the Test Framework | ||
*/ | ||
class TestFrameworkRuntimeException extends RuntimeException { | ||
private static final long serialVersionUID = -5686395831712095972L; | ||
private String errorCode; | ||
|
||
public TestFrameworkRuntimeException(String errorCode, Throwable cause) { | ||
super(cause); | ||
this.errorCode = errorCode; | ||
} | ||
|
||
public TestFrameworkRuntimeException(String errorCode) { | ||
super(); | ||
this.errorCode = errorCode; | ||
} | ||
|
||
public String getErrorCode() { | ||
|
||
return errorCode; | ||
} | ||
|
||
public void setErrorCode(String errorCode) { | ||
|
||
this.errorCode = errorCode; | ||
} | ||
} | ||
|
68 changes: 68 additions & 0 deletions
68
.../bfsi-test-framework/src/main/groovy/org/wso2/bfsi/test/framework/util/TestContext.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/** | ||
* Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). | ||
* <p> | ||
* WSO2 LLC. 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 | ||
* <p> | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* 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.bfsi.test.framework.util | ||
|
||
/** | ||
* Optional Context Management class | ||
* Use for manage context details through the test class | ||
*/ | ||
class TestContext { | ||
|
||
private static TestContext context | ||
// To enable attempted thread-safety using double-check locking | ||
private static final Object lock = new Object() | ||
|
||
private Map<String, Object> contextMap; | ||
|
||
/** | ||
* Private Constructor of config parser. | ||
*/ | ||
private TestContext() { | ||
contextMap = new HashMap<>() | ||
} | ||
|
||
/** | ||
* Singleton getInstance method to create only one object. | ||
* | ||
* @return ConfigParser object | ||
*/ | ||
static TestContext getInstance() { | ||
if (context == null) { | ||
synchronized (lock) { | ||
if (context == null) { | ||
return new TestContext() | ||
} | ||
} | ||
} | ||
return context | ||
} | ||
|
||
void addContext(String key, Object object) { | ||
contextMap.put(key, object) | ||
} | ||
|
||
Object getContext(String key) { | ||
return contextMap.get(key) | ||
} | ||
|
||
Map getContextMap() { | ||
return contextMap | ||
} | ||
} | ||
|
37 changes: 37 additions & 0 deletions
37
...ork/bfsi-test-framework/src/main/groovy/org/wso2/bfsi/test/framework/util/TestUtil.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). | ||
* <p> | ||
* WSO2 LLC. 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 | ||
* <p> | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* 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.bfsi.test.framework.util | ||
|
||
/** | ||
* BFSI domain Util class | ||
* keeps utility features that needed for bfsi layer | ||
*/ | ||
class TestUtil { | ||
|
||
static String getParamListAsString(List<String> params, String delimiter) { | ||
|
||
String result = ""; | ||
for (String param : params) { | ||
result = result.concat(param + delimiter); | ||
} | ||
return result.substring(0, result.length() - 1); | ||
} | ||
|
||
} | ||
|
Oops, something went wrong.