SetOption() public method

Sets a given option and a value for that option.
public SetOption ( String name, Object value ) : void
name String The name of the option
value Object The value of the option. Must be one of the types that /// we can serialize. /// See for a list of supported types.
return void
コード例 #1
0
        public void TestTimeout()
        {
            ConnectorInfoManager manager = GetConnectorInfoManager();
            ConnectorInfo info1 = FindConnectorInfo(manager, "1.0.0.0", "org.identityconnectors.testconnector.TstConnector");
            Assert.IsNotNull(info1);

            APIConfiguration config = info1.CreateDefaultAPIConfiguration();
            config.SetTimeout(SafeType<APIOperation>.ForRawType(typeof(CreateApiOp)), 5000);
            config.SetTimeout(SafeType<APIOperation>.ForRawType(typeof(SearchApiOp)), 5000);
            ConfigurationProperties props = config.ConfigurationProperties;
            ConfigurationProperty property = props.GetProperty("numResults");
            // 1000 is several times the remote size between pauses
            property.Value = 2;
            OperationOptionsBuilder opBuilder = new OperationOptionsBuilder();
            opBuilder.SetOption("delay", 10000);

            ConnectorFacade facade1 = ConnectorFacadeFactory.GetInstance().NewInstance(config);

            ICollection<ConnectorAttribute> attrs = CollectionUtil.NewReadOnlySet<ConnectorAttribute>();
            try
            {
                facade1.Create(ObjectClass.ACCOUNT, attrs, opBuilder.Build()).GetUidValue();
                Assert.Fail("expected timeout");
            }
            catch (OperationTimeoutException)
            {
                // expected
            }
            //catch (RemoteWrappedException e)
            //{
            //    Assert.IsTrue(e.Is(typeof(OperationTimeoutException)));
            //}

            try
            {
                facade1.Search(ObjectClass.ACCOUNT, null, new ResultsHandler()
                {
                    Handle = obj =>
                    {
                        return true;
                    }
                }, opBuilder.Build());
                Assert.Fail("expected timeout");
            }
            catch (OperationTimeoutException)
            {
                // expected
            }
            //catch (RemoteWrappedException e)
            //{
            //    Assert.IsTrue(e.Is(typeof(OperationTimeoutException)));
            //}
        }
コード例 #2
0
 public void TestOperationOptions()
 {
     OperationOptionsBuilder builder = new OperationOptionsBuilder();
     builder.SetOption("foo", "bar");
     builder.SetOption("foo2", "bar2");
     OperationOptions v1 = builder.Build();
     OperationOptions v2 = (OperationOptions)CloneObject(v1);
     Assert.AreEqual(2, v2.Options.Count);
     Assert.AreEqual("bar", v2.Options["foo"]);
     Assert.AreEqual("bar2", v2.Options["foo2"]);
 }
コード例 #3
0
        public void TestConnectionPooling()
        {
            ConnectorPoolManager.Dispose();
            ConnectorInfoManager manager =
                GetConnectorInfoManager();
            ConnectorInfo info1 =
                FindConnectorInfo(manager,
                                  "1.0.0.0",
                                  "org.identityconnectors.testconnector.TstConnector");
            Assert.IsNotNull(info1);
            //reset connection count
            {
                //trigger TstConnection.init to be called
                APIConfiguration config2 =
                    info1.CreateDefaultAPIConfiguration();
                config2.ConfigurationProperties.GetProperty("resetConnectionCount").Value = (true);
                ConnectorFacade facade2 =
                    ConnectorFacadeFactory.GetInstance().NewInstance(config2);
                facade2.Schema(); //force instantiation
            }

            APIConfiguration config =
                info1.CreateDefaultAPIConfiguration();

            config.ConnectorPoolConfiguration.MinIdle = (0);
            config.ConnectorPoolConfiguration.MaxIdle = (0);

            ConnectorFacade facade1 =
                ConnectorFacadeFactory.GetInstance().NewInstance(config);

            OperationOptionsBuilder builder = new OperationOptionsBuilder();
            builder.SetOption("testPooling", "true");
            OperationOptions options = builder.Build();
            ICollection<ConnectorAttribute> attrs = CollectionUtil.NewReadOnlySet<ConnectorAttribute>();
            Assert.AreEqual("1", facade1.Create(ObjectClass.ACCOUNT, attrs, options).GetUidValue());
            Assert.AreEqual("2", facade1.Create(ObjectClass.ACCOUNT, attrs, options).GetUidValue());
            Assert.AreEqual("3", facade1.Create(ObjectClass.ACCOUNT, attrs, options).GetUidValue());
            Assert.AreEqual("4", facade1.Create(ObjectClass.ACCOUNT, attrs, options).GetUidValue());
            config =
                info1.CreateDefaultAPIConfiguration();
            config.ConnectorPoolConfiguration.MinIdle = (1);
            config.ConnectorPoolConfiguration.MaxIdle = (2);
            facade1 =
                ConnectorFacadeFactory.GetInstance().NewInstance(config);
            Assert.AreEqual("5", facade1.Create(ObjectClass.ACCOUNT, attrs, options).GetUidValue());
            Assert.AreEqual("5", facade1.Create(ObjectClass.ACCOUNT, attrs, options).GetUidValue());
            Assert.AreEqual("5", facade1.Create(ObjectClass.ACCOUNT, attrs, options).GetUidValue());
            Assert.AreEqual("5", facade1.Create(ObjectClass.ACCOUNT, attrs, options).GetUidValue());
        }