Inheritance: IRecoveryLogger
Exemplo n.º 1
0
        public void TestInitWithNoLocationSet()
        {
            RecoveryFileLogger logger = new RecoveryFileLogger();

            logger.Initialize(rmId.ToString());

            Assert.AreEqual(Directory.GetCurrentDirectory(), logger.Location);
        }
Exemplo n.º 2
0
        public void TestInitWithNonDefaultLocationSet()
        {
            RecoveryFileLogger logger = new RecoveryFileLogger();

            logger.Location = nonDefaultLogLocation;
            logger.Initialize(rmId.ToString());

            Assert.AreEqual(nonDefaultLogLocation, logger.Location);
        }
Exemplo n.º 3
0
        public void TestInitWithAutoCreateLocation()
        {
            RecoveryFileLogger logger = new RecoveryFileLogger();

            Assert.IsFalse(Directory.Exists(autoCreatePath));

            logger.AutoCreateLocation = true;
            logger.Location = autoCreatePath;
            logger.Initialize(rmId.ToString());

            Assert.IsTrue(Directory.Exists(autoCreatePath));
            Assert.AreEqual(autoCreatePath, logger.Location);
        }
Exemplo n.º 4
0
        public void TestInitWithLocationSetToBadPath()
        {
            RecoveryFileLogger logger = new RecoveryFileLogger();

            logger.Location = this.nonExistantPath;

            try
            {
                logger.Initialize(rmId.ToString());
                Assert.Fail("Should have detected an invalid dir and thrown an exception");
            }
            catch
            {
            }
        }
Exemplo n.º 5
0
        public void TestRecoverLoggedRecord()
        {
            RecoveryFileLogger logger = new RecoveryFileLogger();

            byte[] globalId = new byte[32];
            byte[] branchQ = new byte[32];
            byte[] recoveryData = new byte[256];

            Random gen = new Random();

            gen.NextBytes(globalId);
            gen.NextBytes(branchQ);
            gen.NextBytes(recoveryData);

            logger.Location = nonDefaultLogLocation;
            logger.Initialize(rmId.ToString());

            XATransactionId xid = new XATransactionId();
            xid.GlobalTransactionId = globalId;
            xid.BranchQualifier = branchQ;

            logger.LogRecoveryInfo(xid, recoveryData);

            Assert.IsTrue(File.Exists(logger.Location + Path.DirectorySeparatorChar + rmId.ToString() + ".bin"),
                          "Recovery File was not created");
            Assert.IsTrue(logger.GetRecoverables().Length == 1,
                          "Did not recover the logged record.");

            KeyValuePair<XATransactionId, byte[]>[] records = logger.GetRecoverables();
            Assert.AreEqual(1, records.Length);

            Assert.AreEqual(globalId, records[0].Key.GlobalTransactionId, "Incorrect Global TX Id returned");
            Assert.AreEqual(branchQ, records[0].Key.BranchQualifier, "Incorrect Branch Qualifier returned");
            Assert.AreEqual(recoveryData, records[0].Value, "Incorrect Recovery Information returned");
        }
Exemplo n.º 6
0
        public void TestPurgeTransactionRecord()
        {
            RecoveryFileLogger logger = new RecoveryFileLogger();

            byte[] globalId = new byte[32];
            byte[] branchQ = new byte[32];
            byte[] recoveryData = new byte[256];

            Random gen = new Random();

            gen.NextBytes(globalId);
            gen.NextBytes(branchQ);
            gen.NextBytes(recoveryData);

            logger.Location = nonDefaultLogLocation;
            logger.Initialize(rmId.ToString());

            XATransactionId xid = new XATransactionId();
            xid.GlobalTransactionId = globalId;
            xid.BranchQualifier = branchQ;

            logger.LogRecoveryInfo(xid, recoveryData);

            Assert.IsTrue(File.Exists(logger.Location + Path.DirectorySeparatorChar + rmId.ToString() + ".bin"),
                          "Recovery File was not created");

            logger.Purge();

            Assert.IsFalse(File.Exists(logger.Location + Path.DirectorySeparatorChar + rmId.ToString() + ".bin"),
                          "Recovery File was not created");
        }
Exemplo n.º 7
0
        public void TestNothingToRecover()
        {
            RecoveryFileLogger logger = new RecoveryFileLogger();

            logger.Location = nonDefaultLogLocation;
            logger.Initialize(rmId.ToString());

            Assert.IsTrue(logger.GetRecoverables().Length == 0);
        }