Commit 843accfa authored by Gwenael Cattez's avatar Gwenael Cattez

Add JUnit test to home automation modules

parent c2009817
/**
* OW2 FraSCAti Assembly Factory
* Copyright (C) 2008-2012 Inria, University of Lille
*
* 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: Gwénaël Cattez
*
* Contributor(s):
*
*/
package org.ow2.frascati.switchTest;
import org.junit.Test;
import org.ow2.frascati.demo.common.homeautomation.actuator.OnOffActuator;
import org.ow2.frascati.examples.test.FraSCAtiTestCase;
/**
*
*/
public class SwitchTestCase extends FraSCAtiTestCase
{
/**
* @see org.ow2.frascati.examples.test.FraSCAtiTestCase#getComposite()
*/
@Override
public String getComposite()
{
return "switch";
}
@Test
public final void testInvoke()
{
OnOffActuator switcher=getService(OnOffActuator.class, "onoff-actuator");
// switcher.acturatorOn();
// switcher.acturatorOff();
}
}
......@@ -49,7 +49,7 @@
<groupId>org.ow2.frascati.demo</groupId>
<artifactId>common-homeautomation-interface</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
......@@ -86,7 +86,8 @@ public class ZibaseMockImpl implements ZibasePortType
*/
public String invokeModule(String idModule, String function, String protocol, String dim)
{
LOG.info("[Zibase Mock] mock request : invoke function "+function+" on module "+idModule+" by protocol "+protocol+" (dim : "+dim+" )");
return "";
String res="[Zibase Mock] mock request : invoke function "+function+" on module "+idModule+" by protocol "+protocol+" (dim : "+dim+" )";
LOG.info(res);
return res;
}
}
/**
* OW2 FraSCAti Assembly Factory
* Copyright (C) 2008-2012 Inria, University of Lille
*
* 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: Gwénaël Cattez
*
* Contributor(s):
*
*/
package org.ow2.frascati.zibase.mock;
import org.junit.Test;
import org.ow2.frascati.demo.zibase.ZibasePortType;
import org.ow2.frascati.examples.test.FraSCAtiTestCase;
import static org.junit.Assert.*;
/**
*
*/
public class ZibaseMockTestCase extends FraSCAtiTestCase
{
/**
* @see org.ow2.frascati.examples.test.FraSCAtiTestCase#getComposite()
*/
@Override
public String getComposite()
{
return "zibase-mock";
}
@Test
public final void testService()
{
ZibasePortType zibaseMock=getService(ZibasePortType.class, "invoke");
String res=zibaseMock.invokeModule("A1", "1", "0", null);
assertEquals("[Zibase Mock] mock request : invoke function 1 on module A1 by protocol 0 (dim : null )", res);
}
}
......@@ -126,7 +126,6 @@ public class ZibaseImpl implements Zibase
@Init
public void updateZibase() throws WrongZibaseInitialisationException, JDOMException, IOException
{
System.out.println("id '"+zibaseID+"' token '"+zibaseToken+"'");
if(this.zibaseID==null || this.zibaseToken==null) return;
MultivaluedMap<String, String> params=getAuthenticationParams();
......@@ -155,8 +154,6 @@ public class ZibaseImpl implements Zibase
macro=new ZibaseMacroElementImpl(macroXML);
addElement(macro);
}
System.out.println(elements);
}
/**
......@@ -174,7 +171,6 @@ public class ZibaseImpl implements Zibase
String actionModule=getActionModuleParam(function, protocol, dim);
params.add("actionModule", actionModule);
System.out.println(zibaseActionResource.queryParams(params).getURI());
ClientResponse response=zibaseActionResource.queryParams(params).post(ClientResponse.class);
if(response.getClientResponseStatus()!=ClientResponse.Status.OK) throw new WrongZibaseInitialisationException(this.zibaseID, this.zibaseToken);
......
/**
* OW2 FraSCAti Assembly Factory
* Copyright (C) 2008-2012 Inria, University of Lille
*
* 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: Gwénaël Cattez
*
* Contributor(s):
*
*/
package org.ow2.frascati.zibase;
import org.junit.Test;
import org.ow2.frascati.demo.zibase.Zibase;
import org.ow2.frascati.demo.zibase.exceptions.WrongZibaseInitialisationException;
import org.ow2.frascati.examples.test.FraSCAtiTestCase;
/**
*
*/
public class ZibaseTestCase extends FraSCAtiTestCase
{
/**
* @see org.ow2.frascati.examples.test.FraSCAtiTestCase#getComposite()
*/
@Override
public String getComposite()
{
return "zibase";
}
@Test
public final void testInvoke()
{
Zibase zibase=getService(Zibase.class, "invoke");
zibase.invokeModule("A6", "1", "6", null);
zibase.invokeModule("A6", "0", "6", null);
}
@Test(expected=WrongZibaseInitialisationException.class)
public final void testBadModuleId()
{
Zibase zibase=getService(Zibase.class, "invoke");
zibase.invokeModule("BAD", "1", "6", null);
}
}
......@@ -41,7 +41,7 @@
<module>common-homeautomation-zibase</module>
<module>common-homeautomation-zibase-mock</module>
</modules>
<build>
<plugins>
<plugin>
......@@ -56,6 +56,11 @@
<groupId>org.ow2.frascati</groupId>
<artifactId>frascati-interface-wsdl</artifactId>
</dependency>
<dependency>
<groupId>org.ow2.frascati.examples.test</groupId>
<artifactId>frascati-test</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
......@@ -301,6 +301,13 @@
<version>${jdom.version}</version>
</dependency>
<dependency>
<groupId>org.ow2.frascati.examples.test</groupId>
<artifactId>frascati-test</artifactId>
<version>${frascati.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
......
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