Commit 11083dea authored by seinturier's avatar seinturier

Moving to Juliac 1.3.

Adding an example to demonstrate the usage of Tinfi with so-called binary components (see advanced/helloworld-bin.)
Adding a RELEASE_NOTES.txt file to document features of released versions.
parent 9bd3b487
......@@ -21,7 +21,7 @@ Contact: Lionel.Seinturier@univ-lille1.fr
Author: Lionel Seinturier
============================================================================
Tinfi 1.0
Tinfi 0.2
---------
Tinfi is a runtime kernel for the SCA component model. Tinfi provides an
......@@ -70,6 +70,11 @@ The following sample applications are available in the examples module:
- forge: a simple SCA application written by Olivier Abdoun
<Olivier.Abdoun@inria.fr>
In addition the examples/advanced directory contains some advanced samples. See
the README.txt in the corresponding directories to obtain more information about
these samples.
- helloworld-bin: binary components (compiled classes) with Tinfi
3. Compiling and installing Tinfi
----------------------------------
......@@ -99,7 +104,7 @@ be put under respectively, src/main/java and src/main/resources.
5.1 Compiling
-------------
A maven plugin is available for compiling your application with TInfi. As
A maven plugin is available for compiling your application with Tinfi. As
illustrated in the examples/helloworld module, the plugin can be configured as
follows:
......@@ -108,7 +113,7 @@ follows:
03 <plugin>
04 <groupId>org.objectweb.fractal.fractaladl.juliac.plugin</groupId>
05 <artifactId>maven-juliac-plugin</artifactId>
06 <version>${project.version}</version>
06 <version>0.2</version>
07 <executions>
08 <execution>
09 <id>juliac-compile</id>
......@@ -121,15 +126,13 @@ follows:
16 <configuration>
17 <opt>org.scorware.tinfi.juliac.FCCompCtrlSourceCodeGenerator</opt>
18 <srcs>src/main/java</srcs>
19 <mixins>org.scorware.tinfi:mixins:1.0-SNAPSHOT:sources
org.objectweb.fractal.julia:julia-mixins:2.5.1:sources
org.objectweb.fractal.julia:koch-mixins:2.5.2-SNAPSHOT:sources</mixins>
19 <mixins>org.scorware.tinfi:mixins:0.2:sources
org.objectweb.fractal.julia:julia-mixins:2.5.2:sources</mixins>
20 <types>example.hw.HelloWorld</types>
21 </compilerArguments>
22 </configuration>
23 </plugin>
24 </plugins>
25 </build>
21 </configuration>
22 </plugin>
23 </plugins>
24 </build>
Lines 17 to 20 in the <configuration> section particularily matter for the
configuration of Juliac. The following tags are supported:
......@@ -182,4 +185,4 @@ To run the conformance tests, type:
For any question concerning Tinfi, please contact
Lionel.Seinturier@univ-lille1.fr
Date of creation of this file: June 24, 2007.
Last modified: April 30, 2008.
Last modified: May 12, 2008.
Tinfi 0.2
---------
* move to Juliac 1.3
* as a consequence component source code is not needed for code generation
* pre-mixed object-oriented control membrane for scaPrimitive
* isolate the component-based version of the membrane in a dedicated module
* artifact identifiers renamed with a frascati-tinfi- prefix
Tinfi 0.1
---------
* first release
* scaPrimitive membrane: object-oriented and component-based
* forge and helloworld examples
* conformance tests
Released on July 4, 2007
http://mail.ow2.org/wws/arc/rntl-sco-2006/2007-07/msg00006.html
......@@ -26,9 +26,19 @@
<artifactId>frascati-tinfi-runtime</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.objectweb.fractal.fractaladl.juliac</groupId>
<artifactId>juliac-jdt</artifactId>
<version>${juliac.version}</version>
</dependency>
<dependency>
<groupId>org.objectweb.fractal.fractaladl.juliac</groupId>
<artifactId>juliac-spoon</artifactId>
<version>${juliac.version}</version>
</dependency>
<dependency>
<groupId>org.objectweb.fractal.fractaladl.juliac</groupId>
<artifactId>compiler</artifactId>
<artifactId>juliac-oo</artifactId>
<version>${juliac.version}</version>
</dependency>
</dependencies>
......
......@@ -25,10 +25,10 @@ package org.scorware.tinfi.juliac;
import java.lang.reflect.Modifier;
import org.objectweb.fractal.adl.juliac.fc.MembraneDesc;
import org.objectweb.fractal.adl.juliac.MembraneDesc;
import org.objectweb.fractal.adl.juliac.proxy.AbstractProxySourceCodeGenerator;
import org.objectweb.fractal.adl.juliac.spoon.UnifiedClass;
import org.objectweb.fractal.adl.juliac.spoon.UnifiedMethod;
import org.objectweb.fractal.adl.juliac.ucf.UnifiedClass;
import org.objectweb.fractal.adl.juliac.ucf.UnifiedMethod;
import org.objectweb.fractal.adl.juliac.visit.ClassSourceCodeVisitor;
import org.objectweb.fractal.adl.juliac.visit.MethodSourceCodeVisitor;
import org.objectweb.fractal.api.Component;
......@@ -93,7 +93,7 @@ extends AbstractProxySourceCodeGenerator {
}
@Override
public void generateConstructors( ClassSourceCodeVisitor cv, UnifiedClass<?> proxycl ) {
public void generateConstructors( ClassSourceCodeVisitor cv, UnifiedClass proxycl ) {
super.generateConstructors(cv, proxycl);
// public constructor()
......@@ -118,7 +118,7 @@ extends AbstractProxySourceCodeGenerator {
@Override
public void generateProxyMethodBodyBeforeCode(
MethodSourceCodeVisitor mv, UnifiedClass<?> proxycl, UnifiedMethod proxym ) {
MethodSourceCodeVisitor mv, UnifiedClass proxycl, UnifiedMethod proxym ) {
super.generateProxyMethodBodyBeforeCode(mv, proxycl, proxym);
// Create the request context
......@@ -149,7 +149,7 @@ extends AbstractProxySourceCodeGenerator {
@Override
public void generateProxyMethodBodyAfterCode(
MethodSourceCodeVisitor mv, UnifiedClass<?> proxycl, UnifiedMethod proxym ) {
MethodSourceCodeVisitor mv, UnifiedClass proxycl, UnifiedMethod proxym ) {
super.generateProxyMethodBodyAfterCode(mv, proxycl, proxym);
// Release the content instance
......@@ -166,7 +166,7 @@ extends AbstractProxySourceCodeGenerator {
mv.visitln(" stack.pop();");
}
public String getDelegatingInstance( UnifiedClass<?> proxycl, UnifiedMethod proxym ) {
public String getDelegatingInstance( UnifiedClass proxycl, UnifiedMethod proxym ) {
return "impl";
}
}
......@@ -25,10 +25,10 @@ package org.scorware.tinfi.juliac;
import java.lang.reflect.Modifier;
import org.objectweb.fractal.adl.juliac.fc.MembraneDesc;
import org.objectweb.fractal.adl.juliac.MembraneDesc;
import org.objectweb.fractal.adl.juliac.proxy.AbstractProxySourceCodeGenerator;
import org.objectweb.fractal.adl.juliac.spoon.UnifiedClass;
import org.objectweb.fractal.adl.juliac.spoon.UnifiedMethod;
import org.objectweb.fractal.adl.juliac.ucf.UnifiedClass;
import org.objectweb.fractal.adl.juliac.ucf.UnifiedMethod;
import org.objectweb.fractal.adl.juliac.visit.ClassSourceCodeVisitor;
import org.objectweb.fractal.adl.juliac.visit.MethodSourceCodeVisitor;
import org.objectweb.fractal.api.type.InterfaceType;
......@@ -100,7 +100,7 @@ extends AbstractProxySourceCodeGenerator {
}
@Override
public void generateConstructors( ClassSourceCodeVisitor cv, UnifiedClass<?> proxycl ) {
public void generateConstructors( ClassSourceCodeVisitor cv, UnifiedClass proxycl ) {
super.generateConstructors(cv, proxycl);
// public constructor(Class<B>,B)
......@@ -115,7 +115,7 @@ extends AbstractProxySourceCodeGenerator {
@Override
public void generateProxyMethodBodyBeforeCode(
MethodSourceCodeVisitor mv, UnifiedClass<?> proxycl, UnifiedMethod proxym ) {
MethodSourceCodeVisitor mv, UnifiedClass proxycl, UnifiedMethod proxym ) {
super.generateProxyMethodBodyBeforeCode(mv, proxycl, proxym);
Conversational conversationalItf = proxycl.getAnnotation(Conversational.class);
......@@ -152,7 +152,7 @@ extends AbstractProxySourceCodeGenerator {
@Override
public void generateProxyMethodBodyAfterCode(
MethodSourceCodeVisitor mv, UnifiedClass<?> proxycl, UnifiedMethod proxym ) {
MethodSourceCodeVisitor mv, UnifiedClass proxycl, UnifiedMethod proxym ) {
super.generateProxyMethodBodyAfterCode(mv, proxycl, proxym);
OneWay oneWayMeth = proxym.getAnnotation(OneWay.class);
......@@ -169,7 +169,7 @@ extends AbstractProxySourceCodeGenerator {
}
}
public String getDelegatingInstance( UnifiedClass<?> proxycl, UnifiedMethod proxym ) {
public String getDelegatingInstance( UnifiedClass proxycl, UnifiedMethod proxym ) {
return "impl";
}
}
......@@ -25,10 +25,10 @@ package org.scorware.tinfi.juliac;
import java.lang.reflect.Modifier;
import org.objectweb.fractal.adl.juliac.fc.MembraneDesc;
import org.objectweb.fractal.adl.juliac.MembraneDesc;
import org.objectweb.fractal.adl.juliac.proxy.InterfaceSourceCodeGenerator;
import org.objectweb.fractal.adl.juliac.proxy.ProxySourceCodeGenerator;
import org.objectweb.fractal.adl.juliac.spoon.UnifiedClass;
import org.objectweb.fractal.adl.juliac.ucf.UnifiedClass;
import org.objectweb.fractal.adl.juliac.visit.ClassSourceCodeVisitor;
import org.objectweb.fractal.adl.juliac.visit.MethodSourceCodeVisitor;
import org.objectweb.fractal.api.type.InterfaceType;
......@@ -68,7 +68,7 @@ extends InterfaceSourceCodeGenerator {
}
@Override
public void generateMethods( ClassSourceCodeVisitor cv, UnifiedClass<?> proxycl ) {
public void generateMethods( ClassSourceCodeVisitor cv, UnifiedClass proxycl ) {
super.generateMethods(cv, proxycl);
MethodSourceCodeVisitor mv =
......
......@@ -25,20 +25,20 @@ package org.scorware.tinfi.juliac;
import java.io.IOException;
import org.objectweb.fractal.adl.juliac.InitializerSourceCodeGenerator;
import org.objectweb.fractal.adl.juliac.Juliac;
import org.objectweb.fractal.adl.juliac.fc.InitializerSourceCodeGenerator;
import org.objectweb.fractal.adl.juliac.proxy.AttributeSourceCodeGenerator;
import org.objectweb.fractal.adl.juliac.proxy.InterfaceSourceCodeGenerator;
import org.objectweb.fractal.adl.juliac.proxy.ProxySourceCodeGenerator;
import org.objectweb.fractal.adl.juliac.spoon.UnifiedClass;
import org.objectweb.fractal.adl.juliac.ucf.UnifiedClass;
import org.objectweb.fractal.adl.juliac.ucf.UnifiedClassFactory;
import org.objectweb.fractal.adl.juliac.ucf.UnifiedClassFactoryItf;
import org.objectweb.fractal.api.control.AttributeController;
import org.objectweb.fractal.api.type.InterfaceType;
import org.objectweb.fractal.julia.control.attribute.CloneableAttributeController;
import org.objectweb.fractal.julia.type.BasicInterfaceType;
import org.osoa.sca.annotations.Callback;
import spoon.reflect.Factory;
/**
* This class generates the source code associated to Fractal components.
* The membrane implementation and the initializer implementation are generated.
......@@ -49,7 +49,7 @@ import spoon.reflect.Factory;
* @author Lionel Seinturier <Lionel.Seinturier@lifl.fr>
*/
public class FCOOCtrlSourceCodeGenerator
extends org.objectweb.fractal.adl.juliac.fc.julia.FCOOCtrlSourceCodeGenerator {
extends org.objectweb.fractal.adl.juliac.opt.oo.FCOOCtrlSourceCodeGenerator {
public FCOOCtrlSourceCodeGenerator() {
......@@ -85,13 +85,12 @@ extends org.objectweb.fractal.adl.juliac.fc.julia.FCOOCtrlSourceCodeGenerator {
throws IOException {
Juliac jc = Juliac.get();
Factory factory = jc.getSpoonFactory();
ClassLoader classloader = jc.getClassLoader();
UnifiedClassFactoryItf ucf = UnifiedClassFactory.get();
String signature = it.getFcItfSignature();
UnifiedClass<?> cl = new UnifiedClass<Object>(factory,classloader,signature);
UnifiedClass<?> ac = new UnifiedClass<AttributeController>(factory,classloader,AttributeController.class);
UnifiedClass<?> cac = new UnifiedClass<CloneableAttributeController>(factory,classloader,CloneableAttributeController.class);
UnifiedClass cl = ucf.create(signature);
UnifiedClass ac = ucf.create(AttributeController.class.getName());
UnifiedClass cac = ucf.create(CloneableAttributeController.class.getName());
/*
* If the interface is a business attribute controller interface,
......
......@@ -38,7 +38,7 @@ import org.objectweb.fractal.api.type.InterfaceType;
* @author Lionel Seinturier <Lionel.Seinturier@lifl.fr>
*/
public class InitializerOOCtrlSourceCodeGenerator
extends org.objectweb.fractal.adl.juliac.fc.julia.InitializerOOCtrlSourceCodeGenerator {
extends org.objectweb.fractal.adl.juliac.opt.oo.InitializerOOCtrlSourceCodeGenerator {
/**
* Return the source file generator for interfaces.
......
......@@ -23,7 +23,7 @@
package org.scorware.tinfi.juliac;
import org.objectweb.fractal.adl.juliac.fc.MembraneDesc;
import org.objectweb.fractal.adl.juliac.MembraneDesc;
import org.objectweb.fractal.adl.juliac.proxy.InterfaceSourceCodeGenerator;
import org.objectweb.fractal.adl.juliac.proxy.ProxySourceCodeGenerator;
import org.objectweb.fractal.api.type.InterfaceType;
......
......@@ -23,10 +23,10 @@
package org.scorware.tinfi.juliac;
import org.objectweb.fractal.adl.juliac.fc.MembraneDesc;
import org.objectweb.fractal.adl.juliac.MembraneDesc;
import org.objectweb.fractal.adl.juliac.proxy.InterceptorSourceCodeGenerator;
import org.objectweb.fractal.adl.juliac.spoon.UnifiedClass;
import org.objectweb.fractal.adl.juliac.spoon.UnifiedMethod;
import org.objectweb.fractal.adl.juliac.ucf.UnifiedClass;
import org.objectweb.fractal.adl.juliac.ucf.UnifiedMethod;
import org.objectweb.fractal.adl.juliac.visit.ClassSourceCodeVisitor;
import org.objectweb.fractal.adl.juliac.visit.MethodSourceCodeVisitor;
import org.objectweb.fractal.api.type.InterfaceType;
......@@ -104,29 +104,29 @@ extends InterceptorSourceCodeGenerator {
}
@Override
public void generateFields( ClassSourceCodeVisitor cv, UnifiedClass<?> proxycl ) {
public void generateFields( ClassSourceCodeVisitor cv, UnifiedClass proxycl ) {
}
@Override
public void generateConstructors( ClassSourceCodeVisitor cv, UnifiedClass<?> proxycl ) {
public void generateConstructors( ClassSourceCodeVisitor cv, UnifiedClass proxycl ) {
}
@Override
protected void generateMethodInitFcController( MethodSourceCodeVisitor mv, UnifiedClass<?> proxycl ) {
protected void generateMethodInitFcController( MethodSourceCodeVisitor mv, UnifiedClass proxycl ) {
mv.visitln(" super.initFcController(ic);");
}
@Override
protected void generateMethodClone( MethodSourceCodeVisitor mv, UnifiedClass<?> proxycl ) {
protected void generateMethodClone( MethodSourceCodeVisitor mv, UnifiedClass proxycl ) {
}
@Override
protected void generateMethodOthers( ClassSourceCodeVisitor cv, UnifiedClass<?> proxycl ) {
protected void generateMethodOthers( ClassSourceCodeVisitor cv, UnifiedClass proxycl ) {
}
@Override
public void generateProxyMethodBodyBeforeCode(
MethodSourceCodeVisitor mv, UnifiedClass<?> proxycl, UnifiedMethod proxym ) {
MethodSourceCodeVisitor mv, UnifiedClass proxycl, UnifiedMethod proxym ) {
// Create the request context
mv.visit (" "+RequestContext.class.getName()+" rq = new ");
......@@ -161,7 +161,7 @@ extends InterceptorSourceCodeGenerator {
@Override
public void generateProxyMethodBodyFinallyCode(
MethodSourceCodeVisitor mv, UnifiedClass<?> proxycl, UnifiedMethod proxym ) {
MethodSourceCodeVisitor mv, UnifiedClass proxycl, UnifiedMethod proxym ) {
// End of try/finally block
mv.visitln(" }");
......
......@@ -25,12 +25,12 @@ package org.scorware.tinfi.juliac;
import java.lang.reflect.Modifier;
import org.objectweb.fractal.adl.juliac.MembraneDesc;
import org.objectweb.fractal.adl.juliac.Utils;
import org.objectweb.fractal.adl.juliac.fc.MembraneDesc;
import org.objectweb.fractal.adl.juliac.proxy.AbstractProxySourceCodeGenerator;
import org.objectweb.fractal.adl.juliac.proxy.ProxySourceCodeGenerator;
import org.objectweb.fractal.adl.juliac.spoon.UnifiedClass;
import org.objectweb.fractal.adl.juliac.spoon.UnifiedMethod;
import org.objectweb.fractal.adl.juliac.ucf.UnifiedClass;
import org.objectweb.fractal.adl.juliac.ucf.UnifiedMethod;
import org.objectweb.fractal.adl.juliac.visit.ClassSourceCodeVisitor;
import org.objectweb.fractal.adl.juliac.visit.MethodSourceCodeVisitor;
import org.objectweb.fractal.api.Component;
......@@ -108,7 +108,7 @@ extends AbstractProxySourceCodeGenerator {
}
@Override
public void generateConstructors( ClassSourceCodeVisitor cv, UnifiedClass<?> proxycl ) {
public void generateConstructors( ClassSourceCodeVisitor cv, UnifiedClass proxycl ) {
super.generateConstructors(cv, proxycl);
// public constructor(Class<B>,B)
......@@ -123,7 +123,7 @@ extends AbstractProxySourceCodeGenerator {
@Override
public void generateProxyMethodBodyBeforeCode(
MethodSourceCodeVisitor mv, UnifiedClass<?> proxycl, UnifiedMethod proxym ) {
MethodSourceCodeVisitor mv, UnifiedClass proxycl, UnifiedMethod proxym ) {
super.generateProxyMethodBodyBeforeCode(mv, proxycl, proxym);
conversationalItf = proxycl.getAnnotation(Conversational.class);
......@@ -196,7 +196,7 @@ extends AbstractProxySourceCodeGenerator {
@Override
public void generateProxyMethodBodyAfterCode(
MethodSourceCodeVisitor mv, UnifiedClass<?> proxycl, UnifiedMethod proxym ) {
MethodSourceCodeVisitor mv, UnifiedClass proxycl, UnifiedMethod proxym ) {
super.generateProxyMethodBodyAfterCode(mv, proxycl, proxym);
EndsConversation end = proxym.getAnnotation(EndsConversation.class);
......@@ -217,7 +217,7 @@ extends AbstractProxySourceCodeGenerator {
}
}
public String getDelegatingInstance( UnifiedClass<?> proxycl, UnifiedMethod proxym ) {
public String getDelegatingInstance( UnifiedClass proxycl, UnifiedMethod proxym ) {
return "impl";
}
}
To compile and run the example:
mvn test
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/resources"/>
<classpathentry kind="src" path="src/test/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry combineaccessrules="false" kind="src" path="/juliac-examples-helloworld-bin-code"/>
<classpathentry combineaccessrules="false" kind="src" path="/tinfi-runtime"/>
<classpathentry combineaccessrules="false" kind="src" path="/fractal-api-2.0.2"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>tinfi-examples-helloworld-bin-assembly</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.scorware.tinfi.examples</groupId>
<artifactId>frascati-tinfi-helloworld-bin</artifactId>
<version>0.2-SNAPSHOT</version>
</parent>
<groupId>org.scorware.tinfi.examples</groupId>
<artifactId>frascati-tinfi-helloworld-bin-assembly</artifactId>
<packaging>jar</packaging>
<name>Assembling</name>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.4</version>
</dependency>
<dependency>
<groupId>org.scorware.tinfi</groupId>
<artifactId>frascati-tinfi-compiler</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.scorware.tinfi.examples</groupId>
<artifactId>frascati-tinfi-helloworld-bin-code</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.scorware.tinfi</groupId>
<artifactId>frascati-tinfi-mixins</artifactId>
<version>${project.version}</version>
<classifier>sources</classifier>
</dependency>
<dependency>
<groupId>org.objectweb.fractal.julia</groupId>
<artifactId>julia-mixins</artifactId>
<version>${julia.version}</version>
<classifier>sources</classifier>
</dependency>
</dependencies>
<build>
<plugins>
<!-- ==================================== -->
<!-- Generate and compile the application -->
<!-- ==================================== -->
<plugin>
<groupId>org.objectweb.fractal.fractaladl.juliac</groupId>
<artifactId>maven-juliac-plugin</artifactId>
<version>${juliac.version}</version>
<executions>
<execution>
<id>juliac-compile</id>
<phase>generate-sources</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<configuration>
<opt>org.scorware.tinfi.juliac.FCOOCtrlSourceCodeGenerator</opt>
<mixins>org.scorware.tinfi:frascati-tinfi-mixins:${project.version}:sources org.objectweb.fractal.julia:julia-mixins:${julia.version}:sources</mixins>
<types>example.hw.HelloWorld</types>
<sysargs>julia.config=tinfi.cfg</sysargs>
<!-- verbose>true</verbose -->
</configuration>
</plugin>
</plugins>
</build>
</project>
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE definition PUBLIC "-//objectweb.org//DTD Fractal ADL 2.0//EN" "classpath://org/objectweb/fractal/adl/xml/standard.dtd">
<definition name="example.hw.HelloWorld" >
<interface name="r" signature="java.lang.Runnable" role="server" />
<component name="client">
<interface name="r" signature="java.lang.Runnable" role="server" />
<interface name="s" signature="example.hw.Service" role="client" />
<content class="example.hw.ClientImpl"/>
<controller desc="scaPrimitive" />
</component>
<component name="server">
<interface name="s" signature="example.hw.Service" role="server" cardinality="singleton" contingency="mandatory"/>
<content class="example.hw.ServerImpl"/>
<controller desc="scaPrimitive"/>
</component>
<binding client="this.r" server="client.r" />
<binding client="client.s" server="server.s" />
</definition>
/***
* Tinfi
* Copyright (C) 2008 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: Lionel.Seinturier@univ-lille1.fr
*
* Author: Lionel Seinturier
*/
package example.hw;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintStream;
import junit.framework.TestCase;
import org.junit.Test;
import org.objectweb.fractal.api.NoSuchInterfaceException;
import org.objectweb.fractal.api.control.IllegalLifeCycleException;
import org.objectweb.fractal.api.factory.InstantiationException;
import org.scorware.tinfi.TinfiDomain;
/**
* Automate the launching of the HelloWorld example and check that the example
* runs as expected.
*
* @author Lionel Seinturier <Lionel.Seinturier@univ-lille1.fr>
* @since 0.2
*/
public class HelloWorldTestCase extends TestCase {
@Test
public void testHelloWorld()
throws
IOException, IllegalArgumentException, ClassNotFoundException,
InstantiationException, IllegalAccessException,
java.lang.InstantiationException, InstantiationException,
IllegalLifeCycleException, NoSuchInterfaceException {
/*
* Use the Console class to direct the output of the example to a
* temporary file.
*/
File tmp = File.createTempFile("helloworld-bin-",".txt");
PrintStream ps = new PrintStream(tmp);
Console.ps = ps;
Runnable r = TinfiDomain.getService("example.hw.HelloWorld",Runnable.class,"r");
r.run();
ps.close();
/*
* Dump the content of the temporay file to the console for visual
* check.
*/
FileReader fr = new FileReader(tmp);
int b;
while( (b=fr.read()) != -1 ) {
char c = (char) b;
System.err.print(c);
}
fr.close();
File tmpExpected = File.createTempFile("helloworld-bin-",".txt");
ps = new PrintStream(tmpExpected);
for (String expected : expecteds) {
ps.println(expected);
}
ps.close();
/*
* Compare the output with the expected result.
*/
fr = new FileReader(tmp);
FileReader frExpected = new FileReader(tmpExpected);
int i=0,line=1,col=1;
while( (b=fr.read()) != -1 ) {
char c = (char) b;
char e = (char) frExpected.read();
if( c != e ) {
String msg = "Unexpected character at line "+line+", column "+col;
System.err.println();
System.err.println("Expected output is: ");
for (String expected : expecteds) {
System.err.println(expected);
}
fail(msg);
}
i++;
if( c == '\n' ) {
line++;
col=1;
}
else {
col++;
}
}
frExpected.close();
fr.close();
/*
* Delete temporary files.
*/
tmp.delete();
tmpExpected.delete();
}
final static private String[] expecteds =
new String[]{
"CLIENT created",
"CLIENT initialized",
"SERVER created",
"Server: begin printing...",
"->hello world",
"Server: print done.",
};
}