// Create the first service
Service service1 = Service.create(wsdlUrl, serviceQName);
ServiceDelegate serviceDelegate1 = DescriptionTestUtils2.getServiceDelegate(service1);
assertNull(ServiceDelegate.getServiceMetadata());
ServiceDescription serviceDesc1 = serviceDelegate1.getServiceDescription();
validatePort(service1, otherWsdl_portLocalPart);
// Create the second service
Service service2 = Service.create(wsdlUrl, serviceQName);
ServiceDelegate serviceDelegate2 = DescriptionTestUtils2.getServiceDelegate(service2);
assertNull(ServiceDelegate.getServiceMetadata());
ServiceDescription serviceDesc2 = serviceDelegate2.getServiceDescription();
validatePort(service2, otherWsdl_portLocalPart);
assertNotSame(serviceDelegate1, serviceDelegate2);
// Since we installed a caching factory, the service descriptions WILL be cached.
// Without that factory, they would not have been cached. The reason is that the
// AxisConfiguration instance is part of the key. The default factory in this
// environment always returns a new instance. The test factory does not.
assertSame(serviceDesc1, serviceDesc2);
} finally {
restoreOriginalFactory();
}
// Sanity check that the factory WAS restored. Do the same thing as above, but this time
// the service descs should NOT be the same since they weren't cached.
QName serviceQName = new QName(namespaceURI, svcLocalPart);
QName portQN = new QName(namespaceURI, otherWsdl_portLocalPart);
URL wsdlUrl = ClientMetadataTest.getWsdlURL(otherWsdl);
// Create the first service
Service service1 = Service.create(wsdlUrl, serviceQName);
ServiceDelegate serviceDelegate1 = DescriptionTestUtils2.getServiceDelegate(service1);
assertNull(ServiceDelegate.getServiceMetadata());
ServiceDescription serviceDesc1 = serviceDelegate1.getServiceDescription();
validatePort(service1, otherWsdl_portLocalPart);
// Create the second service
Service service2 = Service.create(wsdlUrl, serviceQName);
ServiceDelegate serviceDelegate2 = DescriptionTestUtils2.getServiceDelegate(service2);
assertNull(ServiceDelegate.getServiceMetadata());
ServiceDescription serviceDesc2 = serviceDelegate2.getServiceDescription();
validatePort(service2, otherWsdl_portLocalPart);
assertNotSame(serviceDelegate1, serviceDelegate2);
assertNotSame("Client Configuration factory NOT restored; subsequent tests may be affected!", serviceDesc1, serviceDesc2);
}