(no commit message)
[utils] / system / general / src / test / java / org / wamblee / system / adapters / ClassConfigurationTest.java
1 /*
2  * Copyright 2008 the original author or authors.
3  * 
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  * 
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  * 
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.wamblee.system.adapters;
17
18 import java.util.List;
19
20 import junit.framework.TestCase;
21
22 import org.wamblee.system.core.DefaultProvidedInterface;
23 import org.wamblee.system.core.DefaultScope;
24 import org.wamblee.system.core.ProvidedInterface;
25 import org.wamblee.system.core.RequiredInterface;
26 import org.wamblee.system.core.Scope;
27 import org.wamblee.test.AssertionUtils;
28 import org.wamblee.test.EventTracker;
29
30 public class ClassConfigurationTest extends AdapterTestCase {
31
32
33         public void testConstructorConfig() {
34                 ClassConfiguration classConfig = new ClassConfiguration(X1.class);
35                 
36                 ConstructorConfiguration config = classConfig.getConstructorConfig()
37                                 .greedy();
38                 ProvidedInterface provided = new DefaultProvidedInterface("arg",
39                                 String.class);
40                 List<RequiredInterface> required = config.getRequiredInterfaces();
41
42                 assertEquals(1, required.size());
43                 assertFalse(required.get(0).isOptional());
44
45                 required.get(0).setProvider(provided);
46
47                 provided.publish("hello", _scope);
48                 config.create(_scope);
49
50                 AssertionUtils.assertEquals(new String[] { "x1(hello)" }, AdapterTestCase.EVENT_TRACKER
51                                 .getEvents(Thread.currentThread()).toArray());
52         }
53 }