edu.vub.at.objects.symbiosis
Class SymbiosisTest

java.lang.Object
  extended byjunit.framework.Assert
      extended byjunit.framework.TestCase
          extended byedu.vub.at.AmbientTalkTest
              extended byedu.vub.at.objects.symbiosis.SymbiosisTest
All Implemented Interfaces:
junit.framework.Test

public class SymbiosisTest
extends AmbientTalkTest

Tests the symbiosis with Java. This is primarily done by wrapping the SymbiosisTest class and instances itself and invoking some of their non-test prefixed methods.

Author:
tvcutsem

Nested Class Summary
private static class SymbiosisTest.ExceptionTest
           
 
Nested classes inherited from class edu.vub.at.AmbientTalkTest
AmbientTalkTest.Actorscript
 
Field Summary
private  JavaClass atTestClass
           
private  JavaObject atTestObject
           
private  JavaPackage jLobby_
           
private  java.lang.Class jTestClass
           
private  SymbiosisTest jTestObject
           
static int TEST_OBJECT_INIT
           
 int xtest
           
static java.lang.String ytest
           
 
Fields inherited from class edu.vub.at.AmbientTalkTest
ctx_
 
Fields inherited from class junit.framework.TestCase
 
Constructor Summary
SymbiosisTest()
           
SymbiosisTest(AmbientTalkTest t)
           
SymbiosisTest(int xval)
           
SymbiosisTest(JavaClass c)
           
SymbiosisTest(SymbiosisTest t)
           
 
Method Summary
 int gettertest()
           
 boolean identitytest(java.lang.Object obj)
           
static void main(java.lang.String[] args)
           
 java.lang.String overloadedmatch2(java.lang.Object x)
           
 java.lang.String overloadedmatch2(SymbiosisTest x)
           
 java.lang.String overloadedtest()
           
 java.lang.String overloadedtest(double x)
           
 java.lang.String overloadedtest(int x)
           
 java.lang.String overloadedtest(java.lang.Object[] vals)
           
 java.lang.String overloadedtest(SymbiosisTest x)
           
 java.lang.Object overloadedvararg(ATObject[] varargs)
           
 int overloadedvararg(int x)
           
static java.lang.String prefix(java.lang.String msg)
           
 void settertest(int xval)
           
 void setUp()
           
 void testAT2JavaConversion()
          Test the conversion function Symbiosis.ambientTalkToJava for various kinds of input.
 void testBugfixOverloadedConstructor()
          BUGFIX TEST: jlobby.java.lang.StringBuffer.new(10) failed to discriminate between constructors StringBuffer(String) and StringBuffer(int), reason was that anything native was convertible to NATText and also to String.
 void testCasting()
          Tests casting to manually resolve overloaded method invocations Selecting a method from a Java object results in a JavaClosure instance.
 void testCloning()
          Tests cloning behaviour for both wrapped class instances and classes.
 void testCreationViaJavaObject()
          Tests the invocation of new on a wrapped Java Object, rather than on a Java Class.
 void testCustomInstanceCreation()
          Tests the invocation of new on a wrapped Java Class.
 void testExceptionInInstanceCreation()
          Tests an instance creation that raises an exception
 void testFaultyArity()
          Invokes the method 'gettertest' with one argument instead of zero.
 void testFirstClassFields()
          Tests first-class field access for both instances and classes
 void testFirstClassMethods()
          Tests first-class method access for both instances and classes
 void testIllegalArgs()
          Invokes the method 'settertest' with a double (fraction) instead of an int (number)
 void testIllegalArgsInstanceCreation()
          Tests whether incorrect arguments passed to constructor terminate cleanly.
 void testIllegalAssignment()
          Tries to assign to a final public field
 void testInterfacesAndStripes()
          Tests whether Java interface types are correctly treated as AT/2 stripes.
 void testJava2ATConversion()
          Test the conversion function Symbiosis.javaToAmbientTalk for various kinds of input.
 void testJLobbyExplicitClassLoading()
          Tests whether lowercase classes can be loaded via the class method of a JavaPackage.
 void testJLobbyExplicitPackageLoading()
          Tests whether the uppercase package 'foo.Bar' can be loaded via the package method of a JavaPackage.
 void testJLobbyNonexistentClassLoading()
          Tests whether access to a nonexistent class gives rise to a selector not found exception.
 void testJLobbyPackageLoading()
          Tests whether jlobby.java results in a new JavaPackage.
 void testNonExistentMethod()
          Invokes a method that is not defined in the class.
 void testNonInstantiatableCreation()
          Tests whether classes with private constructors terminate cleanly.
 void testOverloadedInstanceCreation()
          Tests whether overloaded constructors which cannot be resolved terminates cleanly.
 void testOverloadedInvWithMultipleMatches()
          Invokes an overloaded method where the symbiosis cannot disambiguate automatically.
 void testOverloadedInvWithNoMatch()
          Invokes an overloaded method that does not match the specified argument type
 void testOverloadedInvWithOneMatch()
          Tests whether overloaded methods can be properly invoked if they can be resolved to one method using the actual arguments.
 void testStripedJavaObject()
          Test whether JavaObject wrappers are correctly striped with all of the interfaces of the wrapped instance's class.
 void testSymbiontClassAdditions()
          Tests whether new per-class methods and fields can be added to a wrapped Java class.
 void testSymbiontDuplicates()
          Tests whether no duplicate methods or fields can be added to a wrapped Java object.
 void testSymbiontInstanceAdditions()
          Tests whether new per-instance methods and fields can be added to a wrapped Java object.
 void testSymbiontParents()
          Tests whether the parent pointers of the AT symbionts refer to the proper objects.
 void testVarArgInvocation()
          Test whether variable arguments work
 void testWorkingClassInvocation()
          Invokes the class method 'prefix' and performs a selection and assignment of the static 'ytest' field
 void testWorkingInstanceCreation()
          Tests the invocation of new on a wrapped Java Class.
 void testWorkingInstanceInvocation()
          Invokes the two instance methods gettertest and settertest on atTestObject.
 
Methods inherited from class edu.vub.at.AmbientTalkTest
actorTest, evalActor, evalAndCompareTo, evalAndCompareTo, evalAndReturn, evalAndTestException, evalInActor, evalSnippet, printedEquals
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

jTestClass

private java.lang.Class jTestClass

atTestClass

private JavaClass atTestClass

jTestObject

private SymbiosisTest jTestObject

atTestObject

private JavaObject atTestObject

jLobby_

private JavaPackage jLobby_

xtest

public int xtest

ytest

public static java.lang.String ytest

TEST_OBJECT_INIT

public static final int TEST_OBJECT_INIT
See Also:
Constant Field Values
Constructor Detail

SymbiosisTest

public SymbiosisTest(int xval)

SymbiosisTest

public SymbiosisTest()

SymbiosisTest

public SymbiosisTest(SymbiosisTest t)

SymbiosisTest

public SymbiosisTest(AmbientTalkTest t)

SymbiosisTest

public SymbiosisTest(JavaClass c)
              throws SymbiosisTest.ExceptionTest
Method Detail

main

public static void main(java.lang.String[] args)

gettertest

public int gettertest()

settertest

public void settertest(int xval)

prefix

public static java.lang.String prefix(java.lang.String msg)

identitytest

public boolean identitytest(java.lang.Object obj)

overloadedtest

public java.lang.String overloadedtest()

overloadedtest

public java.lang.String overloadedtest(int x)

overloadedtest

public java.lang.String overloadedtest(java.lang.Object[] vals)

overloadedtest

public java.lang.String overloadedtest(double x)

overloadedtest

public java.lang.String overloadedtest(SymbiosisTest x)

overloadedvararg

public java.lang.Object overloadedvararg(ATObject[] varargs)

overloadedvararg

public int overloadedvararg(int x)

overloadedmatch2

public java.lang.String overloadedmatch2(java.lang.Object x)

overloadedmatch2

public java.lang.String overloadedmatch2(SymbiosisTest x)

setUp

public void setUp()

testAT2JavaConversion

public void testAT2JavaConversion()
Test the conversion function Symbiosis.ambientTalkToJava for various kinds of input.


testJava2ATConversion

public void testJava2ATConversion()
Test the conversion function Symbiosis.javaToAmbientTalk for various kinds of input.


testWorkingInstanceInvocation

public void testWorkingInstanceInvocation()
Invokes the two instance methods gettertest and settertest on atTestObject. Also performs a selection of the field 'xtest' Also invokes the method 'identitytest' to see whether AT->Java conversion does proper unwrapping


testWorkingClassInvocation

public void testWorkingClassInvocation()
Invokes the class method 'prefix' and performs a selection and assignment of the static 'ytest' field


testFaultyArity

public void testFaultyArity()
Invokes the method 'gettertest' with one argument instead of zero.


testIllegalArgs

public void testIllegalArgs()
Invokes the method 'settertest' with a double (fraction) instead of an int (number)


testIllegalAssignment

public void testIllegalAssignment()
Tries to assign to a final public field


testVarArgInvocation

public void testVarArgInvocation()
Test whether variable arguments work


testOverloadedInvWithOneMatch

public void testOverloadedInvWithOneMatch()
Tests whether overloaded methods can be properly invoked if they can be resolved to one method using the actual arguments.


testOverloadedInvWithMultipleMatches

public void testOverloadedInvWithMultipleMatches()
Invokes an overloaded method where the symbiosis cannot disambiguate automatically.


testOverloadedInvWithNoMatch

public void testOverloadedInvWithNoMatch()
Invokes an overloaded method that does not match the specified argument type


testNonExistentMethod

public void testNonExistentMethod()
Invokes a method that is not defined in the class.


testFirstClassFields

public void testFirstClassFields()
Tests first-class field access for both instances and classes


testFirstClassMethods

public void testFirstClassMethods()
Tests first-class method access for both instances and classes


testCasting

public void testCasting()
Tests casting to manually resolve overloaded method invocations Selecting a method from a Java object results in a JavaClosure instance. Such a Java closure understands the message 'cast', which allows the programmer to manually restrict the wrapped JavaMethods to specific type signatures. In this case, the two choices overloadedmatch2(Object) overloadedmatch2(SymbiosisTest) are manually restricted such that only the second one remains applicable


testSymbiontParents

public void testSymbiontParents()
Tests whether the parent pointers of the AT symbionts refer to the proper objects.


testSymbiontInstanceAdditions

public void testSymbiontInstanceAdditions()
Tests whether new per-instance methods and fields can be added to a wrapped Java object.


testSymbiontDuplicates

public void testSymbiontDuplicates()
Tests whether no duplicate methods or fields can be added to a wrapped Java object.


testSymbiontClassAdditions

public void testSymbiontClassAdditions()
Tests whether new per-class methods and fields can be added to a wrapped Java class. Also tests whether existing instances can make use of these newly added methods


testCloning

public void testCloning()
Tests cloning behaviour for both wrapped class instances and classes.


testWorkingInstanceCreation

public void testWorkingInstanceCreation()
Tests the invocation of new on a wrapped Java Class. Instantiates the Java class via the default init implementation.


testNonInstantiatableCreation

public void testNonInstantiatableCreation()
Tests whether classes with private constructors terminate cleanly.


testIllegalArgsInstanceCreation

public void testIllegalArgsInstanceCreation()
Tests whether incorrect arguments passed to constructor terminate cleanly.


testOverloadedInstanceCreation

public void testOverloadedInstanceCreation()
Tests whether overloaded constructors which cannot be resolved terminates cleanly.


testExceptionInInstanceCreation

public void testExceptionInInstanceCreation()
Tests an instance creation that raises an exception


testCreationViaJavaObject

public void testCreationViaJavaObject()
Tests the invocation of new on a wrapped Java Object, rather than on a Java Class.


testCustomInstanceCreation

public void testCustomInstanceCreation()
Tests the invocation of new on a wrapped Java Class. Instantiates the Java class via a custom new implementation. BEWARE: this test should be the last for testing symbiotic instance creation as it MODIFIES the test fixture (the JavaClass wrapper object)! Ths is because the JavaClass wrapper is pooled and reused throughout subsequent tests.


testJLobbyPackageLoading

public void testJLobbyPackageLoading()
                              throws InterpreterException
Tests whether jlobby.java results in a new JavaPackage. Tests whether jlobby.java.lang results in a new JavaPackage. Tests whether jlobby.java.lang.Object results in the proper loading of that class

Throws:
InterpreterException

testJLobbyExplicitClassLoading

public void testJLobbyExplicitClassLoading()
                                    throws InterpreterException
Tests whether lowercase classes can be loaded via the class method of a JavaPackage.

Throws:
InterpreterException

testJLobbyNonexistentClassLoading

public void testJLobbyNonexistentClassLoading()
                                       throws InterpreterException
Tests whether access to a nonexistent class gives rise to a selector not found exception.

Throws:
InterpreterException

testJLobbyExplicitPackageLoading

public void testJLobbyExplicitPackageLoading()
                                      throws InterpreterException
Tests whether the uppercase package 'foo.Bar' can be loaded via the package method of a JavaPackage.

Throws:
InterpreterException

testBugfixOverloadedConstructor

public void testBugfixOverloadedConstructor()
                                     throws InterpreterException
BUGFIX TEST: jlobby.java.lang.StringBuffer.new(10) failed to discriminate between constructors StringBuffer(String) and StringBuffer(int), reason was that anything native was convertible to NATText and also to String. Fixed by reimplementing asNativeText in NATNil to throw a type exception as usual.

Throws:
InterpreterException

testInterfacesAndStripes

public void testInterfacesAndStripes()
                              throws InterpreterException
Tests whether Java interface types are correctly treated as AT/2 stripes. Test cases: interface java.util.Set extends java.util.Collection

Throws:
InterpreterException

testStripedJavaObject

public void testStripedJavaObject()
                           throws InterpreterException
Test whether JavaObject wrappers are correctly striped with all of the interfaces of the wrapped instance's class. Test case: java.util.Vector implements List, RandomAccess, Cloneable, Serializable

Throws:
InterpreterException