Skip to content

Commit 8a73003

Browse files
committed
Modify the signatures for verify methods
1 parent 667bd1a commit 8a73003

File tree

1 file changed

+97
-60
lines changed

1 file changed

+97
-60
lines changed

integration-tests/src/test/resources/sitconfig/java/SitConfigTests.java

Lines changed: 97 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030
import weblogic.j2ee.descriptor.wl.JMSBean;
3131
import weblogic.j2ee.descriptor.wl.UniformDistributedTopicBean;
3232
import weblogic.management.configuration.DomainMBean;
33-
import weblogic.management.mbeanservers.edit.EditServiceMBean;
34-
import weblogic.management.mbeanservers.edit.ConfigurationManagerMBean;
3533
import weblogic.management.configuration.JDBCSystemResourceMBean;
3634
import weblogic.management.configuration.JMSSystemResourceMBean;
3735
import weblogic.management.configuration.NetworkAccessPointMBean;
@@ -40,6 +38,8 @@
4038
import weblogic.management.configuration.WLDFSystemResourceMBean;
4139
import weblogic.management.jmx.MBeanServerInvocationHandler;
4240
import weblogic.management.mbeanservers.domainruntime.DomainRuntimeServiceMBean;
41+
import weblogic.management.mbeanservers.edit.ConfigurationManagerMBean;
42+
import weblogic.management.mbeanservers.edit.EditServiceMBean;
4343
import weblogic.management.mbeanservers.runtime.RuntimeServiceMBean;
4444
import weblogic.management.runtime.ServerRuntimeMBean;
4545

@@ -75,6 +75,7 @@ public class SitConfigTests {
7575
private final String adminPort;
7676
private final String adminUser;
7777
private final String adminPassword;
78+
private final String serverName;
7879

7980
/**
8081
* 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 {
9495
String adminUser = args[2];
9596
String adminPassword = args[3];
9697
String testName = args[4];
98+
String serverName = args[5];
9799

98-
SitConfigTests test = new SitConfigTests(adminHost, adminPort, adminUser, adminPassword);
100+
SitConfigTests test =
101+
new SitConfigTests(adminHost, adminPort, adminUser, adminPassword, serverName);
99102

100103
ServerRuntimeMBean runtimeMBean = test.runtimeServiceMBean.getServerRuntime();
101104
println("Sitconfig State:" + runtimeMBean.isInSitConfigState());
102105

103106
if (testName.equals("testCustomSitConfigOverridesForDomain")) {
104107
// the values passed to these verify methods are the attribute values overrrideen in the
105108
// 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);
114123
}
115124

116125
if (testName.equals("testCustomSitConfigOverridesForJdbc")) {
117-
String JDBC_URL = args[5];
126+
String JDBC_URL = args[6];
118127
test.testSystemResourcesJDBCAttributeChange("JdbcTestDataSource-0", JDBC_URL);
119128
}
120129

@@ -133,16 +142,19 @@ public static void main(String args[]) throws Exception {
133142
* @param adminHost - administration server t3 public address
134143
* @param adminPort - administration server t3 public port
135144
* @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
137147
* @throws Exception when connection cannot be created for reasons like incorrect administration
138148
* server name, port , user name , password or administration server not running
139149
*/
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)
141152
throws Exception {
142153
this.adminHost = adminHost;
143154
this.adminPort = adminPort;
144155
this.adminUser = adminUser;
145156
this.adminPassword = adminPassword;
157+
this.serverName = serverName;
146158
createConnections();
147159
}
148160

@@ -165,9 +177,8 @@ private void createConnections() throws Exception {
165177
runtimeServiceMBean =
166178
(RuntimeServiceMBean)
167179
MBeanServerInvocationHandler.newProxyInstance(runtimeMbs, runtimeserviceObjectName);
168-
169-
ObjectName domainServiceObjectName = new ObjectName(DomainRuntimeServiceMBean.OBJECT_NAME);
170180

181+
ObjectName domainServiceObjectName = new ObjectName(DomainRuntimeServiceMBean.OBJECT_NAME);
171182
}
172183

173184
/**
@@ -227,9 +238,11 @@ private MBeanServerConnection lookupMBeanServerConnection(
227238
*
228239
* @param expectedValue - boolean value to be checked in the debug-jmx-core attribute in
229240
* 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
230243
*/
231-
protected void verifyDebugFlagJMXCore(boolean expectedValue) {
232-
ServerMBean serverMBean = getServerMBean();
244+
protected void verifyDebugFlagJMXCore(String serverName, boolean expectedValue) {
245+
ServerMBean serverMBean = getServerMBean(serverName);
233246
ServerDebugMBean serverDebugMBean = serverMBean.getServerDebug();
234247
boolean debugFlag = serverDebugMBean.getDebugJMXCore();
235248
assert expectedValue == debugFlag
@@ -242,10 +255,11 @@ protected void verifyDebugFlagJMXCore(boolean expectedValue) {
242255
* Java assertions to verify if both the values match.
243256
*
244257
* @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
246260
*/
247-
protected void verifyDebugFlagServerLifeCycle(boolean expectedValue) {
248-
ServerMBean serverMBean = getServerMBean();
261+
protected void verifyDebugFlagServerLifeCycle(String serverName, boolean expectedValue) {
262+
ServerMBean serverMBean = getServerMBean(serverName);
249263
ServerDebugMBean serverDebugMBean = serverMBean.getServerDebug();
250264
boolean debugFlag = serverDebugMBean.getDebugServerLifeCycle();
251265
assert expectedValue == debugFlag
@@ -259,9 +273,11 @@ protected void verifyDebugFlagServerLifeCycle(boolean expectedValue) {
259273
*
260274
* @param expectedValue - integer value to be checked in the connect-timeout attribute in
261275
* 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
262278
*/
263-
protected void verifyConnectTimeout(int expectedValue) {
264-
ServerMBean serverMBean = getServerMBean();
279+
protected void verifyConnectTimeout(String serverName, int expectedValue) {
280+
ServerMBean serverMBean = getServerMBean(serverName);
265281
int got = serverMBean.getConnectTimeout();
266282
assert expectedValue == got
267283
: "Didn't get the expected value " + expectedValue + " for ConnectTimeout";
@@ -274,9 +290,11 @@ protected void verifyConnectTimeout(int expectedValue) {
274290
*
275291
* @param expectedValue - integer value to be checked in the restart-max attribute in ServerMBean
276292
* in ServerConfig tree.
293+
* @param serverName - name of the weblogic server instance for which the restart max to be
294+
* checked as a String
277295
*/
278-
protected void verifyRestartMax(int expectedValue) {
279-
ServerMBean serverMBean = getServerMBean();
296+
protected void verifyRestartMax(String serverName, int expectedValue) {
297+
ServerMBean serverMBean = getServerMBean(serverName);
280298
int got = serverMBean.getRestartMax();
281299
assert expectedValue == got
282300
: "Didn't get the expected value " + expectedValue + " for RestartMax";
@@ -289,38 +307,43 @@ protected void verifyRestartMax(int expectedValue) {
289307
*
290308
* @param expectedValue - integer value to be checked in the max-message-size attribute in
291309
* 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
292312
*/
293-
protected void verifyMaxMessageSize(int expectedValue) {
294-
ServerMBean serverMBean = getServerMBean();
313+
protected void verifyMaxMessageSize(String serverName, int expectedValue) {
314+
ServerMBean serverMBean = getServerMBean(serverName);
295315
int got = serverMBean.getMaxMessageSize();
296316
assert expectedValue == got
297317
: "Didn't get the expected value " + expectedValue + " for MaxMessageSize";
298318
}
299-
319+
300320
/**
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.
304324
*
305325
* @param expectedValue - integer value to be checked in the max-message-size attribute in
306326
* EditMBean in ServerConfig tree
307327
*/
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();
313333
cfgMgr.startEdit(-1, -1);
314334
DomainMBean editDomainMBean = editSvc.getDomainConfiguration();
315-
335+
316336
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+
}
324347
}
325348

326349
/**
@@ -331,9 +354,9 @@ protected void verifyMsSeverMaxMessageSize(int expectedValue,String serverName)
331354
* @param expectedValue - string value to be checked in the public-address attribute in
332355
* ServerMBean in ServerConfig tree.
333356
*/
334-
protected void verifyT3ChannelPublicAddress(String expectedValue) {
357+
protected void verifyT3ChannelPublicAddress(String serverName, String expectedValue) {
335358
boolean got = false;
336-
ServerMBean serverMBean = getServerMBean();
359+
ServerMBean serverMBean = getServerMBean(serverName);
337360
NetworkAccessPointMBean[] networkAccessPoints = serverMBean.getNetworkAccessPoints();
338361

339362
for (NetworkAccessPointMBean networkAccessPoint : networkAccessPoints) {
@@ -350,10 +373,12 @@ protected void verifyT3ChannelPublicAddress(String expectedValue) {
350373
*
351374
* @param expectedValue - integer value to be checked in the public-port attribute in ServerMBean
352375
* in ServerConfig tree
376+
* @param serverName - name of the weblogic server instance for which the t3 port to be checked as
377+
* a String
353378
*/
354-
protected void verifyT3ChannelPublicPort(int expectedValue) {
379+
protected void verifyT3ChannelPublicPort(String serverName, int expectedValue) {
355380
boolean got = false;
356-
ServerMBean serverMBean = getServerMBean();
381+
ServerMBean serverMBean = getServerMBean(serverName);
357382
NetworkAccessPointMBean[] networkAccessPoints = serverMBean.getNetworkAccessPoints();
358383

359384
for (NetworkAccessPointMBean networkAccessPoint : networkAccessPoints) {
@@ -367,27 +392,39 @@ protected void verifyT3ChannelPublicPort(int expectedValue) {
367392
/**
368393
* Looks up the ServerMBean from RuntimeServiceMBean.
369394
*
395+
* @param the name weblogic server instance for which to lookup the ServerMBean
370396
* @return the ServerMBean reference
371397
*/
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;
377408
}
378-
409+
379410
/**
380411
* Looks up the EditServiceMBean from MBeanServerConnection.
381412
*
382413
* @return the EditServiceMBean reference
383414
*/
384-
//Get edit Service
415+
// Get edit Service
385416
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;
391428
}
392429

393430
/**

0 commit comments

Comments
 (0)