Skip to content
Permalink
Browse files
JUDDI-937 adding test cases, discovered a caching mechanism that had …
…no way of being cleared which was resolved.
  • Loading branch information
spyhunter99 committed Jan 20, 2020
1 parent 07790a2 commit 5ac79c870c2e804ca154ee1dc207e6a8087d609d
Showing 7 changed files with 96 additions and 7 deletions.
@@ -77,6 +77,10 @@ public class UDDIClient {
private Properties properties = null;
private static Map<String, ServiceLocator> serviceLocators = new HashMap<String, ServiceLocator>();


public static void clearServiceLocatorCaches(){
serviceLocators.clear();
}
/**
* Default constructor, loads from the default config, META-INF/uddi.xml
*
@@ -89,5 +89,9 @@ public static void removeClerkManager(String clientName)
public static boolean contains(String name) {
return (clients.containsKey(name)) ;
}

public static void removeAll() {
clients.clear();
}

}
@@ -21,13 +21,18 @@
import org.apache.commons.logging.LogFactory;
import org.apache.juddi.Registry;
import org.apache.juddi.v3.client.UDDIConstants;
import org.apache.juddi.v3.client.config.UDDIClient;
import org.apache.juddi.v3.client.config.UDDIClientContainer;
import org.apache.juddi.v3.client.ext.wsdm.WSDMQosConstants;
import org.apache.juddi.v3.client.mapping.ServiceLocator;
import org.apache.juddi.v3.client.transport.Transport;
import org.apache.juddi.v3.error.ValueNotAllowedException;
import org.apache.juddi.v3.tck.TckBindingTemplate;
import static org.apache.juddi.v3.tck.TckBindingTemplate.JOE_BINDING_KEY;
import static org.apache.juddi.v3.tck.TckBindingTemplate.JOE_BINDING_XML;
import org.apache.juddi.v3.tck.TckBusiness;
import org.apache.juddi.v3.tck.TckBusinessService;
import org.apache.juddi.v3.tck.TckCommon;
import org.apache.juddi.v3.tck.TckFindEntity;
import org.apache.juddi.v3.tck.TckPublisher;
import org.apache.juddi.v3.tck.TckSecurity;
@@ -43,6 +48,7 @@
import org.uddi.api_v3.IdentifierBag;
import org.uddi.api_v3.KeyedReference;
import org.uddi.api_v3.TModelBag;
import org.uddi.v3_service.UDDIPublicationPortType;
import org.uddi.v3_service.UDDISecurityPortType;

/**
@@ -244,4 +250,60 @@ public void testJUDDI_999_2() throws Exception {
tckTModel.deleteJoePublisherTmodel(authInfoJoe);
}
}

@Test
public void testJuddi937ServiceLocatorWithCache() throws Exception {
try {
tckTModel.saveJoePublisherTmodel(authInfoJoe);
tckBusiness.saveJoePublisherBusiness(authInfoJoe);
tckBusinessService.saveJoePublisherService(authInfoJoe);
tckBindingTemplate.saveBinding(authInfoJoe, "uddi_data/joepublisher/bindingTemplate.xml", JOE_BINDING_KEY, false);

//create a client using invm transport
UDDIClientContainer.removeAll();
UDDIClient.clearServiceLocatorCaches();
UDDIClient c = new UDDIClient("META-INF/uddi.xml");
ServiceLocator serviceLocator = c.getServiceLocator("joe");
serviceLocator.withSimpleCache();
serviceLocator.clearCaches();
String lookupEndpoint = serviceLocator.lookupEndpoint(TckBusinessService.JOE_SERVICE_KEY);
String lookupEndpoint2 = serviceLocator.lookupEndpoint(TckBusinessService.JOE_SERVICE_KEY);
System.out.println(TckCommon.DumpAllServices(authInfoJoe, c.getTransport("default").getUDDIInquiryService()));
Assert.assertNotEquals(lookupEndpoint, lookupEndpoint2);
} finally {
tckBusinessService.deleteJoePublisherService(authInfoJoe);
tckBusiness.deleteJoePublisherBusiness(authInfoJoe);
tckTModel.deleteJoePublisherTmodel(authInfoJoe);
}
}



@Test
public void testJuddi937ServiceLocatorWithoutCache() throws Exception {
try {

tckTModel.saveJoePublisherTmodel(authInfoJoe);
tckBusiness.saveJoePublisherBusiness(authInfoJoe);
tckBusinessService.saveJoePublisherService(authInfoJoe);
tckBindingTemplate.saveBinding(authInfoJoe, "uddi_data/joepublisher/bindingTemplate.xml", JOE_BINDING_KEY, false);

//create a client using invm transport
UDDIClientContainer.removeAll();
UDDIClient.clearServiceLocatorCaches();
UDDIClient c = new UDDIClient("META-INF/uddi.xml");
ServiceLocator serviceLocator = c.getServiceLocator("joe");
serviceLocator.clearCaches();
//serviceLocator.withSimpleCache();
String lookupEndpoint = serviceLocator.lookupEndpoint(TckBusinessService.JOE_SERVICE_KEY);
String lookupEndpoint2 = serviceLocator.lookupEndpoint(TckBusinessService.JOE_SERVICE_KEY);

System.out.println(TckCommon.DumpAllServices(authInfoJoe, c.getTransport("default").getUDDIInquiryService()));
Assert.assertEquals(lookupEndpoint, lookupEndpoint2);
} finally {
tckBusinessService.deleteJoePublisherService(authInfoJoe);
tckBusiness.deleteJoePublisherBusiness(authInfoJoe);
tckTModel.deleteJoePublisherTmodel(authInfoJoe);
}
}
}
@@ -53,8 +53,8 @@ public static void stopManager() throws ConfigurationException {
static String replUrl = null;
static String juddiUrl = null;
static boolean sink = false;
static replicantImpl repl= new replicantImpl();
static juddiTestimpl jude= new juddiTestimpl();
static ReplicantImpl repl= new ReplicantImpl();
static JuddiTestimpl jude= new JuddiTestimpl();

@BeforeClass
public static void startManager() throws Exception {
@@ -62,7 +62,7 @@
@WebService(serviceName = "JUDDIApiService",
endpointInterface = "org.apache.juddi.v3_service.JUDDIApiPortType",
targetNamespace = "urn:juddi-apache-org:v3_service")
public class juddiTestimpl implements JUDDIApiPortType {
public class JuddiTestimpl implements JUDDIApiPortType {


@Override
@@ -36,9 +36,9 @@
*/
@WebService(serviceName = "UDDI_Replication_PortType", targetNamespace = "urn:uddi-org:repl_v3_portType",
endpointInterface = "org.uddi.v3_service.UDDIReplicationPortType")
public class replicantImpl implements UDDIReplicationPortType {
public class ReplicantImpl implements UDDIReplicationPortType {

public replicantImpl(){
public ReplicantImpl(){
}


@@ -19,10 +19,12 @@
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.uddi.api_v3.BindingTemplate;
import org.uddi.api_v3.BindingTemplates;
import org.uddi.api_v3.BusinessEntity;
import org.uddi.api_v3.BusinessInfos;
import org.uddi.api_v3.BusinessList;
import org.uddi.api_v3.BusinessService;
import org.uddi.api_v3.CategoryBag;
import org.uddi.api_v3.Contacts;
import org.uddi.api_v3.DeleteBusiness;
@@ -32,9 +34,11 @@
import org.uddi.api_v3.FindService;
import org.uddi.api_v3.FindTModel;
import org.uddi.api_v3.GetOperationalInfo;
import org.uddi.api_v3.GetServiceDetail;
import org.uddi.api_v3.KeyedReference;
import org.uddi.api_v3.Name;
import org.uddi.api_v3.OperationalInfos;
import org.uddi.api_v3.ServiceDetail;
import org.uddi.api_v3.ServiceInfos;
import org.uddi.api_v3.ServiceList;
import org.uddi.api_v3.TModelList;
@@ -268,8 +272,23 @@ public static String DumpAllServices(String authinfo, UDDIInquiryPortType inquir
return ("NO SERVICES RETURNED!");
} else {
for (int i = 0; i < findService.getServiceInfos().getServiceInfo().size(); i++) {
sb.append(findService.getServiceInfos().getServiceInfo().get(i).getName().get(0).getValue()).append(" lang=").append(findService.getServiceInfos().getServiceInfo().get(i).getName().get(0).getLang()).append(" ").append(findService.getServiceInfos().getServiceInfo().get(i).getServiceKey()).append(" ").append(findService.getServiceInfos().getServiceInfo().get(i).getBusinessKey()).append(
System.getProperty("line.separator"));
sb.append(findService.getServiceInfos().getServiceInfo().get(i).getName().get(0).getValue()).
append(" lang=").append(findService.getServiceInfos().getServiceInfo().get(i).getName().get(0).getLang()).
append(" ").append(findService.getServiceInfos().getServiceInfo().get(i).getServiceKey()).
append(" ").append(findService.getServiceInfos().getServiceInfo().get(i).getBusinessKey()).
append(System.getProperty("line.separator"));
GetServiceDetail req=new GetServiceDetail();
req.setAuthInfo(authinfo);
req.getServiceKey().add(findService.getServiceInfos().getServiceInfo().get(i).getServiceKey());
ServiceDetail d=inquiry.getServiceDetail(req);
for(BusinessService bs : d.getBusinessService()){
for(BindingTemplate bt:bs.getBindingTemplates().getBindingTemplate()){
sb.append(bt.getBindingKey());
sb.append(" ");
sb.append(bt.getAccessPoint().getValue());
sb. append(System.getProperty("line.separator"));
}
}
}
}
} catch (Exception ex) {

0 comments on commit 5ac79c8

Please sign in to comment.