Skip to content

Commit 0fdfc20

Browse files
committed
[FABCJ-214] - Java chaincode gRPC server
add cleaning for env variables in tests Signed-off-by: Oleksandr Yamkovyi <[email protected]>
1 parent a48b7ec commit 0fdfc20

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

fabric-chaincode-shim/src/test/java/org/hyperledger/fabric/shim/ChaincodeBaseTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.junit.Rule;
3434
import org.junit.Test;
3535
import org.junit.contrib.java.lang.system.EnvironmentVariables;
36+
import org.junit.jupiter.api.AfterEach;
3637
import org.junit.jupiter.api.Assertions;
3738
import org.junit.rules.ExpectedException;
3839
import org.mockito.ArgumentCaptor;
@@ -47,6 +48,16 @@ public class ChaincodeBaseTest {
4748
@Rule
4849
public ExpectedException thrown = ExpectedException.none();
4950

51+
@AfterEach
52+
void clearEnv() {
53+
environmentVariables.clear("CORE_CHAINCODE_ID_NAME");
54+
environmentVariables.clear("CORE_PEER_ADDRESS");
55+
environmentVariables.clear("CORE_PEER_TLS_ENABLED");
56+
environmentVariables.clear("CORE_PEER_TLS_ROOTCERT_FILE");
57+
environmentVariables.clear("CORE_TLS_CLIENT_KEY_PATH");
58+
environmentVariables.clear("CORE_TLS_CLIENT_CERT_PATH");
59+
}
60+
5061
@Test
5162
public void testNewSuccessResponseEmpty() {
5263
final org.hyperledger.fabric.shim.Chaincode.Response response = ResponseUtils.newSuccessResponse();

fabric-chaincode-shim/src/test/java/org/hyperledger/fabric/shim/impl/InnvocationTaskManagerTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.hyperledger.fabric.shim.chaincode.EmptyChaincode;
1515
import org.junit.Rule;
1616
import org.junit.contrib.java.lang.system.EnvironmentVariables;
17+
import org.junit.jupiter.api.AfterEach;
1718
import org.junit.jupiter.api.Assertions;
1819
import org.junit.jupiter.api.BeforeEach;
1920
import org.junit.jupiter.api.Test;
@@ -38,6 +39,16 @@ void setEnv() {
3839
environmentVariables.set("CORE_TLS_CLIENT_CERT_PATH", "src/test/resources/client.crt.enc");
3940
}
4041

42+
@AfterEach
43+
void clearEnv() {
44+
environmentVariables.clear("CORE_CHAINCODE_ID_NAME");
45+
environmentVariables.clear("CORE_PEER_ADDRESS");
46+
environmentVariables.clear("CORE_PEER_TLS_ENABLED");
47+
environmentVariables.clear("CORE_PEER_TLS_ROOTCERT_FILE");
48+
environmentVariables.clear("CORE_TLS_CLIENT_KEY_PATH");
49+
environmentVariables.clear("CORE_TLS_CLIENT_CERT_PATH");
50+
}
51+
4152
@Test
4253
void getManager() throws IOException {
4354

0 commit comments

Comments
 (0)