Пример #1
0
 /// <summary>
 /// Add migration participant into a participants list.
 /// Participant will be added into the end of a list and will be executed only after all predecessors. </summary>
 /// <param name="participant"> - participant to add into migration </param>
 public virtual void AddParticipant(StoreMigrationParticipant participant)
 {
     Debug.Assert(participant != null);
     if (!StoreMigrationParticipant_Fields.NotParticipating.Equals(participant))
     {
         this._participants.Add(participant);
     }
 }
Пример #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldContinueMovingFilesIfUpgradeCancelledWhileMoving() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldContinueMovingFilesIfUpgradeCancelledWhileMoving()
        {
            PageCache          pageCache          = _pageCacheRule.getPageCache(_fileSystem);
            UpgradableDatabase upgradableDatabase = GetUpgradableDatabase(pageCache);

            string versionToMigrateTo   = upgradableDatabase.CurrentVersion();
            string versionToMigrateFrom = upgradableDatabase.CheckUpgradable(_databaseLayout).storeVersion();

            {
                // GIVEN
                StoreUpgrader upgrader       = NewUpgrader(upgradableDatabase, _allowMigrateConfig, pageCache);
                string        failureMessage = "Just failing";
                upgrader.AddParticipant(ParticipantThatWillFailWhenMoving(failureMessage));

                // WHEN
                try
                {
                    upgrader.MigrateIfNeeded(_databaseLayout);
                    fail("should have thrown");
                }
                catch (UnableToUpgradeException e)
                {                         // THEN
                    assertTrue(e.InnerException is IOException);
                    assertEquals(failureMessage, e.InnerException.Message);
                }
            }

            {
                // AND WHEN

                StoreUpgrader             upgrader             = NewUpgrader(upgradableDatabase, pageCache);
                StoreMigrationParticipant observingParticipant = Mockito.mock(typeof(StoreMigrationParticipant));
                upgrader.AddParticipant(observingParticipant);
                upgrader.MigrateIfNeeded(_databaseLayout);

                // THEN
                verify(observingParticipant, Mockito.never()).migrate(any(typeof(DatabaseLayout)), any(typeof(DatabaseLayout)), any(typeof(ProgressReporter)), eq(versionToMigrateFrom), eq(versionToMigrateTo));
                verify(observingParticipant, Mockito.times(1)).moveMigratedFiles(any(typeof(DatabaseLayout)), any(typeof(DatabaseLayout)), eq(versionToMigrateFrom), eq(versionToMigrateTo));

                verify(observingParticipant, Mockito.times(1)).cleanup(any(typeof(DatabaseLayout)));
            }
        }