Skip to content

Commit e14d3af

Browse files
Fix tests failing the PR builder
1 parent bcedf88 commit e14d3af

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

core/org.wso2.carbon.registry.xboot/pom.xml

Whitespace-only changes.

core/org.wso2.carbon.utils/src/test/java/org/wso2/carbon/context/internal/CarbonContextDataHolderTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.apache.naming.java.javaURLContextFactory;
2121
import org.mockito.Mockito;
2222
import org.testng.Assert;
23+
import org.testng.annotations.BeforeClass;
2324
import org.testng.annotations.Test;
2425
import org.wso2.carbon.BaseTest;
2526
import org.wso2.carbon.base.ServerConfiguration;
@@ -30,6 +31,7 @@
3031
import org.wso2.carbon.registry.api.Registry;
3132
import org.wso2.carbon.user.api.UserRealm;
3233
import org.wso2.carbon.user.api.UserRealmService;
34+
import org.wso2.carbon.utils.ServerConstants;
3335
import org.wso2.carbon.utils.multitenancy.MultitenantCarbonQueueManager;
3436

3537
import javax.naming.CompositeName;
@@ -54,6 +56,18 @@
5456
description = "CarbonContextDataHolder related test cases")
5557
public class CarbonContextDataHolderTest extends BaseTest {
5658

59+
@BeforeClass(alwaysRun = true)
60+
public void setupTestClass() {
61+
// Ensure carbon.home is set before any test method runs
62+
// This is critical because getInitialContext() -> initTestServerConfiguration()
63+
// -> ServerConfiguration.forceInit() -> SecretManagerInitializer.loadProperties()
64+
// requires carbon.home to be set
65+
if (System.getProperty(ServerConstants.CARBON_HOME) == null) {
66+
testSampleDirectory.mkdirs();
67+
System.setProperty(ServerConstants.CARBON_HOME, testSampleDirectory.getAbsolutePath());
68+
}
69+
}
70+
5771
@Test
5872
public void testCarbonContextDataHolder() throws Exception {
5973
CarbonContextDataHolder carbonContextDataHolder1 = CarbonContextDataHolder.getThreadLocalCarbonContextHolder();

0 commit comments

Comments
 (0)