Skip to content

Commit

Permalink
Merge pull request #526 from ballerina-platform/parallel-test
Browse files Browse the repository at this point in the history
Make test functions isolated
  • Loading branch information
TharmiganK authored May 27, 2024
2 parents b75d950 + 0becd58 commit abf505a
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 141 deletions.
8 changes: 4 additions & 4 deletions ballerina/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
org = "ballerina"
name = "mime"
version = "2.9.0"
version = "2.9.1"
authors = ["Ballerina"]
keywords = ["mime", "multipart", "entity"]
repository = "https://github.com/ballerina-platform/module-ballerina-mime"
Expand All @@ -15,11 +15,11 @@ graalvmCompatible = true
[[platform.java17.dependency]]
groupId = "io.ballerina.stdlib"
artifactId = "mime-native"
version = "2.9.0"
path = "../native/build/libs/mime-native-2.9.0.jar"
version = "2.9.1"
path = "../native/build/libs/mime-native-2.9.1-SNAPSHOT.jar"

[[platform.java17.dependency]]
path = "../test-utils/build/libs/mime-test-utils-2.9.0.jar"
path = "../test-utils/build/libs/mime-test-utils-2.9.1-SNAPSHOT.jar"
scope = "testOnly"

[[platform.java17.dependency]]
Expand Down
4 changes: 2 additions & 2 deletions ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ modules = [
[[package]]
org = "ballerina"
name = "mime"
version = "2.9.0"
version = "2.9.1"
dependencies = [
{org = "ballerina", name = "io"},
{org = "ballerina", name = "jballerina.java"},
Expand All @@ -127,7 +127,7 @@ modules = [
[[package]]
org = "ballerina"
name = "observe"
version = "1.2.0"
version = "1.2.2"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "jballerina.java"}
Expand Down
35 changes: 17 additions & 18 deletions ballerina/tests/header_test.bal
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import ballerina/test;

//Test whether the correct http header value is returned when the header exist as requested
@test:Config {}
public function testGetHeaderAsIs() {
isolated function testGetHeaderAsIs() {
string headerName = "Content-Type";
string headerValue = "application/json";
string headerNameToBeUsedForRetrieval = "Content-Type";
Expand All @@ -28,7 +28,7 @@ public function testGetHeaderAsIs() {

//Test whether the empty http header value is returned when the header exist
@test:Config {}
public function testGetEmptyHeaderValue() {
isolated function testGetEmptyHeaderValue() {
string headerName = "X-Empty-Header";
string headerValue = "";
string headerNameToBeUsedForRetrieval = "X-Empty-Header";
Expand All @@ -38,7 +38,7 @@ public function testGetEmptyHeaderValue() {

//Test whether the case is ignored when dealing with http headers
@test:Config {}
public function testCaseInsensitivityOfHeaders() {
isolated function testCaseInsensitivityOfHeaders() {
string headerName = "content-type";
string headerValue = "application/json";
string headerNameToBeUsedForRetrieval = "ConTeNT-TYpE";
Expand All @@ -48,7 +48,7 @@ public function testCaseInsensitivityOfHeaders() {

//Test adding multiple headers to entity
@test:Config {}
public function testAddingMultipleHeadersToEntity() {
isolated function testAddingMultipleHeadersToEntity() {
Entity entity = new;
entity.addHeader("header1", "value1");
entity.addHeader("header2", "value2");
Expand All @@ -61,7 +61,7 @@ public function testAddingMultipleHeadersToEntity() {

//Test adding multiple values to same header
@test:Config {}
public function testAddingMultipleValuesToSameHeaderKey() {
isolated function testAddingMultipleValuesToSameHeaderKey() {
Entity entity = new;
entity.addHeader("heAder1", "value1");
entity.addHeader("header1", "value2");
Expand All @@ -82,7 +82,7 @@ public function testAddingMultipleValuesToSameHeaderKey() {

//Test set header function
@test:Config {}
public function testSetHeaderWitheHeaders() {
isolated function testSetHeaderWitheHeaders() {
Entity entity = new;
entity.setHeader("HeADEr2", "totally different value");
var headers = entity.getHeaders("header2");
Expand All @@ -97,7 +97,7 @@ public function testSetHeaderWitheHeaders() {

//Test set header after add header
@test:Config {}
public function testSetHeaderAfterAddheader() {
isolated function testSetHeaderAfterAddheader() {
Entity entity = new;
entity.addHeader("heAder1", "value1");
entity.addHeader("header1", "value2");
Expand All @@ -119,7 +119,7 @@ public function testSetHeaderAfterAddheader() {

//Test add header after set header
@test:Config {}
public function testAddHeaderAfterTheSetHeader() {
isolated function testAddHeaderAfterTheSetHeader() {
Entity entity = new;
entity.addHeader("heAder1", "value1");
entity.addHeader("header1", "value2");
Expand All @@ -140,7 +140,7 @@ public function testAddHeaderAfterTheSetHeader() {

//Test remove header function
@test:Config {}
public function testRemoveHeaderError() {
isolated function testRemoveHeaderError() {
Entity entity = new;
entity.addHeader("heAder1", "value1");
entity.addHeader("header1", "value2");
Expand All @@ -157,7 +157,7 @@ public function testRemoveHeaderError() {
}

@test:Config {}
public function testRemoveAllHeaderError() {
isolated function testRemoveAllHeaderError() {
Entity entity = new;
entity.addHeader("heAder1", "value1");
entity.addHeader("header1", "value2");
Expand All @@ -174,7 +174,7 @@ public function testRemoveAllHeaderError() {

//Test getting a value out of a non existence header
@test:Config {}
public function testForNonExistenceHeader() {
isolated function testForNonExistenceHeader() {
Entity entity = new;
entity.addHeader("heAder1", "value1");
var result = entity.getHeader("header");
Expand All @@ -185,7 +185,7 @@ public function testForNonExistenceHeader() {

//Test getting all header names
@test:Config {}
public function testGetAllHeaderNames() {
isolated function testGetAllHeaderNames() {
Entity entity = new;
entity.addHeader("heAder1", "value1");
entity.addHeader("header1", "value2");
Expand All @@ -202,7 +202,7 @@ public function testGetAllHeaderNames() {

//Test manipulating return headers
@test:Config {}
public function testManipulatingReturnHeaders() {
isolated function testManipulatingReturnHeaders() {
Entity entity = new;
entity.addHeader("heAder1", "value1");
entity.addHeader("header1", "value2");
Expand All @@ -221,30 +221,29 @@ public function testManipulatingReturnHeaders() {

//Test has header function
@test:Config {}
public function testHasHeaderFunction() {
isolated function testHasHeaderFunction() {
Entity entity = new;
entity.addHeader("heAder1", "value1");
test:assertTrue(entity.hasHeader("header1"), msg = "Found unexpected output");
}

//Test has header function for a non-existence header
@test:Config {}
public function testHasHeaderForNonExistence() {
isolated function testHasHeaderForNonExistence() {
Entity entity = new;
entity.addHeader("heAder1", "value1");
test:assertFalse(entity.hasHeader("header2"), msg = "Found unexpected output");
}

//Test headers with a newly created entity
@test:Config {}
public function testHeaderInNewEntity() {
isolated function testHeaderInNewEntity() {
Entity entity = new;
test:assertFalse(entity.hasHeader("header2"), msg = "Newly created entity can't have any headers");
test:assertTrue(entity.getHeaderNames().length() == 0, msg = "HeaderNames for newly created entity are empty");
}

function testAddHeader(string headerName, string headerValue, string headerNameToBeUsedForRetrieval) returns
@tainted string {
isolated function testAddHeader(string headerName, string headerValue, string headerNameToBeUsedForRetrieval) returns string {
Entity entity = new;
entity.addHeader(headerName, headerValue);
var value = entity.getHeader(headerNameToBeUsedForRetrieval);
Expand Down
Loading

0 comments on commit abf505a

Please sign in to comment.