svc1.addPort(portQN2, bindingID1, epr1);
svc2.addPort(portQN1,bindingID1, epr1);
svc2.addPort(portQN2, bindingID1, epr1);
ServiceDelegate sd1 = DescriptionTestUtils2.getServiceDelegate(svc1);
ServiceDelegate sd2 = DescriptionTestUtils2.getServiceDelegate(svc2);
assertNotSame(sd1, sd2);
ServiceDescription svcDesc1 = sd1.getServiceDescription();
ServiceDescription svcDesc2 = sd2.getServiceDescription();
AxisConfiguration axisConfig = svcDesc1.getAxisConfigContext().getAxisConfiguration();
assertSame(svcDesc1, svcDesc2);
EndpointDescription epDesc1_port1 = svcDesc1.getEndpointDescription(portQN1, sd1);
EndpointDescription epDesc2_port1 = svcDesc1.getEndpointDescription(portQN1, sd2);
assertSame(epDesc1_port1, epDesc2_port1);
AxisService axisSvc1_port1 = epDesc1_port1.getAxisService();
AxisService axisSvc2_port1 = epDesc2_port1.getAxisService();
assertSame(axisSvc1_port1, axisSvc2_port1);
EndpointDescription epDesc1_port2 = svcDesc1.getEndpointDescription(portQN2, sd1);
EndpointDescription epDesc2_port2 = svcDesc1.getEndpointDescription(portQN2, sd2);
assertSame(epDesc1_port2, epDesc2_port2);
AxisService axisSvc1_port2 = epDesc1_port2.getAxisService();
AxisService axisSvc2_port2 = epDesc2_port2.getAxisService();
assertSame(axisSvc1_port2, axisSvc2_port2);
// First close should NOT cleanup the endpoints since the other service is
// still using them.
org.apache.axis2.jaxws.spi.ServiceDelegate.releaseService(svc1);
ServiceDescription svcDesc2_afterClose = sd2.getServiceDescription();
assertSame(svcDesc2, svcDesc2_afterClose);
EndpointDescription epDesc2_port1_afterClose =
svcDesc2_afterClose.getEndpointDescription(portQN1, sd2);
assertSame(epDesc2_port1, epDesc2_port1_afterClose);
EndpointDescription epDesc2_port2_afterClose =
svcDesc2_afterClose.getEndpointDescription(portQN2, sd2);
assertSame(epDesc2_port2, epDesc2_port2_afterClose);
// Add a third, should use the same
Service svc3 = Service.create(svcQN);
svc3.addPort(portQN1,bindingID1, epr1);
svc3.addPort(portQN2, bindingID1, epr1);
ServiceDelegate sd3 = DescriptionTestUtils2.getServiceDelegate(svc3);
assertNotSame(sd2, sd3);
ServiceDescription svcDesc3 = sd3.getServiceDescription();
assertSame(svcDesc2_afterClose, svcDesc3);
EndpointDescription epDesc3_port1 = svcDesc3.getEndpointDescription(portQN1, sd3);
assertSame(epDesc3_port1, epDesc2_port1_afterClose);
EndpointDescription epDesc3_port2 = svcDesc3.getEndpointDescription(portQN2, sd3);
assertSame(epDesc3_port2, epDesc2_port2_afterClose);
// Close the 2nd delegate and make sure cahced objects are still there
// since there's a 3rd delegate now
org.apache.axis2.jaxws.spi.ServiceDelegate.releaseService(svc2);
ServiceDescription svcDesc3_afterClose = sd3.getServiceDescription();
assertSame(svcDesc3, svcDesc3_afterClose);
EndpointDescription epDesc3_port1_afterClose =
svcDesc3_afterClose.getEndpointDescription(portQN1, sd3);
assertSame(epDesc3_port1, epDesc3_port1_afterClose);
EndpointDescription epDesc3_port2_afterClose =