Commit ff910e52 authored by Gwenael Cattez's avatar Gwenael Cattez

Add JSONRPC, REST, SCA and UPNP Binding processors

parent 7e2027c7
......@@ -106,6 +106,7 @@ public interface RemoteScaDomain
@POST
@Path("/port/{id:.*}")
@Consumes("application/x-www-form-urlencoded")
@Produces({"text/plain"})
public String invokeMethod(@PathParam("id") String fullInterfaceId ,MultivaluedMap<String, String> params);
......
......@@ -101,6 +101,7 @@
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
......@@ -208,6 +209,13 @@
<type>jar</type>
<destFileName>helloworld-ws-client.jar</destFileName>
</artifactItem>
<artifactItem>
<groupId>org.ow2.frascati.examples</groupId>
<artifactId>helloworld-annotations</artifactId>
<version>1.5-SNAPSHOT</version>
<type>jar</type>
<destFileName>helloworld-annotated.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
......@@ -314,6 +322,13 @@
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.ow2.frascati.mojo</groupId>
<artifactId>frascati-contribution-plugin</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
......@@ -114,11 +114,10 @@ public class DeploymentImpl implements Deployment
public String deployComposite(String compositeName, String encodedComposite)
{
File destFile = null;
JarFile jarFile = null;
try
{
destFile = FileUtil.decodeFile(encodedComposite, "jar");
jarFile = new JarFile(destFile);
new JarFile(destFile);
}
catch (Base64Exception b64e)
{
......
......@@ -329,7 +329,7 @@ public class RemoteScaDomainImpl implements RemoteScaDomain
throw new MyWebApplicationException(bpte);
}
String invocationResponse;
String invocationResponse=null;
try
{
Object invokationReturn = method.invoke(itf, arguments);
......
......@@ -30,7 +30,6 @@ package org.ow2.frascati.remote;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.File;
......@@ -73,7 +72,6 @@ import org.ow2.frascati.util.FrascatiException;
*/
@RunWith(Suite.class)
@SuiteClasses({DeploymentTest.class, FractalUtilTest.class,SCAModelUtilTest.class,BindingManagerTest.class,ResourceUtilTest.class})
//@SuiteClasses({ResourceUtilTest.class})
public class IntrospectionTestSuite
{
/** REST binding URI */
......@@ -162,39 +160,42 @@ public class IntrospectionTestSuite
return bindingManager;
}
public static String getResourcePath(String resourceName)
public static File getResource(String resourceName)
{
return RESOURCES_FOLDER+resourceName;
String resourcePath=RESOURCES_FOLDER+resourceName;
File resource=new File(resourcePath);
if(!resource.exists())
{
resourcePath="src/test/resources/"+resourceName;
resource=new File(resourcePath);
}
return resource;
}
/** Helper methods */
public static StringList deployContribution(String contributionName)
{
//TODO remove comment when contribution file will be imported from maven repo
// String contributionPath=getResourcePath(contributionName+".zip");
String contributionPath="src/test/resources/"+contributionName+".zip";
File contribution=getResource(contributionName+".zip");
String contrib = null;
try
{
contrib = FileUtil.getStringFromFile(new File(contributionPath));
contrib = FileUtil.getStringFromFile(contribution);
} catch (IOException e)
{
fail("Cannot read the contribution "+contributionName);
}
StringList deployedComponents=IntrospectionTestSuite.deployment.deployContribution(contrib);
assertTrue(deployedComponents.getStringList().size()>0);
return deployedComponents;
}
public static String deployComposite(String compositeFinaleName, String compositeName)
{
String compositePath=getResourcePath(compositeFinaleName+".jar");
File composite=getResource(compositeFinaleName+".jar");
String compositeFile = null;
try
{
compositeFile = FileUtil.getStringFromFile(new File(compositePath));
compositeFile = FileUtil.getStringFromFile(composite);
}
catch (IOException e)
{
......
......@@ -63,20 +63,20 @@ public class DeploymentTest
deployment=IntrospectionTestSuite.getDeployment();
String contributionName="helloworld-multiple-reference.zip";
String contributionPath=IntrospectionTestSuite.getResourcePath(contributionName);
File contributionFile=IntrospectionTestSuite.getResource(contributionName);
try
{
contributionString = FileUtil.getStringFromFile(new File(contributionPath));
contributionString = FileUtil.getStringFromFile(contributionFile);
} catch (IOException e)
{
fail("Cannot read the contribution "+contributionName);
}
String compositeName="helloworld-multiple-reference.jar";
String compositePath=IntrospectionTestSuite.getResourcePath(compositeName);
File compositeFile=IntrospectionTestSuite.getResource(compositeName);
try
{
compositeString = FileUtil.getStringFromFile(new File(compositePath));
compositeString = FileUtil.getStringFromFile(compositeFile);
}
catch (IOException e)
{
......
......@@ -31,11 +31,16 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import java.io.IOException;
import org.jdom.JDOMException;
import org.junit.BeforeClass;
import org.junit.Test;
import org.objectweb.fractal.api.Interface;
import org.objectweb.fractal.api.NoSuchInterfaceException;
import org.objectweb.fractal.api.control.IllegalLifeCycleException;
import org.ow2.frascati.remote.IntrospectionTestSuite;
import org.ow2.frascati.remote.introspection.binding.exception.NoBindingKindException;
import org.ow2.frascati.remote.introspection.binding.exception.UnsupportedBindingComponentException;
import org.ow2.frascati.remote.introspection.binding.exception.UnsupportedBindingException;
import org.ow2.frascati.remote.introspection.binding.processor.BindingProcessorException;
......@@ -148,7 +153,7 @@ public class BindingManagerTest
}
@Test
public void jsonrpcBindingProcessor() throws NoSuchInterfaceException, UnsupportedBindingComponentException, UnsupportedBindingException, BindingProcessorException
public void jsonrpcBindingProcessor() throws NoSuchInterfaceException, UnsupportedBindingComponentException, UnsupportedBindingException, BindingProcessorException, IllegalLifeCycleException, NoBindingKindException
{
JSONRPCBindingProcessorTest jsonrpcBindingProcessorTest=new JSONRPCBindingProcessorTest();
jsonrpcBindingProcessorTest.startTest();
......@@ -160,7 +165,7 @@ public class BindingManagerTest
}
@Test
public void restBindingProcessor() throws NoSuchInterfaceException, UnsupportedBindingComponentException, UnsupportedBindingException, BindingProcessorException
public void restBindingProcessor() throws NoSuchInterfaceException, UnsupportedBindingComponentException, UnsupportedBindingException, BindingProcessorException, IllegalLifeCycleException, NoBindingKindException
{
RestBindingProcessorTest restBindingProcessorTest=new RestBindingProcessorTest();
restBindingProcessorTest.startTest();
......@@ -171,20 +176,21 @@ public class BindingManagerTest
restBindingProcessorTest.finishTest();
}
// @Test
// public void rmiBindingProcessor() throws NoSuchInterfaceException, UnsupportedBindingComponentException, UnsupportedBindingException, BindingProcessorException
// {
// RMIBindingProcessorTest rmiBindingProcessorTest=new RMIBindingProcessorTest();
// rmiBindingProcessorTest.startTest();
// this.getBindinProcessor(rmiBindingProcessorTest);
// this.getClientBindingBundle(rmiBindingProcessorTest);
// //TODO RMI server is not proceed
// rmiBindingProcessorTest.testSuite();
// rmiBindingProcessorTest.finishTest();
// }
//FIXME
//@Test
public void rmiBindingProcessor() throws NoSuchInterfaceException, UnsupportedBindingComponentException, UnsupportedBindingException, BindingProcessorException
{
RMIBindingProcessorTest rmiBindingProcessorTest=new RMIBindingProcessorTest();
rmiBindingProcessorTest.startTest();
this.getBindinProcessor(rmiBindingProcessorTest);
this.getClientBindingBundle(rmiBindingProcessorTest);
//FIXME RMI server is not proceed
rmiBindingProcessorTest.testSuite();
rmiBindingProcessorTest.finishTest();
}
@Test
public void scaBindingProcessor() throws NoSuchInterfaceException, UnsupportedBindingComponentException, UnsupportedBindingException, BindingProcessorException
public void scaBindingProcessor() throws NoSuchInterfaceException, UnsupportedBindingComponentException, UnsupportedBindingException, BindingProcessorException, IllegalLifeCycleException, NoBindingKindException, IOException, JDOMException
{
SCABindingProcessorTest scaBindingProcessorTest=new SCABindingProcessorTest();
scaBindingProcessorTest.startTest();
......@@ -208,7 +214,7 @@ public class BindingManagerTest
}
@Test
public void wsBindingProcessor() throws NoSuchInterfaceException, UnsupportedBindingComponentException, UnsupportedBindingException, BindingProcessorException
public void wsBindingProcessor() throws NoSuchInterfaceException, UnsupportedBindingComponentException, UnsupportedBindingException, BindingProcessorException, IllegalLifeCycleException, NoBindingKindException
{
WSBindingProcessorTest wsBindingProcessorTest=new WSBindingProcessorTest();
wsBindingProcessorTest.startTest();
......
......@@ -27,6 +27,14 @@
package org.ow2.frascati.remote.introspection.binding.processor;
import java.util.HashMap;
import java.util.Map;
import org.objectweb.fractal.api.NoSuchInterfaceException;
import org.objectweb.fractal.api.control.IllegalLifeCycleException;
import org.ow2.frascati.remote.introspection.binding.exception.NoBindingKindException;
import org.ow2.frascati.remote.introspection.binding.exception.UnsupportedBindingComponentException;
import org.ow2.frascati.remote.introspection.binding.exception.UnsupportedBindingException;
import org.ow2.frascati.remote.introspection.resources.BindingKind;
/**
......@@ -42,8 +50,19 @@ public class JSONRPCBindingProcessorTest extends BindingProcessorTest
}
@Override
public void testSuite() throws BindingProcessorException
public void testSuite() throws BindingProcessorException, NoSuchInterfaceException, IllegalLifeCycleException, UnsupportedBindingComponentException, NoBindingKindException, UnsupportedBindingException
{
this.log("Not Implemented yet");
this.invokeClient("print", this.getClass().getName());
this.removeClientBinding();
this.removeServerBinding();
Map<String,String> serverBindingHints=new HashMap<String, String>();
serverBindingHints.put("uri", "http://localhost:9399/JSON-RPC/HelloServiceReconfigured");
this.addServerBinding(serverBindingHints);
Map<String, String> clientBindingHints = new HashMap<String, String>();
clientBindingHints.put("uri", "http://localhost:9399/JSON-RPC/HelloServiceReconfigured");
this.addClientBinding(clientBindingHints);
this.invokeClient("print", this.getClass().getName());
}
}
......@@ -27,6 +27,19 @@
package org.ow2.frascati.remote.introspection.binding.processor;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.junit.Assert.*;
import org.objectweb.fractal.api.NoSuchInterfaceException;
import org.objectweb.fractal.api.control.IllegalLifeCycleException;
import org.ow2.frascati.remote.introspection.binding.BindingAttribute;
import org.ow2.frascati.remote.introspection.binding.exception.NoBindingKindException;
import org.ow2.frascati.remote.introspection.binding.exception.UnsupportedBindingComponentException;
import org.ow2.frascati.remote.introspection.binding.exception.UnsupportedBindingException;
import org.ow2.frascati.remote.introspection.resources.BindingKind;
/**
......@@ -35,11 +48,6 @@ import org.ow2.frascati.remote.introspection.resources.BindingKind;
public class RestBindingProcessorTest extends BindingProcessorTest
{
/**
* @param bindingKind
* @param serverInterfacePath
* @param clientInterfacePath
*/
public RestBindingProcessorTest()
{
super(BindingKind.REST, "counter-server/server/counter","counter-client/client/counter");
......@@ -47,8 +55,53 @@ public class RestBindingProcessorTest extends BindingProcessorTest
}
@Override
public void testSuite() throws BindingProcessorException
public void testSuite() throws BindingProcessorException, NoSuchInterfaceException, IllegalLifeCycleException, UnsupportedBindingComponentException, NoBindingKindException, UnsupportedBindingException
{
this.logEntering("testSuite");
testCounter();
this.removeClientBinding();
this.removeServerBinding();
Map<String,String> serverBindingHints=new HashMap<String, String>();
serverBindingHints.put("uri", "http://localhost:9299/CounterServiceReconfigured");
this.addServerBinding(serverBindingHints);
Map<String, String> clientBindingHints = new HashMap<String, String>();
clientBindingHints.put("uri", "http://localhost:9299/CounterServiceReconfigured");
this.addClientBinding(clientBindingHints);
testCounter();
List<BindingAttribute> serverBindingAttributes = new ArrayList<BindingAttribute>();
BindingAttribute uriBindingAttribute = new BindingAttribute("uri", "http://localhost:9299/CounterServiceReconfiguredAttribute");
serverBindingAttributes.add(uriBindingAttribute);
this.setServerAttribute(serverBindingAttributes);
List<BindingAttribute> setBindingAttributesToSet=new ArrayList<BindingAttribute>();
setBindingAttributesToSet.add(uriBindingAttribute);
this.setClientAttribute(setBindingAttributesToSet);
testCounter();
}
private void testCounter()
{
this.log("Not Implemented yet");
String response=this.invokeClient("getValue");
assertNotNull(response);
assertEquals("0", response);
this.invokeClient("increment","3");
response=this.invokeClient("getValue");
assertNotNull(response);
assertEquals("3", response);
this.invokeClient("decrement","5");
response=this.invokeClient("getValue");
assertNotNull(response);
assertEquals("-2", response);
this.invokeClient("resetIt");
response=this.invokeClient("getValue");
assertNotNull(response);
assertEquals("0", response);
}
}
......@@ -27,24 +27,40 @@
package org.ow2.frascati.remote.introspection.binding.processor;
import org.ow2.frascati.remote.introspection.resources.BindingKind;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import org.jdom.JDOMException;
import org.objectweb.fractal.api.NoSuchInterfaceException;
import org.objectweb.fractal.api.control.IllegalLifeCycleException;
import org.ow2.frascati.remote.introspection.binding.exception.NoBindingKindException;
import org.ow2.frascati.remote.introspection.binding.exception.UnsupportedBindingComponentException;
import org.ow2.frascati.remote.introspection.binding.exception.UnsupportedBindingException;
import org.ow2.frascati.remote.introspection.resources.BindingKind;
/**
*
*/
public class SCABindingProcessorTest extends BindingProcessorTest
{
public SCABindingProcessorTest()
public SCABindingProcessorTest() throws IOException, JDOMException
{
super(BindingKind.SCA, "","helloworld-binding-sca/client/client/s");
this.addContributionToDeploy("helloworld-binding-sca");
}
@Override
public void testSuite() throws BindingProcessorException
public void testSuite() throws BindingProcessorException, NoSuchInterfaceException, IllegalLifeCycleException, UnsupportedBindingComponentException, NoBindingKindException, UnsupportedBindingException
{
this.log("Not Implemented yet");
this.logEntering("testSuite");
this.invokeClient("print", this.getClass().getName());
this.removeClientBinding();
Map<String,String> clientBindingHints=new HashMap<String, String>();
clientBindingHints.put("uri", "helloworld-binding-sca/server/server/PrintService");
this.addClientBinding(clientBindingHints);
this.invokeClient("print", this.getClass().getName());
}
}
......@@ -44,6 +44,6 @@ public class UPnPBindingProcessorTest extends BindingProcessorTest
@Override
public void testSuite() throws BindingProcessorException
{
this.log("Not Implemented yet");
this.invokeClient("print", this.getClass().getName());
}
}
......@@ -40,7 +40,11 @@ import java.util.List;
import java.util.Map;
import org.objectweb.fractal.api.NoSuchInterfaceException;
import org.objectweb.fractal.api.control.IllegalLifeCycleException;
import org.ow2.frascati.remote.introspection.binding.BindingAttribute;
import org.ow2.frascati.remote.introspection.binding.exception.NoBindingKindException;
import org.ow2.frascati.remote.introspection.binding.exception.UnsupportedBindingComponentException;
import org.ow2.frascati.remote.introspection.binding.exception.UnsupportedBindingException;
import org.ow2.frascati.remote.introspection.resources.BindingKind;
/**
......@@ -64,9 +68,10 @@ public class WSBindingProcessorTest extends BindingProcessorTest
}
@Override
public void testSuite() throws BindingProcessorException
public void testSuite() throws BindingProcessorException,NoSuchInterfaceException, IllegalLifeCycleException, UnsupportedBindingComponentException, NoBindingKindException, UnsupportedBindingException
{
this.logEntering("testSuite");
this.invokeClient("print", this.getClass().getName());
this.removeClientBinding();
this.removeServerBinding();
......@@ -80,6 +85,7 @@ public class WSBindingProcessorTest extends BindingProcessorTest
clientBindingHints.put("wsdlLocation", "http://localhost:9299/HelloServiceReconfigured?wsdl");
clientBindingHints.put("wsdlElement", "http://annotated.helloworld.examples.frascati.ow2.org/#wsdl.port(HelloService/HelloServicePort)");
this.addClientBinding(clientBindingHints);
this.invokeClient("print", this.getClass().getName());
List<BindingAttribute> serverBindingAttributes = new ArrayList<BindingAttribute>();
BindingAttribute uriBindingAttribute = new BindingAttribute("uri", "http://localhost:9299/HelloServiceReconfiguredAttribute");
......@@ -92,6 +98,10 @@ public class WSBindingProcessorTest extends BindingProcessorTest
List<BindingAttribute> setBindingAttributesToSet=new ArrayList<BindingAttribute>();
BindingAttribute wsdlLocationBindingAttribute=new BindingAttribute("wsdlLocation", "http://localhost:9299/HelloServiceReconfiguredAttribute?wsdl");
setBindingAttributesToSet.add(wsdlLocationBindingAttribute);
this.setClientAttribute(setBindingAttributesToSet);
this.invokeClient("print", this.getClass().getName());
//the client still works so the setAttribute is not proceed
}
/**
......
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