30
30
import weblogic .j2ee .descriptor .wl .JMSBean ;
31
31
import weblogic .j2ee .descriptor .wl .UniformDistributedTopicBean ;
32
32
import weblogic .management .configuration .DomainMBean ;
33
- import weblogic .management .mbeanservers .edit .EditServiceMBean ;
34
- import weblogic .management .mbeanservers .edit .ConfigurationManagerMBean ;
35
33
import weblogic .management .configuration .JDBCSystemResourceMBean ;
36
34
import weblogic .management .configuration .JMSSystemResourceMBean ;
37
35
import weblogic .management .configuration .NetworkAccessPointMBean ;
40
38
import weblogic .management .configuration .WLDFSystemResourceMBean ;
41
39
import weblogic .management .jmx .MBeanServerInvocationHandler ;
42
40
import weblogic .management .mbeanservers .domainruntime .DomainRuntimeServiceMBean ;
41
+ import weblogic .management .mbeanservers .edit .ConfigurationManagerMBean ;
42
+ import weblogic .management .mbeanservers .edit .EditServiceMBean ;
43
43
import weblogic .management .mbeanservers .runtime .RuntimeServiceMBean ;
44
44
import weblogic .management .runtime .ServerRuntimeMBean ;
45
45
@@ -75,6 +75,7 @@ public class SitConfigTests {
75
75
private final String adminPort ;
76
76
private final String adminUser ;
77
77
private final String adminPassword ;
78
+ private final String serverName ;
78
79
79
80
/**
80
81
* Main method to create the SitConfigTests object and run the configuration override tests. To
@@ -94,27 +95,35 @@ public static void main(String args[]) throws Exception {
94
95
String adminUser = args [2 ];
95
96
String adminPassword = args [3 ];
96
97
String testName = args [4 ];
98
+ String serverName = args [5 ];
97
99
98
- SitConfigTests test = new SitConfigTests (adminHost , adminPort , adminUser , adminPassword );
100
+ SitConfigTests test =
101
+ new SitConfigTests (adminHost , adminPort , adminUser , adminPassword , serverName );
99
102
100
103
ServerRuntimeMBean runtimeMBean = test .runtimeServiceMBean .getServerRuntime ();
101
104
println ("Sitconfig State:" + runtimeMBean .isInSitConfigState ());
102
105
103
106
if (testName .equals ("testCustomSitConfigOverridesForDomain" )) {
104
107
// the values passed to these verify methods are the attribute values overrrideen in the
105
108
// config.xml. These are just randomly chosen attributes and values to override
106
- test .verifyDebugFlagJMXCore (true );
107
- test .verifyDebugFlagServerLifeCycle (true );
108
- test .verifyMaxMessageSize (78787878 );
109
- test .verifyConnectTimeout (120 );
110
- test .verifyRestartMax (5 );
111
- test .verifyT3ChannelPublicAddress (adminHost );
112
- test .verifyT3ChannelPublicPort (30091 );
113
- test .verifyMsSeverMaxMessageSize (77777777 ,"managed-server1" );
109
+ test .verifyDebugFlagJMXCore (serverName , true );
110
+ test .verifyDebugFlagServerLifeCycle (serverName , true );
111
+ test .verifyMaxMessageSize (serverName , 78787878 );
112
+ test .verifyMaxMessageSize (serverName , 77777777 );
113
+ test .verifyConnectTimeout (serverName , 120 );
114
+ test .verifyRestartMax (serverName , 5 );
115
+ test .verifyT3ChannelPublicAddress (serverName , adminHost );
116
+ test .verifyT3ChannelPublicPort (serverName , 30091 );
117
+ }
118
+
119
+ if (testName .equals ("testCustomSitConfigOverridesForDomainMS" )) {
120
+ // the values passed to these verify methods are the attribute values overrrideen in the
121
+ // config.xml. These are just randomly chosen attributes and values to override
122
+ test .verifyMaxMessageSize (serverName , 77777777 );
114
123
}
115
124
116
125
if (testName .equals ("testCustomSitConfigOverridesForJdbc" )) {
117
- String JDBC_URL = args [5 ];
126
+ String JDBC_URL = args [6 ];
118
127
test .testSystemResourcesJDBCAttributeChange ("JdbcTestDataSource-0" , JDBC_URL );
119
128
}
120
129
@@ -133,16 +142,19 @@ public static void main(String args[]) throws Exception {
133
142
* @param adminHost - administration server t3 public address
134
143
* @param adminPort - administration server t3 public port
135
144
* @param adminUser - administration server user name
136
- * @param adminPassword - - administration server password
145
+ * @param adminPassword - administration server password
146
+ * @param serverName - name of the server for which the configuration values to be checked
137
147
* @throws Exception when connection cannot be created for reasons like incorrect administration
138
148
* server name, port , user name , password or administration server not running
139
149
*/
140
- public SitConfigTests (String adminHost , String adminPort , String adminUser , String adminPassword )
150
+ public SitConfigTests (
151
+ String adminHost , String adminPort , String adminUser , String adminPassword , String serverName )
141
152
throws Exception {
142
153
this .adminHost = adminHost ;
143
154
this .adminPort = adminPort ;
144
155
this .adminUser = adminUser ;
145
156
this .adminPassword = adminPassword ;
157
+ this .serverName = serverName ;
146
158
createConnections ();
147
159
}
148
160
@@ -165,9 +177,8 @@ private void createConnections() throws Exception {
165
177
runtimeServiceMBean =
166
178
(RuntimeServiceMBean )
167
179
MBeanServerInvocationHandler .newProxyInstance (runtimeMbs , runtimeserviceObjectName );
168
-
169
- ObjectName domainServiceObjectName = new ObjectName (DomainRuntimeServiceMBean .OBJECT_NAME );
170
180
181
+ ObjectName domainServiceObjectName = new ObjectName (DomainRuntimeServiceMBean .OBJECT_NAME );
171
182
}
172
183
173
184
/**
@@ -227,9 +238,11 @@ private MBeanServerConnection lookupMBeanServerConnection(
227
238
*
228
239
* @param expectedValue - boolean value to be checked in the debug-jmx-core attribute in
229
240
* ServerMBean in ServerConfig tree.
241
+ * @param serverName - name of the weblogic server instance for which the debug flag to be checked
242
+ * as a String
230
243
*/
231
- protected void verifyDebugFlagJMXCore (boolean expectedValue ) {
232
- ServerMBean serverMBean = getServerMBean ();
244
+ protected void verifyDebugFlagJMXCore (String serverName , boolean expectedValue ) {
245
+ ServerMBean serverMBean = getServerMBean (serverName );
233
246
ServerDebugMBean serverDebugMBean = serverMBean .getServerDebug ();
234
247
boolean debugFlag = serverDebugMBean .getDebugJMXCore ();
235
248
assert expectedValue == debugFlag
@@ -242,10 +255,11 @@ protected void verifyDebugFlagJMXCore(boolean expectedValue) {
242
255
* Java assertions to verify if both the values match.
243
256
*
244
257
* @param expectedValue - boolean value to be checked in the debug-server-life-cycle attribute in
245
- * ServerMBean in ServerConfig MBean tree
258
+ * ServerMBean in ServerConfig MBean tree * @param serverName - name of the weblogic server
259
+ * instance for which the debug flag to be checked as a String
246
260
*/
247
- protected void verifyDebugFlagServerLifeCycle (boolean expectedValue ) {
248
- ServerMBean serverMBean = getServerMBean ();
261
+ protected void verifyDebugFlagServerLifeCycle (String serverName , boolean expectedValue ) {
262
+ ServerMBean serverMBean = getServerMBean (serverName );
249
263
ServerDebugMBean serverDebugMBean = serverMBean .getServerDebug ();
250
264
boolean debugFlag = serverDebugMBean .getDebugServerLifeCycle ();
251
265
assert expectedValue == debugFlag
@@ -259,9 +273,11 @@ protected void verifyDebugFlagServerLifeCycle(boolean expectedValue) {
259
273
*
260
274
* @param expectedValue - integer value to be checked in the connect-timeout attribute in
261
275
* ServerMBean in ServerConfig tree.
276
+ * @param serverName - name of the weblogic server instance for which the connect timeout to be
277
+ * checked as a String
262
278
*/
263
- protected void verifyConnectTimeout (int expectedValue ) {
264
- ServerMBean serverMBean = getServerMBean ();
279
+ protected void verifyConnectTimeout (String serverName , int expectedValue ) {
280
+ ServerMBean serverMBean = getServerMBean (serverName );
265
281
int got = serverMBean .getConnectTimeout ();
266
282
assert expectedValue == got
267
283
: "Didn't get the expected value " + expectedValue + " for ConnectTimeout" ;
@@ -274,9 +290,11 @@ protected void verifyConnectTimeout(int expectedValue) {
274
290
*
275
291
* @param expectedValue - integer value to be checked in the restart-max attribute in ServerMBean
276
292
* in ServerConfig tree.
293
+ * @param serverName - name of the weblogic server instance for which the restart max to be
294
+ * checked as a String
277
295
*/
278
- protected void verifyRestartMax (int expectedValue ) {
279
- ServerMBean serverMBean = getServerMBean ();
296
+ protected void verifyRestartMax (String serverName , int expectedValue ) {
297
+ ServerMBean serverMBean = getServerMBean (serverName );
280
298
int got = serverMBean .getRestartMax ();
281
299
assert expectedValue == got
282
300
: "Didn't get the expected value " + expectedValue + " for RestartMax" ;
@@ -289,38 +307,43 @@ protected void verifyRestartMax(int expectedValue) {
289
307
*
290
308
* @param expectedValue - integer value to be checked in the max-message-size attribute in
291
309
* ServerMBean in ServerConfig tree
310
+ * @param serverName - name of the weblogic server instance for which the max message size to be
311
+ * checked as a String
292
312
*/
293
- protected void verifyMaxMessageSize (int expectedValue ) {
294
- ServerMBean serverMBean = getServerMBean ();
313
+ protected void verifyMaxMessageSize (String serverName , int expectedValue ) {
314
+ ServerMBean serverMBean = getServerMBean (serverName );
295
315
int got = serverMBean .getMaxMessageSize ();
296
316
assert expectedValue == got
297
317
: "Didn't get the expected value " + expectedValue + " for MaxMessageSize" ;
298
318
}
299
-
319
+
300
320
/**
301
- * A utility method to check if the max-message-size in the ServerConfig tree of a managed server matches with the
302
- * expected value, a integer value set in the configuration override file config.xml. Uses Java
303
- * assertions to verify if both the values match.
321
+ * A utility method to check if the max-message-size in the ServerConfig tree of a managed server
322
+ * matches with the expected value, a integer value set in the configuration override file
323
+ * config.xml. Uses Java assertions to verify if both the values match.
304
324
*
305
325
* @param expectedValue - integer value to be checked in the max-message-size attribute in
306
326
* EditMBean in ServerConfig tree
307
327
*/
308
- protected void verifyMsSeverMaxMessageSize (int expectedValue ,String serverName ) {
309
-
310
- try {
311
- EditServiceMBean editSvc = getEditService ();
312
- ConfigurationManagerMBean cfgMgr = editSvc .getConfigurationManager ();
328
+ protected void verifyMsSeverMaxMessageSize (int expectedValue , String serverName ) {
329
+
330
+ try {
331
+ EditServiceMBean editSvc = getEditService ();
332
+ ConfigurationManagerMBean cfgMgr = editSvc .getConfigurationManager ();
313
333
cfgMgr .startEdit (-1 , -1 );
314
334
DomainMBean editDomainMBean = editSvc .getDomainConfiguration ();
315
-
335
+
316
336
ServerMBean serverMbean = editDomainMBean .lookupServer (serverName );
317
- int got = serverMbean .getMaxMessageSize ();
318
- assert expectedValue == got
319
- : "Didn't get the expected value " + expectedValue + " for " + serverName + " MaxMessageSize" ;
320
- }
321
- catch (Exception e ) {
322
- e .printStackTrace ();
323
- }
337
+ int got = serverMbean .getMaxMessageSize ();
338
+ assert expectedValue == got
339
+ : "Didn't get the expected value "
340
+ + expectedValue
341
+ + " for "
342
+ + serverName
343
+ + " MaxMessageSize" ;
344
+ } catch (Exception e ) {
345
+ e .printStackTrace ();
346
+ }
324
347
}
325
348
326
349
/**
@@ -331,9 +354,9 @@ protected void verifyMsSeverMaxMessageSize(int expectedValue,String serverName)
331
354
* @param expectedValue - string value to be checked in the public-address attribute in
332
355
* ServerMBean in ServerConfig tree.
333
356
*/
334
- protected void verifyT3ChannelPublicAddress (String expectedValue ) {
357
+ protected void verifyT3ChannelPublicAddress (String serverName , String expectedValue ) {
335
358
boolean got = false ;
336
- ServerMBean serverMBean = getServerMBean ();
359
+ ServerMBean serverMBean = getServerMBean (serverName );
337
360
NetworkAccessPointMBean [] networkAccessPoints = serverMBean .getNetworkAccessPoints ();
338
361
339
362
for (NetworkAccessPointMBean networkAccessPoint : networkAccessPoints ) {
@@ -350,10 +373,12 @@ protected void verifyT3ChannelPublicAddress(String expectedValue) {
350
373
*
351
374
* @param expectedValue - integer value to be checked in the public-port attribute in ServerMBean
352
375
* in ServerConfig tree
376
+ * @param serverName - name of the weblogic server instance for which the t3 port to be checked as
377
+ * a String
353
378
*/
354
- protected void verifyT3ChannelPublicPort (int expectedValue ) {
379
+ protected void verifyT3ChannelPublicPort (String serverName , int expectedValue ) {
355
380
boolean got = false ;
356
- ServerMBean serverMBean = getServerMBean ();
381
+ ServerMBean serverMBean = getServerMBean (serverName );
357
382
NetworkAccessPointMBean [] networkAccessPoints = serverMBean .getNetworkAccessPoints ();
358
383
359
384
for (NetworkAccessPointMBean networkAccessPoint : networkAccessPoints ) {
@@ -367,27 +392,39 @@ protected void verifyT3ChannelPublicPort(int expectedValue) {
367
392
/**
368
393
* Looks up the ServerMBean from RuntimeServiceMBean.
369
394
*
395
+ * @param the name weblogic server instance for which to lookup the ServerMBean
370
396
* @return the ServerMBean reference
371
397
*/
372
- private ServerMBean getServerMBean () {
373
- ServerMBean serverMBean = runtimeServiceMBean .getServerConfiguration ();
374
- println ("ServerMBean: " + serverMBean );
375
-
376
- return serverMBean ;
398
+ private ServerMBean getServerMBean (String serverName ) {
399
+ ServerMBean servermbean = null ;
400
+ ServerMBean [] servers = runtimeServiceMBean .getDomainConfiguration ().getServers ();
401
+ for (ServerMBean server : servers ) {
402
+ if (server .getName ().equals (serverName )) {
403
+ servermbean = server ;
404
+ }
405
+ }
406
+ println ("ServerMBean: " + servermbean );
407
+ return servermbean ;
377
408
}
378
-
409
+
379
410
/**
380
411
* Looks up the EditServiceMBean from MBeanServerConnection.
381
412
*
382
413
* @return the EditServiceMBean reference
383
414
*/
384
- //Get edit Service
415
+ // Get edit Service
385
416
private EditServiceMBean getEditService () throws Exception {
386
- MBeanServerConnection msc = lookupMBeanServerConnection (adminHost , adminPort , adminUser , adminPassword , "weblogic.management.mbeanservers.edit" );
387
- ObjectName serviceObjectName = new ObjectName (EditServiceMBean .OBJECT_NAME );
388
- EditServiceMBean editSvc = (EditServiceMBean )
389
- MBeanServerInvocationHandler .newProxyInstance (msc , serviceObjectName );
390
- return editSvc ;
417
+ MBeanServerConnection msc =
418
+ lookupMBeanServerConnection (
419
+ adminHost ,
420
+ adminPort ,
421
+ adminUser ,
422
+ adminPassword ,
423
+ "weblogic.management.mbeanservers.edit" );
424
+ ObjectName serviceObjectName = new ObjectName (EditServiceMBean .OBJECT_NAME );
425
+ EditServiceMBean editSvc =
426
+ (EditServiceMBean ) MBeanServerInvocationHandler .newProxyInstance (msc , serviceObjectName );
427
+ return editSvc ;
391
428
}
392
429
393
430
/**
0 commit comments