Exemplo n.º 1
0
        public void DeclarativeViaTransactionProxyFactoryObject()
        {
            ITestObjectManager mgr = ctx["testObjectManagerTP"] as ITestObjectManager;
            ITestObjectDao     dao = (ITestObjectDao)ctx["testObjectDao"];

            PerformOperations(mgr, dao);
        }
Exemplo n.º 2
0
        private static void ExecuteDaoOperations(ITestObjectDao dao)
        {
            TestObject toGeorge = new TestObject();

            toGeorge.Name = "George";
            toGeorge.Age  = 33;
            dao.Create(toGeorge);
            TestObject to = dao.FindByName("George");

            Assert.IsNotNull(to, "FindByName for George should not return null");
            Assert.AreEqual("George", to.Name);
            Assert.AreEqual(33, to.Age);

            to.Age = 34;
            dao.Update(to);

            TestObject to2 = dao.FindByName("George");

            Assert.AreEqual(34, to2.Age);

            dao.Delete(to);

            TestObject to3 = dao.FindByName("George");

            Assert.IsNull(to3, "Should not have found TestObject with name George. TestObject = " + to.ToString());
        }
Exemplo n.º 3
0
        public static void PerformOperations(ITestObjectManager mgr,
                                             ITestObjectDao dao)
        {
            Assert.IsNotNull(mgr);
            TestObject to1 = new TestObject();

            to1.Name = "Jack";
            to1.Age  = 7;
            TestObject to2 = new TestObject();

            to2.Name = "Jill";
            to2.Age  = 8;
            mgr.SaveTwoTestObjects(to1, to2);

            TestObject to = dao.FindByName("Jack");

            Assert.IsNotNull(to);

            to = dao.FindByName("Jill");
            Assert.IsNotNull(to);
            Assert.AreEqual("Jill", to.Name);

            mgr.DeleteTwoTestObjects("Jack", "Jill");

            to = dao.FindByName("Jack");
            Assert.IsNull(to);

            to = dao.FindByName("Jill");
            Assert.IsNull(to);
        }
Exemplo n.º 4
0
        public static void PerformOperations(ITestObjectManager mgr,
            ITestObjectDao dao)
        {
            Assert.IsNotNull(mgr);
            TestObject to1 = new TestObject();
            to1.Name = "Jack";
            to1.Age = 7;
            TestObject to2 = new TestObject();
            to2.Name = "Jill";
            to2.Age = 8;
            mgr.SaveTwoTestObjects(to1, to2);

            TestObject to = dao.FindByName("Jack");
            Assert.IsNotNull(to);

            to = dao.FindByName("Jill");
            Assert.IsNotNull(to);
            Assert.AreEqual("Jill", to.Name);

            mgr.DeleteTwoTestObjects("Jack", "Jill");

            to = dao.FindByName("Jack");
            Assert.IsNull(to);

            to = dao.FindByName("Jill");
            Assert.IsNull(to);
        }
Exemplo n.º 5
0
        private static void ExecuteAndRollbackDaoOperations(ITestObjectDao dao)
        {
            TestObject toBugs = new TestObject();

            toBugs.Name = "Bugs";
            toBugs.Age  = 33;
            dao.CreateUpdateRollback(toBugs);
        }
Exemplo n.º 6
0
        public void DemoDao()
        {
            ITestObjectDao dao      = (ITestObjectDao)ctx["testObjectDaoViaTxAttributes"];
            TestObject     toGeorge = new TestObject();

            toGeorge.Name = "George";
            toGeorge.Age  = 33;
            dao.Create(toGeorge);
        }
Exemplo n.º 7
0
        public void SimpleDao()
        {
            ITestObjectDao dao = (ITestObjectDao)ctx["NHTestObjectDao"];

            Assert.IsNotNull(dao);
            TestObject to = dao.FindByName("Gabriel");

            Assert.IsNotNull(to);
            Assert.AreEqual("Gabriel", to.Name);
        }
Exemplo n.º 8
0
        public void ExecuteTemplate()
        {
            ITestObjectDao      dao = (ITestObjectDao)ctx["NHTestObjectDao"];
            TransactionTemplate tt  = new TransactionTemplate(transactionManager);
            object     result       = tt.Execute(new SimpleTransactionCallback(dbProvider, dao));
            TestObject to           = result as TestObject;

            Assert.IsNotNull(to, "FindByName for Gabriel should not return null");
            Assert.AreEqual("Gabriel", to.Name);
        }
Exemplo n.º 9
0
        private void zzzExecuteDaoOperations()
        {
            ITestObjectDao dao = (ITestObjectDao)ctx["SimpleTestDao"];

            TestObject toGeorge = new TestObject();

            toGeorge.Name = "George";
            toGeorge.Age  = 33;
            dao.Create(toGeorge);
        }
Exemplo n.º 10
0
        public void SimpleCreate()
        {
            IApplicationContext ctx =
                new XmlApplicationContext("assembly://Spring.Data.Integration.Tests/Spring.Data/nativeAdoTests.xml");

            Assert.IsNotNull(ctx);
            ITestObjectDao dao = (ITestObjectDao)ctx["testObjectDao"];

            Assert.IsNotNull(dao);
            dao.Create("John", 44);
        }
Exemplo n.º 11
0
        public static void PerformOperations(ITestCoordinator coordinator, ITestObjectDao dao)
        {
            TestObject to1 = new TestObject();
            to1.Name = "Jack";
            to1.Age = 7;
            TestObject to2 = new TestObject();
            to2.Name = "Jill";
            to2.Age = 8;

            coordinator.WorkOn(to1, to2);

            coordinator.TestObjectManager.DeleteTwoTestObjects("Jack", "Jill");
        }
Exemplo n.º 12
0
        public void CreateNative()
        {
            IApplicationContext ctx;
            string assemblyName = GetType().Assembly.GetName().Name;

            ctx = new XmlApplicationContext("assembly://" + assemblyName + "/Spring.Data.NHibernate/templateTests.xml");

            ITestObjectDao dao = (ITestObjectDao)ctx.GetObject("nativeNHTestObjectDao");

            TestObject toGeorge = new TestObject();

            toGeorge.Name = "George";
            toGeorge.Age  = 34;
            dao.Create(toGeorge);
        }
Exemplo n.º 13
0
        public static void PerformOperations(ITestCoordinator coordinator, ITestObjectDao dao)
        {
            TestObject to1 = new TestObject();

            to1.Name = "Jack";
            to1.Age  = 7;
            TestObject to2 = new TestObject();

            to2.Name = "Jill";
            to2.Age  = 8;

            coordinator.WorkOn(to1, to2);

            coordinator.TestObjectManager.DeleteTwoTestObjects("Jack", "Jill");
        }
Exemplo n.º 14
0
        public void DaoOperationsWithRollback()
        {
            ITestObjectDao dao = (ITestObjectDao)ctx["testObjectDaoTransProxy"];

            try
            {
                ExecuteAndRollbackDaoOperations(dao);
            } catch (Exception e)
            {
                TestObject to = dao.FindByName("Bugs");
                Assert.IsNull(to);

                //just to get rid of compiler warning...
                Assert.IsNotNull(e);
            }
        }
Exemplo n.º 15
0
        public void UserCredentialsDbProvider()
        {
            ITestObjectDao dao = (ITestObjectDao)ctx["testObjectDaoTransProxy"];

            userCredentialsDbProvider.SetCredentialsForCurrentThread("User ID=springqa", "Password=springqa");
            TestObject toGeorge = new TestObject();

            toGeorge.Name = "George";
            toGeorge.Age  = 33;
            dao.Create(toGeorge);

            userCredentialsDbProvider.SetCredentialsForCurrentThread("User ID=springqa2", "Password=springqa2");

            TestObject toMary = new TestObject();

            toMary.Name = "Mary";
            toMary.Age  = 34;
            dao.Create(toMary);
        }
Exemplo n.º 16
0
        public void ExecuteTransactionManager()
        {
            DefaultTransactionDefinition def = new DefaultTransactionDefinition();

            def.PropagationBehavior = TransactionPropagation.Required;

            ITransactionStatus status = transactionManager.GetTransaction(def);

            ITestObjectDao dao = (ITestObjectDao)ctx["NHTestObjectDao"];
            TestObject     to;

            try
            {
                to = dao.FindByName("Gabriel");
            }
            catch (Exception)
            {
                transactionManager.Rollback(status);
                throw;
            }
            transactionManager.Commit(status);
            Assert.IsNotNull(to, "FindByName for Gabriel should not return null");
            Assert.AreEqual("Gabriel", to.Name);
        }
Exemplo n.º 17
0
 public SimpleTransactionCallback(IDbProvider dbp, ITestObjectDao dao)
 {
     dbProvider = dbp;
     this.dao   = dao;
 }
Exemplo n.º 18
0
        private static void ExecuteAndRollbackDaoOperations(ITestObjectDao dao)
        {
            TestObject toBugs = new TestObject();
            toBugs.Name = "Bugs";
            toBugs.Age = 33;
            dao.CreateUpdateRollback(toBugs);

        }
Exemplo n.º 19
0
	    private static void ExecuteDaoOperations(ITestObjectDao dao)
	    {
	        TestObject toGeorge = new TestObject();
	        toGeorge.Name = "George";
	        toGeorge.Age = 33;
	        dao.Create(toGeorge);
	        TestObject to = dao.FindByName("George");
	        Assert.IsNotNull(to, "FindByName for George should not return null");
	        Assert.AreEqual("George", to.Name);
	        Assert.AreEqual(33, to.Age);
    
	        to.Age=34;
	        dao.Update(to);
    
	        TestObject to2 = dao.FindByName("George");
	        Assert.AreEqual(34, to2.Age);
    
	        dao.Delete(to);
    
	        TestObject to3 = dao.FindByName("George");
	        Assert.IsNull(to3, "Should not have found TestObject with name George. TestObject = " + to.ToString()   );
	    }
Exemplo n.º 20
0
 public SimpleTransactionCallback(IDbProvider dbp, ITestObjectDao dao)
 {
     dbProvider = dbp;
     this.dao = dao;
 }
Exemplo n.º 21
0
        public void DaoOperationsViaTransactionProxy()
        {
            ITestObjectDao dao = (ITestObjectDao)ctx["testObjectDaoTransProxy"];

            ExecuteDaoOperations(dao);
        }
Exemplo n.º 22
0
        public void DaoOperationsViaProxyFactoryWithTxAttributes()
        {
            ITestObjectDao dao = (ITestObjectDao)ctx["testObjectDaoViaTxAttributes"];

            ExecuteDaoOperations(dao);
        }