import java.io.IOException;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Properties;
public static EventTracker<String> EVENT_TRACKER;
- private Scope _externalScope;
+ private Scope externalScope;
@Override
protected void setUp() throws Exception {
super.setUp();
EVENT_TRACKER = new EventTracker<String>();
- _externalScope = new DefaultScope(new ProvidedInterface[0]);
+ externalScope = new DefaultScope(new ProvidedInterface[0]);
}
public void testBlackboxSystem() {
new HashMap<String, ProvidedInterface>(),
new HashMap<RequiredInterface, String>());
- Scope runtime = system.start(_externalScope);
- assertEquals(0, _externalScope.getProvidedInterfaces().length);
+ Scope runtime = system.start(externalScope);
+ assertEquals(0, externalScope.getProvidedInterfaces().size());
system.stop(runtime);
}
SpringComponent system = new SpringComponent("system",
new String[] { HELLO_SERVICE_SPRING_XML }, provided,
new HashMap<RequiredInterface, String>());
- Scope runtime = system.start(_externalScope);
- ProvidedInterface[] services = runtime.getProvidedInterfaces();
+ Scope runtime = system.start(externalScope);
+ List<ProvidedInterface> services = runtime.getProvidedInterfaces();
- assertEquals(1, services.length);
- Object service = runtime.getInterfaceImplementation(services[0],
+ assertEquals(1, services.size());
+ Object service = runtime.getInterfaceImplementation(services.get(0),
Object.class);
assertTrue(service instanceof HelloService);
// BUG; Provided services should be made available in the external
// scope.
- Object service2 = _externalScope.getInterfaceImplementation(provided
+ Object service2 = externalScope.getInterfaceImplementation(provided
.get("helloService"), Object.class);
assertSame(service, service2);
props.load(new ClassPathResource(PROPERTY_FILE).getInputStream());
system.addProperties(props);
- Scope scope = system.start(_externalScope);
+ Scope scope = system.start(externalScope);
// BUG: Hello service was constructed multiple times. Once with the
// unprocessed property
// and another time with the processed property.
assertEquals(1, EVENT_TRACKER.getEventCount());
- ProvidedInterface[] services = scope.getProvidedInterfaces();
+ List<ProvidedInterface> services = scope.getProvidedInterfaces();
assertEquals("Property Value", scope.getInterfaceImplementation(
- services[0], HelloService.class).say());
+ services.get(0), HelloService.class).say());
}
public void testWithPropertiesAsBean() throws IOException {
props.load(new ClassPathResource(PROPERTY_FILE).getInputStream());
system.addProperties("properties", props);
- Scope scope = system.start(_externalScope);
+ Scope scope = system.start(externalScope);
- ProvidedInterface[] services = scope.getProvidedInterfaces();
+ List<ProvidedInterface> services = scope.getProvidedInterfaces();
- Properties props2 = scope.getInterfaceImplementation(services[0],
+ Properties props2 = scope.getInterfaceImplementation(services.get(0),
HelloService2.class).getProperties();
assertEquals(props, props2);
}
new String[] { HELLO_SERVICE_SPRING_WITH_REQS_XML },
new HashMap<String, ProvidedInterface>(),
new HashMap<RequiredInterface, String>());
- system.start(_externalScope);
+ system.start(externalScope);
} catch (SystemAssemblyException e) {
// e.printStackTrace();
return;
HelloService.class);
Scope scope = new DefaultScope(new ProvidedInterface[] { helloService });
scope.publishInterface(helloService, helloObject);
- system.getRequiredInterfaces()[0].setProvider(helloService);
+ system.getRequiredInterfaces().get(0).setProvider(helloService);
Scope runtime = system.start(scope);
system.stop(runtime);
HelloService.class);
Scope scope = new DefaultScope(new ProvidedInterface[] { helloService });
scope.publishInterface(helloService, helloObject);
- system.getRequiredInterfaces()[0].setProvider(helloService);
+ system.getRequiredInterfaces().get(0).setProvider(helloService);
Scope runtime = system.start(scope);
- ProvidedInterface started = runtime.getProvidedInterfaces()[0];
+ ProvidedInterface started = runtime.getProvidedInterfaces().get(0);
Object impl = runtime.getInterfaceImplementation(started,
BlaService.class);
new String[] { HELLO_SERVICE_SPRING_XML }, provided,
new HashMap<RequiredInterface, String>());
- Scope runtime = system.start(_externalScope);
- ProvidedInterface[] services = runtime.getProvidedInterfaces();
+ Scope runtime = system.start(externalScope);
+ List<ProvidedInterface> services = runtime.getProvidedInterfaces();
- assertEquals(2, services.length);
- Object service = runtime.getInterfaceImplementation(services[0],
+ assertEquals(2, services.size());
+ Object service = runtime.getInterfaceImplementation(services.get(0),
Object.class);
assertTrue(service instanceof HelloService);
// BUG; Provided services should be made available in the external
// scope.
- Object service2 = _externalScope.getInterfaceImplementation(provided
+ Object service2 = externalScope.getInterfaceImplementation(provided
.get("helloService"), Object.class);
assertSame(service, service2);
- Object floatsvc = _externalScope.getInterfaceImplementation(system
- .getProvidedInterfaces()[1], Object.class);
+ Object floatsvc = externalScope.getInterfaceImplementation(system
+ .getProvidedInterfaces().get(1), Object.class);
assertTrue(floatsvc instanceof Float);
assertTrue((((Float) floatsvc).floatValue() - 100.345f) < 0.00001);
Scope scope = new DefaultScope(new ProvidedInterface[] { helloService });
scope.publishInterface(helloService, helloObject);
scope.publishInterface(floatService, 100.234f);
- system.getRequiredInterfaces()[0].setProvider(helloService);
- system.getRequiredInterfaces()[1].setProvider(floatService);
+ system.getRequiredInterfaces().get(0).setProvider(helloService);
+ system.getRequiredInterfaces().get(1).setProvider(floatService);
Scope runtime = system.start(scope);
system.stop(runtime);