1 21 package db4ounit.extensions.fixtures; 22 23 import java.io.IOException ; 24 25 import com.db4o.Db4o; 26 import com.db4o.ext.ExtObjectContainer; 27 28 import db4ounit.TestException; 29 import db4ounit.extensions.Db4oTestCase; 30 31 public class Db4oSingleClient extends AbstractClientServerDb4oFixture { 32 33 private ExtObjectContainer _objectContainer; 34 35 public Db4oSingleClient(ConfigurationSource config, String fileName, 36 int port) { 37 super(config, fileName, port); 38 } 39 40 public Db4oSingleClient(ConfigurationSource config) { 41 super(config); 42 } 43 44 public Db4oSingleClient() { 45 this(new IndependentConfigurationSource()); 46 } 47 48 public void close() throws Exception { 49 _objectContainer.close(); 50 super.close(); 51 } 52 53 public void open() throws Exception { 54 super.open(); 55 try { 56 _objectContainer = Db4o.openClient(config(), HOST, PORT, USERNAME, 57 PASSWORD).ext(); 58 } catch (IOException e) { 59 e.printStackTrace(); 60 throw new TestException(e); 61 } 62 } 63 64 71 public boolean accept(Class clazz) { 72 if ((OptOutCS.class.isAssignableFrom(clazz)) 73 || !Db4oTestCase.class.isAssignableFrom(clazz)) { 74 return false; 75 } 76 return true; 77 } 78 79 public ExtObjectContainer db() { 80 return _objectContainer; 81 } 82 83 public String getLabel() { 84 return "C/S SINGLE-CLIENT"; 85 } 86 87 } 88 | Popular Tags |