64
64
public class SitConfigTests {
65
65
66
66
private MBeanServerConnection runtimeMbs ;
67
+ private MBeanServerConnection editMbs ;
67
68
private DomainMBean domainMBean = null ;
69
+ private EditServiceMBean editServiceMBean = null ;
70
+ private ConfigurationManagerMBean cfgMgr ;
68
71
private JMXConnector jmxConnector ;
69
72
private static ObjectName service ;
70
73
private RuntimeServiceMBean runtimeServiceMBean ;
@@ -93,7 +96,7 @@ public static void main(String args[]) throws Exception {
93
96
String adminHost = args [0 ];
94
97
String adminPort = args [1 ];
95
98
String adminUser = args [2 ];
96
- String adminPassword = args [3 ];
99
+ String adminPassword = args [3 ];
97
100
String serverName = args [4 ];
98
101
String testName = args [5 ];
99
102
@@ -109,7 +112,6 @@ public static void main(String args[]) throws Exception {
109
112
test .verifyDebugFlagJMXCore (serverName , true );
110
113
test .verifyDebugFlagServerLifeCycle (serverName , true );
111
114
test .verifyMaxMessageSize (serverName , 78787878 );
112
- test .verifyMaxMessageSize (serverName , 77777777 );
113
115
test .verifyConnectTimeout (serverName , 120 );
114
116
test .verifyRestartMax (serverName , 5 );
115
117
test .verifyT3ChannelPublicAddress (serverName , adminHost );
@@ -177,8 +179,17 @@ private void createConnections() throws Exception {
177
179
runtimeServiceMBean =
178
180
(RuntimeServiceMBean )
179
181
MBeanServerInvocationHandler .newProxyInstance (runtimeMbs , runtimeserviceObjectName );
180
-
181
182
ObjectName domainServiceObjectName = new ObjectName (DomainRuntimeServiceMBean .OBJECT_NAME );
183
+ editMbs =
184
+ lookupMBeanServerConnection (
185
+ adminHost , adminPort , adminUser , adminPassword , EditServiceMBean .MBEANSERVER_JNDI_NAME );
186
+ ObjectName serviceObjectName = new ObjectName (EditServiceMBean .OBJECT_NAME );
187
+ editServiceMBean =
188
+ (EditServiceMBean )
189
+ MBeanServerInvocationHandler .newProxyInstance (editMbs , serviceObjectName );
190
+ cfgMgr = editServiceMBean .getConfigurationManager ();
191
+
192
+ cfgMgr .startEdit (-1 , -1 );
182
193
}
183
194
184
195
/**
@@ -254,11 +265,14 @@ protected void verifyDebugFlagJMXCore(String serverName, boolean expectedValue)
254
265
* with the expected value, a boolean value set in the configuration override file config.xml.Uses
255
266
* Java assertions to verify if both the values match.
256
267
*
268
+ * @param serverName name of the weblogic server instance for which the debug flag to be checked
269
+ * as a String
257
270
* @param expectedValue - boolean value to be checked in the debug-server-life-cycle attribute in
258
271
* ServerMBean in ServerConfig MBean tree * @param serverName - name of the weblogic server
259
272
* instance for which the debug flag to be checked as a String
260
273
*/
261
- protected void verifyDebugFlagServerLifeCycle (String serverName , boolean expectedValue ) {
274
+ protected void verifyDebugFlagServerLifeCycle (String serverName , boolean expectedValue )
275
+ {
262
276
ServerMBean serverMBean = getServerMBean (serverName );
263
277
ServerDebugMBean serverDebugMBean = serverMBean .getServerDebug ();
264
278
boolean debugFlag = serverDebugMBean .getDebugServerLifeCycle ();
@@ -276,7 +290,7 @@ protected void verifyDebugFlagServerLifeCycle(String serverName, boolean expecte
276
290
* @param serverName - name of the weblogic server instance for which the connect timeout to be
277
291
* checked as a String
278
292
*/
279
- protected void verifyConnectTimeout (String serverName , int expectedValue ) {
293
+ protected void verifyConnectTimeout (String serverName , int expectedValue ) {
280
294
ServerMBean serverMBean = getServerMBean (serverName );
281
295
int got = serverMBean .getConnectTimeout ();
282
296
assert expectedValue == got
@@ -317,44 +331,18 @@ protected void verifyMaxMessageSize(String serverName, int expectedValue) {
317
331
: "Didn't get the expected value " + expectedValue + " for MaxMessageSize" ;
318
332
}
319
333
320
- /**
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.
324
- *
325
- * @param expectedValue - integer value to be checked in the max-message-size attribute in
326
- * EditMBean in ServerConfig tree
327
- */
328
- protected void verifyMsSeverMaxMessageSize (int expectedValue , String serverName ) {
329
-
330
- try {
331
- EditServiceMBean editSvc = getEditService ();
332
- ConfigurationManagerMBean cfgMgr = editSvc .getConfigurationManager ();
333
- cfgMgr .startEdit (-1 , -1 );
334
- DomainMBean editDomainMBean = editSvc .getDomainConfiguration ();
335
-
336
- ServerMBean serverMbean = editDomainMBean .lookupServer (serverName );
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
- }
347
- }
348
-
349
334
/**
350
335
* A utility method to check if the Network Access Point public-address in the ServerConfig tree
351
336
* matches with the expected value, a string value set in the configuration override file
352
337
* config.xml. Uses Java assertions to verify if both the values match.
353
338
*
339
+ * @param serverName name of the weblogic server instance for which the t3 public address to be checked
340
+ * as a String
354
341
* @param expectedValue - string value to be checked in the public-address attribute in
355
342
* ServerMBean in ServerConfig tree.
356
343
*/
357
- protected void verifyT3ChannelPublicAddress (String serverName , String expectedValue ) {
344
+ protected void verifyT3ChannelPublicAddress (String serverName , String expectedValue )
345
+ {
358
346
boolean got = false ;
359
347
ServerMBean serverMBean = getServerMBean (serverName );
360
348
NetworkAccessPointMBean [] networkAccessPoints = serverMBean .getNetworkAccessPoints ();
@@ -396,35 +384,8 @@ protected void verifyT3ChannelPublicPort(String serverName, int expectedValue) {
396
384
* @return the ServerMBean reference
397
385
*/
398
386
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 ;
408
- }
409
-
410
- /**
411
- * Looks up the EditServiceMBean from MBeanServerConnection.
412
- *
413
- * @return the EditServiceMBean reference
414
- */
415
- // Get edit Service
416
- private EditServiceMBean getEditService () throws Exception {
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 ;
387
+ DomainMBean editDomainMBean = editServiceMBean .getDomainConfiguration ();
388
+ return editDomainMBean .lookupServer (serverName );
428
389
}
429
390
430
391
/**
0 commit comments