Return-Path: X-Original-To: apmail-tuscany-commits-archive@www.apache.org Delivered-To: apmail-tuscany-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 958E96A2E for ; Thu, 26 May 2011 11:10:18 +0000 (UTC) Received: (qmail 93046 invoked by uid 500); 26 May 2011 11:10:18 -0000 Delivered-To: apmail-tuscany-commits-archive@tuscany.apache.org Received: (qmail 93030 invoked by uid 500); 26 May 2011 11:10:18 -0000 Mailing-List: contact commits-help@tuscany.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tuscany.apache.org Delivered-To: mailing list commits@tuscany.apache.org Received: (qmail 93023 invoked by uid 99); 26 May 2011 11:10:18 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 May 2011 11:10:18 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 May 2011 11:10:15 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id BBF942388A29; Thu, 26 May 2011 11:09:55 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1127870 - in /tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src: main/java/helloworld/ main/java/implementation/lifecycle/ main/resources/ main/resources/META-INF/services/ test/java/org/apache/tuscany/sca/itest/lifecycle/ Date: Thu, 26 May 2011 11:09:55 -0000 To: commits@tuscany.apache.org From: slaws@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110526110955.BBF942388A29@eris.apache.org> Author: slaws Date: Thu May 26 11:09:54 2011 New Revision: 1127870 URL: http://svn.apache.org/viewvc?rev=1127870&view=rev Log: Add a test implementation provider and extend the test case to cover init and destroy exceptions Added: tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/implementation/lifecycle/LifecycleImplementation.java tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/implementation/lifecycle/LifecycleImplementationProcessor.java tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/implementation/lifecycle/LifecycleJavaInvoker.java tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/implementation/lifecycle/LifecycleProvider.java tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/implementation/lifecycle/LifecycleProviderFactory.java tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/implementation-lifecycle.xsd Modified: tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/Helloworld.java tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/HelloworldClientImpl.java tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/HelloworldServiceImpl.java tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/lifecycle.composite tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/test/java/org/apache/tuscany/sca/itest/lifecycle/LifecycleTestCase.java Modified: tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/Helloworld.java URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/Helloworld.java?rev=1127870&r1=1127869&r2=1127870&view=diff ============================================================================== --- tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/Helloworld.java (original) +++ tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/Helloworld.java Thu May 26 11:09:54 2011 @@ -25,5 +25,7 @@ import org.oasisopen.sca.annotation.Remo public interface Helloworld { String sayHello(String name) throws Exception; + + String throwException(String name) throws Exception; } Modified: tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/HelloworldClientImpl.java URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/HelloworldClientImpl.java?rev=1127870&r1=1127869&r2=1127870&view=diff ============================================================================== --- tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/HelloworldClientImpl.java (original) +++ tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/HelloworldClientImpl.java Thu May 26 11:09:54 2011 @@ -28,23 +28,41 @@ import org.oasisopen.sca.annotation.Scop @EagerInit @Scope("COMPOSITE") public class HelloworldClientImpl implements Helloworld { + + public static boolean throwTestExceptionOnInit = false; + public static boolean throwTestExceptionOnDestroy = false; + @Reference public Helloworld service; @Init public void initialize() throws Exception{ + if (throwTestExceptionOnInit) { + StatusImpl.statusString += "Exception on init "; + throw new Exception("Exception on init"); + } + StatusImpl.statusString += "HelloworldClientImpl init "; System.out.println(">>>>>> " + sayHello("init")); } @Destroy public void destroy() throws Exception{ + if (throwTestExceptionOnDestroy) { + StatusImpl.statusString += "Exception on destroy "; + throw new Exception("Exception on destroy"); + } + StatusImpl.statusString += "HelloworldClientImpl destroy "; } public String sayHello(String name) throws Exception { return "Hi " + service.sayHello(name); } + + public String throwException(String name) throws Exception { + throw new Exception("test exception"); + } } Modified: tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/HelloworldServiceImpl.java URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/HelloworldServiceImpl.java?rev=1127870&r1=1127869&r2=1127870&view=diff ============================================================================== --- tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/HelloworldServiceImpl.java (original) +++ tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/HelloworldServiceImpl.java Thu May 26 11:09:54 2011 @@ -26,5 +26,10 @@ public class HelloworldServiceImpl imple System.out.println("At service - " + response); return response; } + + public String throwException(String name) throws Exception { + // not used + return null; + } } Added: tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/implementation/lifecycle/LifecycleImplementation.java URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/implementation/lifecycle/LifecycleImplementation.java?rev=1127870&view=auto ============================================================================== --- tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/implementation/lifecycle/LifecycleImplementation.java (added) +++ tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/implementation/lifecycle/LifecycleImplementation.java Thu May 26 11:09:54 2011 @@ -0,0 +1,41 @@ +/* + * 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 implementation.lifecycle; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.assembly.impl.ImplementationImpl; + +/** + * Model representing a Sample implementation in an SCA assembly. + * + * @version $Rev$ $Date$ + */ +public class LifecycleImplementation extends ImplementationImpl { + static final QName QN = new QName(SCA11_TUSCANY_NS, "implementation.lifecycle"); + + final String name; + Class clazz; + + LifecycleImplementation(final String name) { + super(QN); + this.name = name; + } + +} Added: tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/implementation/lifecycle/LifecycleImplementationProcessor.java URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/implementation/lifecycle/LifecycleImplementationProcessor.java?rev=1127870&view=auto ============================================================================== --- tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/implementation/lifecycle/LifecycleImplementationProcessor.java (added) +++ tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/implementation/lifecycle/LifecycleImplementationProcessor.java Thu May 26 11:09:54 2011 @@ -0,0 +1,105 @@ +/* + * 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 implementation.lifecycle; + +import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Field; + +import javax.wsdl.PortType; +import javax.xml.namespace.QName; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; + +import org.apache.tuscany.sca.assembly.AssemblyFactory; +import org.apache.tuscany.sca.assembly.Service; +import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.ContributionReadException; +import org.apache.tuscany.sca.contribution.processor.ContributionResolveException; +import org.apache.tuscany.sca.contribution.processor.ContributionWriteException; +import org.apache.tuscany.sca.contribution.processor.ProcessorContext; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.resolver.ClassReference; +import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.FactoryExtensionPoint; +import org.apache.tuscany.sca.databinding.xml.DOMDataBinding; +import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException; +import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract; +import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLObject; + +/** + * StAX artifact processor for Sample implementations. + * + * @version $Rev$ $Date$ + */ +public class LifecycleImplementationProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor { + final AssemblyFactory af; + final JavaInterfaceFactory jif; + final WSDLFactory wf; + + public LifecycleImplementationProcessor(final ExtensionPointRegistry ep) { + final FactoryExtensionPoint fep = ep.getExtensionPoint(FactoryExtensionPoint.class); + this.af = fep.getFactory(AssemblyFactory.class); + this.jif = fep.getFactory(JavaInterfaceFactory.class); + this.wf = fep.getFactory(WSDLFactory.class); + } + + public QName getArtifactType() { + return LifecycleImplementation.QN; + } + + public Class getModelType() { + return LifecycleImplementation.class; + } + + public LifecycleImplementation read(final XMLStreamReader r, final ProcessorContext ctx) throws ContributionReadException, XMLStreamException { + // not actually going to read any config for this test + // so just create a model + LifecycleImplementation impl = new LifecycleImplementation("helloworld.Helloworld"); + impl.setUnresolved(true); + return impl; + } + + public void resolve(final LifecycleImplementation impl, final ModelResolver res, final ProcessorContext ctx) throws ContributionResolveException { + try { + Class c = Class.forName("helloworld.Helloworld"); + Service s = af.createService(); + s.setName("Helloworld"); + JavaInterfaceContract ic = jif.createJavaInterfaceContract(); + ic.setInterface(jif.createJavaInterface(c)); + s.setInterfaceContract(ic); + impl.getServices().add(s); + impl.setUnresolved(false); + } catch (Exception ex){ + throw new ContributionResolveException(ex); + } + } + + public void write(final LifecycleImplementation impl, final XMLStreamWriter w, final ProcessorContext ctx) throws ContributionWriteException, XMLStreamException { + // not required for this test + } + +} Added: tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/implementation/lifecycle/LifecycleJavaInvoker.java URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/implementation/lifecycle/LifecycleJavaInvoker.java?rev=1127870&view=auto ============================================================================== --- tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/implementation/lifecycle/LifecycleJavaInvoker.java (added) +++ tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/implementation/lifecycle/LifecycleJavaInvoker.java Thu May 26 11:09:54 2011 @@ -0,0 +1,46 @@ +/* + * 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 implementation.lifecycle; + +import java.lang.reflect.Method; + +import org.apache.tuscany.sca.interfacedef.java.JavaOperation; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Message; + +/** + * Invoker for Sample components that implement a Java interface. + * + * @version $Rev$ $Date$ + */ +class SampleJavaInvoker implements Invoker { + final Object instance; + final Method method; + + SampleJavaInvoker(final JavaOperation op, final Class clazz, final Object instance) throws SecurityException, NoSuchMethodException { + this.instance = instance; + this.method = clazz.getMethod(op.getJavaMethod().getName(), op.getJavaMethod().getParameterTypes()); + } + + public Message invoke(final Message msg) { + // we don't actually do anything here + return msg; + } +} Added: tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/implementation/lifecycle/LifecycleProvider.java URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/implementation/lifecycle/LifecycleProvider.java?rev=1127870&view=auto ============================================================================== --- tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/implementation/lifecycle/LifecycleProvider.java (added) +++ tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/implementation/lifecycle/LifecycleProvider.java Thu May 26 11:09:54 2011 @@ -0,0 +1,77 @@ +/* + * 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 implementation.lifecycle; + +import helloworld.StatusImpl; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.invocation.ProxyFactory; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.interfacedef.java.JavaOperation; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.provider.ImplementationProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; + +/** + * Implementation provider for Sample component implementations. + * + * @version $Rev$ $Date$ + */ +class LifecycleProvider implements ImplementationProvider { + final RuntimeComponent comp; + final LifecycleImplementation impl; + final ProxyFactory pxf; + final ExtensionPointRegistry ep; + Object instance; + + // make this static rather than worrying about persistence on the reference side + static Map asyncMessageMap = new HashMap(); + + LifecycleProvider(final RuntimeComponent comp, final LifecycleImplementation impl, ProxyFactory pf, ExtensionPointRegistry ep) { + this.comp = comp; + this.impl = impl; + this.pxf = pf; + this.ep = ep; + } + + public void start() { + StatusImpl.statusString += "Implementation start "; + } + + public void stop() { + StatusImpl.statusString += "Implementation stop "; + } + + public boolean supportsOneWayInvocation() { + return false; + } + + public Invoker createInvoker(final RuntimeComponentService s, final Operation op) { + try { + return new SampleJavaInvoker((JavaOperation)op, impl.clazz, instance); + } catch(Exception e) { + throw new RuntimeException(e); + } + } +} Added: tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/implementation/lifecycle/LifecycleProviderFactory.java URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/implementation/lifecycle/LifecycleProviderFactory.java?rev=1127870&view=auto ============================================================================== --- tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/implementation/lifecycle/LifecycleProviderFactory.java (added) +++ tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/implementation/lifecycle/LifecycleProviderFactory.java Thu May 26 11:09:54 2011 @@ -0,0 +1,50 @@ +/* + * 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 implementation.lifecycle; + +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory; +import org.apache.tuscany.sca.core.invocation.ProxyFactory; +import org.apache.tuscany.sca.provider.ImplementationProvider; +import org.apache.tuscany.sca.provider.ImplementationProviderFactory; +import org.apache.tuscany.sca.runtime.RuntimeComponent; + +/** + * Factory for Sample implementation providers. + * + * @version $Rev$ $Date$ + */ +public class LifecycleProviderFactory implements ImplementationProviderFactory { + final ProxyFactory pxf; + final ExtensionPointRegistry ep; + + public LifecycleProviderFactory(final ExtensionPointRegistry ep) { + this.ep = ep; + pxf = ExtensibleProxyFactory.getInstance(ep); + } + + public ImplementationProvider createImplementationProvider(final RuntimeComponent comp, final LifecycleImplementation impl) { + return new LifecycleProvider(comp, impl, pxf, ep); + } + + public Class getModelType() { + return LifecycleImplementation.class; + } +} Modified: tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor?rev=1127870&r1=1127869&r2=1127870&view=diff ============================================================================== --- tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor (original) +++ tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor Thu May 26 11:09:54 2011 @@ -17,4 +17,5 @@ # Implementation class for the artifact processor extension org.apache.tuscany.sca.assembly.xml.DefaultBeanModelProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#binding.lifecycle,model=binding.lifecycle.LifecycleBinding,factory=binding.lifecycle.LifecycleBindingFactory +implementation.lifecycle.LifecycleImplementationProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#implementation.lifecycle,model=implementation.lifecycle.LifecycleImplementation Modified: tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema?rev=1127870&r1=1127869&r2=1127870&view=diff ============================================================================== --- tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema (original) +++ tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema Thu May 26 11:09:54 2011 @@ -15,5 +15,7 @@ # specific language governing permissions and limitations # under the License. # +implementation-lifecycle.xsd binding-lifecycle.xsd + Added: tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory?rev=1127870&view=auto ============================================================================== --- tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory (added) +++ tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory Thu May 26 11:09:54 2011 @@ -0,0 +1,20 @@ +# 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. + +# Implementation provider for Sample components +implementation.lifecycle.LifecycleProviderFactory;model=implementation.lifecycle.LifecycleImplementation + Added: tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/implementation-lifecycle.xsd URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/implementation-lifecycle.xsd?rev=1127870&view=auto ============================================================================== --- tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/implementation-lifecycle.xsd (added) +++ tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/implementation-lifecycle.xsd Thu May 26 11:09:54 2011 @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + Modified: tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/lifecycle.composite URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/lifecycle.composite?rev=1127870&r1=1127869&r2=1127870&view=diff ============================================================================== --- tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/lifecycle.composite (original) +++ tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/lifecycle.composite Thu May 26 11:09:54 2011 @@ -22,16 +22,23 @@ targetNamespace="http://sample" name="domainview"> - + - + + + + + + + + - + Modified: tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/test/java/org/apache/tuscany/sca/itest/lifecycle/LifecycleTestCase.java URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/test/java/org/apache/tuscany/sca/itest/lifecycle/LifecycleTestCase.java?rev=1127870&r1=1127869&r2=1127870&view=diff ============================================================================== --- tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/test/java/org/apache/tuscany/sca/itest/lifecycle/LifecycleTestCase.java (original) +++ tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/test/java/org/apache/tuscany/sca/itest/lifecycle/LifecycleTestCase.java Thu May 26 11:09:54 2011 @@ -20,6 +20,8 @@ package org.apache.tuscany.sca.itest.lifecycle; +import helloworld.Helloworld; +import helloworld.HelloworldClientImpl; import helloworld.StatusImpl; import junit.framework.Assert; @@ -46,7 +48,7 @@ public class LifecycleTestCase { } @Test - public void test1() throws Exception{ + public void testNormalShutdown() throws Exception{ TuscanyRuntime tuscanyRuntime = TuscanyRuntime.newInstance(); @@ -74,13 +76,158 @@ public class LifecycleTestCase { // see what happened System.out.println(StatusImpl.statusString); Assert.assertEquals("Service binding start " + + "Implementation start " + + "Service binding start " + "HelloworldClientImpl init " + "Reference binding start " + "Service binding stop " + + "Service binding stop " + + "Implementation stop " + "Reference binding stop " + "HelloworldClientImpl destroy ", StatusImpl.statusString); - } + @Test + public void testInitExceptionShutdown() throws Exception{ + + HelloworldClientImpl.throwTestExceptionOnInit = true; + + TuscanyRuntime tuscanyRuntime = TuscanyRuntime.newInstance(); + + // create a Tuscany node + node = tuscanyRuntime.createNode(); + + // install a contribution + node.installContribution("HelloworldContrib", "target/classes", null, null); + + // start a composite + try { + node.startComposite("HelloworldContrib", "lifecycle.composite"); + } catch (Exception exception) { + // it's thrown from the HelloworldClientImpl @Init method + } + + // stop a composite + node.stopComposite("HelloworldContrib", "lifecycle.composite"); + + // uninstall a constribution + node.uninstallContribution("HelloworldContrib"); + + // stop a Tuscany node + node.stop(); + + // stop the runtime + tuscanyRuntime.stop(); + + // see what happened + System.out.println(StatusImpl.statusString); + Assert.assertEquals("Service binding start " + + "Implementation start " + + "Service binding start " + + "HelloworldClientImpl init " + + "Reference binding start " + + "Service binding stop " + + "Service binding stop " + + "Implementation stop " + + "Reference binding stop " + + "HelloworldClientImpl destroy ", + StatusImpl.statusString); + + HelloworldClientImpl.throwTestExceptionOnInit = false; + } + + @Test + public void testDestroyExceptionShutdown() throws Exception{ + + HelloworldClientImpl.throwTestExceptionOnDestroy = true; + + TuscanyRuntime tuscanyRuntime = TuscanyRuntime.newInstance(); + + // create a Tuscany node + node = tuscanyRuntime.createNode(); + + // install a contribution + node.installContribution("HelloworldContrib", "target/classes", null, null); + + // start a composite + node.startComposite("HelloworldContrib", "lifecycle.composite"); + + // stop a composite + node.stopComposite("HelloworldContrib", "lifecycle.composite"); + + // uninstall a constribution + node.uninstallContribution("HelloworldContrib"); + + // stop a Tuscany node + node.stop(); + + // stop the runtime + tuscanyRuntime.stop(); + + // see what happened + System.out.println(StatusImpl.statusString); + Assert.assertEquals("Service binding start " + + "Implementation start " + + "Service binding start " + + "HelloworldClientImpl init " + + "Reference binding start " + + "Service binding stop " + + "Service binding stop " + + "Implementation stop " + + "Reference binding stop " + + "HelloworldClientImpl destroy ", + StatusImpl.statusString); + + HelloworldClientImpl.throwTestExceptionOnDestroy = false; + } + + @Test + public void testAppExceptionShutdown() throws Exception{ + + TuscanyRuntime tuscanyRuntime = TuscanyRuntime.newInstance(); + + // create a Tuscany node + node = tuscanyRuntime.createNode(); + + // install a contribution + node.installContribution("HelloworldContrib", "target/classes", null, null); + + // start a composite + node.startComposite("HelloworldContrib", "lifecycle.composite"); + + try { + Helloworld hw = node.getService(Helloworld.class, "Helloworld1"); + hw.throwException("name"); + } catch (Exception ex) { + // do nothing + } + + // stop a composite + node.stopComposite("HelloworldContrib", "lifecycle.composite"); + + // uninstall a constribution + node.uninstallContribution("HelloworldContrib"); + + // stop a Tuscany node + node.stop(); + + // stop the runtime + tuscanyRuntime.stop(); + + // see what happened + System.out.println(StatusImpl.statusString); + Assert.assertEquals("Service binding start " + + "Implementation start " + + "Service binding start " + + "HelloworldClientImpl init " + + "Reference binding start " + + "Service binding stop " + + "Service binding stop " + + "Implementation stop " + + "Reference binding stop " + + "HelloworldClientImpl destroy ", + StatusImpl.statusString); + } + }