Return-Path: Delivered-To: apmail-incubator-aries-commits-archive@minotaur.apache.org Received: (qmail 79091 invoked from network); 5 Aug 2010 21:02:43 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 5 Aug 2010 21:02:43 -0000 Received: (qmail 67986 invoked by uid 500); 5 Aug 2010 21:02:43 -0000 Delivered-To: apmail-incubator-aries-commits-archive@incubator.apache.org Received: (qmail 67895 invoked by uid 500); 5 Aug 2010 21:02:42 -0000 Mailing-List: contact aries-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: aries-dev@incubator.apache.org Delivered-To: mailing list aries-commits@incubator.apache.org Received: (qmail 67887 invoked by uid 99); 5 Aug 2010 21:02:42 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Aug 2010 21:02:42 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.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, 05 Aug 2010 21:02:39 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id CE39E23889B9; Thu, 5 Aug 2010 21:01:21 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r982784 - in /incubator/aries/trunk/transaction/transaction-blueprint/src: main/java/org/apache/aries/transaction/ test/java/org/apache/aries/transaction/ test/resources/org/apache/aries/transaction/ Date: Thu, 05 Aug 2010 21:01:21 -0000 To: aries-commits@incubator.apache.org From: linsun@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100805210121.CE39E23889B9@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: linsun Date: Thu Aug 5 21:01:21 2010 New Revision: 982784 URL: http://svn.apache.org/viewvc?rev=982784&view=rev Log: ARIES-376 [blueprint transaction] with the 1.1 schema, method is optional Added: incubator/aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/NameSpaceHandlerOptionMethodTest.java (with props) incubator/aries/trunk/transaction/transaction-blueprint/src/test/resources/org/apache/aries/transaction/aries2.xml (with props) Modified: incubator/aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/TxComponentMetaDataHelperImpl.java Modified: incubator/aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/TxComponentMetaDataHelperImpl.java URL: http://svn.apache.org/viewvc/incubator/aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/TxComponentMetaDataHelperImpl.java?rev=982784&r1=982783&r2=982784&view=diff ============================================================================== --- incubator/aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/TxComponentMetaDataHelperImpl.java (original) +++ incubator/aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/TxComponentMetaDataHelperImpl.java Thu Aug 5 21:01:21 2010 @@ -167,6 +167,10 @@ public class TxComponentMetaDataHelperIm data.put(component, td); } + if (method == null || method.isEmpty()) { + method = "*"; + } + String[] names = method.split("[, \t]"); for (int i = 0; i < names.length; i++) { Added: incubator/aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/NameSpaceHandlerOptionMethodTest.java URL: http://svn.apache.org/viewvc/incubator/aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/NameSpaceHandlerOptionMethodTest.java?rev=982784&view=auto ============================================================================== --- incubator/aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/NameSpaceHandlerOptionMethodTest.java (added) +++ incubator/aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/NameSpaceHandlerOptionMethodTest.java Thu Aug 5 21:01:21 2010 @@ -0,0 +1,100 @@ +/* + * 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.aries.transaction; + +import static org.junit.Assert.assertEquals; + +import java.net.URI; +import java.net.URL; +import java.util.LinkedList; +import java.util.List; +import java.util.Properties; +import java.util.Set; + +import javax.transaction.TransactionManager; + +import org.apache.aries.mocks.BundleMock; + +import org.apache.aries.blueprint.ComponentDefinitionRegistry; +import org.apache.aries.blueprint.NamespaceHandler; +import org.apache.aries.blueprint.container.NamespaceHandlerRegistry; +import org.apache.aries.blueprint.container.Parser; +import org.apache.aries.blueprint.container.NamespaceHandlerRegistry.NamespaceHandlerSet; +import org.apache.aries.blueprint.namespace.ComponentDefinitionRegistryImpl; +import org.apache.aries.blueprint.namespace.NamespaceHandlerRegistryImpl; +import org.junit.Test; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +import org.osgi.service.blueprint.reflect.BeanMetadata; +import org.osgi.service.blueprint.reflect.BeanProperty; + +import org.apache.aries.transaction.TxComponentMetaDataHelperImpl; +import org.apache.aries.transaction.TxInterceptorImpl; +import org.apache.aries.transaction.parsing.TxElementHandler; +import org.apache.aries.unittest.mocks.Skeleton; + +public class NameSpaceHandlerOptionMethodTest { + + + @Test + public void testMultipleElements() throws Exception + { + Bundle b = Skeleton.newMock(new BundleMock("org.apache.aries.tx", new Properties()), Bundle.class); + BundleContext ctx = b.getBundleContext(); + NamespaceHandlerRegistry nhri = new NamespaceHandlerRegistryImpl(ctx); + + TransactionManager tm = Skeleton.newMock(TransactionManager.class); + + TxComponentMetaDataHelperImpl txenhancer = new TxComponentMetaDataHelperImpl(); + + TxInterceptorImpl txinterceptor = new TxInterceptorImpl(); + txinterceptor.setTransactionManager(tm); + txinterceptor.setTxMetaDataHelper(txenhancer); + + TxElementHandler namespaceHandler = new TxElementHandler(); + namespaceHandler.setTransactionInterceptor(txinterceptor); + namespaceHandler.setTxMetaDataHelper(txenhancer); + + Properties props = new Properties(); + props.put("osgi.service.blueprint.namespace", new String[]{"http://aries.apache.org/xmlns/transactions/v1.0.0", "http://aries.apache.org/xmlns/transactions/v1.1.0"}); + ctx.registerService(NamespaceHandler.class.getName(), namespaceHandler, props); + Parser p = new Parser(); + + URL bpxml = this.getClass().getResource("aries2.xml"); + List bpxmlList = new LinkedList(); + bpxmlList.add(bpxml); + + p.parse(bpxmlList); + Set nsuris = p.getNamespaces(); + NamespaceHandlerSet nshandlers = nhri.getNamespaceHandlers(nsuris, b); + p.validate(nshandlers.getSchema()); + + ComponentDefinitionRegistry cdr = new ComponentDefinitionRegistryImpl(); + p.populate(nshandlers, cdr); + + BeanMetadata comp = (BeanMetadata) cdr.getComponentDefinition("top"); + + BeanMetadata anon = (BeanMetadata) ((BeanProperty) comp.getProperties().get(0)).getValue(); + BeanMetadata anonToo = (BeanMetadata) ((BeanProperty) comp.getProperties().get(1)).getValue(); + + assertEquals("Required", txenhancer.getComponentMethodTxAttribute(anon, "doSomething")); + assertEquals("Never", txenhancer.getComponentMethodTxAttribute(anonToo, "doSomething")); + + } +} Propchange: incubator/aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/NameSpaceHandlerOptionMethodTest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/NameSpaceHandlerOptionMethodTest.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: incubator/aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/NameSpaceHandlerOptionMethodTest.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: incubator/aries/trunk/transaction/transaction-blueprint/src/test/resources/org/apache/aries/transaction/aries2.xml URL: http://svn.apache.org/viewvc/incubator/aries/trunk/transaction/transaction-blueprint/src/test/resources/org/apache/aries/transaction/aries2.xml?rev=982784&view=auto ============================================================================== --- incubator/aries/trunk/transaction/transaction-blueprint/src/test/resources/org/apache/aries/transaction/aries2.xml (added) +++ incubator/aries/trunk/transaction/transaction-blueprint/src/test/resources/org/apache/aries/transaction/aries2.xml Thu Aug 5 21:01:21 2010 @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file Propchange: incubator/aries/trunk/transaction/transaction-blueprint/src/test/resources/org/apache/aries/transaction/aries2.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/aries/trunk/transaction/transaction-blueprint/src/test/resources/org/apache/aries/transaction/aries2.xml ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: incubator/aries/trunk/transaction/transaction-blueprint/src/test/resources/org/apache/aries/transaction/aries2.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml