Commit 59f7b5d1 authored by Christophe Demarey's avatar Christophe Demarey

Add tests and doc.

parent e1dbe7b6
......@@ -286,6 +286,11 @@ Success (took 1 ms).</programlisting>
nodes representing their direct SCA sub-component</para>
</listitem>
<listitem>
<para>scaparent labels arcs which connect component nodes to the
nodes representing their direct parents (if any)</para>
</listitem>
<listitem>
<para>scaservice labels arcs which connect component nodes to the
nodes representing its SCA services</para>
......@@ -329,7 +334,12 @@ Success (took 1 ms).</programlisting>
<programlisting>FScript&gt; $c/scachild::*
=&gt; a node-set with 2 element(s):
#&lt;scacomponent: client&gt; #&lt;scacomponent: server&gt;</programlisting>
#&lt;scacomponent: client&gt; #&lt;scacomponent: server&gt;
FScript&gt; client = $c/scachild::client;
=&gt; a node-set with 1 element(s):
#&lt;scacomponent: client&gt;
Success (took 1 ms).</programlisting>
<para>The expression $c/scachild::* is our first example of an actual
path expression. It selects all the (direct) children of component
......@@ -342,6 +352,19 @@ Success (took 1 ms).</programlisting>
HelloWorld example.”).</para>
</section>
<section>
<title>Parent</title>
<programlisting>FScript&gt; $client/scaparent::*
=&gt; a node-set with 2 element(s):
#&lt;scacomponent: helloworld-rmi-standalone&gt;</programlisting>
<para>The expression $c/scaparent::* selects all the (direct) parents
(if any) of component <varname>$c</varname>lient, and returns them in
a node-set. In this case, the result is a set of one component named
<varname>helloworld-rmi-standalone</varname>.</para>
</section>
<section>
<title>Service</title>
......@@ -458,6 +481,67 @@ FScript&gt; value( $header )
f<varname>rascati.debug</varname> defined on the <varname>s</varname>
interface (service) of the <varname>server</varname> component.</para>
</section>
<section>
<title>Additional axes</title>
<para>In addition to previous axes, there are other derivated
axes:</para>
<itemizedlist>
<listitem>
<para>Transitive axes: select nodes recursively by applying the
axis on results</para>
<itemizedlist>
<listitem>
<para>scadescendant</para>
</listitem>
<listitem>
<para>scaancestor</para>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<para>Composed axis: combination of two axes</para>
<itemizedlist>
<listitem>
<para>scasibling</para>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<para>Reflexive axes: add the source component to selected
node</para>
<itemizedlist>
<listitem>
<para>scachild-or-self</para>
</listitem>
<listitem>
<para>scaparent-or-self</para>
</listitem>
<listitem>
<para>scadescendant-or-self</para>
</listitem>
<listitem>
<para>scaancestor-or-self</para>
</listitem>
<listitem>
<para>scasibling-or-self</para>
</listitem>
</itemizedlist>
</listitem>
</itemizedlist>
</section>
</section>
</section>
</chapter>
/***
* OW2 FraSCAti fscript
* Copyright (C) 2009 INRIA, USTL
* Copyright (C) 2009-2010 INRIA, USTL
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -56,6 +56,7 @@ public abstract class HelloWorldBasedTest {
this.engine = FScript.getFScriptEngine(fscript);
this.helloWorldRoot = (ScaComponentNode) engine.execute("root = sca-new(\"helloworld-rmi-standalone\");");
engine.execute("client = $root/scachild::client;");
}
// TODO: Add a tearDown() method used to unload loaded SCA composite(s)
......
/***
* OW2 FraSCAti fscript
* Copyright (C) 2009-2010 INRIA, USTL
*
* 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: Christophe Demarey
*
* Contributor(s):
*/
package org.ow2.frascati.fscript.model;
import static org.junit.Assert.*;
import java.util.Set;
import org.junit.Test;
import org.objectweb.fractal.fscript.model.Node;
/**
* JUnit test case for tha scachild axis.
*
* @author Christophe Demarey.
*/
public class ScadescendantAxisTest extends HelloWorldBasedTest {
@Test
public void testSelectFromNode() throws Exception {
Set<Node> result = (Set<Node>) engine.execute("$root/scadescendant::*;");
for (Node node : result) {
assertTrue(node+" is not an instance of ScaComponentNode", node instanceof ScaComponentNode );
}
assertTrue( "The HelloWorld composite has 2 descendants! (found "+result.size()+")",
result.size() == 2);
}
}
/***
* OW2 FraSCAti fscript
* Copyright (C) 2009-2010 INRIA, USTL
*
* 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: Christophe Demarey
*
* Contributor(s):
*/
package org.ow2.frascati.fscript.model;
import static org.junit.Assert.*;
import java.util.Set;
import org.junit.Test;
import org.objectweb.fractal.fscript.model.Node;
/**
* JUnit test case for tha scachild axis.
*
* @author Christophe Demarey.
*/
public class ScaparentAxisTest extends HelloWorldBasedTest {
@Test
public void testSelectFromNode() throws Exception {
Set<Node> result = (Set<Node>) engine.execute("$client/scaparent::*;");
for (Node node : result) {
assertTrue(node+" is not an instance of ScaComponentNode", node instanceof ScaComponentNode );
}
assertTrue( "The client component has only 1 parent! (found "+result.size()+")",
result.size() == 1);
}
}
/***
* OW2 FraSCAti fscript
* Copyright (C) 2009-2010 INRIA, USTL
*
* 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: Christophe Demarey
*
* Contributor(s):
*/
package org.ow2.frascati.fscript.model;
import static org.junit.Assert.*;
import java.util.Set;
import org.junit.Test;
import org.objectweb.fractal.fscript.model.Node;
/**
* JUnit test case for tha scachild axis.
*
* @author Christophe Demarey.
*/
public class ScasiblingAxisTest extends HelloWorldBasedTest {
@Test
public void testSelectFromNode() throws Exception {
Set<Node> result = (Set<Node>) engine.execute("$client/scasibling::*;");
for (Node node : result) {
assertTrue(node+" is not an instance of ScaComponentNode", node instanceof ScaComponentNode );
}
assertTrue( "There are 2 components on the same hierarchy level than client! (found "+result.size()+")",
result.size() == 2);
}
}
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