1
1
package org .testcontainers .oceanbase ;
2
2
3
- import org .apache .commons .lang3 .StringUtils ;
4
3
import org .testcontainers .containers .JdbcDatabaseContainer ;
5
4
import org .testcontainers .utility .DockerImageName ;
6
5
@@ -27,8 +26,6 @@ public class OceanBaseCEContainer extends JdbcDatabaseContainer<OceanBaseCEConta
27
26
28
27
private static final Integer RPC_PORT = 2882 ;
29
28
30
- private static final String SYSTEM_TENANT_NAME = "sys" ;
31
-
32
29
private static final String DEFAULT_TEST_TENANT_NAME = "test" ;
33
30
34
31
private static final String DEFAULT_USERNAME = "root" ;
@@ -37,8 +34,6 @@ public class OceanBaseCEContainer extends JdbcDatabaseContainer<OceanBaseCEConta
37
34
38
35
private static final String DEFAULT_DATABASE_NAME = "test" ;
39
36
40
- private String tenantName = DEFAULT_TEST_TENANT_NAME ;
41
-
42
37
public OceanBaseCEContainer (String dockerImageName ) {
43
38
this (DockerImageName .parse (dockerImageName ));
44
39
}
@@ -73,7 +68,9 @@ public String getDatabaseName() {
73
68
74
69
@ Override
75
70
public String getUsername () {
76
- return DEFAULT_USERNAME + "@" + tenantName ;
71
+ // In OceanBase, the jdbc username is related to the name of user, tenant and cluster, if a tenant name other than
72
+ // the default value 'test' is used, you should manually construct the jdbc username by yourself.
73
+ return DEFAULT_USERNAME + "@" + DEFAULT_TEST_TENANT_NAME ;
77
74
}
78
75
79
76
@ Override
@@ -85,28 +82,4 @@ public String getPassword() {
85
82
protected String getTestQueryString () {
86
83
return "SELECT 1" ;
87
84
}
88
-
89
- /**
90
- * Set the non-system tenant to be created for testing.
91
- *
92
- * @param tenantName the name of tenant to be created
93
- * @return this
94
- */
95
- public OceanBaseCEContainer withTenant (String tenantName ) {
96
- if (StringUtils .isEmpty (tenantName )) {
97
- throw new IllegalArgumentException ("Tenant name cannot be null or empty" );
98
- }
99
- if (SYSTEM_TENANT_NAME .equals (tenantName )) {
100
- throw new IllegalArgumentException ("Tenant name cannot be " + SYSTEM_TENANT_NAME );
101
- }
102
- this .tenantName = tenantName ;
103
- return self ();
104
- }
105
-
106
- @ Override
107
- protected void configure () {
108
- if (!DEFAULT_TEST_TENANT_NAME .equals (tenantName )) {
109
- withEnv ("OB_TENANT_NAME" , tenantName );
110
- }
111
- }
112
85
}
0 commit comments