ConnectionManagerCache implements ConnectionManager { @Override public String getDefaultEndpointURLByServiceName(String sHomeCommunityId, String sUniformServiceName) throws ConnectionManagerException { ConnectionManagerCacheHelper helper = new ConnectionManagerCacheHelper(); LOG.trace("begin getEndpointURLByServiceName"); String sEndpointURL = ""; BusinessEntity oEntity = getBusinessEntityByHCID(sHomeCommunityId); if (oEntity == null) { return sEndpointURL; } BusinessService oService = helper.getBusinessServiceByServiceName(oEntity, sUniformServiceName); if (oService == null) { return sEndpointURL; } List<UDDI_SPEC_VERSION> specVersions = helper.getSpecVersions(oService); if (specVersions.isEmpty()) { return sEndpointURL; } UDDI_SPEC_VERSION highestSpec = helper.getHighestUDDISpecVersion(specVersions); if (highestSpec == null) { return sEndpointURL; } if (LOG.isDebugEnabled()) { LOG.debug("Attempting to find binding template with spec version (" + highestSpec.toString() + ")."); } BindingTemplate bindingTemplate = helper.findBindingTemplateByKey(oService, UDDIConstants.UDDI_SPEC_VERSION_KEY, highestSpec.toString()); if (bindingTemplate == null || bindingTemplate.getAccessPoint() == null) { LOG.error("No binding templates found for home community"); return sEndpointURL; } sEndpointURL = bindingTemplate.getAccessPoint().getValue(); if (LOG.isDebugEnabled()) { LOG.debug("getEndpointURLByServiceName for home community (" + sHomeCommunityId + ") and service name (" + sUniformServiceName + ") returned endpoint address: " + sEndpointURL); LOG.debug("end getEndpointURLByServiceName url = " + sEndpointURL); } return sEndpointURL; } ConnectionManagerCache();  ConnectionManagerCache(PropertyAccessor accessor); static ConnectionManagerCache getInstance(); void setCommunityId(BusinessEntity businessEntity, String newId); void forceRefreshUDDICache(); void forceRefreshInternalConnectCache(); @Override List<BusinessEntity> getAllBusinessEntities(); @Override BusinessEntity getBusinessEntity(String sHomeCommunityId); @Override String getBusinessEntityName(String homeCommunityId); @Override Set<BusinessEntity> getBusinessEntitySet(List<String> saHomeCommunityId); @Override BusinessEntity getBusinessEntityByServiceName(String sHomeCommunityId, String sUniformServiceName); @Override BusinessEntity getBusinessEntityByHCID(String sHomeCommunityId); @Override Set<BusinessEntity> getBusinessEntitySetByServiceName(List<String> saHomeCommunityId,
        String sUniformServiceName); @Override Set<BusinessEntity> getAllBusinessEntitySetByServiceName(String sUniformServiceName); @Override List<UDDI_SPEC_VERSION> getSpecVersions(String homeCommunityId,
        NhincConstants.NHIN_SERVICE_NAMES serviceName); @Override String getAdapterEndpointURL(String sHomeCommunityId, String sServiceName, ADAPTER_API_LEVEL level); @Override String getAdapterEndpointURL(String sServiceName, ADAPTER_API_LEVEL level); @Override String getDefaultEndpointURLByServiceName(String sHomeCommunityId, String sUniformServiceName); @Override String getEndpointURLByServiceNameSpecVersion(String sHomeCommunityId, String sUniformServiceName,
        UDDI_SPEC_VERSION version); @Override String getInternalEndpointURLByServiceName(String sUniformServiceName); @Override String getEndpointURLFromNhinTarget(NhinTargetSystemType targetSystem, String serviceName); @Override List<UrlInfo> getEndpointURLFromNhinTargetCommunities(NhinTargetCommunitiesType targets, String serviceName); boolean updateInternalServiceUrl(String serviceName, String url);  }
@Test public void testMerging() { try { ConnectionManagerCache connectionManager = createConnectionManager_Override(); String url = connectionManager.getDefaultEndpointURLByServiceName(HCID_2, QUERY_FOR_DOCUMENTS_NAME); assertEquals(QUERY_FOR_DOCUMENTS_URL_22, url); url = connectionManager.getDefaultEndpointURLByServiceName(HCID_2, "QueryForDocument"); assertEquals(QUERY_FOR_DOCUMENTS_URL_22, url); url = connectionManager.getDefaultEndpointURLByServiceName(HCID_1, QUERY_FOR_DOCUMENTS_NAME); assertEquals(QUERY_FOR_DOCUMENTS_URL, url); } catch (Throwable t) { t.printStackTrace(); fail("Error running testMerging test: " + t.getMessage()); } }
@Test public void testGetEndpointURLByServiceName() { try { ConnectionManagerCache connectionManager = createConnectionManager(); String url = connectionManager.getDefaultEndpointURLByServiceName(HCID_1, QUERY_FOR_DOCUMENTS_NAME); assertEquals(QUERY_FOR_DOCUMENTS_URL, url); url = connectionManager.getDefaultEndpointURLByServiceName("hcidValue123", QUERY_FOR_DOCUMENTS_NAME); assertEquals("", url); url = connectionManager.getDefaultEndpointURLByServiceName(HCID_2, DOC_QUERY_DEFERRED_NAME); assertEquals(QUERY_FOR_DOCUMENTS_DEFERRED_URL_22, url); } catch (Throwable t) { t.printStackTrace(); fail("Error running testGetEndpointURLByServiceName test: " + t.getMessage()); } }