X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=system%2Fgeneral%2Fsrc%2Ftest%2Fjava%2Forg%2Fwamblee%2Fsystem%2Fadapters%2FDefaultContainerTest.java;h=108cd961a2b2bb27215c9bae09f237f5a2ac108f;hb=ddd261f331280640c5b53c7128230b629ebcd268;hp=938a12228763493b6596d13a832e6a7c1bc9e98c;hpb=92e23e5ecf9614f2ab770a8cdedc0b21ddf1e127;p=utils diff --git a/system/general/src/test/java/org/wamblee/system/adapters/DefaultContainerTest.java b/system/general/src/test/java/org/wamblee/system/adapters/DefaultContainerTest.java index 938a1222..108cd961 100644 --- a/system/general/src/test/java/org/wamblee/system/adapters/DefaultContainerTest.java +++ b/system/general/src/test/java/org/wamblee/system/adapters/DefaultContainerTest.java @@ -1,12 +1,12 @@ /* * Copyright 2008 the original author or authors. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,69 +16,89 @@ package org.wamblee.system.adapters; import org.wamblee.system.core.Scope; + import org.wamblee.test.AssertionUtils; -public class DefaultContainerTest extends AdapterTestCase { +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class DefaultContainerTest extends AdapterTestCase { + /** + * DOCUMENT ME! + */ public void testConstructorInjection() { ClassConfiguration x1Config = new ClassConfiguration(X1.class); x1Config.getConstructorConfig().getParameters().setValue(0, "hello"); x1Config.getObjectConfig().getSetterConfig().initAllSetters(); - + ClassConfiguration x4Config = new ClassConfiguration(X4.class); x4Config.getObjectConfig().getSetterConfig().initAllSetters(); - DefaultContainer container = new DefaultContainer("top").addComponent( - "x1", x1Config).addComponent("x4", x4Config); + DefaultContainer container = new DefaultContainer("top").addComponent("x1", + x1Config).addComponent("x4", x4Config); - Scope scope = container.start(); + Scope scope = container.start(); AssertionUtils.assertEquals(new String[] { "x1(hello)", "x4(x1)" }, - EVENT_TRACKER.getEvents(Thread.currentThread()).toArray()); + EVENT_TRACKER.getEvents(Thread.currentThread()).toArray()); Object obj = scope.getRuntime("x1"); assertTrue(obj instanceof X1); obj = scope.getRuntime("x4"); assertTrue(obj instanceof X4); } - + + /** + * DOCUMENT ME! + */ public void testConstructorInjectionAndSetterInjection() { ClassConfiguration x1Config = new ClassConfiguration(X1.class); x1Config.getConstructorConfig().getParameters().setValue(0, "hello"); x1Config.getObjectConfig().getSetterConfig().initAllSetters(); - - X8 x8 = new X8(null); + + X8 x8 = new X8(null); EVENT_TRACKER.clear(); ClassConfiguration x4Config = new ClassConfiguration(X4.class); x4Config.getObjectConfig().getSetterConfig().initAllSetters(); - + ObjectConfiguration x8Config = new ObjectConfiguration(X8.class); x8Config.getSetterConfig().initAllSetters(); - - DefaultContainer container = new DefaultContainer("top").addComponent( - "x1", x1Config).addComponent("x4", x4Config).addComponent("x8", x8, x8Config); - Scope scope = container.start(); - AssertionUtils.assertEquals(new String[] { "x1(hello)", "x4(x1)", - "x8.setX4(x4)"}, - EVENT_TRACKER.getEvents(Thread.currentThread()).toArray()); + DefaultContainer container = new DefaultContainer("top").addComponent("x1", + x1Config).addComponent("x4", x4Config) + .addComponent("x8", x8, x8Config); + + Scope scope = container.start(); + AssertionUtils.assertEquals(new String[] { + "x1(hello)", "x4(x1)", "x8.setX4(x4)" + }, EVENT_TRACKER.getEvents(Thread.currentThread()).toArray()); Object obj1 = scope.getRuntime("x1"); assertTrue(obj1 instanceof X1); + Object obj4 = scope.getRuntime("x4"); assertTrue(obj4 instanceof X4); + Object obj8 = scope.getRuntime("x8"); assertSame(x8, obj8); assertSame(obj4, x8.getX4()); } - - public void testWrongObjectType() { + + /** + * DOCUMENT ME! + */ + public void testWrongObjectType() { final DefaultContainer container = new DefaultContainer("top"); AssertionUtils.assertException(new AssertionUtils.ErroneousCode() { - @Override - public void run() throws Exception { - container.addComponent("x", "y", new ObjectConfiguration(Integer.class)); - } - }, IllegalArgumentException.class); + @Override + public void run() throws Exception { + container.addComponent("x", "y", + new ObjectConfiguration(Integer.class)); + } + }, IllegalArgumentException.class); } }