ServiceDelegate serviceDelegate1 = DescriptionTestUtils2.getServiceDelegate(service1);
assertNull(ServiceDelegate.getServiceMetadata());
ServiceDescription serviceDesc1 = serviceDelegate1.getServiceDescription();
// Do the first getPort on the first Service
DescriptionBuilderComposite sparseComposite1 = new DescriptionBuilderComposite();
assertNull(ServiceDelegate.getPortMetadata());
ServiceDelegate.setPortMetadata(sparseComposite1);
assertNull(ServiceDelegate.getServiceMetadata());
assertSame(sparseComposite1, ServiceDelegate.getPortMetadata());
ClientMetadataPortSEI port1 = service1.getPort(portQN, ClientMetadataPortSEI.class);
EndpointDescription epDescArray1[] = serviceDesc1.getEndpointDescriptions();
assertEquals(1, epDescArray1.length);
DescriptionBuilderComposite epDBC1 = epDescArray1[0].getDescriptionBuilderComposite();
assertNotNull(epDBC1);
assertNotSame(sparseComposite1, epDBC1);
assertSame(sparseComposite1, epDBC1.getSparseComposite(serviceDelegate1));
// Create the second service
Service service2 = Service.create(wsdlUrl, serviceQName);
ServiceDelegate serviceDelegate2 = DescriptionTestUtils2.getServiceDelegate(service2);
assertNull(ServiceDelegate.getServiceMetadata());
ServiceDescription serviceDesc2 = serviceDelegate2.getServiceDescription();
// Do the getPort on the second Service
DescriptionBuilderComposite sparseComposite2 = new DescriptionBuilderComposite();
assertNull(ServiceDelegate.getPortMetadata());
ServiceDelegate.setPortMetadata(sparseComposite2);
assertNull(ServiceDelegate.getServiceMetadata());
assertSame(sparseComposite2, ServiceDelegate.getPortMetadata());
ClientMetadataPortSEI port2 = service2.getPort(portQN, ClientMetadataPortSEI.class);
EndpointDescription epDescArray2[] = serviceDesc2.getEndpointDescriptions();
assertEquals(1, epDescArray2.length);
DescriptionBuilderComposite epDBC2 = epDescArray2[0].getDescriptionBuilderComposite();
assertNotNull(epDBC2);
assertNotSame(sparseComposite2, epDBC2);
// Since we installed a caching configuration factory above, the ServiceDescriptions
// should match for the two service delegates. The EndpointDesc and the composite
// in the EndpointDesc should be the same. The sparse composite should be unique to
// each service delegate.
assertNotSame(serviceDelegate1, serviceDelegate2);
assertSame(serviceDesc1, serviceDesc2);
assertSame(epDBC1, epDBC2);
assertSame(epDescArray1[0], epDescArray2[0]);
assertNotSame(sparseComposite1, sparseComposite2);
assertSame(sparseComposite1, epDBC1.getSparseComposite(serviceDelegate1));
assertSame(sparseComposite2, epDBC2.getSparseComposite(serviceDelegate2));
} finally {
ClientMetadataTest.restoreOriginalFactory();
}
}