Commit ba45ef06 authored by Gwenael Cattez's avatar Gwenael Cattez

new feature : Generic test for BindingProcessor

Remove propagation for binding on collection interface (to refactor)
Generic tests for SCA, JSONRPC, UPnP
parent fbc619de
......@@ -217,17 +217,16 @@ public interface FractalUtilItf
public Interface findInterfaceById(Component owner, String itfId) throws NoSuchInterfaceException;
//TODO doc
public Interface getServerInterface(Interface itf);
/**
*
* @param itf
* @return
*/
public Object getServerInterface(Interface itf);
//TODO doc
public List<Interface> getClientInterfaces(Interface itf);
//TODO doc
public Interface getDeepestClient(Interface itf);
public List<Object> getClientInterfaces(Interface itf);
//TODO doc
public Interface getHighestServer(Interface itf);
/**
* Get the name of the last interface bound to a collection Reference define by collectionName
......
......@@ -159,6 +159,33 @@
<!-- <classifier>frascati-contribution</classifier> -->
<!-- <overWrite>true</overWrite> -->
<!-- <destFileName>helloworld-jms.zip</destFileName> -->
<!-- </artifactItem> -->
<!-- <artifactItem> -->
<!-- <groupId>org.ow2.frascati.examples</groupId> -->
<!-- <artifactId>helloworld-jsonrpc-contribution</artifactId> -->
<!-- <version>1.5-SNAPSHOT</version> -->
<!-- <type>zip</type> -->
<!-- <classifier>frascati-contribution</classifier> -->
<!-- <overWrite>true</overWrite> -->
<!-- <destFileName>helloworld-jsonrpc.zip</destFileName> -->
<!-- </artifactItem> -->
<!-- <artifactItem> -->
<!-- <groupId>org.ow2.frascati.examples</groupId> -->
<!-- <artifactId>helloworld-upnp-contribution</artifactId> -->
<!-- <version>1.5-SNAPSHOT</version> -->
<!-- <type>zip</type> -->
<!-- <classifier>frascati-contribution</classifier> -->
<!-- <overWrite>true</overWrite> -->
<!-- <destFileName>helloworld-upnp.zip</destFileName> -->
<!-- </artifactItem> -->
<!-- <artifactItem> -->
<!-- <groupId>org.ow2.frascati.examples</groupId> -->
<!-- <artifactId>helloworld-binding-sca</artifactId> -->
<!-- <version>1.5-SNAPSHOT</version> -->
<!-- <type>zip</type> -->
<!-- <classifier>frascati-contribution</classifier> -->
<!-- <overWrite>true</overWrite> -->
<!-- <destFileName>helloworld-binding-sca.zip</destFileName> -->
<!-- </artifactItem> -->
</artifactItems>
</configuration>
......
......@@ -489,28 +489,28 @@ public class BindingManagerImpl implements BindingManagerItf
private Interface propagateUnbind(Interface itf) throws NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException
{
InterfaceType interfaceType=(InterfaceType) itf.getFcItfType();
if(interfaceType.isFcCollectionItf())
{
Interface deepestClientInterface=this.fractalUtil.getDeepestClient(itf);
Interface deepestClientServerInterface=this.fractalUtil.getServerInterface(deepestClientInterface);
org.objectweb.fractal.api.Component deepestClientOwner;
BindingController deepestOwnerBindingController;
while(deepestClientServerInterface!=null)
{
deepestClientOwner=deepestClientInterface.getFcItfOwner();
deepestOwnerBindingController=Fractal.getBindingController(deepestClientOwner);
fractalUtil.stopComponent(deepestClientOwner);
deepestOwnerBindingController.unbindFc(deepestClientInterface.getFcItfName());
logger.info("unbind "+deepestClientInterface.getFcItfName()+" from "+fractalUtil.getComponentName(deepestClientOwner));
fractalUtil.startComponent(deepestClientOwner);
deepestClientInterface=deepestClientServerInterface;
deepestClientServerInterface=fractalUtil.getServerInterface(deepestClientInterface);
}
logger.info(deepestClientInterface.getFcItfName());
return deepestClientInterface;
}
// InterfaceType interfaceType=(InterfaceType) itf.getFcItfType();
// if(interfaceType.isFcCollectionItf())
// {
// Interface deepestClientInterface=this.fractalUtil.getDeepestClient(itf);
// Interface deepestClientServerInterface=(Interface) this.fractalUtil.getServerInterface(deepestClientInterface);
// org.objectweb.fractal.api.Component deepestClientOwner;
// BindingController deepestOwnerBindingController;
//
// while(deepestClientServerInterface!=null)
// {
// deepestClientOwner=deepestClientInterface.getFcItfOwner();
// deepestOwnerBindingController=Fractal.getBindingController(deepestClientOwner);
// fractalUtil.stopComponent(deepestClientOwner);
// deepestOwnerBindingController.unbindFc(deepestClientInterface.getFcItfName());
// logger.info("unbind "+deepestClientInterface.getFcItfName()+" from "+fractalUtil.getComponentName(deepestClientOwner));
// fractalUtil.startComponent(deepestClientOwner);
// deepestClientInterface=deepestClientServerInterface;
// deepestClientServerInterface=(Interface) fractalUtil.getServerInterface(deepestClientInterface);
// }
// logger.info(deepestClientInterface.getFcItfName());
// return deepestClientInterface;
// }
return itf;
}
......
......@@ -538,14 +538,14 @@ public class FractalUtilImpl implements FractalUtilItf
/**
* @see org.ow2.frascati.remote.introspection.util.FractalUtilItf#getClientInterfaces(org.objectweb.fractal.api.Interface)
*/
public List<Interface> getClientInterfaces(Interface itf)
public List<Object> getClientInterfaces(Interface itf)
{
String interfaceName=itf.getFcItfName();
Component owner=itf.getFcItfOwner();
String ownerName=this.getComponentName(owner);
logger.finest("getPromotedInterface owner : "+ownerName+" interface : "+interfaceName);
List<Interface> clientInterfaces=new ArrayList<Interface>();
List<Object> clientInterfaces=new ArrayList<Object>();
List<org.objectweb.fractal.api.Component> children=null;
try
{
......@@ -607,65 +607,37 @@ public class FractalUtilImpl implements FractalUtilItf
/**
* @see org.ow2.frascati.remote.introspection.util.FractalUtilItf#getServerInterface(org.objectweb.fractal.api.Interface)
*/
public Interface getServerInterface(Interface itf)
public Object getServerInterface(Interface itf)
{
logger.fine("getServerInterface " + itf.getFcItfName());
Component owner = itf.getFcItfOwner();
BindingController ownerBindingController = null;
try
{
logger.fine("getServerInterface " + itf.getFcItfName());
Component owner = itf.getFcItfOwner();
BindingController ownerBindingController = Fractal.getBindingController(owner);
Object promoter = ownerBindingController.lookupFc(itf.getFcItfName());
ownerBindingController = Fractal.getBindingController(owner);
if(promoter!=null && promoter instanceof Interface)
{
logger.fine(promoter.getClass().getName()+" instanceof Interface");
Interface promoterInterface=(Interface) promoter;
Component promoterInterfaceOwner=promoterInterface.getFcItfOwner();
logger.fine("owner "+this.getComponentName(promoterInterfaceOwner));
String promoterInterfaceOwnerName=this.getComponentName(promoterInterfaceOwner);
if(promoterInterfaceOwnerName.endsWith("-stub") || promoterInterfaceOwnerName.endsWith("-skeleton") || promoterInterfaceOwnerName.endsWith("-connector"))
{
logger.fine("promoter : "+promoterInterface.getFcItfName());
return promoterInterface;
}
}
}
catch (NoSuchInterfaceException noSuchInterfaceException)
{
logger.fine("Can't get BindingController for owner of interface : "+itf.getFcItfName());
return null;
}
return null;
}
public Interface getDeepestClient(Interface itf)
{
Interface tmpClient=itf;
List<Interface> clientInterfaces=this.getClientInterfaces(tmpClient);
while(!clientInterfaces.isEmpty())
try
{
tmpClient=clientInterfaces.get(0);
clientInterfaces=this.getClientInterfaces(tmpClient);
return ownerBindingController.lookupFc(itf.getFcItfName());
}
return tmpClient;
}
public Interface getHighestServer(Interface itf)
{
Interface server,serverTmp;
server=null;
serverTmp=itf;
while(serverTmp!=null)
catch (NoSuchInterfaceException noSuchInterfaceException)
{
server=serverTmp;
serverTmp=this.getServerInterface(server);
logger.fine("No object bound to interface "+itf.getFcItfName());
return null;
}
return server;
}
/**
* Get the name of the last interface bound to a collection Reference define
* by collectionName i.e collectionName-(highest index found)
......
......@@ -168,7 +168,7 @@ public class IntrospectionTestSuite
/** Helper methods */
public static void deployContribution(String contributionName)
public static StringList deployContribution(String contributionName)
{
String contributionPath=getResourcePath(contributionName+".zip");
......@@ -183,9 +183,10 @@ public class IntrospectionTestSuite
StringList deployedComponents=IntrospectionTestSuite.deployment.deployContribution(contrib);
assertTrue(deployedComponents.getStringList().size()>0);
return deployedComponents;
}
public static void deployComposite(String compositeFinaleName, String compositeName)
public static String deployComposite(String compositeFinaleName, String compositeName)
{
String compositePath=getResourcePath(compositeFinaleName+".jar");
System.out.println(compositePath);
......@@ -201,6 +202,7 @@ public class IntrospectionTestSuite
String deployedComponent=IntrospectionTestSuite.deployment.deployComposite(compositeName,compositeFile);
assertEquals(deployedComponent, compositeName);
return deployedComponent;
}
public static void undeployComposite(String compositePath)
......
......@@ -33,6 +33,7 @@ import static org.junit.Assert.fail;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import javax.ws.rs.WebApplicationException;
......@@ -89,11 +90,12 @@ public class DeploymentTest
String entriesString=deployment.getCompositeEntriesFromJar(compositeString);
String[] entries=entriesString.split(FileUtil.JAR_ENTRIES_SEPARATOR);
assertEquals(5, entries.length);
assertEquals("RunnerMultipleContainer", entries[0]);
assertEquals("RunnerMultipleLevel1", entries[1]);
assertEquals("RunnerMultipleLevel2", entries[2]);
assertEquals("RunnerMultipleTopLevel", entries[3]);
assertEquals("RunnerSimple", entries[4]);
List<String> entriesList=Arrays.asList(entries);
assertEquals(true, entriesList.contains("RunnerMultipleContainer"));
assertEquals(true, entriesList.contains("RunnerMultipleLevel1"));
assertEquals(true, entriesList.contains("RunnerMultipleLevel2"));
assertEquals(true, entriesList.contains("RunnerMultipleTopLevel"));
assertEquals(true, entriesList.contains("RunnerSimple"));
/** Test with invalid parameter*/
try
......
/**
* OW2 FraSCAti
* Copyright (C) 2013 Inria, University of Lille 1
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* Contact: frascati@ow2.org
*
* Author: Gwenael Cattez
*
* Contributor(s):
*
*/
package org.ow2.frascati.remote.introspection.binding.processor;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import junit.framework.TestCase;
import org.junit.Test;
import org.objectweb.fractal.api.Interface;
import org.objectweb.fractal.api.NoSuchInterfaceException;
import org.ow2.frascati.remote.IntrospectionTestSuite;
import org.ow2.frascati.remote.introspection.resources.BindingKind;
import org.ow2.frascati.remote.introspection.stringlist.StringList;
import org.ow2.frascati.remote.introspection.util.FractalUtilItf;
/**
*
*/
public abstract class BindingProcessorTest
{
protected Logger logger=Logger.getLogger(BindingProcessorTest.class.getName());
protected List<String> deployedComposites;
protected BindingKind bindingKind;
protected String serverInterfacePath;
protected String clientInterfacePath;
protected Interface serverInterfaceFc;
protected Object skeltonInterfaceFc;
protected Interface clientInterfaceFc;
protected Object stubInterfaceFc;
public BindingProcessorTest(BindingKind bindingKind, String serverInterfacePath, String clientInterfacePath)
{
this.bindingKind=bindingKind;
this.serverInterfacePath=serverInterfacePath;
this.clientInterfacePath=clientInterfacePath;
}
public void initTest(FractalUtilItf fractalUtil) throws NoSuchInterfaceException
{
logger.info("Init test "+this.getClass().getName());
this.deployedComposites=new ArrayList<String>();
List<String> contributionsToDeploy=this.getContributionsToDeploy();
if(contributionsToDeploy!=null)
{
StringList deployedContributionStringList;
for(String contributionFileName : contributionsToDeploy)
{
deployedContributionStringList=IntrospectionTestSuite.deployContribution(contributionFileName);
this.deployedComposites.addAll(deployedContributionStringList.getStringList());
}
}
Map<String,String> compositesToDeploy=this.getCompositesToDeploy();
if(compositesToDeploy!=null)
{
String deployedComposite;
for(String compositeFileName : compositesToDeploy.keySet())
{
deployedComposite=IntrospectionTestSuite.deployComposite(compositeFileName, compositesToDeploy.get(compositeFileName));
this.deployedComposites.add(deployedComposite);
}
}
this.serverInterfaceFc=fractalUtil.getInterface(this.serverInterfacePath);
assertNotNull(this.serverInterfaceFc);
List<Object> clientInterfaces=fractalUtil.getClientInterfaces(this.serverInterfaceFc);
if(clientInterfaces.size()>0)
{
this.skeltonInterfaceFc=clientInterfaces.get(0);
assertNotNull(skeltonInterfaceFc);
}
this.clientInterfaceFc=fractalUtil.getInterface(this.clientInterfacePath);
assertNotNull(this.clientInterfaceFc);
this.stubInterfaceFc=fractalUtil.getServerInterface(this.clientInterfaceFc);
assertNotNull(this.stubInterfaceFc);
}
protected List<String> getContributionsToDeploy()
{
return new ArrayList<String>();
}
protected Map<String,String> getCompositesToDeploy()
{
return new HashMap<String, String>();
}
public void finishTest()
{
for(String deployedComposite : this.deployedComposites)
{
IntrospectionTestSuite.undeployComposite(deployedComposite);
}
}
public BindingKind getBindingKind()
{
return this.bindingKind;
}
public Interface getServerInterfaceFc()
{
return serverInterfaceFc;
}
public Object getStubInterfaceFc()
{
return stubInterfaceFc;
}
public Interface getClientInterfaceFc()
{
return clientInterfaceFc;
}
public Object getSkeltonInterfaceFc()
{
return skeltonInterfaceFc;
}
}
/**
* OW2 FraSCAti
* Copyright (C) 2013 Inria, University of Lille 1
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* Contact: frascati@ow2.org
*
* Author: Gwenael Cattez
*
* Contributor(s):
*
*/
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 JMSBindingProcessorTest extends BindingProcessorTest
{
/**
* @param bindingKind
* @param serverInterfacePath
* @param clientInterfacePath
*/
public JMSBindingProcessorTest()
{
super(BindingKind.JMS, "Subscriber/sub/messageIn", "Publisher/pub/jmsWire");
}
@Override
protected List<String> getContributionsToDeploy()
{
List<String> contributionToDeploy=new ArrayList<String>();
contributionToDeploy.add("helloworld-jms");
return contributionToDeploy;
}
}
/**
* OW2 FraSCAti
* Copyright (C) 2013 Inria, University of Lille 1
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* Contact: frascati@ow2.org
*
* Author: Gwenael Cattez
*
* Contributor(s):
*
*/
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 JSONRPCBindingProcessorTest extends BindingProcessorTest
{
/**
* @param bindingKind
* @param serverInterfacePath
* @param clientInterfacePath
*/
public JSONRPCBindingProcessorTest()
{
super(BindingKind.JSON_RPC, "helloworld-jsonrpc-server/s","helloworld-jsonrpc-client/client/printService");
}
@Override
protected List<String> getContributionsToDeploy()
{
List<String> contributionToDeploy=new ArrayList<String>();
contributionToDeploy.add("helloworld-jsonrpc");
return contributionToDeploy;
}
}
/**
* OW2 FraSCAti
* Copyright (C) 2013 Inria, University of Lille 1
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* Contact: frascati@ow2.org
*
* Author: Gwenael Cattez
*
* Contributor(s):
*
*/
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 RESTBindingProcessorTest extends BindingProcessorTest
{
/**
* @param bindingKind
* @param serverInterfacePath
* @param clientInterfacePath
*/
public RESTBindingProcessorTest()
{
super(BindingKind.REST, "counter-server/server/counter","counter-client/client/counter");
}
@Override
protected List<String> getContributionsToDeploy()
{
List<String> contributionToDeploy=new ArrayList<String>();
contributionToDeploy.add("counter");
return contributionToDeploy;
}
}
/**
* OW2 FraSCAti
* Copyright (C) 2013 Inria, University of Lille 1
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*