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.Container;
21 import org.wamblee.system.core.Component;
22 import org.wamblee.system.core.DefaultProvidedInterface;
23 import org.wamblee.system.core.Environment;
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;
36 public class ConnectExternalProvidedProvidedEdgeFilterTest extends TestCase {
40 private Container container;
45 private Component<Object> internal;
50 private String externalInterfaceName;
55 private String internalComponentName;
60 private String internalInterfaceName;
70 * @throws Exception DOCUMENT ME!
73 protected void setUp() throws Exception {
74 container = new Container("container")
75 .addProvidedInterface(new DefaultProvidedInterface("string",
77 internal = new Environment("env1");
79 externalInterfaceName = container.getProvidedInterfaces().get(0)
81 internalComponentName = internal.getName();
82 internalInterfaceName = internal.getProvidedInterfaces().get(0)
85 edge = new DefaultEdge(new ExternalProvidedInterfaceNode(
86 container, container.getProvidedInterfaces().get(0)),
87 new ProvidedInterfaceNode(internal,
88 internal.getProvidedInterfaces().get(0)));
94 public void testWrongExternal() {
95 EdgeFilter filter = new ConnectExternalProvidedProvidedFilter(externalInterfaceName
96 + "x", internalComponentName, internalInterfaceName);
97 assertFalse(filter.isViolated(edge));
103 public void testRightExternalWrongComponent() {
104 EdgeFilter filter = new ConnectExternalProvidedProvidedFilter(externalInterfaceName,
105 internalComponentName + "x", internalInterfaceName);
106 assertTrue(filter.isViolated(edge));
112 public void testRightExternalWrongInternal() {
113 EdgeFilter filter = new ConnectExternalProvidedProvidedFilter(externalInterfaceName,
114 internalComponentName, internalInterfaceName + "x");
115 assertTrue(filter.isViolated(edge));
121 public void testEverythingRight() {
122 EdgeFilter filter = new ConnectExternalProvidedProvidedFilter(externalInterfaceName,
123 internalComponentName, internalInterfaceName);
124 assertFalse(filter.isViolated(edge));
130 public void testWrongEdgeType() {
131 EdgeFilter filter = new ConnectExternalProvidedProvidedFilter(externalInterfaceName,
132 internalComponentName, internalInterfaceName);
133 DefaultEdge edge = new DefaultEdge(new DefaultNode("x"),
134 new DefaultNode("y"));
135 assertFalse(filter.isViolated(edge));