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.graph.component;
18 import junit.framework.TestCase;
20 import org.wamblee.system.container.Application;
21 import org.wamblee.system.container.Container;
22 import org.wamblee.system.core.Component;
23 import org.wamblee.system.core.DefaultRequiredInterface;
24 import org.wamblee.system.graph.DefaultEdge;
25 import org.wamblee.system.graph.DefaultNode;
26 import org.wamblee.system.graph.Edge;
27 import org.wamblee.system.graph.EdgeFilter;
28 import org.wamblee.system.graph.Node;
30 public class ConnectRequiredExternallyRequiredEdgeFilterTest extends TestCase {
32 private Component<?> comp;
33 private Container container;
37 protected void setUp() throws Exception {
38 comp = new Application();
39 container = new Container("container")
40 .addRequiredInterface(new DefaultRequiredInterface("x",
42 Node req = new RequiredInterfaceNode(comp, comp
43 .getRequiredInterfaces().get(0));
44 Node external = new ExternalRequiredInterfaceNode(container,
45 container.getRequiredInterfaces().get(0));
46 edge = new DefaultEdge(req, external);
49 public void testRightComponentRightInterface() {
50 EdgeFilter filter = new ConnectRequiredExternallyRequiredEdgeFilter(
51 comp.getName(), comp.getRequiredInterfaces().get(0).getName(),
52 container.getRequiredInterfaces().get(0).getName());
53 assertFalse(filter.isViolated(edge));
56 public void testWrongInterface() {
57 EdgeFilter filter = new ConnectRequiredExternallyRequiredEdgeFilter(
58 comp.getName(), comp.getRequiredInterfaces().get(0).getName()
59 + "xx", container.getRequiredInterfaces().get(0).getName());
60 assertFalse(filter.isViolated(edge));
63 public void testWrongComponent() {
64 EdgeFilter filter = new ConnectRequiredExternallyRequiredEdgeFilter(
65 comp.getName() + "xx", comp.getRequiredInterfaces().get(0)
66 .getName(), container.getRequiredInterfaces().get(0)
68 assertFalse(filter.isViolated(edge));
71 public void testWrongExternalInterface() {
72 EdgeFilter filter = new ConnectRequiredExternallyRequiredEdgeFilter(
73 comp.getName(), comp.getRequiredInterfaces().get(0).getName(),
74 container.getRequiredInterfaces().get(0).getName() + "xx");
75 assertTrue(filter.isViolated(edge));
78 public void testWrongEdgeType() {
79 DefaultEdge edge = new DefaultEdge(new DefaultNode("x"),
80 new DefaultNode("y"));
81 EdgeFilter filter = new ConnectRequiredExternallyRequiredEdgeFilter(
82 comp.getName(), comp.getRequiredInterfaces().get(0).getName(),
83 container.getRequiredInterfaces().get(0).getName());
84 assertFalse(filter.isViolated(edge));