com.xenonsoft.bridgetown.test
Class TestRecursiveConstruction

java.lang.Object
  extended byjunit.framework.Assert
      extended byjunit.framework.TestCase
          extended bycom.xenonsoft.bridgetown.test.TestRecursiveConstruction
All Implemented Interfaces:
junit.framework.Test

public class TestRecursiveConstruction
extends junit.framework.TestCase

A unit test to check validity of recursive constructor injection.

One of the test demonstrates that recursive constructor injection with cyclic dependencies is impossible with Java SDK circa 2004 / 2005!!!

The other test demonstrates how to unravel the former cyclic dependency in Bridgetown. Use property injection for one of the beans instead of constructor injection. In other words this is a work around!

Version:
$Id: TestRecursiveConstruction.java,v 1.3 2005/03/29 23:42:21 peter_pilgrim Exp $
Author:
Peter Pilgrim, 10-Aug-2004

Field Summary
static java.lang.String CONFIG_FILE1
          Configuration file
static java.lang.String CONFIG_FILE2
          Configuration file
 
Constructor Summary
TestRecursiveConstruction(java.lang.String name)
          Constructor for TestCalcService.
 
Method Summary
static void main(java.lang.String[] args)
           
protected  void setUp()
           
static junit.framework.Test suite()
           
protected  void tearDown()
           
 void testRecursive1()
          Test construction injection where we have two beans that both reference each other.
 void testRecursive2()
          Test construction injection where we have two beans that both reference each other.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, 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

CONFIG_FILE1

public static final java.lang.String CONFIG_FILE1
Configuration file

See Also:
Constant Field Values

CONFIG_FILE2

public static final java.lang.String CONFIG_FILE2
Configuration file

See Also:
Constant Field Values
Constructor Detail

TestRecursiveConstruction

public TestRecursiveConstruction(java.lang.String name)
Constructor for TestCalcService.

Parameters:
name -
Method Detail

main

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

suite

public static junit.framework.Test suite()

setUp

protected void setUp()
              throws java.lang.Exception
Throws:
java.lang.Exception

tearDown

protected void tearDown()
                 throws java.lang.Exception
Throws:
java.lang.Exception

testRecursive1

public void testRecursive1()
Test construction injection where we have two beans that both reference each other. Can the assembly factory work out how to initialise them successfully?

NB: For the current default implementation AbstractServiceAssembler cannot be successfully resolve this case. Therefore the method checks for a thrown RecursiveDependencyException and then exits normally.


testRecursive2

public void testRecursive2()
Test construction injection where we have two beans that both reference each other. Can the assembly factory work out how to initialise them successfully?

In this case we uses a work around either method injection or setter injection after construction.



Copyright © 2005 XeNoNSoFT.com. All Rights Reserved.