Commit 7cc83554 authored by Gwenael Cattez's avatar Gwenael Cattez

New generic Test for BindingProcessor, allow testing CRUD operation on both service and reference

Add Generic test for WSBindingProcessor
parent f1d0e70e
......@@ -37,6 +37,12 @@ public class BindingAttribute
private String clazz;
private String value;
public BindingAttribute(String name, String value)
{
this.name=name;
this.value=value;
}
public BindingAttribute(String name, Class<?> clazz, Object value)
{
this.name=name;
......@@ -65,6 +71,19 @@ public class BindingAttribute
{
return value;
}
@Override
public boolean equals(Object obj)
{
if(obj==null || !(obj instanceof BindingAttribute))
{
return false;
}
BindingAttribute bindingAttribte=(BindingAttribute) obj;
boolean isNameEquals= this.name.equals(bindingAttribte.getName());
boolean isValueEquals=this.value.equals(bindingAttribte.getValue());
return isNameEquals && isValueEquals;
}
}
......@@ -142,12 +142,12 @@ public class BindingManagerImpl implements BindingManagerItf
/**
* @see org.ow2.frascati.remote.introspection.binding.BindingManagerItf#getBindingProcessor(java.lang.Object)
*/
public BindingProcessorItf getBindingProcessor(Object component) throws UnsupportedBindingComponentException
public BindingProcessorItf getBindingProcessor(Object boundedObject) throws UnsupportedBindingComponentException
{
BindingProcessorItf bindingProcessor;
try
{
bindingProcessor=this.getReferenceBindingProcessor(component);
bindingProcessor=this.getReferenceBindingProcessor(boundedObject);
return bindingProcessor;
}
catch (UnsupportedBindingComponentException unsupportedBindingComponentException)
......@@ -155,7 +155,7 @@ public class BindingManagerImpl implements BindingManagerItf
//nothing to do try to find a serviceBindingProcessor
}
bindingProcessor=this.getServiceBindingProcessor(component);
bindingProcessor=this.getServiceBindingProcessor(boundedObject);
return bindingProcessor;
}
......
......@@ -77,8 +77,10 @@ public class ResourceUtilImpl implements ResourceUtilItf
@Reference(name = "bindingManager")
private BindingManagerItf bindingManager;
@Reference(name= "scaModelUtil")
private SCAModelUtilItf scaModelUtil;
/**
* @see org.ow2.frascati.remote.introspection.util.ResourceUtilItf#getComponentResource(org.objectweb.fractal.api.Component)
*/
......@@ -95,6 +97,7 @@ public class ResourceUtilImpl implements ResourceUtilItf
{
compResource.setStatus(ComponentStatus.STOPPED);
}
return compResource;
}
......
......@@ -111,6 +111,7 @@
</service>
<reference name="fractalUtil" target="fractalUtil/util"/>
<reference name="bindingManager" target="bindingManager/manager"/>
<reference name="scaModelUtil" target="scaModelUtil/util"/>
</component>
<component name="scaModelUtil">
......
......@@ -170,8 +170,9 @@ public class IntrospectionTestSuite
public static StringList deployContribution(String contributionName)
{
String contributionPath=getResourcePath(contributionName+".zip");
//TODO remove comment when contribution file will be imported from maven repo
// String contributionPath=getResourcePath(contributionName+".zip");
String contributionPath="src/test/resources/"+contributionName+".zip";
String contrib = null;
try
{
......
......@@ -27,9 +27,6 @@
package org.ow2.frascati.remote.introspection.binding.processor;
import java.util.ArrayList;
import java.util.List;
import org.ow2.frascati.remote.introspection.resources.BindingKind;
/**
......@@ -37,22 +34,16 @@ import org.ow2.frascati.remote.introspection.resources.BindingKind;
*/
public class JMSBindingProcessorTest extends BindingProcessorTest
{
/**
* @param bindingKind
* @param serverInterfacePath
* @param clientInterfacePath
*/
public JMSBindingProcessorTest()
{
super(BindingKind.JMS, "Subscriber/sub/messageIn", "Publisher/pub/jmsWire");
this.addContributionToDeploy("helloworld-jms");
}
@Override
protected List<String> getContributionsToDeploy()
public void testSuite() throws BindingProcessorException
{
List<String> contributionToDeploy=new ArrayList<String>();
contributionToDeploy.add("helloworld-jms");
return contributionToDeploy;
this.log("Not Implemented yet");
}
}
......@@ -27,9 +27,6 @@
package org.ow2.frascati.remote.introspection.binding.processor;
import java.util.ArrayList;
import java.util.List;
import org.ow2.frascati.remote.introspection.resources.BindingKind;
/**
......@@ -38,21 +35,15 @@ import org.ow2.frascati.remote.introspection.resources.BindingKind;
public class JSONRPCBindingProcessorTest extends BindingProcessorTest
{
/**
* @param bindingKind
* @param serverInterfacePath
* @param clientInterfacePath
*/
public JSONRPCBindingProcessorTest()
{
super(BindingKind.JSON_RPC, "helloworld-jsonrpc-server/s","helloworld-jsonrpc-client/client/printService");
}
this.addContributionToDeploy("helloworld-jsonrpc");
}
@Override
protected List<String> getContributionsToDeploy()
{
List<String> contributionToDeploy=new ArrayList<String>();
contributionToDeploy.add("helloworld-jsonrpc");
return contributionToDeploy;
}
@Override
public void testSuite() throws BindingProcessorException
{
this.log("Not Implemented yet");
}
}
......@@ -27,15 +27,12 @@
package org.ow2.frascati.remote.introspection.binding.processor;
import java.util.ArrayList;
import java.util.List;
import org.ow2.frascati.remote.introspection.resources.BindingKind;
/**
*
*/
public class RMIPBindingProcessorTest extends BindingProcessorTest
public class RMIBindingProcessorTest extends BindingProcessorTest
{
/**
......@@ -43,16 +40,16 @@ public class RMIPBindingProcessorTest extends BindingProcessorTest
* @param serverInterfacePath
* @param clientInterfacePath
*/
public RMIPBindingProcessorTest()
public RMIBindingProcessorTest()
{
super(BindingKind.RMI, "ServerRMI/server/s","ClientRMI/client/printService");
super(BindingKind.RMI, "ServerRMI/server/s", "ClientRMI/client/printService");
this.addContributionToDeploy("helloworld-rmi");
}
@Override
protected List<String> getContributionsToDeploy()
public void testSuite() throws BindingProcessorException
{
List<String> contributionToDeploy=new ArrayList<String>();
contributionToDeploy.add("helloworld-rmi");
return contributionToDeploy;
this.log("Not Implemented yet");
}
}
......@@ -27,9 +27,6 @@
package org.ow2.frascati.remote.introspection.binding.processor;
import java.util.ArrayList;
import java.util.List;
import org.ow2.frascati.remote.introspection.resources.BindingKind;
/**
......@@ -46,13 +43,12 @@ public class RestBindingProcessorTest extends BindingProcessorTest
public RestBindingProcessorTest()
{
super(BindingKind.REST, "counter-server/server/counter","counter-client/client/counter");
this.addContributionToDeploy("counter");
}
@Override
protected List<String> getContributionsToDeploy()
public void testSuite() throws BindingProcessorException
{
List<String> contributionToDeploy=new ArrayList<String>();
contributionToDeploy.add("counter");
return contributionToDeploy;
this.log("Not Implemented yet");
}
}
......@@ -27,9 +27,6 @@
package org.ow2.frascati.remote.introspection.binding.processor;
import java.util.ArrayList;
import java.util.List;
import org.ow2.frascati.remote.introspection.resources.BindingKind;
/**
......@@ -38,21 +35,16 @@ import org.ow2.frascati.remote.introspection.resources.BindingKind;
public class SCABindingProcessorTest extends BindingProcessorTest
{
/**
* @param bindingKind
* @param serverInterfacePath
* @param clientInterfacePath
*/
public SCABindingProcessorTest()
{
super(BindingKind.SCA, "helloworld-binding-sca/server/server/PrintService","helloworld-binding-sca/client/client/s");
super(BindingKind.SCA, "","helloworld-binding-sca/client/client/s");
this.addContributionToDeploy("helloworld-binding-sca");
}
@Override
protected List<String> getContributionsToDeploy()
public void testSuite() throws BindingProcessorException
{
List<String> contributionToDeploy=new ArrayList<String>();
contributionToDeploy.add("helloworld-binding-sca");
return contributionToDeploy;
this.log("Not Implemented yet");
}
}
......@@ -27,9 +27,6 @@
package org.ow2.frascati.remote.introspection.binding.processor;
import java.util.ArrayList;
import java.util.List;
import org.ow2.frascati.remote.introspection.resources.BindingKind;
/**
......@@ -38,21 +35,15 @@ import org.ow2.frascati.remote.introspection.resources.BindingKind;
public class UPnPBindingProcessorTest extends BindingProcessorTest
{
/**
* @param bindingKind
* @param serverInterfacePath
* @param clientInterfacePath
*/
public UPnPBindingProcessorTest()
{
super(BindingKind.UPNP, "helloworld-device/server/s","helloworld-controlpoint/client/printService");
this.addContributionToDeploy("helloworld-upnp");
}
@Override
protected List<String> getContributionsToDeploy()
public void testSuite() throws BindingProcessorException
{
List<String> contributionToDeploy=new ArrayList<String>();
contributionToDeploy.add("helloworld-upnp");
return contributionToDeploy;
this.log("Not Implemented yet");
}
}
......@@ -27,11 +27,20 @@
package org.ow2.frascati.remote.introspection.binding.processor;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.objectweb.fractal.api.NoSuchInterfaceException;
import org.ow2.frascati.remote.introspection.binding.BindingAttribute;
import org.ow2.frascati.remote.introspection.resources.BindingKind;
/**
......@@ -40,22 +49,82 @@ import org.ow2.frascati.remote.introspection.resources.BindingKind;
public class WSBindingProcessorTest extends BindingProcessorTest
{
/**
* @param bindingKind
* @param serverInterfacePath
* @param clientInterfacePath
*/
public WSBindingProcessorTest()
{
super(BindingKind.WS, "helloworld-ws-server/s","helloworld-ws-client/client/printService");
this.addCompositeToDeploy("helloworld-ws-server", "helloworld-ws-server");
this.addCompositeToDeploy("helloworld-ws-client", "helloworld-ws-client");
}
@Override
protected Map<String,String> getCompositesToDeploy()
public void startTest() throws NoSuchInterfaceException
{
super.startTest();
assertWSDLIsExposed(true, "http://localhost:9000/HelloService?wsdl");
}
@Override
public void testSuite() throws BindingProcessorException
{
this.logEntering("testSuite");
this.removeClientBinding();
this.removeServerBinding();
Map<String,String> serverBindingHints=new HashMap<String, String>();
serverBindingHints.put("uri", "http://localhost:9001/HelloServiceReconfigured");
this.addServerBinding(serverBindingHints);
assertWSDLIsExposed(true,"http://localhost:9001/HelloServiceReconfigured?wsdl");
Map<String, String> clientBindingHints = new HashMap<String, String>();
clientBindingHints.put("uri", "http://localhost:9001/HelloServiceReconfigured");
clientBindingHints.put("wsdlLocation", "http://localhost:9001/HelloServiceReconfigured?wsdl");
clientBindingHints.put("wsdlElement", "http://annotated.helloworld.examples.frascati.ow2.org/#wsdl.port(HelloService/HelloServicePort)");
this.addClientBinding(clientBindingHints);
List<BindingAttribute> serverBindingAttributes = new ArrayList<BindingAttribute>();
BindingAttribute uriBindingAttribute = new BindingAttribute("uri", "http://localhost:9001/HelloServiceReconfiguredAttribute");
serverBindingAttributes.add(uriBindingAttribute);
this.setServerAttribute(serverBindingAttributes);
//FIXME setting wsdl attribute does not work, wsdl is still expose on the previous URL
// assertWSDLIsExposed(false,"http://localhost:9001/HelloServiceReconfigured?wsdl");
// assertWSDLIsExposed(true,"http://localhost:9001/HelloServiceReconfiguredAttribute?wsdl");
List<BindingAttribute> setBindingAttributesToSet=new ArrayList<BindingAttribute>();
BindingAttribute wsdlLocationBindingAttribute=new BindingAttribute("wsdlLocation", "http://localhost:9001/HelloServiceReconfiguredAttribute?wsdl");
setBindingAttributesToSet.add(wsdlLocationBindingAttribute);
}
/**
* Assert assertion an hhtp request on wsdlLocation get a 200 response, ie wsdl is exposed
*
* @param assertion
* @param wsdlLocation URL of the wsdl location
*/
private void assertWSDLIsExposed(boolean assertion, String wsdlLocation)
{
HashMap<String, String> compositesToDeploy=new HashMap<String, String>();
compositesToDeploy.put("helloworld-ws-server", "helloworld-ws-server");
compositesToDeploy.put("helloworld-ws-client", "helloworld-ws-client");
return compositesToDeploy;
URL wsdl = null;
try
{
wsdl = new URL(wsdlLocation);
} catch (MalformedURLException e)
{
fail("assertWSDLExist the provided wsdlLocation : "+wsdlLocation+" is not a valid URL");
}
int responseCode = 404;
try
{
HttpURLConnection huc = (HttpURLConnection)wsdl.openConnection();
huc.setRequestMethod("GET");
huc.connect ();
responseCode=huc.getResponseCode();
} catch (IOException e)
{
fail("assertWSDLExist unable to connect to "+wsdl.getPath());
}
logger.info("GET "+wsdlLocation+" HTTP status "+responseCode);
boolean isResponseCodeOK=HttpURLConnection.HTTP_OK==responseCode;
assertEquals(assertion,isResponseCodeOK);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment