2 * Copyright 2005-2010 the original author or authors.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org.wamblee.system.core;
18 import junit.framework.TestCase;
25 public class AbstractComponentTest extends TestCase {
26 public void testNotAllInterfacesStarted() {
28 Component<?> component = new AbstractComponent<Object>("xx",
29 new ProvidedInterface[] { new DefaultProvidedInterface("xxx",
30 String.class) }, new RequiredInterface[0]) {
32 protected Object doStart(Scope aScope) {
33 // Empty, not starting service.
38 protected void doStop(Object aRuntime) {
44 .start(new DefaultScope(component.getProvidedInterfaces()));
45 } catch (SystemAssemblyException e) {
46 // e.printStackTrace();
53 public void testUnexpectedServicesStarted() {
55 Component<?> component = new AbstractComponent<Object>("xx",
56 new ProvidedInterface[0], new RequiredInterface[0]) {
58 protected Object doStart(Scope aScope) {
59 addInterface(new DefaultProvidedInterface("x",
60 Integer.class), 100, aScope);
66 protected void doStop(Object aRuntime) {
72 .start(new DefaultScope(component.getProvidedInterfaces()));
73 } catch (SystemAssemblyException e) {
74 // e.printStackTrace();