Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
frascati
frascati
Commits
e517d86d
Commit
e517d86d
authored
Mar 12, 2013
by
Lionel Seinturier
Browse files
Julia conformance tests for the binding controller.
parent
2055469a
Changes
10
Hide whitespace changes
Inline
Side-by-side
tinfi/tests/oasis/pom.xml
View file @
e517d86d
...
...
@@ -95,6 +95,9 @@
<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>
<adl>
org.objectweb.fractal.julia.conform.components.BindingController
</adl>
<adl>
org.objectweb.fractal.julia.conform.components.C7scaPrimitive
</adl>
<adl>
org.objectweb.fractal.julia.conform.components.C8scaPrimitive
</adl>
</adls>
<modules>
<module>
JDT
</module>
...
...
tinfi/tests/oasis/src/main/java/org/objectweb/fractal/julia/conform/components/C.java
0 → 100644
View file @
e517d86d
/***
* OW2 FraSCAti Tinfi
* Copyright (C) 2007-2012-2013 Inria, Univ. 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: Lionel Seinturier
*/
package
org.objectweb.fractal.julia.conform.components
;
import
org.objectweb.fractal.api.control.BindingController
;
import
java.util.Map
;
import
java.util.HashMap
;
public
class
C
implements
CAttributes
,
BindingController
,
I
,
J
{
private
boolean
x1
;
private
byte
x2
;
private
char
x3
;
private
short
x4
;
private
int
x5
;
private
long
x6
;
private
float
x7
;
private
double
x8
;
private
String
x9
;
private
boolean
x11
;
private
I
i
;
private
Map
j
=
new
HashMap
();
// ATTRIBUTE CONTROLLER
public
boolean
getX1
()
{
return
x1
;
}
public
void
setX1
(
boolean
x1
)
{
this
.
x1
=
x1
;
}
public
byte
getX2
()
{
return
x2
;
}
public
void
setX2
(
byte
x2
)
{
this
.
x2
=
x2
;
}
public
char
getX3
()
{
return
x3
;
}
public
void
setX3
(
char
x3
)
{
this
.
x3
=
x3
;
}
public
short
getX4
()
{
return
x4
;
}
public
void
setX4
(
short
x4
)
{
this
.
x4
=
x4
;
}
public
int
getX5
()
{
return
x5
;
}
public
void
setX5
(
int
x5
)
{
this
.
x5
=
x5
;
}
public
long
getX6
()
{
return
x6
;
}
public
void
setX6
(
long
x6
)
{
this
.
x6
=
x6
;
}
public
float
getX7
()
{
return
x7
;
}
public
void
setX7
(
float
x7
)
{
this
.
x7
=
x7
;
}
public
double
getX8
()
{
return
x8
;
}
public
void
setX8
(
double
x8
)
{
this
.
x8
=
x8
;
}
public
String
getX9
()
{
return
x9
;
}
public
void
setX9
(
String
x9
)
{
this
.
x9
=
x9
;
}
public
boolean
getReadOnlyX10
()
{
return
true
;
}
public
void
setWriteOnlyX11
(
boolean
x11
)
{
this
.
x11
=
x11
;
}
// BINDING CONTROLLER
public
String
[]
listFc
()
{
String
[]
result
=
new
String
[
j
.
size
()
+
1
];
j
.
keySet
().
toArray
(
result
);
result
[
j
.
size
()]
=
"client"
;
return
result
;
}
public
Object
lookupFc
(
String
s
)
{
if
(
s
.
equals
(
"client"
))
{
return
i
;
}
else
if
(
s
.
startsWith
(
"clients"
))
{
return
j
.
get
(
s
);
}
return
null
;
}
public
void
bindFc
(
String
s
,
Object
o
)
{
if
(
s
.
equals
(
"client"
))
{
i
=
(
I
)
o
;
}
else
if
(
s
.
startsWith
(
"clients"
))
{
j
.
put
(
s
,
o
);
}
}
public
void
unbindFc
(
String
s
)
{
if
(
s
.
equals
(
"client"
))
{
i
=
null
;
}
else
if
(
s
.
startsWith
(
"clients"
))
{
j
.
remove
(
s
);
}
}
// FUNCTIONAL INTERFACE
public
void
m
(
boolean
v
)
{
}
public
void
m
(
byte
v
)
{
}
public
void
m
(
char
v
)
{
}
public
void
m
(
short
v
)
{
}
public
void
m
(
int
v
)
{
}
public
void
m
(
long
v
)
{
}
public
void
m
(
float
v
)
{
}
public
void
m
(
double
v
)
{
}
public
void
m
(
String
v
)
{
}
public
void
m
(
String
[]
v
)
{
}
public
boolean
n
(
boolean
v
,
String
[]
w
)
{
return
v
|
x11
;
// for write only attribute tests
}
public
byte
n
(
byte
v
,
String
w
)
{
return
v
;
}
public
char
n
(
char
v
,
double
w
)
{
return
v
;
}
public
short
n
(
short
v
,
float
w
)
{
return
v
;
}
public
int
n
(
int
v
,
long
w
)
{
if
(
i
!=
null
)
{
// for interceptors tests
return
w
==
0
?
v
:
i
.
n
(
v
+
1
,
w
-
1
);
}
else
if
(
j
.
size
()
>
0
)
{
// for interceptors tests
return
w
==
0
?
v
:
((
I
)
j
.
values
().
iterator
().
next
()).
n
(
v
+
1
,
w
-
1
);
}
else
{
return
v
;
}
}
public
long
n
(
long
v
,
int
w
)
{
return
v
;
}
public
float
n
(
float
v
,
short
w
)
{
return
v
;
}
public
double
n
(
double
v
,
char
w
)
{
return
v
;
}
public
String
n
(
String
v
,
byte
w
)
{
return
v
;
}
public
String
[]
n
(
String
[]
v
,
boolean
w
)
{
return
v
;
}
}
tinfi/tests/oasis/src/main/java/org/objectweb/fractal/julia/conform/components/CAttributes.java
0 → 100644
View file @
e517d86d
/***
* OW2 FraSCAti Tinfi
* Copyright (C) 2007-2012-2013 Inria, Univ. 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: Lionel Seinturier
*/
package
org.objectweb.fractal.julia.conform.components
;
import
org.objectweb.fractal.api.control.AttributeController
;
public
interface
CAttributes
extends
AttributeController
{
boolean
getX1
();
void
setX1
(
boolean
v
);
byte
getX2
();
void
setX2
(
byte
v
);
char
getX3
();
void
setX3
(
char
v
);
short
getX4
();
void
setX4
(
short
v
);
int
getX5
();
void
setX5
(
int
v
);
long
getX6
();
void
setX6
(
long
v
);
float
getX7
();
void
setX7
(
float
v
);
double
getX8
();
void
setX8
(
double
v
);
String
getX9
();
void
setX9
(
String
v
);
boolean
getReadOnlyX10
();
void
setWriteOnlyX11
(
boolean
v
);
}
tinfi/tests/oasis/src/main/java/org/objectweb/fractal/julia/conform/components/I.java
0 → 100644
View file @
e517d86d
/***
* OW2 FraSCAti Tinfi
* Copyright (C) 2007-2012-2013 Inria, Univ. 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: Lionel Seinturier
*/
package
org.objectweb.fractal.julia.conform.components
;
public
interface
I
{
void
m
(
boolean
v
);
void
m
(
byte
v
);
void
m
(
char
v
);
void
m
(
short
v
);
void
m
(
int
v
);
void
m
(
long
v
);
void
m
(
float
v
);
void
m
(
double
v
);
void
m
(
String
v
);
void
m
(
String
[]
v
);
boolean
n
(
boolean
v
,
String
[]
w
);
byte
n
(
byte
v
,
String
w
);
char
n
(
char
v
,
double
w
);
short
n
(
short
v
,
float
w
);
int
n
(
int
v
,
long
w
);
long
n
(
long
v
,
int
w
);
float
n
(
float
v
,
short
w
);
double
n
(
double
v
,
char
w
);
String
n
(
String
v
,
byte
w
);
String
[]
n
(
String
[]
v
,
boolean
w
);
}
tinfi/tests/oasis/src/main/java/org/objectweb/fractal/julia/conform/components/J.java
0 → 100644
View file @
e517d86d
/***
* OW2 FraSCAti Tinfi
* Copyright (C) 2007-2012-2013 Inria, Univ. 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: Lionel Seinturier
*/
package
org.objectweb.fractal.julia.conform.components
;
public
interface
J
{
}
tinfi/tests/oasis/src/main/resources/org/objectweb/fractal/julia/conform/components/BindingController.fractal
0 → 100644
View file @
e517d86d
<?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/basic.dtd">
<definition
name=
"org.objectweb.fractal.julia.conform.components.BindingController"
>
<controller
desc=
"scaComposite"
/>
</definition>
tinfi/tests/oasis/src/main/resources/org/objectweb/fractal/julia/conform/components/C7scaPrimitive.fractal
0 → 100644
View file @
e517d86d
<?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/basic.dtd">
<definition
name=
"org.objectweb.fractal.julia.conform.components.C7scaPrimitive"
>
<interface
name=
"server"
role=
"server"
cardinality=
"singleton"
signature=
"org.objectweb.fractal.julia.conform.components.I"
/>
<interface
name=
"servers"
role=
"server"
cardinality=
"collection"
signature=
"org.objectweb.fractal.julia.conform.components.I"
/>
<interface
name=
"client"
role=
"client"
cardinality=
"singleton"
signature=
"org.objectweb.fractal.julia.conform.components.I"
/>
<interface
name=
"clients"
role=
"client"
cardinality=
"collection"
signature=
"org.objectweb.fractal.julia.conform.components.I"
/>
<content
class=
"org.objectweb.fractal.julia.conform.components.C"
/>
<controller
desc=
"scaPrimitive"
/>
</definition>
tinfi/tests/oasis/src/main/resources/org/objectweb/fractal/julia/conform/components/C8scaPrimitive.fractal
0 → 100644
View file @
e517d86d
<?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/basic.dtd">
<definition
name=
"org.objectweb.fractal.julia.conform.components.C8scaPrimitive"
>
<interface
name=
"serverI"
role=
"server"
contingency=
"optional"
signature=
"org.objectweb.fractal.julia.conform.components.I"
/>
<interface
name=
"serverJ"
role=
"server"
signature=
"org.objectweb.fractal.julia.conform.components.J"
/>
<content
class=
"org.objectweb.fractal.julia.conform.components.C"
/>
<controller
desc=
"scaPrimitive"
/>
</definition>
tinfi/tests/oasis/src/test/java/org/objectweb/fractal/julia/conform/components/BindingControllerTestCase.java
0 → 100644
View file @
e517d86d
/***
* OW2 FraSCAti Tinfi
* Copyright (C) 2007-2012-2013 Inria, Univ. 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: Lionel Seinturier
*/
package
org.objectweb.fractal.julia.conform.components
;
import
java.util.Arrays
;
import
java.util.HashSet
;
import
org.objectweb.fractal.api.Component
;
import
org.objectweb.fractal.api.NoSuchInterfaceException
;
import
org.objectweb.fractal.api.control.BindingController
;
import
org.objectweb.fractal.api.control.ContentController
;
import
org.objectweb.fractal.api.control.IllegalBindingException
;
import
org.objectweb.fractal.api.factory.GenericFactory
;
import
org.objectweb.fractal.api.type.ComponentType
;
import
org.objectweb.fractal.api.type.InterfaceType
;
import
org.objectweb.fractal.api.type.TypeFactory
;
import
org.objectweb.fractal.util.Fractal
;
import
org.ow2.frascati.tinfi.TinfiDomain
;
public
class
BindingControllerTestCase
extends
Test
{
protected
Component
boot
;
protected
TypeFactory
tf
;
protected
GenericFactory
gf
;
protected
ComponentType
t
,
u
;
protected
Component
c
,
d
,
e
;
protected
boolean
isTemplate
;
protected
final
static
String
serverI
=
"server/"
+
PKG
+
".I/false,false,false"
;
protected
final
static
String
clientI
=
"client/"
+
PKG
+
".I/true,false,false"
;
protected
final
static
String
clients0I
=
"clients0/"
+
PKG
+
".I/true,false,true"
;
// -------------------------------------------------------------------------
// Constructor and setup
// -------------------------------------------------------------------------
public
BindingControllerTestCase
(
final
String
name
)
{
super
(
name
);
}
protected
void
setUp
()
throws
Exception
{
boot
=
Fractal
.
getBootstrapComponent
();
tf
=
Fractal
.
getTypeFactory
(
boot
);
gf
=
Fractal
.
getGenericFactory
(
boot
);
t
=
tf
.
createFcType
(
new
InterfaceType
[]
{
tf
.
createFcItfType
(
"server"
,
I
.
class
.
getName
(),
false
,
false
,
false
),
tf
.
createFcItfType
(
"servers"
,
I
.
class
.
getName
(),
false
,
false
,
true
),
tf
.
createFcItfType
(
"client"
,
I
.
class
.
getName
(),
true
,
false
,
false
),
tf
.
createFcItfType
(
"clients"
,
I
.
class
.
getName
(),
true
,
false
,
true
)
});
u
=
tf
.
createFcType
(
new
InterfaceType
[]
{
tf
.
createFcItfType
(
"serverI"
,
I
.
class
.
getName
(),
false
,
true
,
false
),
tf
.
createFcItfType
(
"serverJ"
,
J
.
class
.
getName
(),
false
,
false
,
false
),
});
setUpComponents
();
}
protected
void
setUpComponents
()
throws
Exception
{
c
=
gf
.
newFcInstance
(
t
,
"scaPrimitive"
,
C
.
class
.
getName
());
d
=
gf
.
newFcInstance
(
t
,
"scaPrimitive"
,
C
.
class
.
getName
());
e
=
gf
.
newFcInstance
(
u
,
"scaPrimitive"
,
C
.
class
.
getName
());
String
adl
=
getClass
().
getPackage
().
getName
()+
".BindingController"
;
Component
composite
=
TinfiDomain
.
getComponent
(
adl
);
ContentController
cc
=
Fractal
.
getContentController
(
composite
);
cc
.
addFcSubComponent
(
c
);
cc
.
addFcSubComponent
(
d
);
cc
.
addFcSubComponent
(
e
);
}
// -------------------------------------------------------------------------
// Test list, lookup, bind, unbind
// -------------------------------------------------------------------------
public
void
testList
()
throws
Exception
{
BindingController
bc
=
Fractal
.
getBindingController
(
c
);
checkList
(
bc
,
new
String
[]
{
"client"
});
}
public
void
testBindLookupUnbind
()
throws
Exception
{
BindingController
bc
=
Fractal
.
getBindingController
(
c
);
bc
.
bindFc
(
"client"
,
d
.
getFcInterface
(
"server"
));
checkList
(
bc
,
new
String
[]
{
"client"
});
assertEquals
(
d
.
getFcInterface
(
"server"
),
bc
.
lookupFc
(
"client"
));
bc
.
unbindFc
(
"client"
);
assertEquals
(
null
,
bc
.
lookupFc
(
"client"
));
}
// public void testCollectionBindLookupUnbind () throws Exception {
// BindingController bc = Fractal.getBindingController(c);
// bc.bindFc("clients0", d.getFcInterface("server"));
// checkList(bc, new String[] { "client", "clients0" });
// assertEquals(d.getFcInterface("server"), bc.lookupFc("clients0"));
// bc.unbindFc("clients0");
//
// /*
// * From below, this differs from the original Julia test. The purpose is to
// * illustrate the fact that although clients0 is unbound and is no longer
// * returned with listFc, it is still present in the array returned by
// * getFcInterfaces.
// */
// assertEquals(null, bc.lookupFc("clients0"));
// checkList(bc, new String[] { "client" });
// checkComponent(c, new HashSet(Arrays.asList(new Object[] {
// COMP, BC, LC, SC, NC, serverI, clientI, clients0I
// })));
// }
protected
void
checkList
(
BindingController
bc
,
String
[]
expected
)
{
String
[]
names
=
bc
.
listFc
();
HashSet
nameSet
=
new
HashSet
();
for
(
int
i
=
0
;
i
<
names
.
length
;
++
i
)
{
String
name
=
names
[
i
];
if
(!
nameSet
.
add
(
name
))
{