Пример #1
0
        public void ThrowsTypeLoadExceptionIfProxyInterfacesValueIsSpecifiedInsteadOfListElement()
        {
            using (DefaultListableObjectFactory of = new DefaultListableObjectFactory())
            {
                XmlObjectDefinitionReader reader = new XmlObjectDefinitionReader(of);
                reader.LoadObjectDefinitions(new StringResource(
                                                 @"<?xml version='1.0' encoding='UTF-8' ?>
<objects xmlns='http://www.springframework.net' xmlns:r='http://www.springframework.net/remoting'>  
    
    <r:saoExporter id='ISimpleCounterExporter' targetName='ISimpleCounterProxy' serviceName='RemotedSaoCounterProxy' />
    
    <object id='ISimpleCounter' type='Spring.Remoting.SimpleCounter, Spring.Services.Tests' />

    <object id='ISimpleCounterProxy' type='Spring.Aop.Framework.ProxyFactoryObject, Spring.Aop'>
        <property name='proxyInterfaces' value='Spring.Remoting.ISimpleCounter, Spring.Services.Tests' />
        <property name='target' ref='ISimpleCounter'/>
    </object>
</objects>
"));
                try
                {
                    SaoExporter saoExporter = (SaoExporter)of.GetObject("ISimpleCounterExporter");
                    Assert.Fail();
                }
                catch (ObjectCreationException oce)
                {
                    TypeLoadException tle = (TypeLoadException)oce.GetBaseException();
                    Assert.AreEqual("Could not load type from string value ' Spring.Services.Tests'.", tle.Message);
                }
            }
        }
Пример #2
0
        public void CanExportFromFactoryObjectIfObjectTypeIsInterface()
        {
            using (DefaultListableObjectFactory of = new DefaultListableObjectFactory())
            {
                MockRepository mocks = new MockRepository();
                IFactoryObject simpleCounterFactory = (IFactoryObject)mocks.DynamicMock(typeof(IFactoryObject));
                Expect.Call(simpleCounterFactory.ObjectType).Return(typeof(ISimpleCounter));
                Expect.Call(simpleCounterFactory.IsSingleton).Return(true);
                Expect.Call(simpleCounterFactory.GetObject()).Return(new SimpleCounter());

                mocks.ReplayAll();

                of.RegisterSingleton("simpleCounter", simpleCounterFactory);
                SaoExporter saoExporter = new SaoExporter();
                saoExporter.ObjectFactory = of;
                saoExporter.TargetName    = "simpleCounter";
                saoExporter.ServiceName   = "RemotedSaoCallCounter";
                saoExporter.AfterPropertiesSet();
                of.RegisterSingleton("simpleCounterExporter", saoExporter); // also tests SaoExporter.Dispose()!

                AssertExportedService(saoExporter.ServiceName, 2);

                mocks.VerifyAll();
            }
        }
Пример #3
0
            /// <summary>
            /// Creates a new instance of the
            /// <see cref="SaoRemoteObjectProxyTypeBuilder"/> class.
            /// </summary>
            /// <param name="saoExporter">
            /// The exporter to be associated with the proxy.
            /// </param>
            public SaoRemoteObjectProxyTypeBuilder(SaoExporter saoExporter)
                : base(saoExporter)
            {
                this._saoExporter = saoExporter;

                Name     = "SaoRemoteObjectProxy";
                BaseType = typeof(BaseRemoteObject);
            }
Пример #4
0
 public void BailsIfTargetNotFound()
 {
     using (DefaultListableObjectFactory of = new DefaultListableObjectFactory())
     {
         SaoExporter saoExporter = new SaoExporter();
         saoExporter.ObjectFactory = of;
         saoExporter.TargetName = "DOESNOTEXIST";
         saoExporter.ServiceName = "RemotedSaoSingletonCounter";
         saoExporter.AfterPropertiesSet();
     }
 }
Пример #5
0
 public void BailsIfTargetNotFound()
 {
     using (DefaultListableObjectFactory of = new DefaultListableObjectFactory())
     {
         SaoExporter saoExporter = new SaoExporter();
         saoExporter.ObjectFactory = of;
         saoExporter.TargetName    = "DOESNOTEXIST";
         saoExporter.ServiceName   = "RemotedSaoSingletonCounter";
         saoExporter.AfterPropertiesSet();
     }
 }
Пример #6
0
        public void ExportSingleton()
        {
            using (DefaultListableObjectFactory of = new DefaultListableObjectFactory())
            {
                of.RegisterSingleton("simpleCounter", new SimpleCounter());
                SaoExporter saoExporter = new SaoExporter();
                saoExporter.ObjectFactory = of;
                saoExporter.TargetName = "simpleCounter";
                saoExporter.ServiceName = "RemotedSaoSingletonCounter";
                saoExporter.AfterPropertiesSet();
                of.RegisterSingleton("simpleCounterExporter", saoExporter); // also tests SaoExporter.Dispose()!

                AssertExportedService(saoExporter.ServiceName, 2);
            }
        }
Пример #7
0
        public void ExportSingleCall()
        {
            using (DefaultListableObjectFactory of = new DefaultListableObjectFactory())
            {
                of.RegisterObjectDefinition("simpleCounter", new RootObjectDefinition(typeof(SimpleCounter), false));
                SaoExporter saoExporter = new SaoExporter();
                saoExporter.ObjectFactory = of;
                saoExporter.TargetName    = "simpleCounter";
                saoExporter.ServiceName   = "RemotedSaoSingleCallCounter";
                saoExporter.AfterPropertiesSet();
                of.RegisterSingleton("simpleCounterExporter", saoExporter); // also tests SaoExporter.Dispose()!

                AssertExportedService(saoExporter.ServiceName, 0);
            }
        }
Пример #8
0
        public void CanExportFromFactoryObjectIfObjectTypeIsInterface()
        {
            using (DefaultListableObjectFactory of = new DefaultListableObjectFactory())
            {
                IFactoryObject simpleCounterFactory = A.Fake <IFactoryObject>();
                A.CallTo(() => simpleCounterFactory.ObjectType).Returns(typeof(ISimpleCounter));
                A.CallTo(() => simpleCounterFactory.IsSingleton).Returns(true);
                A.CallTo(() => simpleCounterFactory.GetObject()).Returns(new SimpleCounter());


                of.RegisterSingleton("simpleCounter", simpleCounterFactory);
                SaoExporter saoExporter = new SaoExporter();
                saoExporter.ObjectFactory = of;
                saoExporter.TargetName    = "simpleCounter";
                saoExporter.ServiceName   = "RemotedSaoCallCounter";
                saoExporter.AfterPropertiesSet();
                of.RegisterSingleton("simpleCounterExporter", saoExporter); // also tests SaoExporter.Dispose()!

                AssertExportedService(saoExporter.ServiceName, 2);
            }
        }
Пример #9
0
 public void BailsWhenNotConfigured()
 {
     SaoExporter exp = new SaoExporter();
     exp.AfterPropertiesSet();
 }
Пример #10
0
        public void CanExportFromFactoryObjectIfObjectTypeIsInterface()
        {
            using (DefaultListableObjectFactory of = new DefaultListableObjectFactory())
            {
                MockRepository mocks = new MockRepository();
                IFactoryObject simpleCounterFactory = (IFactoryObject) mocks.DynamicMock(typeof (IFactoryObject));
                Expect.Call(simpleCounterFactory.ObjectType).Return(typeof (ISimpleCounter));
                Expect.Call(simpleCounterFactory.IsSingleton).Return(true);
                Expect.Call(simpleCounterFactory.GetObject()).Return(new SimpleCounter());

                mocks.ReplayAll();

                of.RegisterSingleton("simpleCounter", simpleCounterFactory);
                SaoExporter saoExporter = new SaoExporter();
                saoExporter.ObjectFactory = of;
                saoExporter.TargetName = "simpleCounter";
                saoExporter.ServiceName = "RemotedSaoCallCounter";
                saoExporter.AfterPropertiesSet();
                of.RegisterSingleton("simpleCounterExporter", saoExporter); // also tests SaoExporter.Dispose()!

                AssertExportedService(saoExporter.ServiceName, 2);

                mocks.VerifyAll();
            }
        }
Пример #11
0
            /// <summary>
            /// Creates a new instance of the 
            /// <see cref="SaoRemoteObjectProxyTypeBuilder"/> class.
            /// </summary>
            /// <param name="saoExporter">
            /// The exporter to be associated with the proxy.
            /// </param>
            public SaoRemoteObjectProxyTypeBuilder( SaoExporter saoExporter )
                : base( saoExporter )
            {
                this._saoExporter = saoExporter;

                Name = "SaoRemoteObjectProxy";
                BaseType = typeof( BaseRemoteObject );
            }
Пример #12
0
        public void BailsWhenNotConfigured()
        {
            SaoExporter exp = new SaoExporter();

            exp.AfterPropertiesSet();
        }
Пример #13
0
        public void BailsWhenNotConfigured()
        {
            SaoExporter exp = new SaoExporter();

            Assert.Throws <ArgumentException>(() => exp.AfterPropertiesSet());
        }
Пример #14
0
 public void BailsWhenNotConfigured()
 {
     SaoExporter exp = new SaoExporter();
     Assert.Throws<ArgumentException>(() => exp.AfterPropertiesSet());
 }