1 27 28 package org.objectweb.perseus.connector.ra.fos; 29 30 32 import junit.framework.Test; 33 import junit.framework.TestSuite; 34 import junit.textui.TestRunner; 35 import org.objectweb.perseus.LogBoot; 36 import org.objectweb.perseus.connector.ra.TestRAUnman; 37 38 import java.util.Properties ; 39 import java.util.Vector ; 40 import javax.naming.Context ; 41 import javax.resource.cci.Connection ; 42 import javax.resource.spi.ManagedConnectionFactory ; 43 44 48 public class TestRAFosUnman extends TestRAUnman { 49 private String dbDir; 50 51 protected Vector getWritings() { 52 if (writings == null) { 53 writings = new Vector (); 54 writings.add(new FosWriting(1, "azerty1")); 56 writings.add(new FosWriting(2, "azerty2")); 57 writings.add(new FosWriting(3, "azerty3")); 58 } 59 return writings; 60 } 61 62 67 protected ManagedConnectionFactory getNewMCFInstance() 68 throws Exception { 69 return (ManagedConnectionFactory ) new FosManagedConnectionFactory(); 70 } 71 72 75 protected void initMCF() throws Exception { 76 ((FosManagedConnectionFactory) mcf).setConnectionURL(dbDir); 77 ((FosManagedConnectionFactory) mcf).setInitializeAtStartUp(true); 78 ((FosManagedConnectionFactory) mcf).setMonologFactory(LogBoot.getLoggerFactory()); 79 ((FosManagedConnectionFactory) mcf).start(); 80 } 81 82 protected void endMCF() throws Exception { 83 ((FosManagedConnectionFactory) mcf).stop(); 84 } 85 86 public void testConnPassThrough() { 87 try { 88 Connection c = cf.getConnection(); 89 if (!((FosWriting) writings.elements().nextElement()).passThrough(c)) 90 fail(); 91 c.close(); 92 } catch (Exception e) { 93 e.printStackTrace(); 94 fail(); 95 } 96 } 97 98 102 public static Test suite() { 103 return new TestSuite(TestRAFosUnman.class); 104 } 105 106 109 public static void main(String args[]) { 110 TestRunner.run(suite()); 111 } 112 113 116 public TestRAFosUnman(String tn) { 117 super(tn); 118 Properties prop = new Properties (); 119 try { 120 prop.load(ClassLoader.getSystemResourceAsStream("owfos.properties")); 121 } catch (Exception e) { 122 e.printStackTrace(); 123 System.exit(1); 124 } 125 dbDir = prop.getProperty("dbdir", null); 126 if (dbDir == null) { 127 System.out.println("Cannot find the 'dbdir' property"); 128 System.exit(1); 129 } 130 } 131 } | Popular Tags |