|
20 | 20 | import org.apache.naming.java.javaURLContextFactory; |
21 | 21 | import org.mockito.Mockito; |
22 | 22 | import org.testng.Assert; |
| 23 | +import org.testng.annotations.BeforeClass; |
23 | 24 | import org.testng.annotations.Test; |
24 | 25 | import org.wso2.carbon.BaseTest; |
25 | 26 | import org.wso2.carbon.base.ServerConfiguration; |
|
30 | 31 | import org.wso2.carbon.registry.api.Registry; |
31 | 32 | import org.wso2.carbon.user.api.UserRealm; |
32 | 33 | import org.wso2.carbon.user.api.UserRealmService; |
| 34 | +import org.wso2.carbon.utils.ServerConstants; |
33 | 35 | import org.wso2.carbon.utils.multitenancy.MultitenantCarbonQueueManager; |
34 | 36 |
|
35 | 37 | import javax.naming.CompositeName; |
|
54 | 56 | description = "CarbonContextDataHolder related test cases") |
55 | 57 | public class CarbonContextDataHolderTest extends BaseTest { |
56 | 58 |
|
| 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 | + |
57 | 71 | @Test |
58 | 72 | public void testCarbonContextDataHolder() throws Exception { |
59 | 73 | CarbonContextDataHolder carbonContextDataHolder1 = CarbonContextDataHolder.getThreadLocalCarbonContextHolder(); |
|
0 commit comments