* @return Scope.
*/
public Scope start() {
- Scope scope = new DefaultScope(getProvidedInterfaces());
+ Scope scope = new DefaultScope(getProvidedInterfaces().toArray());
return super.start(scope);
}
protected Scope doStart(Scope aExternalScope) {
checkSealed();
validate();
- Scope scope = new DefaultScope(getProvidedInterfaces(), aExternalScope);
+ Scope scope = new DefaultScope(getProvidedInterfaces().toArray(), aExternalScope);
ComponentGraph graph = doStartOptionalDryRun(scope, false);
exposeProvidedInterfaces(graph, aExternalScope, scope);
seal();
private String _context;
private String _name;
- private List<ProvidedInterface> _provided;
- private List<RequiredInterface> _required;
+ private ReadWriteProvidedInterfaces _provided;
+ private ReadWriteRequiredInterfaces _required;
/**
* Constructs the subsystem.
_remaining = new ThreadLocal<List<ProvidedInterface>>();
_context = null;
_name = aName;
- _provided = new ArrayList<ProvidedInterface>();
- _provided.addAll(Arrays.asList(aProvided));
- _required = new ArrayList<RequiredInterface>();
- _required.addAll(Arrays.asList(aRequired));
+ _provided = new ReadWriteProvidedInterfaces(aProvided);
+ _required = new ReadWriteRequiredInterfaces(aRequired);
}
protected AbstractComponent(String aName) {
}
@Override
- public final ProvidedInterface[] getProvidedInterfaces() {
- return _provided.toArray(new ProvidedInterface[0]);
+ public final ProvidedInterfaces getProvidedInterfaces() {
+ return _provided.readOnlyView();
}
@Override
- public final RequiredInterface[] getRequiredInterfaces() {
- return _required.toArray(new RequiredInterface[0]);
+ public final RequiredInterfaces getRequiredInterfaces() {
+ return _required.readOnlyView();
}
@Override
public final Type start(Scope aScope) {
LOG.info("Initialization starting '" + getQualifiedName() + "'");
List<ProvidedInterface> oldRemaining = _remaining.get();
- _remaining.set(new ArrayList<ProvidedInterface>(Arrays.asList(getProvidedInterfaces())));
+ _remaining.set(new ArrayList<ProvidedInterface>(Arrays.asList(getProvidedInterfaces().toArray())));
try {
Type runtime = doStart(aScope);
checkNotStartedInterfaces();
* Gets a description of the provided interfaces.
* @return Provided interfaces.
*/
- ProvidedInterface[] getProvidedInterfaces();
+ ProvidedInterfaces getProvidedInterfaces();
/**
* Gets a description of the required interfaces.
* @return Required interfaces.
*/
- RequiredInterface[] getRequiredInterfaces();
+ RequiredInterfaces getRequiredInterfaces();
/**
--- /dev/null
+/*
+ * Copyright 2008 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.wamblee.system.core;
+
+public interface NamedInterface {
+ /**
+ * Name for the interface.
+ */
+ String getName();
+}
*
* @author Erik Brakkee
*/
-public interface ProvidedInterface {
-
- /**
- * Symbolic name for the service as used by the subsystem.
- * @return Service name.
- */
- String getName();
+public interface ProvidedInterface extends NamedInterface {
/**
* Returns the service type.
--- /dev/null
+/*
+ * Copyright 2008 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.wamblee.system.core;
+
+import java.util.List;
+
+/**
+ * Read-only access to the provided interfaces of a component.
+ *
+ * @author Erik Brakkee.
+ *
+ */
+public class ProvidedInterfaces extends ReadOnlyNamedInterfaces<ProvidedInterface> {
+
+ /**
+ * Constructs the provided interfaces.
+ * @param aInterfaces List of interfaces.
+ */
+ public ProvidedInterfaces(List<ProvidedInterface> aInterfaces) {
+ super(ProvidedInterface.class, aInterfaces);
+ }
+}
--- /dev/null
+/*
+ * Copyright 2008 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.wamblee.system.core;
+
+import java.lang.reflect.Array;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * A set of interfaces that cannot be changed with useful added functionality.
+ *
+ * @author Erik Brakkee
+ *
+ * @param <T>
+ */
+public class ReadOnlyNamedInterfaces<T extends NamedInterface> implements Iterable<T> {
+
+ private Class<T> _type;
+ private List<T> _interfaces;
+
+ public ReadOnlyNamedInterfaces(Class<T> aType, List<T> aInterfaces) {
+ _type = aType;
+ _interfaces = Collections.unmodifiableList(aInterfaces);
+ }
+
+ /**
+ * @return Number of interfaces.
+ */
+ public int size() {
+ return _interfaces.size();
+ }
+
+ /**
+ * Gets the interface at a given index.
+ * @param aIndex Index of the interface to return.
+ * @return Interface.
+ */
+ public T get(int aIndex) {
+ return _interfaces.get(aIndex);
+ }
+
+ /**
+ * Gets the interface with a specific name.
+ * @param aName Interface name.
+ * @return Interface.
+ */
+ public T get(String aName) {
+ for (T intf: _interfaces) {
+ if ( intf.getName().equals(aName)) {
+ return intf;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public Iterator<T> iterator() {
+ return _interfaces.iterator();
+ }
+
+ /**
+ * Converts the interfaces to an array.
+ * @return List of interfaces in an array.
+ */
+ public T[] toArray() {
+ T[] storage = (T[])Array.newInstance(_type, _interfaces.size());
+ return _interfaces.toArray(storage);
+ }
+}
--- /dev/null
+/*
+ * Copyright 2008 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.wamblee.system.core;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+public class ReadWriteNamedInterfaces<T extends NamedInterface> implements Iterable<T> {
+
+ protected List<T> _interfaces;
+
+ public ReadWriteNamedInterfaces() {
+ _interfaces = new ArrayList<T>();
+ }
+
+ public ReadWriteNamedInterfaces(T[] aInterfaces) {
+ _interfaces = new ArrayList<T>();
+ _interfaces.addAll(Arrays.asList(aInterfaces));
+ }
+
+ public int size() {
+ return _interfaces.size();
+ }
+
+ public T get(int aIndex) {
+ return _interfaces.get(aIndex);
+ }
+
+ public T get(String aName) {
+ for (T intf: _interfaces) {
+ if ( intf.getName().equals(aName)) {
+ return intf;
+ }
+ }
+ return null;
+ }
+
+ public void add(T aInterface) {
+ _interfaces.add(aInterface);
+ }
+
+ @Override
+ public Iterator<T> iterator() {
+ return _interfaces.iterator();
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2008 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.wamblee.system.core;
+
+public class ReadWriteProvidedInterfaces extends ReadWriteNamedInterfaces<ProvidedInterface> {
+
+ public ReadWriteProvidedInterfaces() {
+ super();
+ }
+
+ public ReadWriteProvidedInterfaces(ProvidedInterface[] aInterfaces) {
+ super(aInterfaces);
+ }
+
+ public ProvidedInterfaces readOnlyView() {
+ return new ProvidedInterfaces(_interfaces);
+ }
+}
--- /dev/null
+/*
+ * Copyright 2008 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.wamblee.system.core;
+
+public class ReadWriteRequiredInterfaces extends ReadWriteNamedInterfaces<RequiredInterface> {
+
+ public ReadWriteRequiredInterfaces() {
+ super();
+ }
+
+ public ReadWriteRequiredInterfaces(RequiredInterface[] aInterfaces) {
+ super(aInterfaces);
+ }
+
+ public RequiredInterfaces readOnlyView() {
+ return new RequiredInterfaces(_interfaces);
+ }
+}
*/
package org.wamblee.system.core;
-public interface RequiredInterface {
-
- /**
- * Name for the interface.
- */
- String getName();
+public interface RequiredInterface extends NamedInterface {
/**
* @return True iff the required interface is optional.
--- /dev/null
+/*
+ * Copyright 2008 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.wamblee.system.core;
+
+import java.util.List;
+
+/**
+ * Read-only access to required interfaces of a component.
+ * @author Erik Brakkee
+ *
+ */
+public class RequiredInterfaces extends ReadOnlyNamedInterfaces<RequiredInterface> {
+
+ public RequiredInterfaces(List<RequiredInterface> aInterfaces) {
+ super(RequiredInterface.class, aInterfaces);
+ }
+
+}
@Override
public Object doStart(Scope aScope) {
track("start." + getName());
- _string = aScope.getInterfaceImplementation(getRequiredInterfaces()[0].getProvider(), String.class);
- _integer = aScope.getInterfaceImplementation(getRequiredInterfaces()[1].getProvider(), Integer.class);
+ _string = aScope.getInterfaceImplementation(getRequiredInterfaces().get(0).getProvider(), String.class);
+ _integer = aScope.getInterfaceImplementation(getRequiredInterfaces().get(1).getProvider(), Integer.class);
return _random;
}
import org.wamblee.system.core.DefaultScope;
import org.wamblee.system.core.Environment;
import org.wamblee.system.core.ProvidedInterface;
+import org.wamblee.system.core.ProvidedInterfaces;
import org.wamblee.system.core.RequiredInterface;
+import org.wamblee.system.core.RequiredInterfaces;
import org.wamblee.system.core.Scope;
import org.wamblee.system.core.StringComponent;
import org.wamblee.system.core.SystemAssemblyException;
application }, new ProvidedInterface[0],
new RequiredInterface[0]);
Scope runtime = system.start();
- RequiredInterface[] required = system.getRequiredInterfaces();
- assertEquals(0, required.length);
- ProvidedInterface[] provided = system.getProvidedInterfaces();
- assertEquals(0, provided.length);
+ RequiredInterfaces required = system.getRequiredInterfaces();
+ assertEquals(0, required.size());
+ ProvidedInterfaces provided = system.getProvidedInterfaces();
+ assertEquals(0, provided.size());
AssertionUtils.assertEquals(new String[] { "start.environment",
"start.application" }, _tracker.getEvents(
application }, new ProvidedInterface[0],
new RequiredInterface[] { new DefaultRequiredInterface("float",
Float.class) });
- system.getRequiredInterfaces()[0]
+ system.getRequiredInterfaces().get(0)
.setProvider(new DefaultProvidedInterface("hallo", Float.class));
system.start();
- RequiredInterface[] required = system.getRequiredInterfaces();
- assertEquals(1, required.length);
- ProvidedInterface[] provided = system.getProvidedInterfaces();
- assertEquals(0, provided.length);
+ RequiredInterfaces required = system.getRequiredInterfaces();
+ assertEquals(1, required.size());
+ ProvidedInterfaces provided = system.getProvidedInterfaces();
+ assertEquals(0, provided.size());
}
public void testCompositeWithExternalDependencesNotProvided() {
Component application = new Application();
Container system = new Container("all",
new Component[] { application }, new ProvidedInterface[0],
- application.getRequiredInterfaces());
+ application.getRequiredInterfaces().toArray());
system.start();
} catch (SystemAssemblyException e) {
return;
Component application = new Application();
Container system = new Container("all",
new Component[] { application }, new ProvidedInterface[0],
- application.getRequiredInterfaces());
+ application.getRequiredInterfaces().toArray());
environment.start(new DefaultScope(new ProvidedInterface[0]));
- system.getRequiredInterfaces()[0].setProvider(environment
- .getProvidedInterfaces()[0]);
- system.getRequiredInterfaces()[1].setProvider(environment
- .getProvidedInterfaces()[1]);
+ system.getRequiredInterfaces().get(0).setProvider(environment
+ .getProvidedInterfaces().get(0));
+ system.getRequiredInterfaces().get(1).setProvider(environment
+ .getProvidedInterfaces().get(1));
system.start();
- RequiredInterface[] required = system.getRequiredInterfaces();
- assertEquals(2, required.length);
- ProvidedInterface[] provided = system.getProvidedInterfaces();
- assertEquals(0, provided.length);
+ RequiredInterfaces required = system.getRequiredInterfaces();
+ assertEquals(2, required.size());
+ ProvidedInterfaces provided = system.getProvidedInterfaces();
+ assertEquals(0, provided.size());
}
new Component[] { application }, new ProvidedInterface[0],
Application.required(true));
Environment env = new Environment();
- container.getRequiredInterfaces()[0].setProvider(env
- .getProvidedInterfaces()[0]);
- container.getRequiredInterfaces()[1].setProvider(env
- .getProvidedInterfaces()[1]);
- Scope external = new DefaultScope(env.getProvidedInterfaces());
+ container.getRequiredInterfaces().get(0).setProvider(env
+ .getProvidedInterfaces().get(0));
+ container.getRequiredInterfaces().get(1).setProvider(env
+ .getProvidedInterfaces().get(1));
+ Scope external = new DefaultScope(env.getProvidedInterfaces().toArray());
env.start(external);
container.start(external);
- assertSame(env.getProvidedInterfaces()[0], container
- .getRequiredInterfaces()[0].getProvider());
- assertSame(env.getProvidedInterfaces()[1], container
- .getRequiredInterfaces()[1].getProvider());
- assertSame(env.getProvidedInterfaces()[0], application
- .getRequiredInterfaces()[0].getProvider());
- assertSame(env.getProvidedInterfaces()[1], application
- .getRequiredInterfaces()[1].getProvider());
+ assertSame(env.getProvidedInterfaces().get(0), container
+ .getRequiredInterfaces().get(0).getProvider());
+ assertSame(env.getProvidedInterfaces().get(1), container
+ .getRequiredInterfaces().get(1).getProvider());
+ assertSame(env.getProvidedInterfaces().get(0), application
+ .getRequiredInterfaces().get(0).getProvider());
+ assertSame(env.getProvidedInterfaces().get(1), application
+ .getRequiredInterfaces().get(1).getProvider());
}
public void testOptionalRequiredInterfaceNotProvidedOptionalInternal() {
new Component[] { application }, new ProvidedInterface[0],
Application.required(true));
Environment env = new Environment();
- container.getRequiredInterfaces()[0].setProvider(env
- .getProvidedInterfaces()[0]);
+ container.getRequiredInterfaces().get(0).setProvider(env
+ .getProvidedInterfaces().get(0));
Scope external = new DefaultScope(new ProvidedInterface[0]);
- external.publishInterface(env.getProvidedInterfaces()[0], env
+ external.publishInterface(env.getProvidedInterfaces().get(0), env
.getString());
container.start(external);
- assertSame(env.getProvidedInterfaces()[0], container
- .getRequiredInterfaces()[0].getProvider());
- assertNull(container.getRequiredInterfaces()[1].getProvider());
- assertSame(env.getProvidedInterfaces()[0], application
- .getRequiredInterfaces()[0].getProvider());
- assertNull(application.getRequiredInterfaces()[1].getProvider());
+ assertSame(env.getProvidedInterfaces().get(0), container
+ .getRequiredInterfaces().get(0).getProvider());
+ assertNull(container.getRequiredInterfaces().get(1).getProvider());
+ assertSame(env.getProvidedInterfaces().get(0), application
+ .getRequiredInterfaces().get(0).getProvider());
+ assertNull(application.getRequiredInterfaces().get(1).getProvider());
}
public void testOptionalRequiredInterfaceProvidedMandatoryInternal() {
new Component[] { application }, new ProvidedInterface[0],
Application.required(true));
Environment env = new Environment();
- container.getRequiredInterfaces()[0].setProvider(env
- .getProvidedInterfaces()[0]);
- container.getRequiredInterfaces()[1].setProvider(env
- .getProvidedInterfaces()[1]);
+ container.getRequiredInterfaces().get(0).setProvider(env
+ .getProvidedInterfaces().get(0));
+ container.getRequiredInterfaces().get(1).setProvider(env
+ .getProvidedInterfaces().get(1));
try {
container.start();
} catch (SystemAssemblyException e) {
ProvidedInterface provided = new DefaultProvidedInterface("hallo",
Integer.class);
- container.getRequiredInterfaces()[0].setProvider(provided);
+ container.getRequiredInterfaces().get(0).setProvider(provided);
Scope external = new DefaultScope(new ProvidedInterface[0]);
external.publishInterface(provided, 100);
}
}, SystemAssemblyException.class);
- container.connectExternalRequired("1", app.getRequiredInterfaces()[0]
+ container.connectExternalRequired("1", app.getRequiredInterfaces().get(0)
.getName(), "y");
ProvidedInterface i = new DefaultProvidedInterface("i", Integer.class);
externalScope.publishInterface(x, "x-value");
externalScope.publishInterface(y, "y-value");
- container.getRequiredInterfaces()[0].setProvider(i);
- container.getRequiredInterfaces()[1].setProvider(x);
- container.getRequiredInterfaces()[2].setProvider(y);
+ container.getRequiredInterfaces().get(0).setProvider(i);
+ container.getRequiredInterfaces().get(1).setProvider(x);
+ container.getRequiredInterfaces().get(2).setProvider(y);
Scope runtime = container.start(externalScope);
// now choose env2
- container.connectExternalProvided(container.getProvidedInterfaces()[0]
- .getName(), env2.getName(), env2.getProvidedInterfaces()[0]
+ container.connectExternalProvided(container.getProvidedInterfaces().get(0)
+ .getName(), env2.getName(), env2.getProvidedInterfaces().get(0)
.getName());
Scope scope = container.start();
// check the value of the provided interface of the container
String value = scope.getInterfaceImplementation(container
- .getProvidedInterfaces()[0], String.class);
+ .getProvidedInterfaces().get(0), String.class);
assertNotNull(value);
assertEquals(value, env2.getString());
assertFalse(value.equals(env1.getString()));
// Empty.
}
};
- component.start(new DefaultScope(component.getProvidedInterfaces()));
+ component.start(new DefaultScope(component.getProvidedInterfaces().toArray()));
} catch (SystemAssemblyException e) {
//e.printStackTrace();
return;
// Empty.
}
};
- component.start(new DefaultScope(component.getProvidedInterfaces()));
+ component.start(new DefaultScope(component.getProvidedInterfaces().toArray()));
} catch (SystemAssemblyException e) {
//e.printStackTrace();
return;
@Override
protected Object doStart(Scope aScope) {
- addInterface(getProvidedInterfaces()[0], getString(), aScope);
- addInterface(getProvidedInterfaces()[1], getInteger(), aScope);
+ addInterface(getProvidedInterfaces().get(0), getString(), aScope);
+ addInterface(getProvidedInterfaces().get(1), getInteger(), aScope);
track("start." + getName());
return _random;
}
@Override
protected Object doStart(Scope aScope) {
- addInterface(getProvidedInterfaces()[1], getInteger(), aScope);
+ addInterface(getProvidedInterfaces().get(1), getInteger(), aScope);
track("start." + getName());
return _random;
}
@Override
protected Object doStart(Scope aScope) {
- addInterface(getProvidedInterfaces()[0], getString(), aScope);
+ addInterface(getProvidedInterfaces().get(0), getString(), aScope);
track("start." + getName());
return _random;
}
public void testEmpty() {
EdgeFilter restriction = new CompositeEdgeFilter();
- assertFalse(restriction.isViolated(createEdge(_app, _app.getRequiredInterfaces()[0],
- _env, _env.getProvidedInterfaces()[0])));
+ assertFalse(restriction.isViolated(createEdge(_app, _app.getRequiredInterfaces().get(0),
+ _env, _env.getProvidedInterfaces().get(0))));
}
private void configureRestriction(EdgeFilter base, boolean aResult) {
configureRestriction(base, false);
control.replay();
- assertFalse(composite.isViolated(createEdge(_app, _app.getRequiredInterfaces()[0],
- _env, _env.getProvidedInterfaces()[0])));
+ assertFalse(composite.isViolated(createEdge(_app, _app.getRequiredInterfaces().get(0),
+ _env, _env.getProvidedInterfaces().get(0))));
control.verify();
// Second let the base return true and verify the result.
configureRestriction(base, true);
control.replay();
- assertTrue(composite.isViolated(createEdge(_app, _app.getRequiredInterfaces()[0],
- _env, _env.getProvidedInterfaces()[0])));
+ assertTrue(composite.isViolated(createEdge(_app, _app.getRequiredInterfaces().get(0),
+ _env, _env.getProvidedInterfaces().get(0))));
control.verify();
}
configureRestriction(base1, false);
configureRestriction(base2, false);
control.replay();
- assertFalse(composite.isViolated(createEdge(_app, _app.getRequiredInterfaces()[0],
- _env, _env.getProvidedInterfaces()[0])));
+ assertFalse(composite.isViolated(createEdge(_app, _app.getRequiredInterfaces().get(0),
+ _env, _env.getProvidedInterfaces().get(0))));
control.verify();
control.reset();
configureRestriction(base1, false);
configureRestriction(base2, true);
control.replay();
- assertTrue(composite.isViolated(createEdge(_app, _app.getRequiredInterfaces()[0],
- _env, _env.getProvidedInterfaces()[0])));
+ assertTrue(composite.isViolated(createEdge(_app, _app.getRequiredInterfaces().get(0),
+ _env, _env.getProvidedInterfaces().get(0))));
control.verify();
control.reset();
configureRestriction(base1, true);
// base 2 should not be called.
control.replay();
- assertTrue(composite.isViolated(createEdge(_app, _app.getRequiredInterfaces()[0],
- _env, _env.getProvidedInterfaces()[0])));
+ assertTrue(composite.isViolated(createEdge(_app, _app.getRequiredInterfaces().get(0),
+ _env, _env.getProvidedInterfaces().get(0))));
control.verify();
control.reset();
}
String.class));
_internal = new Environment("env1");
- _externalInterfaceName = _container.getProvidedInterfaces()[0]
+ _externalInterfaceName = _container.getProvidedInterfaces().get(0)
.getName();
_internalComponentName = _internal.getName();
- _internalInterfaceName = _internal.getProvidedInterfaces()[0].getName();
+ _internalInterfaceName = _internal.getProvidedInterfaces().get(0).getName();
_edge = new DefaultEdge(new ExternalProvidedInterfaceNode(_container,
- _container.getProvidedInterfaces()[0]),
+ _container.getProvidedInterfaces().get(0)),
new ProvidedInterfaceNode(_internal, _internal
- .getProvidedInterfaces()[0]));
+ .getProvidedInterfaces().get(0)));
}
public void testWrongExternal() {
.addRequiredInterface(new DefaultRequiredInterface("x",
String.class));
Node req = new RequiredInterfaceNode(_comp, _comp
- .getRequiredInterfaces()[0]);
+ .getRequiredInterfaces().get(0));
Node external = new ExternalRequiredInterfaceNode(_container,
- _container.getRequiredInterfaces()[0]);
+ _container.getRequiredInterfaces().get(0));
_edge = new DefaultEdge(req, external);
}
public void testRightComponentRightInterface() {
EdgeFilter filter = new ConnectRequiredExternallyRequiredEdgeFilter(
- _comp.getName(), _comp.getRequiredInterfaces()[0].getName(),
- _container.getRequiredInterfaces()[0].getName());
+ _comp.getName(), _comp.getRequiredInterfaces().get(0).getName(),
+ _container.getRequiredInterfaces().get(0).getName());
assertFalse(filter.isViolated(_edge));
}
public void testWrongInterface() {
EdgeFilter filter = new ConnectRequiredExternallyRequiredEdgeFilter(
- _comp.getName(), _comp.getRequiredInterfaces()[0].getName()
- + "xx", _container.getRequiredInterfaces()[0].getName());
+ _comp.getName(), _comp.getRequiredInterfaces().get(0).getName()
+ + "xx", _container.getRequiredInterfaces().get(0).getName());
assertFalse(filter.isViolated(_edge));
}
public void testWrongComponent() {
EdgeFilter filter = new ConnectRequiredExternallyRequiredEdgeFilter(
- _comp.getName() + "xx", _comp.getRequiredInterfaces()[0]
- .getName(), _container.getRequiredInterfaces()[0]
+ _comp.getName() + "xx", _comp.getRequiredInterfaces().get(0)
+ .getName(), _container.getRequiredInterfaces().get(0)
.getName());
assertFalse(filter.isViolated(_edge));
}
public void testWrongExternalInterface() {
EdgeFilter filter = new ConnectRequiredExternallyRequiredEdgeFilter(
- _comp.getName(), _comp.getRequiredInterfaces()[0].getName(),
- _container.getRequiredInterfaces()[0].getName() + "xx");
+ _comp.getName(), _comp.getRequiredInterfaces().get(0).getName(),
+ _container.getRequiredInterfaces().get(0).getName() + "xx");
assertTrue(filter.isViolated(_edge));
}
DefaultEdge edge = new DefaultEdge(new DefaultNode("x"),
new DefaultNode("y"));
EdgeFilter filter = new ConnectRequiredExternallyRequiredEdgeFilter(
- _comp.getName(), _comp.getRequiredInterfaces()[0].getName(),
- _container.getRequiredInterfaces()[0].getName());
+ _comp.getName(), _comp.getRequiredInterfaces().get(0).getName(),
+ _container.getRequiredInterfaces().get(0).getName());
assertFalse(filter.isViolated(edge));
}
}
for (Environment env: new Environment[] { _env1, _env2} ) {
for (Application app: new Application[] { _app1, _app2} ) {
Node from = new RequiredInterfaceNode(
- app, app.getRequiredInterfaces()[0]);
+ app, app.getRequiredInterfaces().get(0));
Node to = new ProvidedInterfaceNode(
- env, env.getProvidedInterfaces()[0]);
+ env, env.getProvidedInterfaces().get(0));
Edge edge = new DefaultEdge(from, to);
result.add(aRestriction.isViolated(edge));
}