incubator-aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lin...@apache.org
Subject svn commit: r982971 - 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 Fri, 06 Aug 2010 14:08:44 GMT
Author: linsun
Date: Fri Aug  6 14:08:44 2010
New Revision: 982971

URL: http://svn.apache.org/viewvc?rev=982971&view=rev
Log:
add one more transaction blueprint test and make sure we default to * when bean or method
is not specified

Added:
    incubator/aries/trunk/transaction/transaction-blueprint/src/test/resources/org/apache/aries/transaction/mixed-aries.xml
  (with props)
Modified:
    incubator/aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/BundleWideTxData.java
    incubator/aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/NameSpaceHandlerTest.java

Modified: incubator/aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/BundleWideTxData.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/BundleWideTxData.java?rev=982971&r1=982970&r2=982971&view=diff
==============================================================================
--- incubator/aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/BundleWideTxData.java
(original)
+++ incubator/aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/BundleWideTxData.java
Fri Aug  6 14:08:44 2010
@@ -25,8 +25,8 @@ import java.util.regex.Pattern;
 public final class BundleWideTxData
 {
   private String value;
-  private List<Pattern> method = new ArrayList<Pattern>();
-  private List<Pattern> bean = new ArrayList<Pattern>();
+  private List<Pattern> methodList = new ArrayList<Pattern>();
+  private List<Pattern> beanList = new ArrayList<Pattern>();
   
   public BundleWideTxData(String value,
           String method, String bean) {
@@ -35,18 +35,26 @@ public final class BundleWideTxData
   }
  
   private void setupPatterns(String method, String bean) {
+	  // when bean or method is not specified, the value is same as "*".
+	  if (method == null || method.isEmpty()) {
+		  method = "*";
+	  }
+	  if (bean == null || bean.isEmpty()) {
+		  bean = "*";
+	  }
+	  
       String[] names = method.split("[, \t]");
       
       for (int i = 0; i < names.length; i++) {
           Pattern p = Pattern.compile(names[i].replaceAll("\\*", ".*"));
-          this.method.add(p);
+          this.methodList.add(p);
       }
       
       names = bean.split("[, \t]");
       
       for (int i = 0; i < names.length; i++) {
           Pattern p = Pattern.compile(names[i].replaceAll("\\*", ".*"));
-          this.bean.add(p);
+          this.beanList.add(p);
       }
   }
   public String getValue() {
@@ -54,10 +62,10 @@ public final class BundleWideTxData
   }
   
   public List<Pattern> getMethod() {
-      return this.method;
+      return this.methodList;
   }
   
   public List<Pattern> getBean() {
-      return this.bean;
+      return this.beanList;
   }
 }

Modified: incubator/aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/NameSpaceHandlerTest.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/NameSpaceHandlerTest.java?rev=982971&r1=982970&r2=982971&view=diff
==============================================================================
--- incubator/aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/NameSpaceHandlerTest.java
(original)
+++ incubator/aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/NameSpaceHandlerTest.java
Fri Aug  6 14:08:44 2010
@@ -140,4 +140,35 @@ public class NameSpaceHandlerTest {
       assertEquals("Never", txenhancer.getComponentMethodTxAttribute(anonToo, "doSomething"));
         
     }
+    
+    @Test
+    public void testBundleWideAndBeanLevelTx() throws Exception
+    {
+      Parser p = new Parser();
+      
+      URL bpxml = this.getClass().getResource("mixed-aries.xml");
+      List<URL> bpxmlList = new LinkedList<URL>();
+      bpxmlList.add(bpxml); 
+      
+      p.parse(bpxmlList);
+      Set<URI> nsuris = p.getNamespaces();
+      NamespaceHandlerSet nshandlers = nhri.getNamespaceHandlers(nsuris, b);
+      p.validate(nshandlers.getSchema());
+      
+      ComponentDefinitionRegistry cdr = new ComponentDefinitionRegistryImpl();
+      p.populate(nshandlers, cdr);
+      
+      BeanMetadata compRequiresNew = (BeanMetadata) cdr.getComponentDefinition("requiresNew");
+      BeanMetadata compNoTx = (BeanMetadata) cdr.getComponentDefinition("noTx");
+      BeanMetadata compSomeTx = (BeanMetadata) cdr.getComponentDefinition("someTx");
+      BeanMetadata compAnotherBean = (BeanMetadata) cdr.getComponentDefinition("anotherBean");
+
+      assertEquals("RequiresNew", txenhancer.getComponentMethodTxAttribute(compRequiresNew,
"doSomething"));
+      assertEquals("Never", txenhancer.getComponentMethodTxAttribute(compNoTx, "doSomething"));
+      assertEquals("Required", txenhancer.getComponentMethodTxAttribute(compSomeTx, "doSomething"));
+      assertEquals("Mandatory", txenhancer.getComponentMethodTxAttribute(compSomeTx, "getRows"));
+      assertEquals("Required", txenhancer.getComponentMethodTxAttribute(compAnotherBean,
"doSomething"));
+      assertEquals("Supports", txenhancer.getComponentMethodTxAttribute(compAnotherBean,
"getWhatever"));
+        
+    }
 }

Added: incubator/aries/trunk/transaction/transaction-blueprint/src/test/resources/org/apache/aries/transaction/mixed-aries.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/transaction/transaction-blueprint/src/test/resources/org/apache/aries/transaction/mixed-aries.xml?rev=982971&view=auto
==============================================================================
--- incubator/aries/trunk/transaction/transaction-blueprint/src/test/resources/org/apache/aries/transaction/mixed-aries.xml
(added)
+++ incubator/aries/trunk/transaction/transaction-blueprint/src/test/resources/org/apache/aries/transaction/mixed-aries.xml
Fri Aug  6 14:08:44 2010
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+
+    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.
+
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+	xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.1.0">
+
+	<tx:transaction value="Required" />
+
+	<tx:transaction method="get*" value="Supports" />
+
+	<tx:transaction bean="noTx" value="Never" />
+
+	<tx:transaction bean="someTx" method="get*" value="Mandatory" />
+
+	<bean id="requiresNew" class="foo1">
+		<tx:transaction value="RequiresNew" />
+	</bean>
+
+	<bean id="noTx" class="foo2" />
+
+	<bean id="someTx" class="foo3" />
+
+	<bean id="anotherBean" class="foo4" />
+</blueprint>
\ No newline at end of file

Propchange: incubator/aries/trunk/transaction/transaction-blueprint/src/test/resources/org/apache/aries/transaction/mixed-aries.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/aries/trunk/transaction/transaction-blueprint/src/test/resources/org/apache/aries/transaction/mixed-aries.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: incubator/aries/trunk/transaction/transaction-blueprint/src/test/resources/org/apache/aries/transaction/mixed-aries.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message