public virtual void TestPartialPersistence() { var oldFileName = FileSession().FileName(); Db().Store(new Item(1)); Db().Commit(); Db().Store(new Item(2)); string newPath = null; try { newPath = SaveOldAs(oldFileName); var items = Db().Query(typeof (Item)); Assert.AreEqual(2, items.Count); Db().Store(new Item(3)); Db().Close(); AssertItems(oldFileName, 1); AssertItems(newPath, 3); } catch (Exception e) { Runtime.PrintStackTrace(e); } finally { File4.Delete(newPath); } }
public void Run() { saveAsBin.Sync(); saveAsBin.Close(); try { File4.Copy(oldUri, newUri); } catch (Exception e) { this._enclosing.ReopenOldConfiguration(saveAsBin, oldConfiguration, newUri, e); } BinConfiguration newConfiguration = this._enclosing.PointToNewUri(oldConfiguration , newUri); try { IBin newBin = this._enclosing._storage.Open(newConfiguration); saveAsBin.DelegateTo(newBin); this._enclosing._binRecords.Remove(oldUri); this._enclosing._binRecords.Put(newUri, new SaveAsStorage.BinRecord(newConfiguration , saveAsBin)); } catch (Exception e) { this._enclosing.ReopenOldConfiguration(saveAsBin, oldConfiguration, newUri, e); } }
public virtual void TestGetTempFileName() { string tempFileName = Path.GetTempFileName(); Assert.IsTrue(System.IO.File.Exists(tempFileName)); File4.Delete(tempFileName); }
/// <exception cref="System.IO.IOException"></exception> protected virtual string OldDatabaseFilePath() { string oldFile = IOServices.BuildTempPath("old_db.db4o"); File4.Copy(SourceFile(), oldFile); return(oldFile); }
/// <exception cref="System.IO.IOException"></exception> public virtual void Test() { var originalFilePath = OriginalFilePath(); var dbFilePath = DbFilePath(); if (!File.Exists(originalFilePath)) { TestPlatform.EmitWarning(originalFilePath + " does not exist. Can not run " + GetType ().FullName); return; } File4.Copy(originalFilePath, dbFilePath); Db4oFactory.Configure().AllowVersionUpdates(true); Db4oFactory.Configure().ExceptionsOnNotStorable(false); var oc = Db4oFactory.OpenFile(dbFilePath); try { Assert.IsNotNull(oc); } finally { oc.Close(); Db4oFactory.Configure().ExceptionsOnNotStorable(true); Db4oFactory.Configure().AllowVersionUpdates(false); } }
/// <exception cref="System.IO.IOException"></exception> private void RunDefrag(string testFileName) { IConfiguration config = Db4oFactory.NewConfiguration(); config.AllowVersionUpdates(true); ConfigureForTest(config); IObjectContainer oc = Db4oFactory.OpenFile(config, testFileName); oc.Close(); string backupFileName = Path.GetTempFileName(); try { DefragmentConfig defragConfig = new DefragmentConfig(testFileName, backupFileName ); defragConfig.ForceBackupDelete(true); ConfigureForTest(defragConfig.Db4oConfig()); defragConfig.ReadOnly(!DefragmentInReadWriteMode()); Db4objects.Db4o.Defragment.Defragment.Defrag(defragConfig); } finally { File4.Delete(backupFileName); } }
public virtual void TestGetTempFileName() { var tempFileName = Path.GetTempFileName(); Assert.IsTrue(File.Exists(tempFileName)); File4.Delete(tempFileName); }
private string SaveOldAs(string oldFileName) { string newPath; newPath = Path.GetTempFileName(); File4.Delete(newPath); _storage.SaveAs(oldFileName, newPath); return newPath; }
public virtual void Test() { Assert.Expect(typeof(IncompatibleFileFormatException), new _ICodeBlock_31(this)); File4.Delete(TempFile()); IoAdapter adapter = new RandomAccessFileAdapter(); Assert.IsFalse(adapter.Exists(TempFile())); }
/// <exception cref="System.Exception"></exception> public virtual void TearDown() { var tempTestFilePath = DbFilePath(); if (File.Exists(tempTestFilePath)) { File4.Delete(tempTestFilePath); } }
/// <exception cref="System.Exception"></exception> public override void SetUp() { File4.Delete(TempFile()); IoAdapter adapter = new RandomAccessFileAdapter(); adapter = adapter.Open(TempFile(), false, 0, false); adapter.Write(new byte[] { 1, 2, 3 }, 3); adapter.Close(); }
public virtual void TestTotalSize() { long actual = Db().SystemInfo().TotalSize(); Close(); long expectedSize = File4.Size(TempFile()); Assert.AreEqual(expectedSize, actual); }
/// <exception cref="System.Exception"></exception> public virtual void TearDown() { string tempTestFilePath = DbFilePath(); if (System.IO.File.Exists(tempTestFilePath)) { File4.Delete(tempTestFilePath); } }
public virtual void Test() { File4.Delete(TempFile()); Assert.IsFalse(Exists(TempFile())); IObjectContainer oc = Db4oEmbedded.OpenFile(NewConfiguration(), TempFile()); oc.Close(); File4.Delete(TempFile()); Assert.IsFalse(Exists(TempFile())); }
/// <exception cref="System.IO.IOException"></exception> private void CreateFile(IConfiguration config, string fileName) { IObjectContainer oc = Db4oFactory.OpenFile(config, fileName); try { Populate(oc); } finally { oc.Close(); } File4.Copy(fileName, fileName + "0"); }
/// <summary>Deletes the directory</summary> /// <exception cref="System.IO.IOException"></exception> public static void DeleteDir(string dir) { var absolutePath = new File(dir).GetCanonicalPath(); var fDir = new File(dir); if (fDir.IsDirectory()) { var files = fDir.List(); for (var i = 0; i < files.Length; i++) { DeleteDir(Path.Combine(absolutePath, files[i])); } } File4.Delete(dir); }
public virtual void Test() { IEmbeddedConfiguration configuration = NewConfiguration(); ConfigurationItemTestCase.ConfigurationItemStub item = new ConfigurationItemTestCase.ConfigurationItemStub (); configuration.Common.Add(item); Assert.AreSame(LegacyConfigFor(configuration), item.PreparedConfiguration()); Assert.IsNull(item.AppliedContainer()); File4.Delete(TempFile()); IObjectContainer container = Db4oEmbedded.OpenFile(configuration, TempFile()); container.Close(); Assert.AreSame(container, item.AppliedContainer()); }
/// <summary>Deletes the directory</summary> /// <exception cref="System.IO.IOException"></exception> public static void DeleteDir(string dir) { string absolutePath = new Sharpen.IO.File(dir).GetCanonicalPath(); Sharpen.IO.File fDir = new Sharpen.IO.File(dir); if (fDir.IsDirectory()) { string[] files = fDir.List(); for (int i = 0; i < files.Length; i++) { DeleteDir(Path.Combine(absolutePath, files[i])); } } File4.Delete(dir); }
public virtual void TestExistingFileWillNotBeOverWritten() { Db().Store(new Item(1)); var oldFileName = FileSession().FileName(); var newPath = new ByRef(); try { newPath.value = Path.GetTempFileName(); Assert.IsTrue(File.Exists(((string) newPath.value))); Assert.Expect(typeof (InvalidOperationException), new _ICodeBlock_34(this, oldFileName , newPath)); AssertItems(Db(), 1); } finally { File4.Delete(((string) newPath.value)); } }
/// <exception cref="System.Exception"></exception> public virtual void Test() { string fileName = DatabaseFile(); File4.Delete(fileName); IObjectServer server = Db4oClientServer.OpenServer(CreateServerConfiguration(), fileName , -1); _port = server.Ext().Port(); try { server.GrantAccess("db4o", "db4o"); RunTest(); } finally { server.Close(); File4.Delete(fileName); } }
/// <exception cref="System.IO.IOException"></exception> public virtual int WriteVersions(string file, bool writeTrash) { var count = 0; var rcount = 0; var lastFileName = file + "0"; var rightFileName = file + "R"; File4.Copy(lastFileName, rightFileName); var syncIter = _writes.GetEnumerator(); while (syncIter.MoveNext()) { rcount++; var writesBetweenSync = (Collection4)syncIter.Current; var rightRaf = new RandomAccessFile(rightFileName, "rw"); var singleForwardIter = writesBetweenSync.GetEnumerator(); while (singleForwardIter.MoveNext()) { var csw = (CrashSimulatingWrite)singleForwardIter.Current; csw.Write(rightFileName, rightRaf, false); } rightRaf.Close(); var singleBackwardIter = writesBetweenSync.GetEnumerator(); while (singleBackwardIter.MoveNext()) { count++; var csw = (CrashSimulatingWrite)singleBackwardIter.Current; var currentFileName = file + "W" + count; File4.Copy(lastFileName, currentFileName); var raf = new RandomAccessFile(currentFileName, "rw"); csw.Write(currentFileName, raf, writeTrash); raf.Close(); lastFileName = currentFileName; } File4.Copy(rightFileName, rightFileName + rcount); lastFileName = rightFileName; } return(count); }
public virtual void Run() { Sharpen.Runtime.Out.WriteLine("MonitoringDemo will run forever to allow you to see JMX/Perfmon statistics." ); Sharpen.Runtime.Out.WriteLine("Cancel running with CTRL + C"); File4.Delete(DatabaseFileName); IObjectContainer objectContainer = OpenContainer(); StorePermanentObjects(objectContainer); try { while (true) { StoreTemporaryObjects(objectContainer); ExecuteQueries(objectContainer); DeleteTemporaryObjects(objectContainer); } } finally { Close(objectContainer); } }
private void CreateDatabase(string file) { if (!IsApplicableForDb4oVersion()) { return; } System.IO.Directory.CreateDirectory(DatabasePath); if (System.IO.File.Exists(file)) { File4.Delete(file); } IExtObjectContainer objectContainer = Db4oFactory.OpenFile(file).Ext(); IObjectContainerAdapter adapter = ObjectContainerAdapterFactory.ForVersion(Db4oMajorVersion (), Db4oMinorVersion()).ForContainer(objectContainer); try { Store(adapter); } finally { objectContainer.Close(); } }
/// <exception cref="System.IO.IOException"></exception> private void PrepareClientServerTest(string fileName) { File4.Copy(fileName, ClientServerFileName(fileName)); }
/// <exception cref="System.IO.IOException"></exception> public virtual void Delete(string uri) { File4.Delete(uri); }
private void DeleteLogFile() { File4.Delete(LogFileName(_fileName)); }
public virtual void Purge(string url) { File4.Delete(url); File4.Delete(MetadataFile(url)); }
/// <exception cref="System.Exception"></exception> protected override void Db4oTearDownBeforeClean() { base.Db4oTearDownBeforeClean(); File4.Delete(BackupFile); }
/// <exception cref="System.Exception"></exception> protected override void Db4oSetupBeforeStore() { base.Db4oSetupBeforeStore(); File4.Delete(BackupFile); }
private void DeleteAllFiles() { File4.Delete(SourceFile()); File4.Delete(BackupFile()); }