diff options
author | dims <dims@13f79535-47bb-0310-9956-ffa450edef68> | 2008-06-17 00:23:01 +0000 |
---|---|---|
committer | dims <dims@13f79535-47bb-0310-9956-ffa450edef68> | 2008-06-17 00:23:01 +0000 |
commit | bdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a (patch) | |
tree | 38a92061c0793434c4be189f1d70c3458b6bc41d /sandbox/ant/container.easy |
Move Tuscany from Incubator to top level.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sandbox/ant/container.easy')
26 files changed, 1860 insertions, 0 deletions
diff --git a/sandbox/ant/container.easy/NOTICE.txt b/sandbox/ant/container.easy/NOTICE.txt new file mode 100644 index 0000000000..d83ebbe236 --- /dev/null +++ b/sandbox/ant/container.easy/NOTICE.txt @@ -0,0 +1,14 @@ +${pom.name} +Copyright (c) 2005 - 2006 The Apache Software Foundation + +Apache Tuscany is an effort undergoing incubation at The Apache Software +Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is +required of all newly accepted projects until a further review indicates that +the infrastructure, communications, and decision making process have stabilized +in a manner consistent with other successful ASF projects. While incubation +status is not necessarily a reflection of the completeness or stability of the +code, it does indicate that the project has yet to be fully endorsed by the ASF. + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + diff --git a/sandbox/ant/container.easy/pom.xml b/sandbox/ant/container.easy/pom.xml new file mode 100644 index 0000000000..4408b9f1ad --- /dev/null +++ b/sandbox/ant/container.easy/pom.xml @@ -0,0 +1,68 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. +--> +<project> + + <parent> + <groupId>org.apache.tuscany.sca.services.containers</groupId> + <artifactId>parent</artifactId> + <version>1.0-incubator-M2-SNAPSHOT</version> + </parent> + + <modelVersion>4.0.0</modelVersion> + <artifactId>easy-container</artifactId> + <name>Apache Tuscany Easy Container</name> + <description>Apache Tuscany Easy Container</description> + + <dependencies> + + <dependency> + <groupId>org.apache.tuscany.sca.kernel</groupId> + <artifactId>core</artifactId> + <version>${sca.version}</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca.kernel</groupId> + <artifactId>tuscany-spi</artifactId> + <version>${sca.version}</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>test</artifactId> + <version>${sca.version}</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.easymock</groupId> + <artifactId>easymock</artifactId> + </dependency> + + <dependency> + <groupId>org.easymock</groupId> + <artifactId>easymockclassextension</artifactId> + </dependency> + + </dependencies> + +</project> diff --git a/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/AsyncInvoker.java b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/AsyncInvoker.java new file mode 100644 index 0000000000..e5786e8a51 --- /dev/null +++ b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/AsyncInvoker.java @@ -0,0 +1,210 @@ +/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.tuscany.container.easy;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.services.work.WorkScheduler;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+import org.osoa.sca.SCA;
+import org.osoa.sca.ServiceRuntimeException;
+
+/**
+ * Responsible for performing a non-blocking dispatch on a component implementation instance
+ *
+ * TODO: Pretty much a direct copy of what the groovy container does for async
+ */
+public class AsyncInvoker extends EasyInvoker {
+
+ private static final ContextBinder BINDER = new ContextBinder();
+ private static final Message RESPONSE = new AsyncInvoker.ImmutableMessage();
+
+ private InboundWire wire;
+ private WorkScheduler workScheduler;
+ private AsyncMonitor monitor;
+ private WorkContext workContext;
+ private Object target;
+ private Object messageId;
+
+ /**
+ * Creates a new invoker
+ *
+ * @param operation the operation the invoker is associated with
+ * @param wire
+ * @param component the target component
+ * @param workScheduler the work scheduler to run the invocation
+ * @param monitor the monitor to pass events to
+ * @param workContext
+ */
+ public AsyncInvoker(String operation,
+ InboundWire wire,
+ EasyComponent component,
+ WorkScheduler workScheduler,
+ AsyncMonitor monitor,
+ WorkContext workContext) {
+ super(operation, component);
+ this.wire = wire;
+ this.workScheduler = workScheduler;
+ this.monitor = monitor;
+ this.workContext = workContext;
+ }
+
+ // Override invocation methods to defer invocation to work item
+ // Both methods return null to indicate asynchrony; result will
+ // be conveyed by callback
+ @Override
+ public Object invokeTarget(final Object payload) throws InvocationTargetException {
+ final CompositeContext currentContext = CurrentCompositeContext.getContext();
+ // Schedule the invocation of the next interceptor in a new Work instance
+ try {
+ workScheduler.scheduleWork(new Runnable() {
+ private Object currentMessageId = messageId;
+
+ public void run() {
+ workContext.setCurrentMessageId(null);
+ workContext.setCurrentCorrelationId(currentMessageId);
+ CompositeContext oldContext = CurrentCompositeContext.getContext();
+ try {
+ BINDER.setContext(currentContext);
+ // REVIEW response must be null for one-way and non-null for callback
+ AsyncInvoker.super.invokeTarget(payload);
+ } catch (Exception e) {
+ // REVIEW uncomment when it is available
+ // monitor.executionError(e);
+ e.printStackTrace();
+ } finally {
+ BINDER.setContext(oldContext);
+ }
+ }
+ });
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ return RESPONSE;
+ }
+
+ public Message invoke(Message msg) throws InvocationRuntimeException {
+ // can't just call overriden invoke because it would bypass async
+ try {
+ messageId = msg.getMessageId();
+ wire.addMapping(messageId, msg.getFromAddress());
+ return (Message) invokeTarget(msg.getBody());
+ } catch (Throwable e) {
+ // FIXME need to log exceptions
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ public AsyncInvoker clone() {
+ AsyncInvoker invoker = (AsyncInvoker) super.clone();
+ invoker.workScheduler = this.workScheduler;
+ invoker.monitor = this.monitor;
+ return invoker;
+ }
+
+ /**
+ * Resolves the target service instance or returns a cached one
+ */
+ protected Object getInstance() throws TargetException {
+ if (!isCacheable()) {
+ return component.getTargetInstance();
+ } else {
+ if (target == null) {
+ target = component.getTargetInstance();
+ }
+ return target;
+ }
+ }
+
+ protected static class ContextBinder extends SCA {
+ public void setContext(CompositeContext context) {
+ setCompositeContext(context);
+ }
+
+ public void start() {
+ throw new AssertionError();
+ }
+
+ public void stop() {
+ throw new AssertionError();
+ }
+ }
+
+ /**
+ * A dummy message passed back on an invocation
+ */
+ protected static class ImmutableMessage implements Message {
+
+ public Object getBody() {
+ return null;
+ }
+
+ public void setBody(Object body) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setTargetInvoker(TargetInvoker invoker) {
+ throw new UnsupportedOperationException();
+ }
+
+ public TargetInvoker getTargetInvoker() {
+ return null;
+ }
+
+ public Object getFromAddress() {
+ return null;
+ }
+
+ public void setFromAddress(Object fromAddress) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object getMessageId() {
+ return null;
+ }
+
+ public void setMessageId(Object messageId) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object getCorrelationId() {
+ return null;
+ }
+
+ public void setCorrelationId(Object correlationId) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isFault() {
+ return false;
+ }
+
+ public void setBodyWithFault(Object fault) {
+ throw new UnsupportedOperationException();
+ }
+ }
+}
diff --git a/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/AsyncMonitor.java b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/AsyncMonitor.java new file mode 100644 index 0000000000..ce39877dff --- /dev/null +++ b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/AsyncMonitor.java @@ -0,0 +1,31 @@ +/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.tuscany.container.easy;
+
+/**
+ * A monitor used to log events during non-blocking invocations
+ */
+public interface AsyncMonitor {
+
+ /**
+ * Logs an exception thrown during an invocation
+ */
+ void executionError(Exception e);
+
+}
diff --git a/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyComponent.java b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyComponent.java new file mode 100644 index 0000000000..62e812a782 --- /dev/null +++ b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyComponent.java @@ -0,0 +1,117 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.tuscany.container.easy; + +import static org.apache.tuscany.spi.idl.java.JavaIDLUtils.findMethod; + +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.tuscany.spi.ObjectCreationException; +import org.apache.tuscany.spi.component.CompositeComponent; +import org.apache.tuscany.spi.component.ScopeContainer; +import org.apache.tuscany.spi.component.TargetException; +import org.apache.tuscany.spi.component.WorkContext; +import org.apache.tuscany.spi.extension.AtomicComponentExtension; +import org.apache.tuscany.spi.model.Operation; +import org.apache.tuscany.spi.services.work.WorkScheduler; +import org.apache.tuscany.spi.wire.InboundWire; +import org.apache.tuscany.spi.wire.OutboundWire; +import org.apache.tuscany.spi.wire.TargetInvoker; +import org.apache.tuscany.spi.wire.WireService; + +/** + * A component implementation for script languages. + */ +public class EasyComponent extends AtomicComponentExtension { + + private final List<Class<?>> services; + + private final Map<String, Object> properties; + + protected EasyInstanceFactory instanceFactory; + + public EasyComponent(String name, EasyInstanceFactory instanceFactory, Map<String, Object> properties, List<Class<?>> services, CompositeComponent parent, ScopeContainer scopeContainer, + WireService wireService, WorkContext workContext, WorkScheduler workScheduler) { + + super(name, parent, scopeContainer, wireService, workContext, workScheduler, 0); + + this.instanceFactory = instanceFactory; + this.services = services; + this.scope = scopeContainer.getScope(); + this.properties = properties; + } + + @SuppressWarnings("unchecked") + public Object createInstance() throws ObjectCreationException { + + Map<String, Object> context = new HashMap<String, Object>(getProperties()); + + for (List<OutboundWire> referenceWires : getOutboundWires().values()) { + for (OutboundWire wire : referenceWires) { + Object wireProxy = wireService.createProxy(wire); + context.put(wire.getReferenceName(), wireProxy); + } + } + + return instanceFactory.createInstance(services, context); + } + + public TargetInvoker createTargetInvoker(String targetName, Operation operation) { + Method[] methods = operation.getServiceContract().getInterfaceClass().getMethods(); + Method method = findMethod(operation, methods); + return new EasyInvoker(method.getName(), this); + } + + public TargetInvoker createAsyncTargetInvoker(InboundWire wire, Operation operation) { + return new AsyncInvoker(operation.getName(), wire, this, workScheduler, null, workContext); + } + + // TODO: move all the following up to AtomicComponentExtension? + + public List<Class<?>> getServiceInterfaces() { + return services; + } + + public Map<String, Object> getProperties() { + return properties; + } + + public Object getTargetInstance() throws TargetException { + return scopeContainer.getInstance(this); + } + + public Object getServiceInstance() throws TargetException { + return getServiceInstance(null); + } + + @SuppressWarnings("unchecked") + public Object getServiceInstance(String service) throws TargetException { + InboundWire wire = getInboundWire(service); + if (wire == null) { + TargetException e = new TargetException("ServiceDefinition not found"); // TODO better error message + e.setIdentifier(service); + throw e; + } + return wireService.createProxy(wire); + } + +} diff --git a/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyComponentBuilder.java b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyComponentBuilder.java new file mode 100644 index 0000000000..fd46c77934 --- /dev/null +++ b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyComponentBuilder.java @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.tuscany.container.easy; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.tuscany.spi.builder.BuilderConfigException; +import org.apache.tuscany.spi.component.Component; +import org.apache.tuscany.spi.component.CompositeComponent; +import org.apache.tuscany.spi.component.ScopeContainer; +import org.apache.tuscany.spi.deployer.DeploymentContext; +import org.apache.tuscany.spi.extension.ComponentBuilderExtension; +import org.apache.tuscany.spi.model.ComponentDefinition; +import org.apache.tuscany.spi.model.PropertyValue; +import org.apache.tuscany.spi.model.Scope; +import org.apache.tuscany.spi.model.ServiceDefinition; + +/** + * Extension point for creating {@link ScriptComponent}s from an assembly configuration + */ +public class EasyComponentBuilder extends ComponentBuilderExtension<EasyImplementation> { + + public EasyComponentBuilder() { + } + + protected Class<EasyImplementation> getImplementationType() { + return EasyImplementation.class; + } + + @SuppressWarnings("unchecked") + public Component build(CompositeComponent parent, ComponentDefinition<EasyImplementation> componentDefinition, + DeploymentContext deploymentContext) throws BuilderConfigException { + + String name = componentDefinition.getName(); + EasyImplementation implementation = componentDefinition.getImplementation(); + EasyComponentType componentType = implementation.getComponentType(); + + // get list of services provided by this component + Collection<ServiceDefinition> collection = componentType.getServices().values(); + List<Class<?>> services = new ArrayList<Class<?>>(collection.size()); + for (ServiceDefinition serviceDefinition : collection) { + services.add(serviceDefinition.getServiceContract().getInterfaceClass()); + } + + // get the properties for the component + Map<String, Object> properties = new HashMap<String, Object>(); + for (PropertyValue propertyValue : componentDefinition.getPropertyValues().values()) { + properties.put(propertyValue.getName(), propertyValue.getValueFactory().getInstance()); + } + + // TODO: have ComponentBuilderExtension pass ScopeContainer in on build method? + ScopeContainer scopeContainer; + Scope scope = componentType.getLifecycleScope(); + if (Scope.MODULE == scope) { + scopeContainer = deploymentContext.getModuleScope(); + } else { + scopeContainer = scopeRegistry.getScopeContainer(scope); + } + + return new EasyComponent(name, implementation.getScriptInstanceFactory(), properties, services, parent, scopeContainer, wireService, workContext, workScheduler); + } + +} diff --git a/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyComponentType.java b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyComponentType.java new file mode 100644 index 0000000000..aa3882a0aa --- /dev/null +++ b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyComponentType.java @@ -0,0 +1,62 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.tuscany.container.easy; + +import org.apache.tuscany.spi.model.ComponentType; +import org.apache.tuscany.spi.model.Property; +import org.apache.tuscany.spi.model.ReferenceDefinition; +import org.apache.tuscany.spi.model.Scope; +import org.apache.tuscany.spi.model.ServiceDefinition; + +/** + * A componentType for script components + * TODO: need lifecycle methods init/destroy + * TODO: really need a generic componentType that supports scope and lifecycle + */ +public class EasyComponentType extends ComponentType<ServiceDefinition, ReferenceDefinition, Property<?>> { + + private Scope lifecycleScope = Scope.MODULE; + + public EasyComponentType() { + } + + @SuppressWarnings("unchecked") + public EasyComponentType(ComponentType ct) { + // TODO: A bit hacky but this is so the generic .componentType XML side file can be used for now + setInitLevel(ct.getInitLevel()); + for (Object property : ct.getProperties().values()) { + add((Property) property); + } + for (Object reference : ct.getReferences().values()) { + add((ReferenceDefinition) reference); + } + for (Object service : ct.getServices().values()) { + add((ServiceDefinition) service); + } + } + + public Scope getLifecycleScope() { + return lifecycleScope; + } + + public void setLifecycleScope(Scope lifecycleScope) { + this.lifecycleScope = lifecycleScope; + } + +} diff --git a/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyComponentTypeLoader.java b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyComponentTypeLoader.java new file mode 100644 index 0000000000..ada889e0a1 --- /dev/null +++ b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyComponentTypeLoader.java @@ -0,0 +1,71 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.tuscany.container.easy; + +import java.net.URL; + +import org.apache.tuscany.spi.component.CompositeComponent; +import org.apache.tuscany.spi.deployer.DeploymentContext; +import org.apache.tuscany.spi.extension.ComponentTypeLoaderExtension; +import org.apache.tuscany.spi.loader.LoaderException; +import org.apache.tuscany.spi.model.ComponentType; + +/** + * ComponentType loader for script components + */ +public class EasyComponentTypeLoader extends ComponentTypeLoaderExtension<EasyImplementation> { + + public EasyComponentTypeLoader() { + } + + @Override + protected Class<EasyImplementation> getImplementationClass() { + return EasyImplementation.class; + } + + // TODO: must be possible to move all the following up in to ComponentTypeLoaderExtension + + public void load(CompositeComponent parent, EasyImplementation implementation, DeploymentContext deploymentContext) throws LoaderException { + String sideFile = getSideFileName(implementation.getResourceName()); + URL resource = implementation.getScriptInstanceFactory().getClassLoader().getResource(sideFile); + EasyComponentType componentType; + if (resource == null) { + throw new IllegalArgumentException("missing .componentType side file: " + sideFile); + // TODO: or else implement introspection + } else { + componentType = loadFromSidefile(resource, deploymentContext); + } + implementation.setComponentType(componentType); + } + + protected EasyComponentType loadFromSidefile(URL url, DeploymentContext deploymentContext) throws LoaderException { + ComponentType ct = loaderRegistry.load(null, null, url, ComponentType.class, deploymentContext); + EasyComponentType scriptComponentType = new EasyComponentType(ct); + return scriptComponentType; + } + + protected String getSideFileName(String resourceName) { + int lastDot = resourceName.lastIndexOf('.'); + if (lastDot != -1) { + resourceName = resourceName.substring(0, lastDot); + } + return resourceName + ".componentType"; + } + +} diff --git a/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyImplementation.java b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyImplementation.java new file mode 100644 index 0000000000..891838d1c6 --- /dev/null +++ b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyImplementation.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.tuscany.container.easy; + +import org.apache.tuscany.spi.model.AtomicImplementation; + +/** + * Model object for a script implementation. + */ +public class EasyImplementation extends AtomicImplementation<EasyComponentType> { + + private String resourceName; + + private EasyInstanceFactory scriptInstanceFactory; + + public String getResourceName() { + return resourceName; + } + + public void setResourceName(String resourceName) { + this.resourceName = resourceName; + } + + public EasyInstanceFactory getScriptInstanceFactory() { + return scriptInstanceFactory; + } + + public void setScriptInstanceFactory(EasyInstanceFactory scriptInstanceFactory) { + this.scriptInstanceFactory = scriptInstanceFactory; + } +} diff --git a/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyImplementationLoader.java b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyImplementationLoader.java new file mode 100644 index 0000000000..79d38f1f35 --- /dev/null +++ b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyImplementationLoader.java @@ -0,0 +1,85 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.tuscany.container.easy; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.net.URL; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.spi.annotation.Autowire; +import org.apache.tuscany.spi.extension.LoaderExtension; +import org.apache.tuscany.spi.loader.LoaderException; +import org.apache.tuscany.spi.loader.LoaderRegistry; +import org.apache.tuscany.spi.loader.MissingResourceException; +import org.osoa.sca.annotations.Constructor; + +/** + * Loader for handling implementation.script elements. + * + * <implementation.script script="path/foo.py" class="myclass"> + * + */ +public abstract class EasyImplementationLoader extends LoaderExtension<EasyImplementation> { + + @Constructor( { "registry" }) + public EasyImplementationLoader(@Autowire LoaderRegistry registry) { + super(registry); + } + + public abstract QName getXMLType(); + + protected String loadSource(ClassLoader cl, String resource) throws LoaderException { + URL url = cl.getResource(resource); + if (url == null) { + throw new MissingResourceException(resource); + } + InputStream is; + try { + is = url.openStream(); + } catch (IOException e) { + MissingResourceException mre = new MissingResourceException(resource, e); + mre.setIdentifier(resource); + throw mre; + } + try { + Reader reader = new InputStreamReader(is, "UTF-8"); + char[] buffer = new char[1024]; + StringBuilder source = new StringBuilder(); + int count; + while ((count = reader.read(buffer)) > 0) { + source.append(buffer, 0, count); + } + return source.toString(); + } catch (IOException e) { + LoaderException le = new LoaderException(e); + le.setIdentifier(resource); + throw le; + } finally { + try { + is.close(); + } catch (IOException e) { + // ignore + } + } + } +} diff --git a/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyInstance.java b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyInstance.java new file mode 100644 index 0000000000..8e80103f04 --- /dev/null +++ b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyInstance.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.tuscany.container.easy; + +import java.lang.reflect.InvocationTargetException; + +/** + * An invokable instance of a script + * + * Basically just a wrapper around a BSF engine with an optional script class object. + */ +public interface EasyInstance { + + public Object invokeTarget(String operationName, Object[] args) throws InvocationTargetException; +} diff --git a/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyInstanceFactory.java b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyInstanceFactory.java new file mode 100644 index 0000000000..403eeb6daf --- /dev/null +++ b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyInstanceFactory.java @@ -0,0 +1,71 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.tuscany.container.easy; + +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * ScriptInstanceFactory creates ScriptInstances for a script + */ +public abstract class EasyInstanceFactory<T extends EasyInstance> { + + protected String resourceName; + + protected ClassLoader classLoader; + + public EasyInstanceFactory(String resourceName, ClassLoader classLoader) { + this.resourceName = resourceName; + this.classLoader = classLoader; + } + + /** + * Create a new invokeable instance of the script + * @param services + * + * @param context + * objects to add to scope of the script instance + * @return a RhinoScriptInstance + * TODO: services should be on the constructor not on this method + */ + public abstract T createInstance(List<Class> services, Map<String, Object> context); + + public String getResourceName() { + return resourceName; + } + + public ClassLoader getClassLoader() { + return classLoader; + } + + protected Map<String, Class> getResponseClasses(List<Class> services) { + Map<String, Class> responseClasses = new HashMap<String, Class>(); + if (services != null) { + for (Class s : services) { + for (Method m : s.getMethods()) { + responseClasses.put(m.getName(), m.getReturnType()); + } + } + } + return responseClasses; + } + +} diff --git a/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyInvoker.java b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyInvoker.java new file mode 100644 index 0000000000..37ba4c5c2d --- /dev/null +++ b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyInvoker.java @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.tuscany.container.easy; + +import java.lang.reflect.InvocationTargetException; + +import org.apache.tuscany.spi.extension.TargetInvokerExtension; + +/** + * TargetInvoker that calls a function on a ScriptInstance + */ +public class EasyInvoker extends TargetInvokerExtension { + + protected EasyComponent component; + + protected String functionName; + + public EasyInvoker(String functionName, EasyComponent component) { + this.functionName = functionName; + this.component = component; + } + + /** + * Invoke the function + */ + public Object invokeTarget(final Object payload) throws InvocationTargetException { + EasyInstance target = (EasyInstance) component.getTargetInstance(); + try { + + return target.invokeTarget(functionName, (Object[]) payload); + + } catch (Exception e) { + throw new InvocationTargetException(e); + } + } + +} diff --git a/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/AsyncInvokerTestCase.java b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/AsyncInvokerTestCase.java new file mode 100644 index 0000000000..b49a74ce57 --- /dev/null +++ b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/AsyncInvokerTestCase.java @@ -0,0 +1,207 @@ +/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.tuscany.container.easy;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.getCurrentArguments;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+
+import java.lang.reflect.Method;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.easy.AsyncInvoker.ContextBinder;
+import org.apache.tuscany.container.easy.AsyncInvoker.ImmutableMessage;
+import org.apache.tuscany.container.easy.mock.AsyncTarget;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.services.work.WorkScheduler;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.MessageImpl;
+import org.easymock.IAnswer;
+import org.easymock.classextension.EasyMock;
+
+/**
+ */
+public class AsyncInvokerTestCase extends TestCase {
+
+ @SuppressWarnings("unchecked")
+ public void testInvoke() throws Exception {
+ EasyInstance instance = createMock(EasyInstance.class);
+ expect(instance.invokeTarget("invoke", null)).andReturn(null).once();
+ replay(instance);
+ EasyComponent component = EasyMock.createMock(EasyComponent.class);
+ expect(component.getTargetInstance()).andReturn(instance);
+ EasyMock.replay(component);
+ AsyncMonitor monitor = createMock(AsyncMonitor.class);
+ replay(monitor);
+
+ WorkScheduler scheduler = createMock(WorkScheduler.class);
+ scheduler.scheduleWork(isA(Runnable.class));
+ expectLastCall().andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ Runnable runnable = (Runnable) getCurrentArguments()[0];
+ runnable.run();
+ return null;
+ }
+ });
+ replay(scheduler);
+ WorkContext context = createMock(WorkContext.class);
+ Method method = AsyncTarget.class.getMethod("invoke");
+ method.setAccessible(true);
+ InboundWire wire = createMock(InboundWire.class);
+ AsyncInvoker invoker = new AsyncInvoker("invoke", wire, component, scheduler, monitor, context);
+ Message msg = new MessageImpl();
+ invoker.invoke(msg);
+ verify(instance);
+ }
+
+ public void testClone() {
+ AsyncInvoker invoker = new AsyncInvoker(null, null, null,null,null,null);
+ assertNotNull(invoker.clone());
+ }
+
+ public void testGetInstance() {
+ EasyComponent component = EasyMock.createMock(EasyComponent.class);
+ expect(component.getTargetInstance()).andReturn("petra");
+ EasyMock.replay(component);
+ AsyncInvoker invoker = new AsyncInvoker(null, null, component,null,null,null);
+ assertEquals("petra", invoker.getInstance());
+ }
+
+ public void testGetInstanceCacheable() {
+ EasyComponent component = EasyMock.createMock(EasyComponent.class);
+ expect(component.getTargetInstance()).andReturn("petra");
+ EasyMock.replay(component);
+ AsyncInvoker invoker = new AsyncInvoker(null, null, component,null,null,null);
+ invoker.setCacheable(true);
+ assertEquals("petra", invoker.getInstance());
+ }
+
+ public void testGetBody() {
+ ImmutableMessage message = new AsyncInvoker.ImmutableMessage();
+ assertNull(message.getBody());
+ }
+
+ public void testSetBody() {
+ ImmutableMessage message = new AsyncInvoker.ImmutableMessage();
+ try {
+ message.setBody(null);
+ fail();
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+ }
+
+ public void testGetTargetInvoker() {
+ ImmutableMessage message = new AsyncInvoker.ImmutableMessage();
+ assertNull(message.getTargetInvoker());
+ }
+
+ public void testSetTargetInvoker() {
+ ImmutableMessage message = new AsyncInvoker.ImmutableMessage();
+ try {
+ message.setTargetInvoker(null);
+ fail();
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+ }
+
+ public void testGetFromAddress() {
+ ImmutableMessage message = new AsyncInvoker.ImmutableMessage();
+ assertNull(message.getFromAddress());
+ }
+
+ public void testSetFromAddress() {
+ ImmutableMessage message = new AsyncInvoker.ImmutableMessage();
+ try {
+ message.setFromAddress(null);
+ fail();
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+ }
+
+ public void testGetMessageId() {
+ ImmutableMessage message = new AsyncInvoker.ImmutableMessage();
+ assertNull(message.getMessageId());
+ }
+
+ public void testSetMessageId() {
+ ImmutableMessage message = new AsyncInvoker.ImmutableMessage();
+ try {
+ message.setMessageId(null);
+ fail();
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+ }
+
+ public void testGetCorrelationId() {
+ ImmutableMessage message = new AsyncInvoker.ImmutableMessage();
+ assertNull(message.getCorrelationId());
+ }
+
+ public void testSetCorrelationId() {
+ ImmutableMessage message = new AsyncInvoker.ImmutableMessage();
+ try {
+ message.setCorrelationId(null);
+ fail();
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+ }
+
+ public void testIsFault() {
+ ImmutableMessage message = new AsyncInvoker.ImmutableMessage();
+ assertFalse(message.isFault());
+ }
+
+ public void testSetBodyWithFault() {
+ ImmutableMessage message = new AsyncInvoker.ImmutableMessage();
+ try {
+ message.setBodyWithFault(null);
+ fail();
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+ }
+
+ public void testContextBinder() {
+ ContextBinder contextBinder = new AsyncInvoker.ContextBinder();
+ contextBinder.setContext(null);
+ try {
+ contextBinder.start();
+ fail();
+ } catch (AssertionError e) {
+ // expected
+ }
+ try {
+ contextBinder.stop();
+ fail();
+ } catch (AssertionError e) {
+ // expected
+ }
+ }
+}
diff --git a/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyComponentBuilderTestCase.java b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyComponentBuilderTestCase.java new file mode 100644 index 0000000000..89858da541 --- /dev/null +++ b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyComponentBuilderTestCase.java @@ -0,0 +1,104 @@ +package org.apache.tuscany.container.easy; + +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.replay; +import junit.framework.TestCase; + +import org.apache.tuscany.core.component.scope.ModuleScopeObjectFactory; +import org.apache.tuscany.core.component.scope.ScopeRegistryImpl; +import org.apache.tuscany.spi.ObjectFactory; +import org.apache.tuscany.spi.component.Component; +import org.apache.tuscany.spi.component.ScopeContainer; +import org.apache.tuscany.spi.component.ScopeRegistry; +import org.apache.tuscany.spi.deployer.DeploymentContext; +import org.apache.tuscany.spi.idl.java.JavaServiceContract; +import org.apache.tuscany.spi.model.ComponentDefinition; +import org.apache.tuscany.spi.model.PropertyValue; +import org.apache.tuscany.spi.model.Scope; +import org.apache.tuscany.spi.model.ServiceContract; +import org.apache.tuscany.spi.model.ServiceDefinition; +import org.easymock.IAnswer; + +public class EasyComponentBuilderTestCase extends TestCase { + + public void testGetImplementationType() { + EasyComponentBuilder builder = new EasyComponentBuilder(); + assertEquals(EasyImplementation.class, builder.getImplementationType()); + } + + @SuppressWarnings("unchecked") + public void testBuild() { + EasyComponentBuilder builder = new EasyComponentBuilder(); + ScopeRegistry scopeRegistry = new ScopeRegistryImpl(); + scopeRegistry.registerFactory(Scope.COMPOSITE, new ModuleScopeObjectFactory(scopeRegistry)); + builder.setScopeRegistry(scopeRegistry); + DeploymentContext deploymentContext = createMock(DeploymentContext.class); + final ScopeContainer scopeContainer = createMock(ScopeContainer.class); + expect(scopeContainer.getScope()).andStubAnswer(new IAnswer() { + public Object answer() throws Throwable { + return Scope.COMPOSITE; + } + }); + expect(deploymentContext.getModuleScope()).andStubAnswer(new IAnswer() { + public Object answer() throws Throwable { + return scopeContainer; + } + }); + replay(deploymentContext); + ComponentDefinition<EasyImplementation> impl = new ComponentDefinition<EasyImplementation>(new EasyImplementation()); + EasyComponentType componentType = new EasyComponentType(); + componentType.setLifecycleScope(Scope.COMPOSITE); + ServiceDefinition service = new ServiceDefinition(); + ServiceContract serviceContract = new JavaServiceContract(); + service.setServiceContract(serviceContract); + componentType.add(service); + impl.getImplementation().setComponentType(componentType); + + PropertyValue pv = new PropertyValue("foo", "", ""); + ObjectFactory pvFactory = createMock(ObjectFactory.class); + expect(pvFactory.getInstance()).andStubAnswer(new IAnswer() { + public Object answer() throws Throwable { + return null; + } + }); + replay(pvFactory); + pv.setValueFactory(pvFactory); + impl.add(pv); + + Component component = builder.build(null, impl, deploymentContext); + assertNotNull(component); + } + + @SuppressWarnings("unchecked") + public void testBuildModuleScope() { + EasyComponentBuilder builder = new EasyComponentBuilder(); + DeploymentContext deploymentContext = createMock(DeploymentContext.class); + final ScopeContainer scopeContainer = createMock(ScopeContainer.class); + expect(scopeContainer.getScope()).andStubAnswer(new IAnswer() { + public Object answer() throws Throwable { + return Scope.MODULE; + } + }); + expect(deploymentContext.getModuleScope()).andStubAnswer(new IAnswer() { + public Object answer() throws Throwable { + return scopeContainer; + } + }); + replay(deploymentContext); + ComponentDefinition<EasyImplementation> impl = new ComponentDefinition<EasyImplementation>(new EasyImplementation()); + EasyComponentType componentType = new EasyComponentType(); + ServiceDefinition service = new ServiceDefinition(); + ServiceContract serviceContract = new JavaServiceContract(); + service.setServiceContract(serviceContract); + componentType.add(service); + impl.getImplementation().setComponentType(componentType); + Component component = builder.build(null, impl, deploymentContext); + assertNotNull(component); + } + + @Override + protected void setUp() throws Exception { + super.setUp(); + } +} diff --git a/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyComponentTestCase.java b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyComponentTestCase.java new file mode 100644 index 0000000000..9f5c2a2f14 --- /dev/null +++ b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyComponentTestCase.java @@ -0,0 +1,142 @@ +package org.apache.tuscany.container.easy; + +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.isA; +import static org.easymock.EasyMock.replay; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import junit.framework.TestCase; + +import org.apache.tuscany.container.easy.mock.MockInstanceFactory; +import org.apache.tuscany.core.wire.InboundWireImpl; +import org.apache.tuscany.core.wire.OutboundWireImpl; +import org.apache.tuscany.spi.component.ScopeContainer; +import org.apache.tuscany.spi.component.TargetException; +import org.apache.tuscany.spi.model.Operation; +import org.apache.tuscany.spi.model.Scope; +import org.apache.tuscany.spi.model.ServiceContract; +import org.apache.tuscany.spi.wire.InboundWire; +import org.apache.tuscany.spi.wire.OutboundWire; +import org.apache.tuscany.spi.wire.RuntimeWire; +import org.apache.tuscany.spi.wire.TargetInvoker; +import org.apache.tuscany.spi.wire.WireService; +import org.easymock.IAnswer; + +public class EasyComponentTestCase extends TestCase { + + private ScopeContainer scopeContainer; + + @SuppressWarnings("unchecked") + public void testCreateTargetInvoker() { + EasyComponent component = new EasyComponent(null,null, null, null, null, scopeContainer, null, null, null); + + Operation operation = new Operation("hashCode", null,null,null,false,null); + ServiceContract contract = new ServiceContract(List.class){}; + operation.setServiceContract(contract); + TargetInvoker invoker = component.createTargetInvoker("hashCode", operation); + + assertNotNull(invoker); + } + + @SuppressWarnings("unchecked") + public void testCreateInstance() throws IOException { + EasyComponent pc = new EasyComponent(null,createBSFEasy(), new HashMap(), null, null, scopeContainer, null, null, null); + Object o = pc.createInstance(); + assertNotNull(o); + assertTrue(o instanceof EasyInstance); + } + + @SuppressWarnings("unchecked") + public void testCreateInstanceWithRef() throws IOException { + WireService wireService = createMock(WireService.class); + expect(wireService.createProxy(isA(RuntimeWire.class))).andStubAnswer(new IAnswer() { + public Object answer() throws Throwable { + return Scope.MODULE; + } + }); + + EasyComponent pc = new EasyComponent(null,createBSFEasy(), new HashMap(), null, null, scopeContainer, wireService, null, null); + OutboundWire wire = new OutboundWireImpl(); + wire.setReferenceName("foo"); + pc.addOutboundWire(wire); + Object o = pc.createInstance(); + assertNotNull(o); + assertTrue(o instanceof EasyInstance); + } + + @SuppressWarnings("unchecked") + public void testGetServiceInstance() { + WireService wireService = createMock(WireService.class); + expect(wireService.createProxy(isA(RuntimeWire.class))).andStubAnswer(new IAnswer() { + public Object answer() throws Throwable { + return "foo"; + } + }); + replay(wireService); + EasyComponent pc = new EasyComponent(null,null, null, null, null, scopeContainer, wireService, null, null); + InboundWire wire = new InboundWireImpl(); + pc.addInboundWire(wire); + assertEquals("foo", pc.getServiceInstance()); + } + + @SuppressWarnings("unchecked") + public void testGetServiceInstanceFail() { + EasyComponent pc = new EasyComponent(null,null, null, null, null, scopeContainer, null, null, null); + try { + pc.getServiceInstance(); + fail(); + } catch (TargetException e) { + // expected + } + } + + @SuppressWarnings("unchecked") + public void testGetproperties() { + EasyComponent pc = new EasyComponent(null,null, new HashMap(), null, null, scopeContainer, null, null, null); + assertNotNull(pc.getProperties()); + } + + @SuppressWarnings("unchecked") + public void testGetServiceInterfaces() { + List services = new ArrayList(); + EasyComponent pc = new EasyComponent(null,null,null, services, null, scopeContainer, null, null, null); + assertEquals(services, pc.getServiceInterfaces()); + } + + @SuppressWarnings("unchecked") + public void testCreateAsyncTargetInvoker() { + EasyComponent pc = new EasyComponent(null,null,null, new ArrayList<Class<?>>(), null, scopeContainer, null, null, null); + assertNotNull(pc.createAsyncTargetInvoker(null, new Operation("foo", null,null,null))); + } + + @Override + @SuppressWarnings("unchecked") + protected void setUp() throws Exception { + super.setUp(); + this.scopeContainer = createMock(ScopeContainer.class); + expect(scopeContainer.getScope()).andStubAnswer(new IAnswer() { + public Object answer() throws Throwable { + return Scope.MODULE; + } + }); + } + + public EasyInstanceFactory createBSFEasy() throws IOException { +// URL scriptURL = getClass().getResource("foo.mock"); +// InputStream is = scriptURL.openStream(); +// StringBuilder sb = new StringBuilder(); +// int i = 0; +// while ((i = is.read()) != -1) { +// sb.append((char) i); +// } +// is.close(); +// String script = sb.toString(); + MockInstanceFactory bsfEasy = new MockInstanceFactory("foo.mock", null); + return bsfEasy; + } +} diff --git a/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyComponentTypeLoaderTestCase.java b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyComponentTypeLoaderTestCase.java new file mode 100644 index 0000000000..2a86172a5e --- /dev/null +++ b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyComponentTypeLoaderTestCase.java @@ -0,0 +1,141 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.tuscany.container.easy; + +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.replay; + +import java.net.MalformedURLException; +import java.net.URL; + +import javax.xml.stream.XMLStreamException; + +import junit.framework.TestCase; + +import org.apache.tuscany.container.easy.mock.MockInstanceFactory; +import org.apache.tuscany.core.loader.LoaderRegistryImpl; +import org.apache.tuscany.spi.component.CompositeComponent; +import org.apache.tuscany.spi.component.ScopeContainer; +import org.apache.tuscany.spi.deployer.DeploymentContext; +import org.apache.tuscany.spi.loader.LoaderException; +import org.apache.tuscany.spi.loader.LoaderRegistry; +import org.apache.tuscany.spi.model.ComponentType; +import org.apache.tuscany.spi.model.ModelObject; +import org.apache.tuscany.spi.model.Scope; +import org.easymock.IAnswer; + +/** + * + */ +public class EasyComponentTypeLoaderTestCase extends TestCase { + + public void testGetSideFileName() { + EasyComponentTypeLoader loader = new EasyComponentTypeLoader(); + assertEquals("BSFEasyTestCase.componentType", loader.getSideFileName("BSFEasyTestCase.mock")); + } + + public void testGetSideFileNameNoDot() { + EasyComponentTypeLoader loader = new EasyComponentTypeLoader(); + assertEquals("BSFEasyTestCase.componentType", loader.getSideFileName("BSFEasyTestCase")); + } + + @SuppressWarnings("unchecked") + public void testLoadFromSideFile() throws MalformedURLException, LoaderException, XMLStreamException { + EasyComponentTypeLoader loader = new EasyComponentTypeLoader(); + LoaderRegistry loaderRegistry = new LoaderRegistryImpl() { + public <MO extends ModelObject> MO load(CompositeComponent parent, ModelObject mo, URL url, Class<MO> type, DeploymentContext ctx) throws LoaderException { + return (MO) new ComponentType(); + } + }; + loader.setLoaderRegistry(loaderRegistry); + loader.loadFromSidefile(null, null); + } + + @SuppressWarnings("unchecked") + public void testLoad() throws LoaderException { + EasyInstanceFactory bsfEasy = new MockInstanceFactory("org/apache/tuscany/container/easy/foo.mock", getClass().getClassLoader()); + EasyComponentTypeLoader loader = new EasyComponentTypeLoader(); + LoaderRegistry loaderRegistry = new LoaderRegistryImpl() { + public <MO extends ModelObject> MO load(CompositeComponent parent, + ModelObject mo, + URL url, + Class<MO> type, + DeploymentContext ctx) throws LoaderException { + return (MO) new ComponentType(); + } + }; + loader.setLoaderRegistry(loaderRegistry); + EasyImplementation implementation = new EasyImplementation(); + implementation.setResourceName("org/apache/tuscany/container/easy/foo.mock"); + implementation.setScriptInstanceFactory(bsfEasy); + DeploymentContext deploymentContext = createMock(DeploymentContext.class); + final ScopeContainer scopeContainer = createMock(ScopeContainer.class); + expect(scopeContainer.getScope()).andStubAnswer(new IAnswer() { + public Object answer() throws Throwable { + return Scope.MODULE; + } + }); + expect(deploymentContext.getModuleScope()).andStubAnswer(new IAnswer() { + public Object answer() throws Throwable { + return scopeContainer; + } + }); + replay(deploymentContext); + loader.load(null, implementation, deploymentContext); + assertNotNull(implementation.getComponentType()); + } + + @SuppressWarnings("unchecked") + public void testLoadMissingSideFile() throws LoaderException { + EasyInstanceFactory bsfEasy = new MockInstanceFactory("org/apche/tuscany/container/easy/foo.mock", getClass().getClassLoader()); + EasyComponentTypeLoader loader = new EasyComponentTypeLoader(); + EasyImplementation implementation = new EasyImplementation(); + implementation.setResourceName("org/apache/tuscany/container/easy/doesntExist"); + implementation.setScriptInstanceFactory(bsfEasy); + DeploymentContext deploymentContext = createMock(DeploymentContext.class); + final ScopeContainer scopeContainer = createMock(ScopeContainer.class); + expect(scopeContainer.getScope()).andStubAnswer(new IAnswer() { + public Object answer() throws Throwable { + return Scope.MODULE; + } + }); + expect(deploymentContext.getModuleScope()).andStubAnswer(new IAnswer() { + public Object answer() throws Throwable { + return scopeContainer; + } + }); + replay(deploymentContext); + try { + loader.load(null, implementation, deploymentContext); + fail(); + } catch (IllegalArgumentException e) { + } + } + + public void testGetImplementationClass() { + EasyComponentTypeLoader loader = new EasyComponentTypeLoader(); + assertEquals(EasyImplementation.class, loader.getImplementationClass()); + } + + @Override + public void setUp() throws Exception { + super.setUp(); + } +} diff --git a/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyComponentTypeTestCase.java b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyComponentTypeTestCase.java new file mode 100644 index 0000000000..5d9b436bc3 --- /dev/null +++ b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyComponentTypeTestCase.java @@ -0,0 +1,37 @@ +package org.apache.tuscany.container.easy; + +import junit.framework.TestCase; + +import org.apache.tuscany.container.easy.EasyComponentType; +import org.apache.tuscany.spi.model.ComponentType; +import org.apache.tuscany.spi.model.Property; +import org.apache.tuscany.spi.model.ReferenceDefinition; +import org.apache.tuscany.spi.model.Scope; +import org.apache.tuscany.spi.model.ServiceDefinition; + +public class EasyComponentTypeTestCase extends TestCase { + + public void testLifecycleScope() { + EasyComponentType ct = new EasyComponentType(); + assertEquals(Scope.MODULE, ct.getLifecycleScope()); + ct.setLifecycleScope(Scope.COMPOSITE); + assertEquals(Scope.COMPOSITE, ct.getLifecycleScope()); + } + + @SuppressWarnings("unchecked") + public void testComponentTypeConstructor() { + ComponentType ct = new ComponentType(); + Property property = new Property(); + ct.add(property); + ReferenceDefinition reference = new ReferenceDefinition(); + ct.add(reference); + ServiceDefinition service = new ServiceDefinition(); + ct.add(service); + + EasyComponentType pct = new EasyComponentType(ct); + + assertEquals(property, pct.getProperties().values().iterator().next()); + assertEquals(reference, pct.getReferences().values().iterator().next()); + assertEquals(service, pct.getServices().values().iterator().next()); + } +} diff --git a/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyImplementationLoaderTestCase.java b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyImplementationLoaderTestCase.java new file mode 100644 index 0000000000..f655015ad4 --- /dev/null +++ b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyImplementationLoaderTestCase.java @@ -0,0 +1,76 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.tuscany.container.easy; + +import static org.easymock.classextension.EasyMock.createMock; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import junit.framework.TestCase; + +import org.apache.tuscany.spi.component.CompositeComponent; +import org.apache.tuscany.spi.deployer.DeploymentContext; +import org.apache.tuscany.spi.loader.LoaderException; +import org.apache.tuscany.spi.loader.LoaderRegistry; +import org.apache.tuscany.spi.loader.MissingResourceException; +import org.apache.tuscany.spi.model.ModelObject; + +/** + * + */ +public class EasyImplementationLoaderTestCase extends TestCase { + + private LoaderRegistry registry; + + private EasyImplementationLoader loader; + + public void testLoadSource() throws LoaderException { + String script = loader.loadSource(getClass().getClassLoader(), "org/apache/tuscany/container/easy/foo.mock"); + assertTrue(script.startsWith("hello")); + } + + public void testLoadSourceMissingResource() throws LoaderException { + try { + loader.loadSource(getClass().getClassLoader(), "doesnt.exist"); + fail(); + } catch (MissingResourceException e) { + // expected + } + } + + public void testGetXMLType() throws LoaderException { + assertEquals("http://foo", loader.getXMLType().getNamespaceURI()); + assertEquals("bar", loader.getXMLType().getLocalPart()); + } + + protected void setUp() throws Exception { + super.setUp(); + registry = createMock(LoaderRegistry.class); + loader = new EasyImplementationLoader(registry){ + public QName getXMLType() { + return new QName("http://foo", "bar"); + } +// @Override + public EasyImplementation load(CompositeComponent arg0, ModelObject arg1, XMLStreamReader arg2, DeploymentContext arg3) throws XMLStreamException, LoaderException { + return null; + }}; + } +} diff --git a/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyImplementationTestCase.java b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyImplementationTestCase.java new file mode 100644 index 0000000000..9a7ec25315 --- /dev/null +++ b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyImplementationTestCase.java @@ -0,0 +1,28 @@ +package org.apache.tuscany.container.easy; + +import junit.framework.TestCase; + +import org.apache.tuscany.container.easy.mock.MockInstanceFactory; + +public class EasyImplementationTestCase extends TestCase { + + private EasyInstanceFactory bsfEasy; + + public void testGetBSFEasy() { + EasyImplementation impl = new EasyImplementation(); + impl.setScriptInstanceFactory(bsfEasy); + assertEquals(bsfEasy, impl.getScriptInstanceFactory()); + } + + public void testGetResourceName() { + EasyImplementation impl = new EasyImplementation(); + impl.setResourceName("foo"); + assertEquals("foo", impl.getResourceName()); + } + + public void setUp() throws Exception { + super.setUp(); + bsfEasy = new MockInstanceFactory("BSFEasyTestCase", null); + } + +} diff --git a/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyInstanceFactoryTestCase.java b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyInstanceFactoryTestCase.java new file mode 100644 index 0000000000..c96d8425eb --- /dev/null +++ b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyInstanceFactoryTestCase.java @@ -0,0 +1,55 @@ +package org.apache.tuscany.container.easy; + +import java.lang.reflect.InvocationTargetException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +import junit.framework.TestCase; + +import org.apache.tuscany.container.easy.mock.MockInstanceFactory; + +public class EasyInstanceFactoryTestCase extends TestCase { + + public void testCreateInstance() throws InvocationTargetException { + MockInstanceFactory factory = new MockInstanceFactory("foo.mock", getClass().getClassLoader()); + Map<String, Object> context = new HashMap<String, Object>(); + context.put("foo", "bar"); + EasyInstance instance = factory.createInstance(null, context); + assertNotNull(instance); + } + + public void testCreateInstanceNoClass() throws InvocationTargetException { + MockInstanceFactory factory = new MockInstanceFactory("foo.mock", getClass().getClassLoader()); + Map<String, Object> context = new HashMap<String, Object>(); + context.put("foo", "bar"); + EasyInstance instance = factory.createInstance(null, context); + assertNotNull(instance); + } + + public void testCreateInstanceRuby() throws InvocationTargetException { + MockInstanceFactory factory = new MockInstanceFactory("foo.mock", getClass().getClassLoader()); + Map<String, Object> context = new HashMap<String, Object>(); + context.put("foo", "bar"); + EasyInstance instance = factory.createInstance(null, context); + assertNotNull(instance); + } + + public void testGetters() throws InvocationTargetException { + MockInstanceFactory factory = new MockInstanceFactory("foo", getClass().getClassLoader()); + assertEquals("foo", factory.getResourceName()); + assertEquals(getClass().getClassLoader(), factory.getClassLoader()); + } + + public void testGetResponseClasses() { + MockInstanceFactory factory = new MockInstanceFactory("foo", getClass().getClassLoader()); + Map<String, Class> classes = factory.getResponseClasses(Arrays.asList( new Class[]{ Runnable.class})); + assertEquals(1, classes.size()); + assertEquals("run", classes.keySet().iterator().next()); + assertEquals(void.class, classes.get("run")); + } + + protected void setUp() throws Exception { + super.setUp(); + } +} diff --git a/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyInvokerTestCase.java b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyInvokerTestCase.java new file mode 100644 index 0000000000..bdd5c4a875 --- /dev/null +++ b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyInvokerTestCase.java @@ -0,0 +1,61 @@ +package org.apache.tuscany.container.easy; + +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.isA; +import static org.easymock.EasyMock.replay; + +import java.lang.reflect.InvocationTargetException; + +import junit.framework.TestCase; + +import org.apache.tuscany.spi.component.AtomicComponent; +import org.apache.tuscany.spi.component.ScopeContainer; +import org.apache.tuscany.spi.model.Scope; +import org.easymock.IAnswer; + +public class EasyInvokerTestCase extends TestCase { + + private EasyComponent component; + + public void testInvokeTarget() throws InvocationTargetException { + EasyInvoker invoker = new EasyInvoker("hello", component); + assertEquals("hello petra", invoker.invokeTarget(null)); + } + + public void testInvokeTargetException() throws InvocationTargetException, SecurityException, NoSuchMethodException { + EasyInvoker badInvoker = new EasyInvoker("bang", component); + try { + badInvoker.invokeTarget(null); + fail(); + } catch (InvocationTargetException e) { + // expected + } + } + + @SuppressWarnings("unchecked") + protected void setUp() throws Exception { + super.setUp(); + + ScopeContainer scopeContainer = createMock(ScopeContainer.class); + expect(scopeContainer.getScope()).andStubAnswer(new IAnswer() { + public Object answer() throws Throwable { + return Scope.MODULE; + } + }); + expect(scopeContainer.getInstance(isA(AtomicComponent.class))).andStubAnswer(new IAnswer() { + public Object answer() throws Throwable { + return new EasyInstance(){ + public Object invokeTarget(String operationName, Object[] args) throws InvocationTargetException { + if ("bang".equals(operationName)) { + throw new RuntimeException("bang"); + } + return "hello petra"; + }}; + } + }); + replay(scopeContainer); + + this.component = new EasyComponent(null, null, null, null, null, scopeContainer, null, null, null); + } +} diff --git a/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/mock/AsyncTarget.java b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/mock/AsyncTarget.java new file mode 100644 index 0000000000..b7317ddcab --- /dev/null +++ b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/mock/AsyncTarget.java @@ -0,0 +1,26 @@ +/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.tuscany.container.easy.mock;
+
+/**
+ */
+public interface AsyncTarget {
+
+ void invoke();
+}
diff --git a/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/mock/MockInstanceFactory.java b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/mock/MockInstanceFactory.java new file mode 100644 index 0000000000..b7c7b3f755 --- /dev/null +++ b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/mock/MockInstanceFactory.java @@ -0,0 +1,30 @@ +package org.apache.tuscany.container.easy.mock; + +import java.lang.reflect.InvocationTargetException; +import java.util.List; +import java.util.Map; + +import org.apache.tuscany.container.easy.EasyInstance; +import org.apache.tuscany.container.easy.EasyInstanceFactory; + +public class MockInstanceFactory extends EasyInstanceFactory<MockInstance> { + + public MockInstanceFactory(String scriptName, ClassLoader classLoader) { + super(scriptName, classLoader); + } + + @Override + public MockInstance createInstance(List<Class> services, Map<String, Object> context) { + return new MockInstance(); + } + +} + +class MockInstance implements EasyInstance { + + public Object invokeTarget(String operationName, Object[] args) throws InvocationTargetException { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/sandbox/ant/container.easy/src/test/resources/org/apache/tuscany/container/easy/foo.componentType b/sandbox/ant/container.easy/src/test/resources/org/apache/tuscany/container/easy/foo.componentType new file mode 100644 index 0000000000..9c37e1cb3e --- /dev/null +++ b/sandbox/ant/container.easy/src/test/resources/org/apache/tuscany/container/easy/foo.componentType @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="ASCII"?>
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="HelloWorldService">
+ <interface.java interface="not.used"/>
+ </service>
+
+</componentType>
diff --git a/sandbox/ant/container.easy/src/test/resources/org/apache/tuscany/container/easy/foo.mock b/sandbox/ant/container.easy/src/test/resources/org/apache/tuscany/container/easy/foo.mock new file mode 100644 index 0000000000..b6fc4c620b --- /dev/null +++ b/sandbox/ant/container.easy/src/test/resources/org/apache/tuscany/container/easy/foo.mock @@ -0,0 +1 @@ +hello
\ No newline at end of file |