Commit 2884d18c authored by Gwenael Cattez's avatar Gwenael Cattez

Add widget + REST example

parent 69ce18bf
......@@ -45,24 +45,39 @@
<composite.file>helloworld-widget</composite.file>
</properties>
<dependencies>
<dependency>
<groupId>org.ow2.frascati</groupId>
<artifactId>frascati-implementation-widget</artifactId>
<version>${project.version}</version>
</dependency>
<dependencies>
<dependency>
<groupId>org.ow2.frascati</groupId>
<artifactId>frascati-implementation-widget</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.ow2.frascati</groupId>
<artifactId>frascati-binding-http</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.ow2.frascati</groupId>
<artifactId>frascati-binding-http</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.ow2.frascati</groupId>
<artifactId>frascati-binding-ws</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<dependency>
<groupId>org.ow2.frascati</groupId>
<artifactId>frascati-binding-ws</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.ow2.frascati</groupId>
<artifactId>frascati-binding-rest</artifactId>
<version>${project.version}</version>
</dependency>
<!-- OW2 FraSCAti Remote Management. -->
<dependency>
<groupId>org.ow2.frascati</groupId>
<artifactId>frascati-introspection-impl</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
......@@ -26,7 +26,13 @@
*/
package org.ow2.frascati.examples.helloworld.widget;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
public interface SayHello
{
String sayHello(String msg);
@POST
@Path("/saylHello/{msg}")
String sayHello( @PathParam("msg")String msg);
}
<?xml version="1.0" encoding="UTF-8"?>
<!-- OW2 FraSCAti Examples: HelloWorld Widget -->
<!-- Copyright (C) 2012 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: Philippe Merle -->
<!-- -->
<!-- Contributor(s): -->
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
xmlns:web="http://frascati.ow2.org/xmlns/web/1.0"
xmlns:frascati="http://frascati.ow2.org/xmlns/sca/1.1"
name="helloworld-rest-widget">
<service name="SayHelloRest" promote="SayHelloRest/SayHelloRest">
<frascati:binding.rest uri="/SayHelloRest"/>
</service>
<component name="SayHelloRest">
<implementation.java class="org.ow2.frascati.examples.helloworld.widget.SayHelloImpl" />
<service name="SayHelloRest"/>
</component>
<component name="Widget">
<web:implementation.widget location="widget" />
<service name="Resource">
<tuscany:binding.http uri="/SayHelloRestWidget"/>
</service>
<reference name="sayHelloRest" target="SayHelloRest/SayHelloRest"/>
</component>
</composite>
<!-- OW2 FraSCAti Examples: HelloWorld Widget -->
<!-- Copyright (C) 2012 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: Philippe Merle -->
<!-- -->
<!-- Contributor(s): -->
<html>
<head>
<link rel="shortcut icon" type="image/png" href="./images/icon.png">
<title>OW2 FraSCAti HelloWorld Widget Example</title>
<style type="text/css">
.yui3-panel {
outline: none;
}
.yui3-panel #panelContent {
-webkit-box-shadow: 0px 0px 2px black;
-moz-box-shadow: 0px 0px 2px black;
box-shadow: 0px 0px 2px black;
}
.yui3-panel #panelContent .yui3-widget-hd {
font-weight: bold;
padding: 5px;
text-align: center;
}
#panelContent .yui3-widget-bd {
padding: 15px;
background: white;
text-align: center;
}
.yui3-skin-sam .yui3-widget-mask {
background-color: #223460;
opacity: 0.9;
}
</style>
<script src="http://yui.yahooapis.com/3.9.1/build/yui/yui-min.js"></script>
<script type="text/javascript">
YUI().use('panel', 'transition', function (Y)
{
var panel = new Y.Panel({
srcNode: '#panelContent',
width : 330,
zIndex : 5,
close: t,
draggable: true,
modal : false,
visible: false,
contained : true,
});
panel.render();
panel.centered();
var bb = panel.get('boundingBox');
// bb.transition({
// });
panel.show();
});
</script>
</head>
<body class="yui3-skin-sam">
<div id="panelContent">
<div class="yui3-widget-hd">
Showing an animated panel
</div>
<div class="yui3-widget-bd">
<p>Making panels animate is easy with the "transition" module!</p>
</div>
</div>
</body>
</html>
<html>
<head>
<link rel="shortcut icon" type="image/png" href="./images/icon.png">
<title>OW2 FraSCAti HelloWorld Widget Example</title>
<script src="http://yui.yahooapis.com/3.9.1/build/yui/yui-min.js"></script>
<script type="text/javascript" src="Widget.js"></script>
<style type="text/css">
.yui3-panel {
outline: none;
}
.yui3-panel #panelContent {
-webkit-box-shadow: 0px 0px 2px black;
-moz-box-shadow: 0px 0px 2px black;
box-shadow: 0px 0px 2px black;
}
.yui3-panel #panelContent .yui3-widget-hd
{
font-weight: bold;
padding: 5px;
text-align: center;
}
#panelContent .yui3-widget-bd
{
padding: 15px;
background: white;
text-align: center;
}
a.footer-image {
width : 100px;
height : 35px;
margin : 0 10 0 10;
vertical-align: middle;
}
</style>
<script type="text/javascript">
function sayHelloResponse(response)
{
document.getElementById('sayHelloResponse').firstChild.nodeValue = response.getReturn();
}
<!-- This is the function called for an error. -->
function sayHelloError(error)
{
alert('error ' + error);
}
<!-- This function is invoked from the button press to run the service. -->
function invokeSayHello(msg)
{
document.getElementById('sayHelloResponse').firstChild.nodeValue = " - pending - ";
sayHello.sayHello(sayHelloResponse, sayHelloError, msg);
}
YUI({ skin: 'night' }).use('panel', 'transition', function (Y)
{
var panel = new Y.Panel({
srcNode: '#panelContent',
width : 500,
height : 300,
// visible: true,
render : true,
centered: true
});
// var bb = panel.get('boundingBox');
// bb.set("opacity",0);
panel.set("opacity",0);
// bb.transition({
// duration : 1,
// easing: 'ease-out',
// opacity: 1
// })
});
</script>
</head>
<body class="yui3-skin-night">
<div id="panelContent" class="yui3-widget-loading">
<div class="yui3-widget-hd">OW2 FraSCAti HelloWorld Widget Example</div>
<div class="yui3-widget-bd">
<form>
<div>
<table>
<tr>
<td>Run sayHello</td>
<td><input type="button" value="invoke" name="sayHello"
onClick="invokeSayHello(this.form.message.value)"></td>
<td><input type="text" value="" name="message"></td>
</tr>
<tr>
<td>sayHello response</td>
<td><span id='sayHelloResponse'>- not yet invoked -</span></td>
</tr>
</table>
</div>
</form>
</div>
<div class="yui3-widget-ft">
<a href="http://adam.lille.inria.fr" class="footer-image">
<img src="http://adam.lille.inria.fr/uploads/Adam/ADAM_logo_web2011.png" title="ADAM" alt="ADAM "/>
</a>
<a href="http://www.inria.fr/en/" class="footer-image">
<img src="http://www.inria.fr/extension/site_inria/design/site_inria/images/logos/logo_INRIA.png" title="Inria" alt="Inria" width="100" height="35"/>
</a>
<a href="http://www.univ-lille1.fr/home/" class="footer-image">
<img src="http://www.univ-lille1.fr/digitalAssets/1/1742_Lille1.jpg" title="University of Lille 1" alt="University of Lille 1" alt="Inria" width="100" height="35"/>
</a>
2013 &copy;
</div>
</div>
</body>
</html>
\ No newline at end of file
......@@ -26,17 +26,57 @@
*/
package org.ow2.frascati.examples.helloworld.widget.test;
import static org.junit.Assert.assertNotNull;
import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
import org.junit.BeforeClass;
import org.junit.Test;
import org.ow2.frascati.test.FraSCAtiTestCase;
import org.objectweb.fractal.api.Component;
import org.ow2.frascati.FraSCAti;
import org.ow2.frascati.examples.helloworld.widget.SayHello;
import org.ow2.frascati.remote.introspection.RemoteScaDomain;
import org.ow2.frascati.test.util.FraSCAtiTestUtils;
import org.ow2.frascati.util.FrascatiException;
public class HelloworldTestCase
extends FraSCAtiTestCase
{
@Test
public final void testService()
{
SayHello sayHello = getService(SayHello.class, "SayHello");
sayHello.sayHello("Philippe");
}
private static FraSCAti frascati;
/** The Frascati Domain */
private static RemoteScaDomain domain;
private static Component helloworldWidgetComponent;
@BeforeClass
public static void beforeClass() throws FrascatiException
{
System.setProperty("org.ow2.frascati.bootstrap", "org.ow2.frascati.bootstrap.FraSCAtiJDTRest");
frascati = FraSCAti.newFraSCAti();
assertNotNull(frascati);
String domainURI = FraSCAtiTestUtils.completeBindingURI("/introspection");
domain = JAXRSClientFactory.create(domainURI, RemoteScaDomain.class);
helloworldWidgetComponent = frascati.getComposite("helloworld-widget");
assertNotNull(helloworldWidgetComponent);
Component helloworldRESTWidgetComponent = frascati.getComposite("helloworld-rest-widget");
assertNotNull(helloworldRESTWidgetComponent);
}
// @Test
public final void testWidgetService() throws FrascatiException
{
SayHello sayHello = frascati.getService(helloworldWidgetComponent, "SayHello", SayHello.class);
sayHello.sayHello("Philippe");
}
@Test
public final void testWidgetRestService()
{
String widgetRestServiceURI = FraSCAtiTestUtils.completeBindingURI("/SayHelloRest");
FraSCAtiTestUtils.assertWADLExist(true, widgetRestServiceURI);
domain.stopComponent("/helloworld-rest-widget");
FraSCAtiTestUtils.assertWADLExist(false, widgetRestServiceURI);
domain.startComponent("/helloworld-rest-widget");
FraSCAtiTestUtils.assertWADLExist(true, widgetRestServiceURI);
}
}
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