1 27 28 package org.objectweb.perseus.connector.ra.fos; 29 30 import junit.framework.Test; 31 import junit.framework.TestSuite; 32 import junit.textui.TestRunner; 33 import org.objectweb.perseus.LogBoot; 34 import org.objectweb.perseus.connector.ra.TestRAMan; 35 36 import java.util.Properties ; 37 import java.util.Vector ; 38 import javax.resource.spi.ManagedConnectionFactory ; 39 40 44 public class TestRAFosMan extends TestRAMan { 45 private String dbDir; 46 47 protected Vector getWritings() { 48 if (writings == null) { 49 writings = new Vector (); 50 writings.add(new FosWriting(1, "azerty1")); 52 writings.add(new FosWriting(2, "azerty2")); 53 writings.add(new FosWriting(3, "azerty3")); 54 } 55 return writings; 56 } 57 58 63 protected ManagedConnectionFactory getNewMCFInstance() 64 throws Exception { 65 return (ManagedConnectionFactory ) new FosManagedConnectionFactory(); 66 } 67 68 71 protected void initMCF() throws Exception { 72 ((FosManagedConnectionFactory) mcf).setConnectionURL(dbDir); 73 ((FosManagedConnectionFactory) mcf).setInitializeAtStartUp(true); 74 ((FosManagedConnectionFactory) mcf).setMonologFactory(LogBoot.getLoggerFactory()); 75 ((FosManagedConnectionFactory) mcf).setConnectionManager(this); 76 ((FosManagedConnectionFactory) mcf).start(); 77 } 78 79 protected void endMCF() throws Exception { 80 ((FosManagedConnectionFactory) mcf).stop(); 81 } 82 83 87 public static Test suite() { 88 return new TestSuite(TestRAFosMan.class); 89 } 90 91 94 public static void main(String args[]) { 95 TestRunner.run(suite()); 96 } 97 98 101 public TestRAFosMan(String tn) { 102 super(tn); 103 Properties prop = new Properties (); 104 try { 105 prop.load(ClassLoader.getSystemResourceAsStream("owfos.properties")); 106 } catch (Exception e) { 107 e.printStackTrace(); 108 System.exit(1); 109 } 110 dbDir = prop.getProperty("dbdir", null); 111 if (dbDir == null) { 112 System.out.println("Cannot find the 'dbdir' property"); 113 System.exit(1); 114 } 115 } 116 } | Popular Tags |