Coverage report

  %line %branch
org.apache.jetspeed.testhelpers.OJBHelper
0% 
0% 

 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  * 
 9  
  *      http://www.apache.org/licenses/LICENSE-2.0
 10  
  * 
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.apache.jetspeed.testhelpers;
 18  
 
 19  
 import java.util.Map;
 20  
 import java.util.Properties;
 21  
 
 22  
 import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 23  
 import org.springframework.context.support.GenericApplicationContext;
 24  
 import org.springframework.transaction.interceptor.TransactionProxyFactoryBean;
 25  
 import org.springframework.orm.ojb.PersistenceBrokerTransactionManager;
 26  
 import org.springframework.orm.ojb.support.LocalOjbConfigurer;
 27  
 
 28  
 public class OJBHelper extends DatasourceHelper
 29  
 {
 30  
 
 31  
     public static final String DATASOURCE_BEAN = "JetspeedDS";
 32  
 
 33  
     private GenericApplicationContext appCtx;
 34  
 
 35  
     private DefaultListableBeanFactory bf;
 36  
 
 37  
     public OJBHelper(Map context)
 38  
     {
 39  0
         super(context);
 40  0
     }
 41  
 
 42  
     public void setUp() throws Exception
 43  
     {
 44  0
         super.setUp();
 45  0
         bf = new DefaultListableBeanFactory();
 46  0
         bf.registerSingleton(DATASOURCE_BEAN, datasource);
 47  0
         LocalOjbConfigurer ojbConfigurer = new LocalOjbConfigurer();
 48  0
         ojbConfigurer.setBeanFactory(bf);
 49  0
         addBeanFactory(bf);
 50  0
         appCtx = new GenericApplicationContext(bf);
 51  0
         bf.preInstantiateSingletons();
 52  0
         getContext().put(APP_CONTEXT, appCtx);
 53  0
     }
 54  
 
 55  
     public void tearDown() throws Exception
 56  
     {
 57  0
         bf.destroySingletons();
 58  0
         super.tearDown();
 59  0
     }
 60  
 
 61  
     /**
 62  
      * Surrounds the <code>object</code> with <code>TransactionProxyFactoryBean</code> that implements all
 63  
      * interfaces specified in <code>interfacesToProxyAs</code>
 64  
      * 
 65  
      * @param object
 66  
      *            object to wrap with a TX Proxy
 67  
      * @param interfacesToProxyAs
 68  
      *            interfeaces to proxy as
 69  
      * @return Tx Wrapped version of the priginal object
 70  
      * @throws Exception
 71  
      */
 72  
     public Object getTxProxiedObject(Object object, String[] interfacesToProxyAs) throws Exception
 73  
     {
 74  0
         Class[] ifaces = new Class[interfacesToProxyAs.length];
 75  0
         for(int i = 0; i < class="keyword">interfacesToProxyAs.length; i++) {
 76  0
                 ifaces[i] = Class.forName(interfacesToProxyAs[i]);
 77  
         }
 78  
 
 79  0
         TransactionProxyFactoryBean txfb = new TransactionProxyFactoryBean();
 80  0
         txfb.setTransactionManager(new PersistenceBrokerTransactionManager());
 81  0
         Properties txProps = new Properties();
 82  0
         txProps.setProperty("*", "PROPAGATION_REQUIRED");
 83  0
         txfb.setTransactionAttributes(txProps);
 84  0
         txfb.setTarget(object);
 85  0
         txfb.setProxyInterfaces(ifaces);
 86  0
         txfb.afterPropertiesSet();
 87  0
         return txfb.getObject();
 88  
     }
 89  
 
 90  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.