コード例 #1
0
        public void GetSaoWithSingletonModeAndAop()
        {
            IApplicationContext ctx = new XmlApplicationContext("assembly://Spring.Services.Tests/Spring.Data.Spring.Remoting/saoSingleton-aop.xml");

            ContextRegistry.RegisterContext(ctx);

            //object saoFactory = ctx.GetObject("&remoteCounter");
            //Assert.IsNotNull(saoFactory);

            object obj = ctx.GetObject("remoteCounter");

            Assert.IsNotNull(obj, "Object is null even though a object has been exported.");
            Assert.IsTrue(AopUtils.IsAopProxy(obj));
            Assert.IsTrue((obj is ISimpleCounter), "Object should implement 'ISimpleCounter' interface.");


            MethodCounter aopCounter = ctx.GetObject("countingBeforeAdvice") as MethodCounter;

            Assert.IsNotNull(aopCounter);

            int aopCount = aopCounter.GetCalls("Count");

            Assert.AreEqual(0, aopCount);

            ISimpleCounter sc = (ISimpleCounter)obj;

            Assert.AreEqual(1, sc.Counter, "Remote object hasn't been activated by the server.");
            sc.Count();
            Assert.AreEqual(2, sc.Counter, "Remote object doesn't work in a 'Singleton' mode.");
            Assert.AreEqual(1, aopCounter.GetCalls("Count"));
        }
コード例 #2
0
        private void AssertExportedService(string serviceName, int expectedCount)
        {
            ISimpleCounter client = (ISimpleCounter)Activator.GetObject(typeof(ISimpleCounter), "tcp://localhost:8005/" + serviceName);

            client.Count();
            client.Count();

            Assert.AreEqual(expectedCount, client.Counter);
        }
コード例 #3
0
        public void GetSimpleObject()
        {
            IApplicationContext ctx = new XmlApplicationContext("assembly://Spring.Services.Tests/Spring.Data.Spring.Remoting/cao.xml");

            ContextRegistry.RegisterContext(ctx);

            object obj = ctx.GetObject("remoteCaoCounter1");

            Assert.IsNotNull(obj, "Object is null even though a object has been registered.");
            Assert.IsTrue((obj is ISimpleCounter), "Object should implement 'ISimpleCounter' interface.");

            ISimpleCounter sc = (ISimpleCounter)obj;

            Assert.AreEqual(7, sc.Counter, "Remote object hasn't been activated by the client.");
            sc.Count();
            Assert.AreEqual(8, sc.Counter);
        }
コード例 #4
0
        public void GetSaoWithSingletonMode()
        {
            IApplicationContext ctx = new XmlApplicationContext("assembly://Spring.Services.Tests/Spring.Data.Spring.Remoting/saoSingleton.xml");

            ContextRegistry.RegisterContext(ctx);

            object obj = ctx.GetObject("remoteSaoSingletonCounter");

            Assert.IsNotNull(obj, "Object is null even though a object has been exported.");
            Assert.IsTrue((obj is ISimpleCounter), "Object should implement 'ISimpleCounter' interface.");

            ISimpleCounter sc = (ISimpleCounter)obj;

            Assert.AreEqual(1, sc.Counter, "Remote object hasn't been activated by the server.");
            sc.Count();
            Assert.AreEqual(2, sc.Counter, "Remote object doesn't work in a 'Singleton' mode.");
        }
コード例 #5
0
 public SPRNET967_SimpleCounterClient(ISimpleCounter service)
 {
     this.service = service;
 }
コード例 #6
0
 public SPRNET967_SimpleCounterWrapper(ISimpleCounter service)
 {
     this.service = service;
 }
コード例 #7
0
 public SPRNET967_SimpleCounterClient(ISimpleCounter service)
 {
     this.service = service;
 }
コード例 #8
0
 public SPRNET967_SimpleCounterWrapper(ISimpleCounter service)
 {
     this.service = service;
 }
コード例 #9
0
 public void Setup()
 {
     Subject = new SimpleCounter <object>();
 }