public void testNameMatchTransactionAttributeSourceWithStarAtEndOfMethodName() throws NoSuchMethodException { NameMatchTransactionAttributeSource tas = new NameMatchTransactionAttributeSource(); Properties attributes = new Properties(); attributes.put("hashCod*", "PROPAGATION_REQUIRED"); tas.setProperties(attributes); TransactionAttribute ta = tas.getTransactionAttribute(Object.class.getMethod("hashCode", (Class[]) null), null); assertNotNull(ta); assertEquals(TransactionDefinition.PROPAGATION_REQUIRED, ta.getPropagationBehavior()); }
public void testNameMatchTransactionAttributeSource() throws NoSuchMethodException { NameMatchTransactionAttributeSource tas = new NameMatchTransactionAttributeSource(); Map methodMap = new HashMap(); methodMap.put("hashCode", "PROPAGATION_REQUIRED"); methodMap.put( "toString", new DefaultTransactionAttribute(TransactionDefinition.PROPAGATION_SUPPORTS)); tas.setNameMap(methodMap); TransactionAttribute ta = tas.getTransactionAttribute(Object.class.getMethod("hashCode", (Class[]) null), null); assertNotNull(ta); assertEquals(TransactionDefinition.PROPAGATION_REQUIRED, ta.getPropagationBehavior()); ta = tas.getTransactionAttribute(Object.class.getMethod("toString", (Class[]) null), null); assertNotNull(ta); assertEquals(TransactionDefinition.PROPAGATION_SUPPORTS, ta.getPropagationBehavior()); }
public void testMatchAlwaysTransactionAttributeSource() throws Exception { MatchAlwaysTransactionAttributeSource tas = new MatchAlwaysTransactionAttributeSource(); TransactionAttribute ta = tas.getTransactionAttribute(Object.class.getMethod("hashCode", (Class[]) null), null); assertNotNull(ta); assertTrue(TransactionDefinition.PROPAGATION_REQUIRED == ta.getPropagationBehavior()); tas.setTransactionAttribute( new DefaultTransactionAttribute(TransactionDefinition.PROPAGATION_SUPPORTS)); ta = tas.getTransactionAttribute( ServletException.class.getMethod("getMessage", (Class[]) null), ServletException.class); assertNotNull(ta); assertTrue(TransactionDefinition.PROPAGATION_SUPPORTS == ta.getPropagationBehavior()); }