2 * Copyright 2008 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;
27 public class AbstractComponentTest extends TestCase {
31 public void testNotAllInterfacesStarted() {
33 Component<?> component = new AbstractComponent<Object>("xx",
34 new ProvidedInterface[] {
35 new DefaultProvidedInterface("xxx", String.class)
36 }, new RequiredInterface[0]) {
38 protected Object doStart(Scope aScope) {
39 // Empty, not starting service.
44 protected void doStop(Object aRuntime) {
49 component.start(new DefaultScope(component.getProvidedInterfaces()));
50 } catch (SystemAssemblyException e) {
51 //e.printStackTrace();
61 public void testUnexpectedServicesStarted() {
63 Component<?> component = new AbstractComponent<Object>("xx",
64 new ProvidedInterface[0], new RequiredInterface[0]) {
66 protected Object doStart(Scope aScope) {
67 addInterface(new DefaultProvidedInterface("x",
68 Integer.class), 100, aScope);
74 protected void doStop(Object aRuntime) {
79 component.start(new DefaultScope(component.getProvidedInterfaces()));
80 } catch (SystemAssemblyException e) {
81 //e.printStackTrace();