Exemplo n.º 1
0
		protected virtual void Delete(ITestableReplicationProviderInside provider)
		{
			ArrayList toDelete = new ArrayList();
			IEnumerator rr = provider.GetStoredObjects(typeof(R0)).GetEnumerator();
			while (rr.MoveNext())
			{
				object o = rr.Current;
				IReflectClass claxx = ReplicationReflector().ForObject(o);
				SetFieldsToNull(o, claxx);
				toDelete.Add(o);
			}
			object commitObject = null;
			for (IEnumerator iterator = toDelete.GetEnumerator(); iterator.MoveNext(); )
			{
				object o = iterator.Current;
				//System.out.println("o = " + o);
				provider.Delete(o);
				commitObject = o;
			}
			if (commitObject != null)
			{
				provider.Commit();
			}
			else
			{
				provider.Commit();
			}
		}
Exemplo n.º 2
0
        protected virtual void Delete(ITestableReplicationProviderInside provider)
        {
            ArrayList   toDelete = new ArrayList();
            IEnumerator rr       = provider.GetStoredObjects(typeof(R0)).GetEnumerator();

            while (rr.MoveNext())
            {
                object        o     = rr.Current;
                IReflectClass claxx = ReplicationReflector().ForObject(o);
                SetFieldsToNull(o, claxx);
                toDelete.Add(o);
            }
            object commitObject = null;

            for (IEnumerator iterator = toDelete.GetEnumerator(); iterator.MoveNext();)
            {
                object o = iterator.Current;
                //System.out.println("o = " + o);
                provider.Delete(o);
                commitObject = o;
            }
            if (commitObject != null)
            {
                provider.Commit();
            }
            else
            {
                provider.Commit();
            }
        }
Exemplo n.º 3
0
        public virtual void Test()
        {
            ITestableReplicationProviderInside providerA = A().Provider();
            ITestableReplicationProviderInside providerB = B().Provider();

            providerA.StoreNew(new Pilot());
            providerA.Commit();
            IReplicationSession replication = Replication.Begin(providerA, providerB, null, _fixtures
                                                                .reflector);
            TimeStamps initialTimeStampsB = AssertTimeStampsForFirstReplication(providerB);
            IObjectSet modifiedObjects    = providerA.ObjectsChangedSinceLastReplication();

            while (modifiedObjects.HasNext())
            {
                replication.Replicate(modifiedObjects.Next());
            }
            replication.Commit();
            Pilot replicatedPilot = (Pilot)providerB.GetStoredObjects(typeof(Pilot)).Next();
            long  version         = providerB.ObjectVersion(replicatedPilot);

            Assert.AreEqual(initialTimeStampsB.Commit(), version);
            replication = Replication.Begin(providerA, providerB, null, _fixtures.reflector);
            TimeStamps timestampsBAfterReplication = AssertTimeStampsForSecondReplication(initialTimeStampsB
                                                                                          , providerB);

            replication.Commit();
            Pilot pilotStoredAfterReplication = new Pilot();

            providerB.StoreNew(pilotStoredAfterReplication);
            providerB.Commit();
            providerB.WaitForPreviousCommits();
            version = providerB.ObjectVersion(pilotStoredAfterReplication);
            Assert.IsGreater(timestampsBAfterReplication.Commit(), version);
        }
        private Replicated Find(ITestableReplicationProviderInside container, string name
                                )
        {
            IEnumerator storedObjects = container.GetStoredObjects(typeof(Replicated)).GetEnumerator
                                            ();
            int        resultCount = 0;
            Replicated result      = null;

            while (storedObjects.MoveNext())
            {
                Replicated replicated = (Replicated)storedObjects.Current;
                if (replicated == null)
                {
                    throw new Exception();
                }
                if (name.Equals(replicated.GetName()))
                {
                    result = replicated;
                    resultCount++;
                }
            }
            if (resultCount > 1)
            {
                Fail("At most one object with name " + name + " was expected.");
            }
            return(result);
        }
 private void CheckEmpty(ITestableReplicationProviderInside provider)
 {
     if (provider.GetStoredObjects(typeof(Replicated)).GetEnumerator().MoveNext())
     {
         throw new Exception(provider.GetName() + " is not empty");
     }
 }
        public object QueryItem(ITestableReplicationProviderInside provider, Type type)
        {
            IObjectSet result = provider.GetStoredObjects(type);

            Assert.AreEqual(1, result.Count);
            return(result.Next());
        }
Exemplo n.º 7
0
		private void EnsureContent(Container container, ITestableReplicationProviderInside
			 provider)
		{
			IObjectSet result = provider.GetStoredObjects(container.GetType());
			Assert.AreEqual(1, result.Count);
			Container c = Next(result);
			Assert.AreEqual(template.GetValue(), c.GetValue());
		}
Exemplo n.º 8
0
        private void EnsureContent(Container container, ITestableReplicationProviderInside
                                   provider)
        {
            IObjectSet result = provider.GetStoredObjects(container.GetType());

            Assert.AreEqual(1, result.Count);
            Container c = Next(result);

            Assert.AreEqual(template.GetValue(), c.GetValue());
        }
		private void ModifyPilotIn(ITestableReplicationProviderInside provider, string newName
			)
		{
			Pilot pilot;
			pilot = (Pilot)provider.GetStoredObjects(typeof(Pilot)).Next();
			pilot.SetName(newName);
			provider.Update(pilot);
			provider.Commit();
			provider.WaitForPreviousCommits();
		}
Exemplo n.º 10
0
        private void PrintProviderContent(ITestableReplicationProviderInside provider)
        {
            IObjectSet storedObjects = provider.GetStoredObjects(typeof(Replicated));

            Sharpen.Runtime.Out.WriteLine("PROVIDER: " + provider);
            while (storedObjects.HasNext())
            {
                Sharpen.Runtime.Out.WriteLine(storedObjects.Next());
            }
        }
        private void ModifyPilotIn(ITestableReplicationProviderInside provider, string newName
                                   )
        {
            Pilot pilot;

            pilot = (Pilot)provider.GetStoredObjects(typeof(Pilot)).Next();
            pilot.SetName(newName);
            provider.Update(pilot);
            provider.Commit();
            provider.WaitForPreviousCommits();
        }
        private void PrintProviderContent(ITestableReplicationProviderInside provider)
        {
            IObjectSet storedObjects = provider.GetStoredObjects(typeof(Replicated));

            Sharpen.Runtime.Out.WriteLine("PROVIDER: " + provider);
            while (storedObjects.HasNext())
            {
                object @object = storedObjects.Next();
                Sharpen.Runtime.Out.WriteLine("-> " + @object + " - c:" + CreationTime(provider,
                                                                                       @object) + " v:" + Version(provider, @object));
            }
        }
Exemplo n.º 13
0
        private void EnsureCount(ITestableReplicationProviderInside provider, Type clazz,
                                 int count)
        {
            IEnumerator instances = provider.GetStoredObjects(clazz).GetEnumerator();
            int         i         = count;

            while (instances.MoveNext())
            {
                object o = instances.Current;
                i--;
            }
            Assert.AreEqual(0, i);
        }
Exemplo n.º 14
0
        private void ModifyR4(ITestableReplicationProviderInside provider)
        {
            object      commitObject = null;
            IEnumerator it           = provider.GetStoredObjects(typeof(R4)).GetEnumerator();

            while (it.MoveNext())
            {
                R4 r4 = (R4)it.Current;
                r4.SetName(r4.GetName() + "_");
                provider.Update(r4);
                commitObject = r4;
            }
            provider.Commit();
        }
Exemplo n.º 15
0
		private void EnsureContent(NewPilot newPilot, ITestableReplicationProviderInside 
			provider)
		{
			IObjectSet objectSet = provider.GetStoredObjects(typeof(NewPilot));
			Assert.AreEqual(1, objectSet.Count);
			IEnumerator iterator = objectSet.GetEnumerator();
			Assert.IsTrue(iterator.MoveNext());
			NewPilot p = (NewPilot)iterator.Current;
			Assert.AreEqual(newPilot.GetName(), p.GetName());
			Assert.AreEqual(newPilot.GetPoints(), p.GetPoints());
			for (int j = 0; j < newPilot.GetArr().Length; j++)
			{
				Assert.AreEqual(newPilot.GetArr()[j], p.GetArr()[j]);
			}
		}
Exemplo n.º 16
0
        private void EnsureContent(NewPilot newPilot, ITestableReplicationProviderInside
                                   provider)
        {
            IObjectSet objectSet = provider.GetStoredObjects(typeof(NewPilot));

            Assert.AreEqual(1, objectSet.Count);
            IEnumerator iterator = objectSet.GetEnumerator();

            Assert.IsTrue(iterator.MoveNext());
            NewPilot p = (NewPilot)iterator.Current;

            Assert.AreEqual(newPilot.GetName(), p.GetName());
            Assert.AreEqual(newPilot.GetPoints(), p.GetPoints());
            for (int j = 0; j < newPilot.GetArr().Length; j++)
            {
                Assert.AreEqual(newPilot.GetArr()[j], p.GetArr()[j]);
            }
        }
Exemplo n.º 17
0
		private void CompareR4(ITestableReplicationProviderInside a, ITestableReplicationProviderInside
			 b, bool isSameExpected)
		{
			IEnumerator it = a.GetStoredObjects(typeof(R4)).GetEnumerator();
			while (it.MoveNext())
			{
				string name = ((R4)it.Current).GetName();
				IEnumerator it2 = b.GetStoredObjects(typeof(R4)).GetEnumerator();
				bool found = false;
				while (it2.MoveNext())
				{
					string name2 = ((R4)it2.Current).GetName();
					if (name.Equals(name2))
					{
						found = true;
					}
				}
				Assert.IsTrue(found == isSameExpected);
			}
		}
Exemplo n.º 18
0
        private void CompareR4(ITestableReplicationProviderInside a, ITestableReplicationProviderInside
                               b, bool isSameExpected)
        {
            IEnumerator it = a.GetStoredObjects(typeof(R4)).GetEnumerator();

            while (it.MoveNext())
            {
                string      name  = ((R4)it.Current).GetName();
                IEnumerator it2   = b.GetStoredObjects(typeof(R4)).GetEnumerator();
                bool        found = false;
                while (it2.MoveNext())
                {
                    string name2 = ((R4)it2.Current).GetName();
                    if (name.Equals(name2))
                    {
                        found = true;
                    }
                }
                Assert.IsTrue(found == isSameExpected);
            }
        }
Exemplo n.º 19
0
		private void ModifyR4(ITestableReplicationProviderInside provider)
		{
			object commitObject = null;
			IEnumerator it = provider.GetStoredObjects(typeof(R4)).GetEnumerator();
			while (it.MoveNext())
			{
				R4 r4 = (R4)it.Current;
				r4.SetName(r4.GetName() + "_");
				provider.Update(r4);
				commitObject = r4;
			}
			provider.Commit();
		}
		private Replicated Find(ITestableReplicationProviderInside container, string name
			)
		{
			IEnumerator storedObjects = container.GetStoredObjects(typeof(Replicated)).GetEnumerator
				();
			int resultCount = 0;
			Replicated result = null;
			while (storedObjects.MoveNext())
			{
				Replicated replicated = (Replicated)storedObjects.Current;
				if (replicated == null)
				{
					throw new Exception();
				}
				if (name.Equals(replicated.GetName()))
				{
					result = replicated;
					resultCount++;
				}
			}
			if (resultCount > 1)
			{
				Fail("At most one object with name " + name + " was expected.");
			}
			return result;
		}
Exemplo n.º 21
0
 public object QueryItem(ITestableReplicationProviderInside provider, Type type)
 {
     IObjectSet result = provider.GetStoredObjects(type);
     Assert.AreEqual(1, result.Count);
     return result.Next();
 }
Exemplo n.º 22
0
		private void EnsureNotExist(ITestableReplicationProviderInside provider, Type type
			)
		{
			Assert.IsTrue(!provider.GetStoredObjects(type).GetEnumerator().MoveNext());
		}
 private void EnsureNotExist(ITestableReplicationProviderInside provider, Type type
                             )
 {
     Assert.IsTrue(!provider.GetStoredObjects(type).GetEnumerator().MoveNext());
 }
Exemplo n.º 24
0
		private int ReplicateAll(ITestableReplicationProviderInside peerA, ITestableReplicationProviderInside
			 peerB, bool modifiedOnly)
		{
			IReplicationSession replication = Replication.Begin(peerA, peerB, null, _fixtures
				.reflector);
			IEnumerator it = modifiedOnly ? peerA.ObjectsChangedSinceLastReplication(typeof(R0
				)).GetEnumerator() : peerA.GetStoredObjects(typeof(R0)).GetEnumerator();
			int replicated = 0;
			while (it.MoveNext())
			{
				R0 r0 = (R0)it.Current;
				replication.Replicate(r0);
				replicated++;
			}
			replication.Commit();
			EnsureCount(peerA, Linkers);
			EnsureCount(peerB, Linkers);
			return replicated;
		}
		private void PrintProviderContent(ITestableReplicationProviderInside provider)
		{
			IObjectSet storedObjects = provider.GetStoredObjects(typeof(Replicated));
			Sharpen.Runtime.Out.WriteLine("PROVIDER: " + provider);
			while (storedObjects.HasNext())
			{
				Sharpen.Runtime.Out.WriteLine(storedObjects.Next());
			}
		}
Exemplo n.º 26
0
        private int ReplicateAll(ITestableReplicationProviderInside peerA, ITestableReplicationProviderInside
                                 peerB, bool modifiedOnly)
        {
            IReplicationSession replication = Replication.Begin(peerA, peerB, null, _fixtures
                                                                .reflector);
            IEnumerator it = modifiedOnly ? peerA.ObjectsChangedSinceLastReplication(typeof(R0
                                                                                            )).GetEnumerator() : peerA.GetStoredObjects(typeof(R0)).GetEnumerator();
            int replicated = 0;

            while (it.MoveNext())
            {
                R0 r0 = (R0)it.Current;
                replication.Replicate(r0);
                replicated++;
            }
            replication.Commit();
            EnsureCount(peerA, Linkers);
            EnsureCount(peerB, Linkers);
            return(replicated);
        }
		private void CheckEmpty(ITestableReplicationProviderInside provider)
		{
			if (provider.GetStoredObjects(typeof(Replicated)).GetEnumerator().MoveNext())
			{
				throw new Exception(provider.GetName() + " is not empty");
			}
		}
Exemplo n.º 28
0
		private void EnsureCount(ITestableReplicationProviderInside provider, Type clazz, 
			int count)
		{
			IEnumerator instances = provider.GetStoredObjects(clazz).GetEnumerator();
			int i = count;
			while (instances.MoveNext())
			{
				object o = instances.Current;
				i--;
			}
			Assert.AreEqual(0, i);
		}
Exemplo n.º 29
0
		private void PrintProviderContent(ITestableReplicationProviderInside provider)
		{
			IObjectSet storedObjects = provider.GetStoredObjects(typeof(Replicated));
			Sharpen.Runtime.Out.WriteLine("PROVIDER: " + provider);
			while (storedObjects.HasNext())
			{
				object @object = storedObjects.Next();
				Sharpen.Runtime.Out.WriteLine("-> " + @object + " - c:" + CreationTime(provider, 
					@object) + " v:" + Version(provider, @object));
			}
		}