Commit 155f641a authored by Lionel Seinturier's avatar Lionel Seinturier
Browse files

Conformance tests for the so-called Light mode.

The light mode generates code with static invocations, instead of using reflection, to perform dependency injection and scope policy instantiation. The goal is to be able to address embedded VMs which do not support reflection.
parent 2dddca56
<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.ow2.frascati.tinfi</groupId>
<artifactId>frascati-tinfi-tests-parent</artifactId>
<version>1.4.5-SNAPSHOT</version>
</parent>
<groupId>org.ow2.frascati.tinfi</groupId>
<artifactId>frascati-tinfi-tests-light</artifactId>
<packaging>jar</packaging>
<name>Tinfi Tests Light Mode</name>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.ow2.frascati.tinfi</groupId>
<artifactId>frascati-tinfi-runtime</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.ow2.frascati.tinfi</groupId>
<artifactId>frascati-tinfi-oo</artifactId>
<version>${project.version}</version>
</dependency>
<!-- Needed to run the org.ow2.frascati.tinfi.mix.Mix TestCase -->
<dependency>
<groupId>org.objectweb.fractal.julia</groupId>
<artifactId>julia-asm</artifactId>
<version>${julia.version}</version>
</dependency>
<dependency>
<groupId>org.objectweb.fractal.julia</groupId>
<artifactId>julia-mixins</artifactId>
<version>${julia.version}</version>
</dependency>
<dependency>
<groupId>org.objectweb.fractal</groupId>
<artifactId>fractal-util</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.objectweb.fractal.juliac</groupId>
<artifactId>maven-juliac-plugin</artifactId>
<version>${juliac.version}</version>
<executions>
<execution>
<id>juliac-compile</id>
<!-- ============================================= -->
<!-- generate-test-sources mandatory -->
<!-- Not generate-sources because Spoon fails if a -->
<!-- compiled version of source classes is missing -->
<!-- See http://lists.gforge.inria.fr/pipermail/spoon-discuss/2007-September/000520.html -->
<!-- ============================================= -->
<phase>generate-test-sources</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<configuration>
<srcs><src>src/main/java</src></srcs>
<adlParsers>
<adlParser>FRACTAL_ADL</adlParser>
<adlParser>org.ow2.frascati.tinfi.tinfilet.TinfiParserSupportImpl</adlParser>
</adlParsers>
<opts>
<opt>org.ow2.frascati.tinfi.opt.oo.light.FCOOCtrlSourceCodeGenerator</opt>
<opt>OO</opt>
</opts>
<mixins>
<mixin>org.ow2.frascati.tinfi:frascati-tinfi-mixins:${project.version}:sources</mixin>
<mixin>org.objectweb.fractal.julia:julia-mixins:${julia.version}:sources</mixin>
</mixins>
<adls>
<adl>org.ow2.frascati.tinfi.ComponentContext</adl>
<adl>org.ow2.frascati.tinfi.ComponentName</adl>
<adl>org.ow2.frascati.tinfi.Constructor</adl>
<adl>org.ow2.frascati.tinfi.Controller</adl>
<adl>org.ow2.frascati.tinfi.OneWay</adl>
<adl>org.ow2.frascati.tinfi.Property</adl>
<adl>org.ow2.frascati.tinfi.PropertyReInject</adl>
<adl>org.ow2.frascati.tinfi.ProvidesImpl</adl>
<adl>org.ow2.frascati.tinfi.ReferenceMultiple</adl>
<adl>org.ow2.frascati.tinfi.ReferenceMandatoryNotSet</adl>
<adl>org.ow2.frascati.tinfi.ReferenceOptional</adl>
<adl>org.ow2.frascati.tinfi.SCAContentController</adl>
<adl>org.ow2.frascati.tinfi.SCAContentControllerImpl2</adl>
<adl>org.ow2.frascati.tinfi.ScopeComposite</adl>
<adl>org.ow2.frascati.tinfi.mix.Mix</adl>
<adl>org.ow2.frascati.tinfi.oabdoun.optionalreference.OptionalReference</adl>
<adl>org.ow2.frascati.tinfi.oabdoun.constructor.ConstructorPropertyInjection</adl>
</adls>
<modules>
<module>org.ow2.frascati.tinfi:frascati-tinfi-oo:${project.version}</module>
<module>org.objectweb.fractal.juliac:juliac-fractaladl:${juliac.version}</module>
<module>org.objectweb.fractal.juliac:juliac-jdt:${juliac.version}</module>
<module>org.objectweb.fractal.juliac:juliac-spoon:${juliac.version}</module>
</modules>
<!-- verbose>true</verbose -->
</configuration>
</plugin>
<!-- Needed to run the org.ow2.frascati.tinfi.mix.Mix TestCase -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemProperties>
<property>
<name>fractal.provider</name>
<value>org.objectweb.fractal.util.ChainedProvider</value>
</property>
<property>
<name>fractal.providers</name>
<value>org.objectweb.fractal.juliac.runtime.Juliac,org.objectweb.fractal.julia.Julia</value>
</property>
</systemProperties>
</configuration>
</plugin>
</plugins>
</build>
</project>
/***
* OW2 FraSCAti Tinfi
* Copyright (C) 2007-2011 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: Lionel Seinturier
*/
package org.ow2.frascati.tinfi;
import java.util.Collection;
import java.util.List;
import org.oasisopen.sca.ComponentContext;
import org.oasisopen.sca.RequestContext;
import org.oasisopen.sca.ServiceReference;
import org.oasisopen.sca.annotation.Context;
import org.oasisopen.sca.annotation.Property;
import org.oasisopen.sca.annotation.Reference;
/**
* Component implementation for testing the features provided by the {@link
* ComponentContext} interface.
*
* @author Lionel Seinturier <Lionel.Seinturier@univ-lille1.fr>
*/
public class ComponentContextImpl implements ComponentContextItf {
@Context
public ComponentContext ctx;
@Reference(required=false)
public ComponentContextItf s;
@Reference(required=false)
public List<ComponentContextItf> cols;
@Property
public String name;
public ServiceReference<ComponentContextItf> cast() {
ServiceReference<ComponentContextItf> sr = ctx.cast(s);
return sr;
}
public <B> B getService( Class<B> cl, String refname ) {
B r = ctx.getService(cl,refname);
return r;
}
public <B> ServiceReference<B> getServiceReference(
Class<B> cl, String refname ) {
ServiceReference<B> sr = ctx.getServiceReference(cl, refname);
return sr;
}
public <B> B getProperty( Class<B> type, String propertyName ) {
B value = ctx.getProperty(type, propertyName);
return value;
}
public String getRequestContextServiceName() {
RequestContext rq = ctx.getRequestContext();
String sn = rq.getServiceName();
return sn;
}
public Class<?> getRequestContextServiceBusinessInterface() {
RequestContext rq = ctx.getRequestContext();
ServiceReference<?> sr = rq.getServiceReference();
Class<?> cl = sr.getBusinessInterface();
return cl;
}
/**
* @since 1.4.1
*/
public <B> Collection<B> getServices( Class<B> cl, String refname ) {
Collection<B> r = ctx.getServices(cl,refname);
return r;
}
/**
* @since 1.4.1
*/
public <B> Collection<ServiceReference<B>> getServiceReferences(
Class<B> cl, String refname ) {
Collection<ServiceReference<B>> sr =
ctx.getServiceReferences(cl, refname);
return sr;
}
}
/***
* OW2 FraSCAti Tinfi
* Copyright (C) 2007-2011 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: Lionel Seinturier
*/
package org.ow2.frascati.tinfi;
import java.util.Collection;
import org.oasisopen.sca.ComponentContext;
import org.oasisopen.sca.ServiceReference;
/**
* Interface provided by the component implementation used for testing the
* features provided by the {@link ComponentContext} interface.
*
* @author Lionel Seinturier <Lionel.Seinturier@univ-lille1.fr>
*/
public interface ComponentContextItf {
public ServiceReference<ComponentContextItf> cast();
public <C> C getService( Class<C> cl, String refname );
public <C> ServiceReference<C> getServiceReference( Class<C> cl, String refname );
public <C> C getProperty( Class<C> type, String propertyName );
public String getRequestContextServiceName();
public Class<?> getRequestContextServiceBusinessInterface();
/**
* @since 1.4.1
*/
public <B> Collection<B> getServices( Class<B> cl, String refname );
/**
* @since 1.4.1
*/
public <B> Collection<ServiceReference<B>> getServiceReferences(
Class<B> cl, String refname );
}
/***
* OW2 FraSCAti Tinfi
* Copyright (C) 2007-2011 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: Lionel Seinturier
*/
package org.ow2.frascati.tinfi;
import org.oasisopen.sca.annotation.ComponentName;
import org.oasisopen.sca.annotation.Scope;
/**
* Component implementation used for testing
* {@link org.osoa.sca.annotations.ComponentName} annotated elements.
*
* @author Lionel Seinturier <Lionel.Seinturier@univ-lille1.fr>
*/
@Scope("COMPOSITE")
public class ComponentNameImpl implements ComponentNameItf {
@ComponentName
public String name;
/**
* Return the name of the component.
*
* @see org.ow2.frascati.tinfi.ComponentNameTestCase
*/
public String name() {
return name;
}
}
/***
* OW2 FraSCAti Tinfi
* Copyright (C) 2007-2011 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: Lionel Seinturier
*/
package org.ow2.frascati.tinfi;
/**
* Interface implemented by components used for testing {@link
* org.osoa.sca.annotations.ComponentName} annotated elements.
*
* @author Lionel Seinturier <Lionel.Seinturier@univ-lille1.fr>
*/
public interface ComponentNameItf {
/**
* Return the name of the component.
*/
public String name();
}
/***
* OW2 FraSCAti Tinfi
* Copyright (C) 2007-2011 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: Lionel Seinturier
*/
package org.ow2.frascati.tinfi;
import org.oasisopen.sca.annotation.Constructor;
import org.oasisopen.sca.annotation.Reference;
import org.oasisopen.sca.annotation.Property;
/**
* Component implementation used for testing the {@link
* org.osoa.sca.annotations.Constructor} annotation.
*
* @author Lionel Seinturier <Lionel.Seinturier@univ-lille1.fr>
*/
public class ConstructorClientImpl implements Runnable {
@SuppressWarnings("static-access")
@Constructor
public ConstructorClientImpl( @Property(name="name") String name ) {
this.name = name;
}
public void run() {
s.run();
}
@Reference
private Runnable s;
static String name;
}
/***
* OW2 FraSCAti Tinfi
* Copyright (C) 2007-2011 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: Lionel Seinturier
*/
package org.ow2.frascati.tinfi;
/**
* Component implementation used for testing the {@link
* org.osoa.sca.annotations.Constructor} annotation.
*
* @author Lionel Seinturier <Lionel.Seinturier@univ-lille1.fr>
*/
public class ConstructorImpl implements Runnable {
static int count = 0;
public void run() {
count++;
}
}
/***
* OW2 FraSCAti Tinfi
* Copyright (C) 2009-2011 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: Lionel Seinturier
*/
package org.ow2.frascati.tinfi;
import org.objectweb.fractal.api.Component;
import org.objectweb.fractal.api.control.NameController;
import org.objectweb.fractal.fraclet.extensions.Controller;
/**
* Component implementation for testing the features provided by @{link
* Controller} annotated fields or setter methods.
*
* @author Lionel Seinturier <Lionel.Seinturier@univ-lille1.fr>
* @since 1.4.1.
*/
public class ControllerImpl implements ControllerItf {
@Controller
private Component fcComp;
@Controller(name="name-controller")
private NameController nc;
public Component getFcComponent() {
return fcComp;
}
/**
* @since 1.4.2
*/
public NameController getFcNameController() {
return nc;
}
}
/***
* OW2 FraSCAti Tinfi
* Copyright (C) 2009-2011 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: Lionel Seinturier
*/
package org.ow2.frascati.tinfi;
import org.objectweb.fractal.api.Component;
import org.objectweb.fractal.api.control.NameController;
/**
* Component interface for testing the features provided by @{link
* Controller} annotated fields or setter methods.
*
* @author Lionel Seinturier <Lionel.Seinturier@univ-lille1.fr>
* @since 1.4.1
*/
public interface ControllerItf {
public Component getFcComponent();
/**
* @since 1.4.2
*/
public NameController getFcNameController();
}
/***
* OW2 FraSCAti Tinfi
* Copyright (C) 2007-2011 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