/// <summary> /// 初始化 inflation 状态,指明窗口位数。可选需排除 RFC1950 的头字节。 /// </summary> /// <param name="expectRfc1950Header">指示是否排除 RFC1950 的头字节。</param> /// <param name="windowBits">窗口位数。</param> /// <returns>如果正常返回 ZlibState.Success 。</returns> public ZlibState InitializeInflate(int windowBits, bool expectRfc1950Header) { WindowBits = windowBits; Thrower.ThrowZlibExceptionIf(DState != null, "在 InitializeDeflate() 后不能调用 InitializeInflate() 。"); IState = new InflateManager(expectRfc1950Header); return(IState.Initialize(this, windowBits)); }
public static ExtendedKey Parse(string serialized) { byte[] data = Base58Encoding.DecodeWithCheckSum(serialized); Thrower.Condition <AddressException>(data.Length != 78, "invalid extended key"); using (var stream = new MemoryStream(data)) { using (var binReader = new BinaryReader(stream)) { var ext = binReader.ReadBytes(4); Thrower.Condition <AddressException>(!(ext.SequenceEqual(Xprv) || ext.SequenceEqual(Xpub)), "invalid magic number for an extended key"); var isPrivate = ext.SequenceEqual(Xprv); var depth = binReader.ReadByte(); var fingerprint = binReader.ReadBytes(4); var index = BitHelper.ToUInt32(binReader.ReadBytes(4), false); var chainCode = binReader.ReadBytes(32); var rawKey = binReader.ReadBytes(33); BitcoinKey key; if (isPrivate) { key = new BitcoinPrivateKey(rawKey.Skip(1).ToArray()); } else { key = new BitcoinPublicKey(rawKey); } return(new ExtendedKey(key, chainCode, depth, fingerprint, index)); } } }
/// <summary> /// The resolve. /// </summary> public static bool PopulateCoinParameters(CoinParameters param) { // places to look for the network parameters // https://github.com/bitcoin/bitcoin/blob/d612837814020ae832499d18e6ee5eb919a87907/src/chainparams.cpp // https://github.com/CrypticApplications/MTR-Update/blob/master/src/base58.h // example MTR => private key prefix is [128 + CBitcoinAddress::PUBKEY_ADDRESS] List <int> vals; if (Params.TryGetValue(param.CoinTag, out vals)) { param.PublicKeyAddressVersion = vals.ElementAt(0); param.ScriptAddressVersion = vals.ElementAt(1); param.ExtendedKeyIndex = vals.ElementAt(2); param.PrivateKeyVersion = vals.ElementAt(3); Thrower.If(param.PrivateKeyVersion == -1).Throw <AddressException>(); Thrower.If(param.ExtendedKeyIndex == -1).Throw <AddressException>(); Thrower.If(param.PublicKeyAddressVersion == -1).Throw <AddressException>(); return(true); } return(false); }
/// <summary> /// 实现关闭流。 /// </summary> protected virtual void CloseInternal() { if (_streamMode == StreamMode.Writer) { bool done = false; do { _z.OutputBuffer = WorkingBuffer; _z.NextOut = 0; _z.AvailableBytesOut = _workingBuffer.Length; ZlibState rc = (WantCompress) ? _z.Deflate(FlushType.Finish) : _z.Inflate(FlushType.Finish); Thrower.ThrowZlibExceptionIf(rc != ZlibState.StreamEnd && rc != ZlibState.Success, (WantCompress ? "压缩" : "解压") + "错误" + (_z.Message == null ? ("状态 = " + Enum.GetName(typeof(ZlibState), rc)) : _z.Message)); if (_workingBuffer.Length - _z.AvailableBytesOut > 0) { _stream.Write(_workingBuffer, 0, _workingBuffer.Length - _z.AvailableBytesOut); } done = _z.AvailableBytesIn == 0 && _z.AvailableBytesOut != 0; // If GZIP and de-compress, we're done when 8 bytes remain. if (_isGZip && !WantCompress) { done = (_z.AvailableBytesIn == 8 && _z.AvailableBytesOut != 0); } } while (!done); Flush(); } }
public void StackTraceHelper_IncludesLineNumbersForFiles() { // Arrange Exception exception = null; try { // Throwing an exception in the current assembly always seems to populate the full stack // trace regardless of symbol type. Crossing assembly boundaries ensures PortablePdbReader gets used // on desktop. Thrower.Throw(); } catch (Exception ex) { exception = ex; } // Act var stackFrames = StackTraceHelper.GetFrames(exception); // Assert Assert.Collection(stackFrames, frame => { Assert.Contains("Thrower.cs", frame.FilePath); Assert.Equal(17, frame.LineNumber); }, frame => { Assert.Contains("StackTraceHelperTest.cs", frame.FilePath); }); }
/// <summary> /// Initializes a new instance of the <see cref="BitcoinPrivateKey"/> class. /// Parses the given private key as created by the BitCoin C++ RPC. /// </summary> /// <param name="coinParameters"> /// The expected header parameters of the key. If you don't care, provide null. /// </param> /// <param name="encoded"> /// The base58 encoded string. /// </param> public BitcoinPrivateKey(CoinParameters coinParameters, string encoded) { var decoded = Base58Encoding.DecodeWithCheckSum(encoded); var version = decoded.First(); Thrower.Condition <ArgumentException>(coinParameters.PrivateKeyVersion != version, string.Format("Mismatched version number, trying to cross networks? expected={0} found={1}", coinParameters.PrivateKeyVersion, version)); var bytes = decoded.Skip(1).ToArray(); this.Compressed = false; if (bytes.Length == 33) { // private key associated with a compressed public key Thrower.Condition <ArgumentException>(bytes.Last() != CompressedBytes.First(), string.Format("Invalid private key")); bytes = bytes.Take(32).ToArray(); this.Compressed = true; } // 256 bit keys Thrower.Condition <ArgumentException>(bytes.Length != Length, string.Format("Keys are 256 bits, so you must provide {0} bytes, got {1}", Length, bytes.Length)); this.Bytes = bytes; }
/// <inheritdoc/> public T Put(string key, T value) { if (key == null || IsNull(value)) { Thrower.ThrowArgumentNullException(key == null ? ExceptionArgument.key : ExceptionArgument.value); } lock (mutex_) { long now = Clock.NanoTime; CacheEntry <T> entry = cache_provider_.Get <CacheEntry <T> >(CacheKey(key)); if (entry != null) { // TODO(neylor.silva): notify the caller about the item removal // REPLACED. } else { // create a new entry entry = new CacheEntry <T>(key); } // add the clobber/new entry entry to cache. SetValue(entry, key, value, now); } return(value); }
public override void launch() { this.transform.localRotation = Quaternion.Euler(0, 0, 35); this.transform.localScale = new Vector2(.25f, .25f); BoxCollider2D bc = GetComponent <BoxCollider2D> (); bc.offset = new Vector2(-0.45f, -0.625f); bc.size = Vector2.one * 0.25f; GameObject player_trail = AddTrailToObject(Thrower.transform, this.transform.localPosition); playerrope = player_trail.GetComponent <ParticleSystem> (); Thrower.GetComponent <PlayerController> ().trailingRope = playerrope; emissionDistance = 1f / playerrope.emission.rate.constant; GameObject throwable_trail = AddTrailToObject(this.transform, Vector3.zero); throwablerope = throwable_trail.GetComponent <ParticleSystem> (); if (Letter == "G") { //change rope color Material m = Resources.Load <Material>("Materials/Graphic/GrappleRope"); playerrope.GetComponent <ParticleSystemRenderer> ().sharedMaterial = m; throwablerope.GetComponent <ParticleSystemRenderer>().sharedMaterial = m; } base.launch(); }
/// <inheritdoc/> public bool GetIfPresent(string key, out T value) { if (key == null) { Thrower.ThrowArgumentNullException(ExceptionArgument.key); } // TODO(neylor.silva) check if the cache is empty. long now = Clock.NanoTime; CacheEntry <T> entry = GetLiveEntry(key, now); if (entry != null) { value = entry.ValueReference.Value; if (!IsNull(value)) { // TODO(neylor.silva): record the cache hit. RecordRead(entry, now); value = ScheduleRefresh(entry, key, value, now, default_cache_loader_); return(true); } } else { // TODO(neylor.silva): record the cache misses } value = default(T); return(false); }
/* * Modbus is Big Endian * Opto22 float is Big Endian * 6 Holding 1234 * 6 Holding 3412 */ private ushort[] FloatToByteArray(float value, int byteOrder) { byte[] bytes = null; switch (byteOrder) { case 0: //1234 opto22 bytes = BitConverter.GetBytes(value); if (BitConverter.IsLittleEndian) { Array.Reverse(bytes); } return(new ushort[] { (ushort)((bytes[0] << 8 | bytes[1]) & 0xFFFF), (ushort)((bytes[2] << 8 | bytes[3]) & 0xFFFF), }); case 1: //3412 selec bytes = BitConverter.GetBytes(value); if (BitConverter.IsLittleEndian) { Array.Reverse(bytes); } return(new ushort[] { (ushort)((bytes[2] << 8 | bytes[3]) & 0xFFFF), (ushort)((bytes[0] << 8 | bytes[1]) & 0xFFFF), }); } throw Thrower.Make("Invalid byte order {0}", byteOrder); }
public void ShouldAbortTransactionIfExceptionThrown() { Thrower instance = new Thrower() { ShouldThrowException = true }; TransactionStatus status = TransactionStatus.InDoubt; instance.Completed = (obj, e) => { status = e.Transaction.TransactionInformation.Status; }; IInvocation invocation = Substitute.For<IInvocation>(); invocation.Request.Target.Returns(instance); MethodInfo method = typeof(Thrower).GetMethod("DoSomething"); invocation.Request.Method.Returns(method); invocation.When(i => i.Proceed()).Do(i => instance.DoSomething()); try { TransactionInterceptor interceptor = new TransactionInterceptor(); interceptor.Intercept(invocation); Assert.Fail("An exception should have been thrown."); } catch (Exception) { Assert.AreEqual(TransactionStatus.Aborted, status, "The transaction was not abandoned."); } }
public void FixedUpdate() { if (IsLaunched) { float angle = Vector3.Angle(Vector3.up, rigid.velocity); angle *= Mathf.Sign(Vector3.Cross(Vector3.up, rigid.velocity).z); float modifier = Mathf.Abs(rigid.velocity.x) < 0.1f ? 1 : Mathf.Sign(rigid.velocity.x); float vectorAngle = GameManager.vectorToAngle(new Vector2(rigid.velocity.x, -rigid.velocity.y)) - 90; throwablerope.startRotation = vectorAngle * Mathf.Deg2Rad; this.transform.localRotation = Quaternion.Euler(0, 0, angle + 35 * modifier); Vector2 pos_change = playerrope.transform.localPosition; playerrope.startRotation = (GameManager.vectorToAngle(new Vector2(Thrower.getVelocity().x, -Thrower.getVelocity().y)) - 90) * Mathf.Deg2Rad; if (linkingRope == null && Vector3.Distance(Thrower.transform.position, launchPosition) > emissionDistance) { linkingRope = Instantiate(ropeSegment_prefab); linkingRope.name = "Linking Rope"; linkingRope.transform.position = launchPosition; linkingRope.transform.localRotation = Quaternion.Euler(0, 0, Vector3.Angle(rigid.velocity, Thrower.getVelocity()) / 2f); } } }
/// <summary> /// Create the signing bag with matching scripts and private keys /// Then sign the inputs. /// </summary> public Transaction Sign(CoinParameters parameters, SignRawTransaction rawTransactions) { var transaction = this.Serializer.FromHex(rawTransactions.RawTransactionHex); var bag = new TransactionSigner.SignerBag { Items = new List <TransactionSigner.RedeemScript>() }; var keys = rawTransactions.PrivateKeys.Select(s => new BitcoinPrivateKey(parameters, s)).ToList(); // create a linked object between the pub key hash and its outpoint var inputs = rawTransactions.Inputs .Select(input => new { Input = input, PubKeyHash = new Script.Script(CryptoUtil.ConvertHex(input.ScriptPubKey)).TryGetPubKeyHash() }) .Where(p => p.PubKeyHash.IsNotNull()).ToList(); // compare private keys with redeem script pub key hash and add to the bag foreach (var key in keys) { // there should be at least one redeem script per private key var inserts = inputs.Where(f => f.PubKeyHash.SequenceEqual(key.Hash160)).ToList(); Thrower.If(inserts.None()).Throw <TransactionException>("Private key had no matching redeem script '{0}'".StringFormat(key.PublicKey.ToAddress(parameters).ToString())); inserts.ForEach(insert => bag.Add(insert.Input.TransactionId, insert.Input.Output, insert.Input.ScriptPubKey, key)); } this.Signer.SignInputs(transaction, bag); return(transaction); }
public Sack(Thrower thrower, BaseDefender defender, int yards, bool fumble) { fumbles = fumble ? 1 : 0; this.yards = yards; sacker = defender; quarterBack = thrower; }
/// <summary> /// Called when the throwable hits a block or entity. /// </summary> protected override void OnImpact(MovingObjectPosition par1MovingObjectPosition) { if (par1MovingObjectPosition.EntityHit != null) { if (!par1MovingObjectPosition.EntityHit.AttackEntityFrom(DamageSource.CauseThrownDamage(this, Thrower), 0)) { ; } } for (int i = 0; i < 32; i++) { WorldObj.SpawnParticle("portal", PosX, PosY + Rand.NextFloat() * 2, PosZ, Rand.NextGaussian(), 0.0F, Rand.NextGaussian()); } if (!WorldObj.IsRemote) { if (Thrower != null) { Thrower.SetPositionAndUpdate(PosX, PosY, PosZ); Thrower.FallDistance = 0.0F; Thrower.AttackEntityFrom(DamageSource.Fall, 5); } SetDead(); } }
public void ShouldAbortTransactionIfExceptionThrown() { Thrower instance = new Thrower() { ShouldThrowException = true }; TransactionStatus status = TransactionStatus.InDoubt; instance.Completed = (obj, e) => { status = e.Transaction.TransactionInformation.Status; }; IInvocation invocation = Substitute.For <IInvocation>(); invocation.Request.Target.Returns(instance); MethodInfo method = typeof(Thrower).GetMethod("DoSomething"); invocation.Request.Method.Returns(method); invocation.When(i => i.Proceed()).Do(i => instance.DoSomething()); try { TransactionInterceptor interceptor = new TransactionInterceptor(); interceptor.Intercept(invocation); Assert.Fail("An exception should have been thrown."); } catch (Exception) { Assert.AreEqual(TransactionStatus.Aborted, status, "The transaction was not abandoned."); } }
/* * Modbus is Big Endian * Opto22 float is Big Endian * 3 Holding 1234 * 3 Holding 3412 * 4 Input 1234 * 4 Input 3412 */ private float ByteArrayToFloat(ushort[] value, int byteOrder) { byte[] bytes = null; switch (byteOrder) { case 0: //1234 opto22 bytes = new byte[] { (byte)((value[0] >> 8) & 0xff), (byte)((value[0] >> 0) & 0xff), (byte)((value[1] >> 8) & 0xff), (byte)((value[1] >> 0) & 0xff), }; if (BitConverter.IsLittleEndian) { Array.Reverse(bytes); } return(BitConverter.ToSingle(bytes, 0)); case 1: //3412 selec bytes = new byte[] { (byte)((value[1] >> 8) & 0xff), (byte)((value[1] >> 0) & 0xff), (byte)((value[0] >> 8) & 0xff), (byte)((value[0] >> 0) & 0xff), }; if (BitConverter.IsLittleEndian) { Array.Reverse(bytes); } return(BitConverter.ToSingle(bytes, 0)); } throw Thrower.Make("Invalid byte order {0}", byteOrder); }
public void ShouldCommitTransactionIfExceptionNotThrown() { Thrower instance = new Thrower() { ShouldThrowException = false }; TransactionStatus status = TransactionStatus.InDoubt; instance.Completed = (obj, e) => { status = e.Transaction.TransactionInformation.Status; }; IInvocation invocation = Substitute.For <IInvocation>(); invocation.Request.Target.Returns(instance); MethodInfo method = typeof(Thrower).GetMethod("DoSomething"); invocation.Request.Method.Returns(method); invocation.When(i => i.Proceed()).Do(i => instance.DoSomething()); TransactionInterceptor interceptor = new TransactionInterceptor(); interceptor.Intercept(invocation); Assert.AreEqual(TransactionStatus.Committed, status, "The transaction was not committed."); }
public Sack(Thrower thrower, BaseDefender defender, int yards, int fumbles) { this.fumbles = fumbles; this.yards = yards; sacker = defender; quarterBack = thrower; }
public override void Run(string[] args) { Dictionary <string, string> properties = CreateTestProperties(ref args); properties["Ice.Warn.Dispatch"] = "0"; properties["Ice.Warn.Connections"] = "0"; properties["Ice.MessageSizeMax"] = "10"; // 10KB max using Communicator communicator = Initialize(properties); communicator.SetProperty("TestAdapter.Endpoints", GetTestEndpoint(0)); communicator.SetProperty("TestAdapter2.Endpoints", GetTestEndpoint(1)); communicator.SetProperty("TestAdapter2.MessageSizeMax", "0"); communicator.SetProperty("TestAdapter3.Endpoints", GetTestEndpoint(2)); communicator.SetProperty("TestAdapter3.MessageSizeMax", "1"); ObjectAdapter adapter = communicator.CreateObjectAdapter("TestAdapter"); ObjectAdapter adapter2 = communicator.CreateObjectAdapter("TestAdapter2"); ObjectAdapter adapter3 = communicator.CreateObjectAdapter("TestAdapter3"); var obj = new Thrower(); adapter.Add("thrower", obj); adapter2.Add("thrower", obj); adapter3.Add("thrower", obj); adapter.Activate(); adapter2.Activate(); adapter3.Activate(); ServerReady(); communicator.WaitForShutdown(); }
private void Throw(object[] data) { int throwerViewID = (int)data[0]; Vector3 direction = (Vector3)data[1]; int timeDiff = (int)data[2]; PlayerController thrower = NetworkingService.Instance.Find(throwerViewID).GetComponent <PlayerController>(); // Exit if thrower can't be found if (thrower == null) { Debug.Log("Can't find thrower with id " + throwerViewID); return; } this.direction = direction; movementSpeedCurrent = movementSpeed; Thrower = thrower; Thrower.ThrowBallLocal(BallType); // Account for timediff between clients speedPerTick = movementSpeedCurrent / 3.6f * Time.fixedDeltaTime; int ticks = timeDiff / Mathf.RoundToInt(Time.fixedDeltaTime * 1000); for (int i = 0; i < ticks; i++) { UpdatePos(); } }
/// <summary> /// 解压数组。解压的结果保存在流中。 /// </summary> /// <param name="b">字节。</param> /// <param name="compressor">用来解压的流。</param> public static void CompressBuffer(byte[] b, Stream compressor) { Thrower.ThrowArgumentNullExceptionIf(compressor, "compressor"); using (compressor) { compressor.Write(b, 0, b.Length); } }
private Control CreateControl(string name, SerializableMap settings) { var context = new ControlContext { ioRunner = ior, uiRunner = uir }; switch (name) { case "WritePointControl": return(new WritePointControl(context, settings)); case "ReadPointControl": return(new ReadPointControl(context, settings)); case "ReadRegisterControl": return(new ReadRegisterControl(context, settings)); case "WriteRegisterControl": return(new WriteRegisterControl(context, settings)); case "ReadFloatControl": return(new ReadFloatControl(context, settings)); case "WriteFloatControl": return(new WriteFloatControl(context, settings)); } Thrower.Throw("Unknown control name {0}", name); return(null); }
public static IModbusCommand Parse(byte[] request, int offset) { var slave = request[offset + 0]; var code = request[offset + 1]; var address = ModbusHelper.GetUShort(request, offset + 2); switch (code) { case 1: return(Parse01(slave, code, address, request, offset)); case 2: return(Parse02(slave, code, address, request, offset)); case 3: return(Parse03(slave, code, address, request, offset)); case 4: return(Parse04(slave, code, address, request, offset)); case 5: return(Parse05(slave, code, address, request, offset)); case 6: return(Parse06(slave, code, address, request, offset)); case 15: return(Parse15(slave, code, address, request, offset)); case 16: return(Parse16(slave, code, address, request, offset)); } throw Thrower.Make("Unsupported function code {0}", code); }
void ICollection.CopyTo(Array array, int index) { if (array == null) { Thrower.ThrowArgumentNullException(ExceptionArgument.array); } int length = array.Length; if ((index < 0) || (index > length)) { Thrower.ThrowArgumentOutOfRangeException(ExceptionArgument.arrayIndex, ExceptionResource.ArgumentOutOfRange_Index); } int num2 = (length - index); if (num2 < _size) { Thrower.ThrowArgumentException(ExceptionResource.Argument_InvalidOfLen); } // If the head is above tha tail we need to do two copies. The first copy will get // the elements between the head and the end of the queue and the second copy will get // the elements between the top of the queue and the tail. if (_tail < _head) { int num3 = _array.Length - _head; Array.Copy(_array, _head, array, index, num3); Array.Copy(_array, 0, array, index + num3, _tail); } else { Array.Copy(_array, _head, array, index, _head - _tail); } }
/// <summary> /// 添加命名参数。 /// </summary> /// <param name="d">参数键/值的集合。</param> /// <exception cref="ArgumentNullException"><paramref name="d" /> 为空。</exception> public override void AddParameters(System.Collections.IDictionary d) { Thrower.ThrowArgumentNullExceptionIf(d, "d"); foreach (string v in d) { _command.Parameters.AddWithValue(v, d[v]); } }
//instance // Start is called before the first frame update void Start() { instance = this; //ideally, would take a GameObject of type ObjectsHolder; //that would contain an array or list of GameObjects; //numObjectsToThrow would = the length of that array or list numObjectsToThrow = numObjectsToThrowInt; }
/// <summary> /// 初始化 deflation 状态。 /// </summary> /// <param name="wantRfc1950Header">是否使用 Rfc1950 文件头。</param> /// <returns>如果正常返回 ZlibState.Success 。</returns> private ZlibState InitializeDeflateInternal(bool wantRfc1950Header) { Thrower.ThrowZlibExceptionIf(IState != null, "在 InitializeInflate() 后不能调用 InitializeDeflate() 。"); DState = new DeflateManager(); DState.WantRfc1950HeaderBytes = wantRfc1950Header; return(DState.Initialize(this, CompressLevel, WindowBits, Strategy)); }
internal CaseOutput(bool possible) { if (possible) { Thrower.TriggerMemLimit(); } IsPossible = possible; }
/// <summary> /// 停止处理。 /// </summary> /// <returns>如果正常返回 ZlibState.Success 。</returns> public ZlibState EndInflate() { Thrower.ThrowZlibExceptionIf(IState == null, "没有初始化 Inflate 状态。"); ZlibState ret = IState.End(); IState = null; return(ret); }
/// <summary> /// 解压字符串。解压的结果保存在流中。 /// </summary> /// <param name="value">字符串。</param> /// <param name="compressor">用来解压的流。</param> public static void CompressString(string value, Stream compressor) { Thrower.ThrowArgumentNullExceptionIf(compressor, "compressor"); byte[] uncompressed = System.Text.Encoding.UTF8.GetBytes(value); using (compressor) { compressor.Write(uncompressed, 0, uncompressed.Length); } }
public void ShouldCommitTransactionIfExceptionNotThrown() { Thrower instance = new Thrower() { ShouldThrowException = false }; TransactionStatus status = TransactionStatus.InDoubt; instance.Completed = (obj, e) => { status = e.Transaction.TransactionInformation.Status; }; IInvocation invocation = Substitute.For<IInvocation>(); invocation.Request.Target.Returns(instance); MethodInfo method = typeof(Thrower).GetMethod("DoSomething"); invocation.Request.Method.Returns(method); invocation.When(i => i.Proceed()).Do(i => instance.DoSomething()); TransactionInterceptor interceptor = new TransactionInterceptor(); interceptor.Intercept(invocation); Assert.AreEqual(TransactionStatus.Committed, status, "The transaction was not committed."); }
public static void allTests(Ice.Communicator communicator) { string sref = "test:default -p 12010"; Ice.ObjectPrx obj = communicator.stringToProxy(sref); test(obj != null); Test.TestIntfPrx p = Test.TestIntfPrxHelper.uncheckedCast(obj); sref = "testController:tcp -p 12011"; obj = communicator.stringToProxy(sref); test(obj != null); Test.TestIntfControllerPrx testController = Test.TestIntfControllerPrxHelper.uncheckedCast(obj); Console.Out.Write("testing begin/end invocation... "); Console.Out.Flush(); { Ice.AsyncResult result; Dictionary<string, string> ctx = new Dictionary<string, string>(); result = p.begin_ice_isA("::Test::TestIntf"); test(p.end_ice_isA(result)); result = p.begin_ice_isA("::Test::TestIntf", ctx); test(p.end_ice_isA(result)); result = p.begin_ice_ping(); p.end_ice_ping(result); result = p.begin_ice_ping(ctx); p.end_ice_ping(result); result = p.begin_ice_id(); test(p.end_ice_id(result).Equals("::Test::TestIntf")); result = p.begin_ice_id(ctx); test(p.end_ice_id(result).Equals("::Test::TestIntf")); result = p.begin_ice_ids(); test(p.end_ice_ids(result).Length == 2); result = p.begin_ice_ids(ctx); test(p.end_ice_ids(result).Length == 2); result = p.begin_op(); p.end_op(result); result = p.begin_op(ctx); p.end_op(result); result = p.begin_opWithResult(); test(p.end_opWithResult(result) == 15); result = p.begin_opWithResult(ctx); test(p.end_opWithResult(result) == 15); result = p.begin_opWithUE(); try { p.end_opWithUE(result); test(false); } catch(Test.TestIntfException) { } result = p.begin_opWithUE(ctx); try { p.end_opWithUE(result); test(false); } catch(Test.TestIntfException) { } } Console.Out.WriteLine("ok"); Console.Out.Write("testing async callback... "); Console.Out.Flush(); { AsyncCallback cb = new AsyncCallback(); Dictionary<string, string> ctx = new Dictionary<string, string>(); Cookie cookie = new Cookie(5); AsyncCallback cbWC = new AsyncCallback(cookie); p.begin_ice_isA("::Test::TestIntf", cb.isA, null); cb.check(); p.begin_ice_isA("::Test::TestIntf", cbWC.isA, cookie); cbWC.check(); p.begin_ice_isA("::Test::TestIntf", ctx, cb.isA, null); cb.check(); p.begin_ice_isA("::Test::TestIntf", ctx, cbWC.isA, cookie); cbWC.check(); p.begin_ice_ping(cb.ping, null); cb.check(); p.begin_ice_ping(cbWC.ping, cookie); cbWC.check(); p.begin_ice_ping(ctx, cb.ping, null); cb.check(); p.begin_ice_ping(ctx, cbWC.ping, cookie); cbWC.check(); p.begin_ice_id(cb.id, null); cb.check(); p.begin_ice_id(cbWC.id, cookie); cbWC.check(); p.begin_ice_id(ctx, cb.id, null); cb.check(); p.begin_ice_id(ctx, cbWC.id, cookie); cbWC.check(); p.begin_ice_ids(cb.ids, null); cb.check(); p.begin_ice_ids(cbWC.ids, cookie); cbWC.check(); p.begin_ice_ids(ctx, cb.ids, null); cb.check(); p.begin_ice_ids(ctx, cbWC.ids, cookie); cbWC.check(); p.begin_op(cb.op, null); cb.check(); p.begin_op(cbWC.op, cookie); cbWC.check(); p.begin_op(ctx, cb.op, null); cb.check(); p.begin_op(ctx, cbWC.op, cookie); cbWC.check(); p.begin_opWithResult(cb.opWithResult, null); cb.check(); p.begin_opWithResult(cbWC.opWithResult, cookie); cbWC.check(); p.begin_opWithResult(ctx, cb.opWithResult, null); cb.check(); p.begin_opWithResult(ctx, cbWC.opWithResult, cookie); cbWC.check(); p.begin_opWithUE(cb.opWithUE, null); cb.check(); p.begin_opWithUE(cbWC.opWithUE, cookie); cbWC.check(); p.begin_opWithUE(ctx, cb.opWithUE, null); cb.check(); p.begin_opWithUE(ctx, cbWC.opWithUE, cookie); cbWC.check(); } Console.Out.WriteLine("ok"); Console.Out.Write("testing response callback... "); Console.Out.Flush(); { ResponseCallback cb = new ResponseCallback(); Dictionary<string, string> ctx = new Dictionary<string, string>(); p.begin_ice_isA("::Test::TestIntf").whenCompleted(cb.isA, null); cb.check(); p.begin_ice_isA("::Test::TestIntf", ctx).whenCompleted(cb.isA, null); cb.check(); p.begin_ice_ping().whenCompleted(cb.ping, null); cb.check(); p.begin_ice_ping(ctx).whenCompleted(cb.ping, null); cb.check(); p.begin_ice_id().whenCompleted(cb.id, null); cb.check(); p.begin_ice_id(ctx).whenCompleted(cb.id, null); cb.check(); p.begin_ice_ids().whenCompleted(cb.ids, null); cb.check(); p.begin_ice_ids(ctx).whenCompleted(cb.ids, null); cb.check(); p.begin_op().whenCompleted(cb.op, null); cb.check(); p.begin_op(ctx).whenCompleted(cb.op, null); cb.check(); p.begin_opWithResult().whenCompleted(cb.opWithResult, null); cb.check(); p.begin_opWithResult(ctx).whenCompleted(cb.opWithResult, null); cb.check(); p.begin_opWithUE().whenCompleted(cb.op, cb.opWithUE); cb.check(); p.begin_opWithUE(ctx).whenCompleted(cb.op, cb.opWithUE); cb.check(); } Console.Out.WriteLine("ok"); Console.Out.Write("testing local exceptions... "); Console.Out.Flush(); { Test.TestIntfPrx indirect = Test.TestIntfPrxHelper.uncheckedCast(p.ice_adapterId("dummy")); Ice.AsyncResult r; r = indirect.begin_op(); try { indirect.end_op(r); test(false); } catch(Ice.NoEndpointException) { } try { r = ((Test.TestIntfPrx)p.ice_oneway()).begin_opWithResult(); test(false); } catch(System.ArgumentException) { } // // Check that CommunicatorDestroyedException is raised directly. // Ice.InitializationData initData = new Ice.InitializationData(); initData.properties = communicator.getProperties().ice_clone_(); Ice.Communicator ic = Ice.Util.initialize(initData); Ice.ObjectPrx o = ic.stringToProxy(p.ToString()); Test.TestIntfPrx p2 = Test.TestIntfPrxHelper.checkedCast(o); ic.destroy(); try { p2.begin_op(); test(false); } catch(Ice.CommunicatorDestroyedException) { // Expected. } } Console.Out.WriteLine("ok"); Console.Out.Write("testing local exceptions with async callback... "); Console.Out.Flush(); { Test.TestIntfPrx i = Test.TestIntfPrxHelper.uncheckedCast(p.ice_adapterId("dummy")); AsyncCallback cb = new AsyncCallback(); Cookie cookie = new Cookie(5); AsyncCallback cbWC = new AsyncCallback(cookie); i.begin_ice_isA("::Test::TestIntf", cb.isAEx, null); cb.check(); i.begin_ice_isA("::Test::TestIntf", cbWC.isAEx, cookie); cbWC.check(); i.begin_ice_ping(cb.pingEx, null); cb.check(); i.begin_ice_ping(cbWC.pingEx, cookie); cbWC.check(); i.begin_ice_id(cb.idEx, null); cb.check(); i.begin_ice_id(cbWC.idEx, cookie); cbWC.check(); i.begin_ice_ids(cb.idsEx, null); cb.check(); i.begin_ice_ids(cbWC.idsEx, cookie); cbWC.check(); i.begin_op(cb.opEx, null); cb.check(); i.begin_op(cbWC.opEx, cookie); cbWC.check(); } Console.Out.WriteLine("ok"); Console.Out.Write("testing local exceptions with response callback... "); Console.Out.Flush(); { Test.TestIntfPrx i = Test.TestIntfPrxHelper.uncheckedCast(p.ice_adapterId("dummy")); ExceptionCallback cb = new ExceptionCallback(); i.begin_ice_isA("::Test::TestIntf").whenCompleted(cb.isA, cb.ex); cb.check(); i.begin_ice_ping().whenCompleted(cb.ping, cb.ex); cb.check(); i.begin_ice_id().whenCompleted(cb.id, cb.ex); cb.check(); i.begin_ice_ids().whenCompleted(cb.ids, cb.ex); cb.check(); i.begin_op().whenCompleted(cb.op, cb.ex); cb.check(); } Console.Out.WriteLine("ok"); Console.Out.Write("testing exception callback... "); Console.Out.Flush(); { Test.TestIntfPrx i = Test.TestIntfPrxHelper.uncheckedCast(p.ice_adapterId("dummy")); ExceptionCallback cb = new ExceptionCallback(); i.begin_ice_isA("::Test::TestIntf").whenCompleted(cb.ex); cb.check(); i.begin_op().whenCompleted(cb.ex); cb.check(); i.begin_opWithResult().whenCompleted(cb.ex); cb.check(); i.begin_opWithUE().whenCompleted(cb.ex); cb.check(); // Ensures no exception is called when response is received p.begin_ice_isA("::Test::TestIntf").whenCompleted(cb.noEx); p.begin_op().whenCompleted(cb.noEx); p.begin_opWithResult().whenCompleted(cb.noEx); // If response is a user exception, it should be received. p.begin_opWithUE().whenCompleted(cb.opWithUE); cb.check(); } Console.Out.WriteLine("ok"); Console.Out.Write("testing sent callback... "); Console.Out.Flush(); { SentCallback cb = new SentCallback(); p.begin_ice_isA("").whenCompleted(cb.isA, cb.ex).whenSent(cb.sent); cb.check(); p.begin_ice_ping().whenCompleted(cb.ping, cb.ex).whenSent(cb.sent); cb.check(); p.begin_ice_id().whenCompleted(cb.id, cb.ex).whenSent(cb.sent); cb.check(); p.begin_ice_ids().whenCompleted(cb.ids, cb.ex).whenSent(cb.sent); cb.check(); p.begin_op().whenCompleted(cb.op, cb.ex).whenSent(cb.sent); cb.check(); p.begin_op(cb.opAsync, null).whenSent((Ice.AsyncCallback)cb.sentAsync); cb.check(); p.begin_op().whenCompleted(cb.ex).whenSent(cb.sent); cb.check(); List<SentCallback> cbs = new List<SentCallback>(); byte[] seq = new byte[10024]; (new System.Random()).NextBytes(seq); testController.holdAdapter(); try { Ice.AsyncResult r; do { SentCallback cb2 = new SentCallback(); r = p.begin_opWithPayload(seq).whenCompleted(cb2.ex).whenSent(cb2.sent); cbs.Add(cb2); } while(r.sentSynchronously()); } finally { testController.resumeAdapter(); } foreach(SentCallback cb3 in cbs) { cb3.check(); } } Console.Out.WriteLine("ok"); Console.Out.Write("testing illegal arguments... "); Console.Out.Flush(); { Ice.AsyncResult result; result = p.begin_op(); p.end_op(result); try { p.end_op(result); test(false); } catch(System.ArgumentException) { } result = p.begin_op(); try { p.end_opWithResult(result); test(false); } catch(System.ArgumentException) { } try { p.end_op(null); test(false); } catch(System.ArgumentException) { } } Console.Out.WriteLine("ok"); Console.Out.Write("testing unexpected exceptions from callback... "); Console.Out.Flush(); { Test.TestIntfPrx q = Test.TestIntfPrxHelper.uncheckedCast(p.ice_adapterId("dummy")); ThrowType[] throwEx = new ThrowType[]{ ThrowType.LocalException, ThrowType.UserException, ThrowType.OtherException }; for(int i = 0; i < 3; ++i) { Thrower cb = new Thrower(throwEx[i]); p.begin_op(cb.opAsync, null); cb.check(); p.begin_op().whenCompleted(cb.op, null); cb.check(); q.begin_op().whenCompleted(cb.op, cb.ex); cb.check(); p.begin_op().whenCompleted(cb.noOp, cb.ex).whenSent(cb.sent); cb.check(); q.begin_op().whenCompleted(cb.ex); cb.check(); } } Console.Out.WriteLine("ok"); Console.Out.Write("testing batch requests with proxy... "); Console.Out.Flush(); { Cookie cookie = new Cookie(5); { // // AsyncResult. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); b1.opBatch(); FlushCallback cb = new FlushCallback(cookie); Ice.AsyncResult r = b1.begin_ice_flushBatchRequests(cb.completedAsync, cookie); r.whenSent((Ice.AsyncCallback)cb.sentAsync); cb.check(); test(r.isSent()); test(r.IsCompleted); test(p.waitForBatch(2)); } { // // AsyncResult exception. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); b1.ice_getConnection().close(false); FlushExCallback cb = new FlushExCallback(cookie); Ice.AsyncResult r = b1.begin_ice_flushBatchRequests(cb.completedAsync, cookie); r.whenSent((Ice.AsyncCallback)cb.sentAsync); cb.check(); test(!r.isSent()); test(r.IsCompleted); test(p.opBatchCount() == 0); } { // // Type-safe. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); b1.opBatch(); FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = b1.begin_ice_flushBatchRequests(); r.whenCompleted(cb.exception); r.whenSent((Ice.SentCallback)cb.sent); cb.check(); test(r.isSent()); test(r.IsCompleted); test(p.waitForBatch(2)); } { // // Type-safe exception. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); b1.ice_getConnection().close(false); FlushExCallback cb = new FlushExCallback(); Ice.AsyncResult r = b1.begin_ice_flushBatchRequests(); r.whenCompleted(cb.exception); r.whenSent((Ice.SentCallback)cb.sent); cb.check(); test(!r.isSent()); test(r.IsCompleted); test(p.opBatchCount() == 0); } } Console.Out.WriteLine("ok"); Console.Out.Write("testing batch requests with connection... "); Console.Out.Flush(); { Cookie cookie = new Cookie(5); { // // AsyncResult. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); b1.opBatch(); FlushCallback cb = new FlushCallback(cookie); Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests(cb.completedAsync, cookie); r.whenSent((Ice.AsyncCallback)cb.sentAsync); cb.check(); test(r.isSent()); test(r.IsCompleted); test(p.waitForBatch(2)); } { // // AsyncResult exception. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); b1.ice_getConnection().close(false); FlushExCallback cb = new FlushExCallback(cookie); Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests(cb.completedAsync, cookie); r.whenSent((Ice.AsyncCallback)cb.sentAsync); cb.check(); test(!r.isSent()); test(r.IsCompleted); test(p.opBatchCount() == 0); } { // // Type-safe. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); b1.opBatch(); FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests(); r.whenCompleted(cb.exception); r.whenSent((Ice.SentCallback)cb.sent); cb.check(); test(r.isSent()); test(r.IsCompleted); test(p.waitForBatch(2)); } { // // Type-safe exception. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); b1.ice_getConnection().close(false); FlushExCallback cb = new FlushExCallback(); Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests(); r.whenCompleted(cb.exception); r.whenSent((Ice.SentCallback)cb.sent); cb.check(); test(!r.isSent()); test(r.IsCompleted); test(p.opBatchCount() == 0); } } Console.Out.WriteLine("ok"); Console.Out.Write("testing batch requests with communicator... "); Console.Out.Flush(); { Cookie cookie = new Cookie(5); { // // AsyncResult - 1 connection. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); b1.opBatch(); FlushCallback cb = new FlushCallback(cookie); Ice.AsyncResult r = communicator.begin_flushBatchRequests(cb.completedAsync, cookie); r.whenSent((Ice.AsyncCallback)cb.sentAsync); cb.check(); test(r.isSent()); test(r.IsCompleted); test(p.waitForBatch(2)); } { // // AsyncResult exception - 1 connection. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); b1.ice_getConnection().close(false); FlushCallback cb = new FlushCallback(cookie); Ice.AsyncResult r = communicator.begin_flushBatchRequests(cb.completedAsync, cookie); r.whenSent((Ice.AsyncCallback)cb.sentAsync); cb.check(); test(r.isSent()); // Exceptions are ignored! test(r.IsCompleted); test(p.opBatchCount() == 0); } { // // AsyncResult - 2 connections. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway(); b2.ice_getConnection(); // Ensure connection is established. b1.opBatch(); b1.opBatch(); b2.opBatch(); b2.opBatch(); FlushCallback cb = new FlushCallback(cookie); Ice.AsyncResult r = communicator.begin_flushBatchRequests(cb.completedAsync, cookie); r.whenSent((Ice.AsyncCallback)cb.sentAsync); cb.check(); test(r.isSent()); test(r.IsCompleted); test(p.waitForBatch(4)); } { // // AsyncResult exception - 2 connections - 1 failure. // // All connections should be flushed even if there are failures on some connections. // Exceptions should not be reported. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway(); b2.ice_getConnection(); // Ensure connection is established. b1.opBatch(); b2.opBatch(); b1.ice_getConnection().close(false); FlushCallback cb = new FlushCallback(cookie); Ice.AsyncResult r = communicator.begin_flushBatchRequests(cb.completedAsync, cookie); r.whenSent((Ice.AsyncCallback)cb.sentAsync); cb.check(); test(r.isSent()); // Exceptions are ignored! test(r.IsCompleted); test(p.waitForBatch(1)); } { // // AsyncResult exception - 2 connections - 2 failures. // // The sent callback should be invoked even if all connections fail. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway(); b2.ice_getConnection(); // Ensure connection is established. b1.opBatch(); b2.opBatch(); b1.ice_getConnection().close(false); b2.ice_getConnection().close(false); FlushCallback cb = new FlushCallback(cookie); Ice.AsyncResult r = communicator.begin_flushBatchRequests(cb.completedAsync, cookie); r.whenSent((Ice.AsyncCallback)cb.sentAsync); cb.check(); test(r.isSent()); // Exceptions are ignored! test(r.IsCompleted); test(p.opBatchCount() == 0); } { // // Type-safe - 1 connection. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); b1.opBatch(); FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = communicator.begin_flushBatchRequests(); r.whenCompleted(cb.exception); r.whenSent((Ice.SentCallback)cb.sent); cb.check(); test(r.isSent()); test(r.IsCompleted); test(p.waitForBatch(2)); } { // // Type-safe exception - 1 connection. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); b1.ice_getConnection().close(false); FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = communicator.begin_flushBatchRequests(); r.whenCompleted(cb.exception); r.whenSent((Ice.SentCallback)cb.sent); cb.check(); test(r.isSent()); // Exceptions are ignored! test(r.IsCompleted); test(p.opBatchCount() == 0); } { // // 2 connections. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway(); b2.ice_getConnection(); // Ensure connection is established. b1.opBatch(); b1.opBatch(); b2.opBatch(); b2.opBatch(); FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = communicator.begin_flushBatchRequests(); r.whenCompleted(cb.exception); r.whenSent((Ice.SentCallback)cb.sent); cb.check(); test(r.isSent()); test(r.IsCompleted); test(p.waitForBatch(4)); } { // // Exception - 2 connections - 1 failure. // // All connections should be flushed even if there are failures on some connections. // Exceptions should not be reported. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway(); b2.ice_getConnection(); // Ensure connection is established. b1.opBatch(); b2.opBatch(); b1.ice_getConnection().close(false); FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = communicator.begin_flushBatchRequests(); r.whenCompleted(cb.exception); r.whenSent((Ice.SentCallback)cb.sent); cb.check(); test(r.isSent()); // Exceptions are ignored! test(r.IsCompleted); test(p.waitForBatch(1)); } { // // Exception - 2 connections - 2 failures. // // The sent callback should be invoked even if all connections fail. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway(); b2.ice_getConnection(); // Ensure connection is established. b1.opBatch(); b2.opBatch(); b1.ice_getConnection().close(false); b2.ice_getConnection().close(false); FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = communicator.begin_flushBatchRequests(); r.whenCompleted(cb.exception); r.whenSent((Ice.SentCallback)cb.sent); cb.check(); test(r.isSent()); // Exceptions are ignored! test(r.IsCompleted); test(p.opBatchCount() == 0); } } Console.Out.WriteLine("ok"); Console.Out.Write("testing AsyncResult operations... "); Console.Out.Flush(); { testController.holdAdapter(); Ice.AsyncResult r1; Ice.AsyncResult r2; try { r1 = p.begin_op(); byte[] seq = new byte[10024]; (new System.Random()).NextBytes(seq); while((r2 = p.begin_opWithPayload(seq)).sentSynchronously()); test(r1.sentSynchronously() && r1.isSent() && !r1.isCompleted_() || !r1.sentSynchronously() && !r1.isCompleted_()); test(!r2.sentSynchronously() && !r2.isCompleted_()); test(!r1.IsCompleted && !r1.CompletedSynchronously); test(!r2.IsCompleted && !r2.CompletedSynchronously); } finally { testController.resumeAdapter(); } WaitHandle w1 = r1.AsyncWaitHandle; WaitHandle w2 = r2.AsyncWaitHandle; r1.waitForSent(); test(r1.isSent()); r2.waitForSent(); test(r2.isSent()); r1.waitForCompleted(); test(r1.isCompleted_()); w1.WaitOne(); r2.waitForCompleted(); test(r2.isCompleted_()); w2.WaitOne(); test(r1.getOperation().Equals("op")); test(r2.getOperation().Equals("opWithPayload")); } Console.Out.WriteLine("ok"); p.shutdown(); }
public static void allTests(Ice.Communicator communicator, bool collocated) #endif { #if SILVERLIGHT bool collocated = false; #endif string sref = "test:default -p 12010"; Ice.ObjectPrx obj = communicator.stringToProxy(sref); test(obj != null); Test.TestIntfPrx p = Test.TestIntfPrxHelper.uncheckedCast(obj); sref = "testController:default -p 12011"; obj = communicator.stringToProxy(sref); test(obj != null); Test.TestIntfControllerPrx testController = Test.TestIntfControllerPrxHelper.uncheckedCast(obj); Write("testing begin/end invocation... "); Flush(); { Ice.AsyncResult result; Dictionary<string, string> ctx = new Dictionary<string, string>(); result = p.begin_ice_isA("::Test::TestIntf"); test(p.end_ice_isA(result)); result = p.begin_ice_isA("::Test::TestIntf", ctx); test(p.end_ice_isA(result)); result = p.begin_ice_ping(); p.end_ice_ping(result); result = p.begin_ice_ping(ctx); p.end_ice_ping(result); result = p.begin_ice_id(); test(p.end_ice_id(result).Equals("::Test::TestIntf")); result = p.begin_ice_id(ctx); test(p.end_ice_id(result).Equals("::Test::TestIntf")); result = p.begin_ice_ids(); test(p.end_ice_ids(result).Length == 2); result = p.begin_ice_ids(ctx); test(p.end_ice_ids(result).Length == 2); if(!collocated) { result = p.begin_ice_getConnection(); test(p.end_ice_getConnection(result) != null); } result = p.begin_op(); p.end_op(result); result = p.begin_op(ctx); p.end_op(result); result = p.begin_opWithResult(); test(p.end_opWithResult(result) == 15); result = p.begin_opWithResult(ctx); test(p.end_opWithResult(result) == 15); result = p.begin_opWithUE(); try { p.end_opWithUE(result); test(false); } catch(Test.TestIntfException) { } result = p.begin_opWithUE(ctx); try { p.end_opWithUE(result); test(false); } catch(Test.TestIntfException) { } } WriteLine("ok"); Write("testing async callback... "); Flush(); { AsyncCallback cb = new AsyncCallback(); Dictionary<string, string> ctx = new Dictionary<string, string>(); Cookie cookie = new Cookie(5); AsyncCallback cbWC = new AsyncCallback(cookie); p.begin_ice_isA("::Test::TestIntf", cb.isA, null); cb.check(); p.begin_ice_isA("::Test::TestIntf", cbWC.isA, cookie); cbWC.check(); p.begin_ice_isA("::Test::TestIntf", ctx, cb.isA, null); cb.check(); p.begin_ice_isA("::Test::TestIntf", ctx, cbWC.isA, cookie); cbWC.check(); p.begin_ice_ping(cb.ping, null); cb.check(); p.begin_ice_ping(cbWC.ping, cookie); cbWC.check(); p.begin_ice_ping(ctx, cb.ping, null); cb.check(); p.begin_ice_ping(ctx, cbWC.ping, cookie); cbWC.check(); p.begin_ice_id(cb.id, null); cb.check(); p.begin_ice_id(cbWC.id, cookie); cbWC.check(); p.begin_ice_id(ctx, cb.id, null); cb.check(); p.begin_ice_id(ctx, cbWC.id, cookie); cbWC.check(); p.begin_ice_ids(cb.ids, null); cb.check(); p.begin_ice_ids(cbWC.ids, cookie); cbWC.check(); p.begin_ice_ids(ctx, cb.ids, null); cb.check(); p.begin_ice_ids(ctx, cbWC.ids, cookie); cbWC.check(); if(!collocated) { p.begin_ice_getConnection(cb.connection, null); cb.check(); p.begin_ice_getConnection(cbWC.connection, cookie); cbWC.check(); } p.begin_op(cb.op, null); cb.check(); p.begin_op(cbWC.op, cookie); cbWC.check(); p.begin_op(ctx, cb.op, null); cb.check(); p.begin_op(ctx, cbWC.op, cookie); cbWC.check(); p.begin_opWithResult(cb.opWithResult, null); cb.check(); p.begin_opWithResult(cbWC.opWithResult, cookie); cbWC.check(); p.begin_opWithResult(ctx, cb.opWithResult, null); cb.check(); p.begin_opWithResult(ctx, cbWC.opWithResult, cookie); cbWC.check(); p.begin_opWithUE(cb.opWithUE, null); cb.check(); p.begin_opWithUE(cbWC.opWithUE, cookie); cbWC.check(); p.begin_opWithUE(ctx, cb.opWithUE, null); cb.check(); p.begin_opWithUE(ctx, cbWC.opWithUE, cookie); cbWC.check(); } WriteLine("ok"); Write("testing response callback... "); Flush(); { ResponseCallback cb = new ResponseCallback(); Dictionary<string, string> ctx = new Dictionary<string, string>(); p.begin_ice_isA("::Test::TestIntf").whenCompleted(cb.isA, null); cb.check(); p.begin_ice_isA("::Test::TestIntf", ctx).whenCompleted(cb.isA, null); cb.check(); p.begin_ice_ping().whenCompleted(cb.ping, null); cb.check(); p.begin_ice_ping(ctx).whenCompleted(cb.ping, null); cb.check(); p.begin_ice_id().whenCompleted(cb.id, null); cb.check(); p.begin_ice_id(ctx).whenCompleted(cb.id, null); cb.check(); p.begin_ice_ids().whenCompleted(cb.ids, null); cb.check(); p.begin_ice_ids(ctx).whenCompleted(cb.ids, null); cb.check(); if(!collocated) { p.begin_ice_getConnection().whenCompleted(cb.connection, null); cb.check(); } p.begin_op().whenCompleted(cb.op, null); cb.check(); p.begin_op(ctx).whenCompleted(cb.op, null); cb.check(); p.begin_opWithResult().whenCompleted(cb.opWithResult, null); cb.check(); p.begin_opWithResult(ctx).whenCompleted(cb.opWithResult, null); cb.check(); p.begin_opWithUE().whenCompleted(cb.op, cb.opWithUE); cb.check(); p.begin_opWithUE(ctx).whenCompleted(cb.op, cb.opWithUE); cb.check(); } WriteLine("ok"); Write("testing lambda callback... "); Flush(); { ResponseCallback cb = new ResponseCallback(); Dictionary<string, string> ctx = new Dictionary<string, string>(); p.begin_ice_isA("::Test::TestIntf").whenCompleted( (bool r) => { cb.isA(r); }, null); cb.check(); p.begin_ice_isA("::Test::TestIntf", ctx).whenCompleted( (bool r) => { cb.isA(r); }, null); cb.check(); p.begin_ice_ping().whenCompleted( () => { cb.ping(); }, null); cb.check(); p.begin_ice_ping(ctx).whenCompleted( () => { cb.ping(); }, null); cb.check(); p.begin_ice_id().whenCompleted( (string id) => { cb.id(id); }, null); cb.check(); p.begin_ice_id(ctx).whenCompleted( (string id) => { cb.id(id); }, null); cb.check(); p.begin_ice_ids().whenCompleted( (string[] ids) => { cb.ids(ids); }, null); cb.check(); p.begin_ice_ids(ctx).whenCompleted( (string[] ids) => { cb.ids(ids); }, null); cb.check(); if(!collocated) { p.begin_ice_getConnection().whenCompleted( (Ice.Connection conn) => { cb.connection(conn); }, null); cb.check(); } p.begin_op().whenCompleted( () => { cb.op(); }, null); cb.check(); p.begin_op(ctx).whenCompleted( () => { cb.op(); }, null); cb.check(); p.begin_opWithResult().whenCompleted( (int r) => { cb.opWithResult(r); }, null); cb.check(); p.begin_opWithResult(ctx).whenCompleted( (int r) => { cb.opWithResult(r); }, null); cb.check(); p.begin_opWithUE().whenCompleted( () => { cb.op(); }, (Ice.Exception ex) => { cb.opWithUE(ex); }); cb.check(); p.begin_opWithUE(ctx).whenCompleted( () => { cb.op(); }, (Ice.Exception ex) => { cb.opWithUE(ex); }); cb.check(); } WriteLine("ok"); Write("testing local exceptions... "); Flush(); { Test.TestIntfPrx indirect = Test.TestIntfPrxHelper.uncheckedCast(p.ice_adapterId("dummy")); Ice.AsyncResult r; r = indirect.begin_op(); try { indirect.end_op(r); test(false); } catch(Ice.NoEndpointException) { } try { r = ((Test.TestIntfPrx)p.ice_oneway()).begin_opWithResult(); test(false); } catch(System.ArgumentException) { } // // Check that CommunicatorDestroyedException is raised directly. // if(p.ice_getConnection() != null) { Ice.InitializationData initData = new Ice.InitializationData(); initData.properties = communicator.getProperties().ice_clone_(); Ice.Communicator ic = Ice.Util.initialize(initData); Ice.ObjectPrx o = ic.stringToProxy(p.ToString()); Test.TestIntfPrx p2 = Test.TestIntfPrxHelper.checkedCast(o); ic.destroy(); try { p2.begin_op(); test(false); } catch(Ice.CommunicatorDestroyedException) { // Expected. } } } WriteLine("ok"); Write("testing local exceptions with async callback... "); Flush(); { Test.TestIntfPrx i = Test.TestIntfPrxHelper.uncheckedCast(p.ice_adapterId("dummy")); AsyncCallback cb = new AsyncCallback(); Cookie cookie = new Cookie(5); AsyncCallback cbWC = new AsyncCallback(cookie); i.begin_ice_isA("::Test::TestIntf", cb.isAEx, null); cb.check(); i.begin_ice_isA("::Test::TestIntf", cbWC.isAEx, cookie); cbWC.check(); i.begin_ice_ping(cb.pingEx, null); cb.check(); i.begin_ice_ping(cbWC.pingEx, cookie); cbWC.check(); i.begin_ice_id(cb.idEx, null); cb.check(); i.begin_ice_id(cbWC.idEx, cookie); cbWC.check(); i.begin_ice_ids(cb.idsEx, null); cb.check(); i.begin_ice_ids(cbWC.idsEx, cookie); cbWC.check(); if(!collocated) { i.begin_ice_getConnection(cb.connectionEx, null); cb.check(); i.begin_ice_getConnection(cbWC.connectionEx, cookie); cbWC.check(); } i.begin_op(cb.opEx, null); cb.check(); i.begin_op(cbWC.opEx, cookie); cbWC.check(); } WriteLine("ok"); Write("testing local exceptions with response callback... "); Flush(); { Test.TestIntfPrx i = Test.TestIntfPrxHelper.uncheckedCast(p.ice_adapterId("dummy")); ExceptionCallback cb = new ExceptionCallback(); i.begin_ice_isA("::Test::TestIntf").whenCompleted(cb.isA, cb.ex); cb.check(); i.begin_ice_ping().whenCompleted(cb.ping, cb.ex); cb.check(); i.begin_ice_id().whenCompleted(cb.id, cb.ex); cb.check(); i.begin_ice_ids().whenCompleted(cb.ids, cb.ex); cb.check(); if(!collocated) { i.begin_ice_getConnection().whenCompleted(cb.connection, cb.ex); cb.check(); } i.begin_op().whenCompleted(cb.op, cb.ex); cb.check(); } WriteLine("ok"); Write("testing local exceptions with lambda callback... "); Flush(); { Test.TestIntfPrx i = Test.TestIntfPrxHelper.uncheckedCast(p.ice_adapterId("dummy")); ExceptionCallback cb = new ExceptionCallback(); i.begin_ice_isA("::Test::TestIntf").whenCompleted( (bool r) => { cb.isA(r); }, (Ice.Exception ex) => { cb.ex(ex); }); cb.check(); i.begin_ice_ping().whenCompleted( () => { cb.ping(); }, (Ice.Exception ex) => { cb.ex(ex); }); cb.check(); i.begin_ice_id().whenCompleted( (string id) => { cb.id(id); }, (Ice.Exception ex) => { cb.ex(ex); }); cb.check(); i.begin_ice_ids().whenCompleted( (string[] ids) => { cb.ids(ids); }, (Ice.Exception ex) => { cb.ex(ex); }); cb.check(); if(!collocated) { i.begin_ice_getConnection().whenCompleted( (Ice.Connection conn) => { cb.connection(conn); }, (Ice.Exception ex) => { cb.ex(ex); }); cb.check(); } i.begin_op().whenCompleted( () => { cb.op(); }, (Ice.Exception ex) => { cb.ex(ex); }); cb.check(); } WriteLine("ok"); Write("testing exception callback... "); Flush(); { Test.TestIntfPrx i = Test.TestIntfPrxHelper.uncheckedCast(p.ice_adapterId("dummy")); ExceptionCallback cb = new ExceptionCallback(); i.begin_ice_isA("::Test::TestIntf").whenCompleted(cb.ex); cb.check(); i.begin_op().whenCompleted(cb.ex); cb.check(); i.begin_opWithResult().whenCompleted(cb.ex); cb.check(); i.begin_opWithUE().whenCompleted(cb.ex); cb.check(); // Ensures no exception is called when response is received p.begin_ice_isA("::Test::TestIntf").whenCompleted(cb.noEx); p.begin_op().whenCompleted(cb.noEx); p.begin_opWithResult().whenCompleted(cb.noEx); // If response is a user exception, it should be received. p.begin_opWithUE().whenCompleted(cb.opWithUE); cb.check(); } WriteLine("ok"); Write("testing lambda exception callback... "); Flush(); { Test.TestIntfPrx i = Test.TestIntfPrxHelper.uncheckedCast(p.ice_adapterId("dummy")); ExceptionCallback cb = new ExceptionCallback(); i.begin_ice_isA("::Test::TestIntf").whenCompleted( (Ice.Exception ex) => { cb.ex(ex); }); cb.check(); i.begin_op().whenCompleted( (Ice.Exception ex) => { cb.ex(ex); }); cb.check(); i.begin_opWithResult().whenCompleted( (Ice.Exception ex) => { cb.ex(ex); }); cb.check(); i.begin_opWithUE().whenCompleted( (Ice.Exception ex) => { cb.ex(ex); }); cb.check(); // Ensures no exception is called when response is received p.begin_ice_isA("::Test::TestIntf").whenCompleted( (Ice.Exception ex) => { cb.noEx(ex); }); p.begin_op().whenCompleted( (Ice.Exception ex) => { cb.noEx(ex); }); p.begin_opWithResult().whenCompleted( (Ice.Exception ex) => { cb.noEx(ex); }); // If response is a user exception, it should be received. p.begin_opWithUE().whenCompleted( (Ice.Exception ex) => { cb.opWithUE(ex); }); cb.check(); } WriteLine("ok"); Write("testing sent callback... "); Flush(); { SentCallback cb = new SentCallback(); p.begin_ice_isA("").whenCompleted(cb.isA, cb.ex).whenSent(cb.sent); cb.check(); p.begin_ice_ping().whenCompleted(cb.ping, cb.ex).whenSent(cb.sent); cb.check(); p.begin_ice_id().whenCompleted(cb.id, cb.ex).whenSent(cb.sent); cb.check(); p.begin_ice_ids().whenCompleted(cb.ids, cb.ex).whenSent(cb.sent); cb.check(); p.begin_op().whenCompleted(cb.op, cb.ex).whenSent(cb.sent); cb.check(); p.begin_op(cb.opAsync, null).whenSent(cb.sentAsync); cb.check(); p.begin_op().whenCompleted(cb.ex).whenSent(cb.sent); cb.check(); List<SentCallback> cbs = new List<SentCallback>(); byte[] seq = new byte[10024]; (new System.Random()).NextBytes(seq); testController.holdAdapter(); try { Ice.AsyncResult r; do { SentCallback cb2 = new SentCallback(); r = p.begin_opWithPayload(seq).whenCompleted(cb2.ex).whenSent(cb2.sent); cbs.Add(cb2); } while(r.sentSynchronously()); } finally { testController.resumeAdapter(); } foreach(SentCallback cb3 in cbs) { cb3.check(); } } WriteLine("ok"); Write("testing lambda sent callback... "); Flush(); { SentCallback cb = new SentCallback(); p.begin_ice_isA("").whenCompleted( (bool r) => { cb.isA(r); }, (Ice.Exception ex) => { cb.ex(ex); } ).whenSent( (bool sentSynchronously) => { cb.sent(sentSynchronously); }); cb.check(); p.begin_ice_ping().whenCompleted( () => { cb.ping(); }, (Ice.Exception ex) => { cb.ex(ex); } ).whenSent( (bool sentSynchronously) => { cb.sent(sentSynchronously); }); cb.check(); p.begin_ice_id().whenCompleted( (string id) => { cb.id(id); }, (Ice.Exception ex) => { cb.ex(ex); } ).whenSent( (bool sentSynchronously) => { cb.sent(sentSynchronously); }); cb.check(); p.begin_ice_ids().whenCompleted( (string[] ids) => { cb.ids(ids); }, (Ice.Exception ex) => { cb.ex(ex); } ).whenSent( (bool sentSynchronously) => { cb.sent(sentSynchronously); }); cb.check(); p.begin_op().whenCompleted( () => { cb.op(); }, (Ice.Exception ex) => { cb.ex(ex); } ).whenSent( (bool sentSynchronously) => { cb.sent(sentSynchronously); }); cb.check(); p.begin_op(cb.opAsync, null).whenSent( (Ice.AsyncResult r) => { cb.sentAsync(r); }); cb.check(); p.begin_op().whenCompleted( (Ice.Exception ex) => { cb.ex(ex); } ).whenSent( (bool sentSynchronously) => { cb.sent(sentSynchronously); }); cb.check(); List<SentCallback> cbs = new List<SentCallback>(); byte[] seq = new byte[10024]; (new System.Random()).NextBytes(seq); testController.holdAdapter(); try { Ice.AsyncResult r; do { SentCallback cb2 = new SentCallback(); r = p.begin_opWithPayload(seq).whenCompleted( (Ice.Exception ex) => { cb2.ex(ex); } ).whenSent( (bool sentSynchronously) => { cb2.sent(sentSynchronously); }); cbs.Add(cb2); } while(r.sentSynchronously()); } finally { testController.resumeAdapter(); } foreach(SentCallback cb3 in cbs) { cb3.check(); } } WriteLine("ok"); Write("testing illegal arguments... "); Flush(); { Ice.AsyncResult result; result = p.begin_op(); p.end_op(result); try { p.end_op(result); test(false); } catch(System.ArgumentException) { } result = p.begin_op(); try { p.end_opWithResult(result); test(false); } catch(System.ArgumentException) { } try { p.end_op(null); test(false); } catch(System.ArgumentException) { } } WriteLine("ok"); Write("testing unexpected exceptions from callback... "); Flush(); { Test.TestIntfPrx q = Test.TestIntfPrxHelper.uncheckedCast(p.ice_adapterId("dummy")); ThrowType[] throwEx = new ThrowType[]{ ThrowType.LocalException, ThrowType.UserException, ThrowType.OtherException }; for(int i = 0; i < 3; ++i) { Thrower cb = new Thrower(throwEx[i]); p.begin_op(cb.opAsync, null); cb.check(); p.begin_op().whenCompleted(cb.op, null); cb.check(); q.begin_op().whenCompleted(cb.op, cb.ex); cb.check(); p.begin_op().whenCompleted(cb.noOp, cb.ex).whenSent(cb.sent); cb.check(); q.begin_op().whenCompleted(cb.ex); cb.check(); } } WriteLine("ok"); Write("testing unexpected exceptions from callback with lambda... "); Flush(); { Test.TestIntfPrx q = Test.TestIntfPrxHelper.uncheckedCast(p.ice_adapterId("dummy")); ThrowType[] throwEx = new ThrowType[]{ ThrowType.LocalException, ThrowType.UserException, ThrowType.OtherException }; for(int i = 0; i < 3; ++i) { Thrower cb = new Thrower(throwEx[i]); p.begin_op().whenCompleted( () => { cb.op(); }, null); cb.check(); q.begin_op().whenCompleted( () => { cb.op(); }, (Ice.Exception ex) => { cb.ex(ex); }); cb.check(); p.begin_op().whenCompleted( () => { cb.noOp(); }, (Ice.Exception ex) => { cb.ex(ex); } ).whenSent( (bool sentSynchronously) => { cb.sent(sentSynchronously); }); cb.check(); q.begin_op().whenCompleted( (Ice.Exception ex) => { cb.ex(ex); }); cb.check(); } } WriteLine("ok"); Write("testing batch requests with proxy... "); Flush(); { test(p.ice_batchOneway().begin_ice_flushBatchRequests().sentSynchronously()); Cookie cookie = new Cookie(5); { // // AsyncResult. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); b1.opBatch(); FlushCallback cb = new FlushCallback(cookie); Ice.AsyncResult r = b1.begin_ice_flushBatchRequests(cb.completedAsync, cookie); r.whenSent(cb.sentAsync); cb.check(); test(r.isSent()); test(r.IsCompleted); test(p.waitForBatch(2)); } if(p.ice_getConnection() != null) { // // AsyncResult exception. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); b1.ice_getConnection().close(false); FlushExCallback cb = new FlushExCallback(cookie); Ice.AsyncResult r = b1.begin_ice_flushBatchRequests(cb.completedAsync, cookie); r.whenSent(cb.sentAsync); cb.check(); test(!r.isSent()); test(r.IsCompleted); test(p.opBatchCount() == 0); } { // // Type-safe. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); b1.opBatch(); FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = b1.begin_ice_flushBatchRequests(); r.whenCompleted(cb.exception); r.whenSent(cb.sent); cb.check(); test(r.isSent()); test(r.IsCompleted); test(p.waitForBatch(2)); } if(p.ice_getConnection() != null) { // // Type-safe exception. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); b1.ice_getConnection().close(false); FlushExCallback cb = new FlushExCallback(); Ice.AsyncResult r = b1.begin_ice_flushBatchRequests(); r.whenCompleted(cb.exception); r.whenSent(cb.sent); cb.check(); test(!r.isSent()); test(r.IsCompleted); test(p.opBatchCount() == 0); } } WriteLine("ok"); Write("testing batch requests with proxy and lambda... "); Flush(); { test(p.ice_batchOneway().begin_ice_flushBatchRequests().sentSynchronously()); Cookie cookie = new Cookie(5); { // // AsyncResult. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); b1.opBatch(); FlushCallback cb = new FlushCallback(cookie); Ice.AsyncResult r = b1.begin_ice_flushBatchRequests( (Ice.AsyncResult result) => { cb.completedAsync(result); }, cookie); r.whenSent( (Ice.AsyncResult result) => { cb.sentAsync(result); }); cb.check(); test(r.isSent()); test(r.IsCompleted); test(p.waitForBatch(2)); FlushCallback cb2 = new FlushCallback(cookie); Ice.AsyncResult r2 = b1.begin_ice_flushBatchRequests( (Ice.AsyncResult result) => { cb2.completedAsync(result); }, cookie); r2.whenSent( (Ice.AsyncResult result) => { cb2.sentAsync(result); }); cb2.check(); test(r2.isSent()); test(r2.IsCompleted); } if(p.ice_getConnection() != null) { // // AsyncResult exception. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); b1.ice_getConnection().close(false); FlushExCallback cb = new FlushExCallback(cookie); Ice.AsyncResult r = b1.begin_ice_flushBatchRequests( (Ice.AsyncResult result) => { cb.completedAsync(result); }, cookie); r.whenSent( (Ice.AsyncResult result) => { cb.sentAsync(result); }); cb.check(); test(!r.isSent()); test(r.IsCompleted); test(p.opBatchCount() == 0); } { // // Type-safe. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); b1.opBatch(); FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = b1.begin_ice_flushBatchRequests(); r.whenCompleted( (Ice.Exception ex) => { cb.exception(ex); }); r.whenSent( (bool sentSynchronously) => { cb.sent(sentSynchronously); }); cb.check(); test(r.isSent()); test(r.IsCompleted); test(p.waitForBatch(2)); } if(p.ice_getConnection() != null) { // // Type-safe exception. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); b1.ice_getConnection().close(false); FlushExCallback cb = new FlushExCallback(); Ice.AsyncResult r = b1.begin_ice_flushBatchRequests(); r.whenCompleted( (Ice.Exception ex) => { cb.exception(ex); }); r.whenSent( (bool sentSynchronously) => { cb.sent(sentSynchronously); }); cb.check(); test(!r.isSent()); test(r.IsCompleted); test(p.opBatchCount() == 0); } } WriteLine("ok"); if(p.ice_getConnection() != null) { Write("testing batch requests with connection... "); Flush(); { Cookie cookie = new Cookie(5); { // // AsyncResult. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); b1.opBatch(); FlushCallback cb = new FlushCallback(cookie); Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests(cb.completedAsync, cookie); r.whenSent(cb.sentAsync); cb.check(); test(r.isSent()); test(r.IsCompleted); test(p.waitForBatch(2)); } { // // AsyncResult exception. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); b1.ice_getConnection().close(false); FlushExCallback cb = new FlushExCallback(cookie); Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests(cb.completedAsync, cookie); r.whenSent(cb.sentAsync); cb.check(); test(!r.isSent()); test(r.IsCompleted); test(p.opBatchCount() == 0); } { // // Type-safe. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); b1.opBatch(); FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests(); r.whenCompleted(cb.exception); r.whenSent(cb.sent); cb.check(); test(r.isSent()); test(r.IsCompleted); test(p.waitForBatch(2)); } { // // Type-safe exception. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); b1.ice_getConnection().close(false); FlushExCallback cb = new FlushExCallback(); Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests(); r.whenCompleted(cb.exception); r.whenSent(cb.sent); cb.check(); test(!r.isSent()); test(r.IsCompleted); test(p.opBatchCount() == 0); } } WriteLine("ok"); } if(p.ice_getConnection() != null) { Write("testing batch requests with connection and lambda... "); Flush(); { Cookie cookie = new Cookie(5); { // // AsyncResult. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); b1.opBatch(); FlushCallback cb = new FlushCallback(cookie); Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests( (Ice.AsyncResult result) => { cb.completedAsync(result); }, cookie); r.whenSent( (Ice.AsyncResult result) => { cb.sentAsync(result); }); cb.check(); test(r.isSent()); test(r.IsCompleted); test(p.waitForBatch(2)); } { // // AsyncResult exception. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); b1.ice_getConnection().close(false); FlushExCallback cb = new FlushExCallback(cookie); Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests( (Ice.AsyncResult result) => { cb.completedAsync(result); }, cookie); r.whenSent( (Ice.AsyncResult result) => { cb.sentAsync(result); }); cb.check(); test(!r.isSent()); test(r.IsCompleted); test(p.opBatchCount() == 0); } { // // Type-safe. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); b1.opBatch(); FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests(); r.whenCompleted( (Ice.Exception ex) => { cb.exception(ex); }); r.whenSent( (bool sentSynchronously) => { cb.sent(sentSynchronously); }); cb.check(); test(r.isSent()); test(r.IsCompleted); test(p.waitForBatch(2)); } { // // Type-safe exception. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); b1.ice_getConnection().close(false); FlushExCallback cb = new FlushExCallback(); Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests(); r.whenCompleted( (Ice.Exception ex) => { cb.exception(ex); }); r.whenSent( (bool sentSynchronously) => { cb.sent(sentSynchronously); }); cb.check(); test(!r.isSent()); test(r.IsCompleted); test(p.opBatchCount() == 0); } } WriteLine("ok"); Write("testing batch requests with communicator... "); Flush(); { Cookie cookie = new Cookie(5); { // // AsyncResult - 1 connection. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); b1.opBatch(); FlushCallback cb = new FlushCallback(cookie); Ice.AsyncResult r = communicator.begin_flushBatchRequests(cb.completedAsync, cookie); r.whenSent(cb.sentAsync); cb.check(); test(r.isSent()); test(r.IsCompleted); test(p.waitForBatch(2)); } { // // AsyncResult exception - 1 connection. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); b1.ice_getConnection().close(false); FlushCallback cb = new FlushCallback(cookie); Ice.AsyncResult r = communicator.begin_flushBatchRequests(cb.completedAsync, cookie); r.whenSent(cb.sentAsync); cb.check(); test(r.isSent()); // Exceptions are ignored! test(r.IsCompleted); test(p.opBatchCount() == 0); } { // // AsyncResult - 2 connections. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway(); b2.ice_getConnection(); // Ensure connection is established. b1.opBatch(); b1.opBatch(); b2.opBatch(); b2.opBatch(); FlushCallback cb = new FlushCallback(cookie); Ice.AsyncResult r = communicator.begin_flushBatchRequests(cb.completedAsync, cookie); r.whenSent(cb.sentAsync); cb.check(); test(r.isSent()); test(r.IsCompleted); test(p.waitForBatch(4)); } { // // AsyncResult exception - 2 connections - 1 failure. // // All connections should be flushed even if there are failures on some connections. // Exceptions should not be reported. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway(); b2.ice_getConnection(); // Ensure connection is established. b1.opBatch(); b2.opBatch(); b1.ice_getConnection().close(false); FlushCallback cb = new FlushCallback(cookie); Ice.AsyncResult r = communicator.begin_flushBatchRequests(cb.completedAsync, cookie); r.whenSent(cb.sentAsync); cb.check(); test(r.isSent()); // Exceptions are ignored! test(r.IsCompleted); test(p.waitForBatch(1)); } { // // AsyncResult exception - 2 connections - 2 failures. // // The sent callback should be invoked even if all connections fail. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway(); b2.ice_getConnection(); // Ensure connection is established. b1.opBatch(); b2.opBatch(); b1.ice_getConnection().close(false); b2.ice_getConnection().close(false); FlushCallback cb = new FlushCallback(cookie); Ice.AsyncResult r = communicator.begin_flushBatchRequests(cb.completedAsync, cookie); r.whenSent(cb.sentAsync); cb.check(); test(r.isSent()); // Exceptions are ignored! test(r.IsCompleted); test(p.opBatchCount() == 0); } { // // Type-safe - 1 connection. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); b1.opBatch(); FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = communicator.begin_flushBatchRequests(); r.whenCompleted(cb.exception); r.whenSent(cb.sent); cb.check(); test(r.isSent()); test(r.IsCompleted); test(p.waitForBatch(2)); } { // // Type-safe exception - 1 connection. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); b1.ice_getConnection().close(false); FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = communicator.begin_flushBatchRequests(); r.whenCompleted(cb.exception); r.whenSent(cb.sent); cb.check(); test(r.isSent()); // Exceptions are ignored! test(r.IsCompleted); test(p.opBatchCount() == 0); } { // // 2 connections. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway(); b2.ice_getConnection(); // Ensure connection is established. b1.opBatch(); b1.opBatch(); b2.opBatch(); b2.opBatch(); FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = communicator.begin_flushBatchRequests(); r.whenCompleted(cb.exception); r.whenSent(cb.sent); cb.check(); test(r.isSent()); test(r.IsCompleted); test(p.waitForBatch(4)); } { // // Exception - 2 connections - 1 failure. // // All connections should be flushed even if there are failures on some connections. // Exceptions should not be reported. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway(); b2.ice_getConnection(); // Ensure connection is established. b1.opBatch(); b2.opBatch(); b1.ice_getConnection().close(false); FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = communicator.begin_flushBatchRequests(); r.whenCompleted(cb.exception); r.whenSent(cb.sent); cb.check(); test(r.isSent()); // Exceptions are ignored! test(r.IsCompleted); test(p.waitForBatch(1)); } { // // Exception - 2 connections - 2 failures. // // The sent callback should be invoked even if all connections fail. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway(); b2.ice_getConnection(); // Ensure connection is established. b1.opBatch(); b2.opBatch(); b1.ice_getConnection().close(false); b2.ice_getConnection().close(false); FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = communicator.begin_flushBatchRequests(); r.whenCompleted(cb.exception); r.whenSent(cb.sent); cb.check(); test(r.isSent()); // Exceptions are ignored! test(r.IsCompleted); test(p.opBatchCount() == 0); } } WriteLine("ok"); Write("testing batch requests with communicator with lambda... "); Flush(); { Cookie cookie = new Cookie(5); { // // AsyncResult - 1 connection. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); b1.opBatch(); FlushCallback cb = new FlushCallback(cookie); Ice.AsyncResult r = communicator.begin_flushBatchRequests( (Ice.AsyncResult result) => { cb.completedAsync(result); }, cookie); r.whenSent( (Ice.AsyncResult result) => { cb.sentAsync(result); }); cb.check(); test(r.isSent()); test(r.IsCompleted); test(p.waitForBatch(2)); } { // // AsyncResult exception - 1 connection. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); b1.ice_getConnection().close(false); FlushCallback cb = new FlushCallback(cookie); Ice.AsyncResult r = communicator.begin_flushBatchRequests( (Ice.AsyncResult result) => { cb.completedAsync(result); }, cookie); r.whenSent( (Ice.AsyncResult result) => { cb.sentAsync(result); }); cb.check(); test(r.isSent()); // Exceptions are ignored! test(r.IsCompleted); test(p.opBatchCount() == 0); } { // // AsyncResult - 2 connections. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway(); b2.ice_getConnection(); // Ensure connection is established. b1.opBatch(); b1.opBatch(); b2.opBatch(); b2.opBatch(); FlushCallback cb = new FlushCallback(cookie); Ice.AsyncResult r = communicator.begin_flushBatchRequests( (Ice.AsyncResult result) => { cb.completedAsync(result); }, cookie); r.whenSent( (Ice.AsyncResult result) => { cb.sentAsync(result); }); cb.check(); test(r.isSent()); test(r.IsCompleted); test(p.waitForBatch(4)); } { // // AsyncResult exception - 2 connections - 1 failure. // // All connections should be flushed even if there are failures on some connections. // Exceptions should not be reported. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway(); b2.ice_getConnection(); // Ensure connection is established. b1.opBatch(); b2.opBatch(); b1.ice_getConnection().close(false); FlushCallback cb = new FlushCallback(cookie); Ice.AsyncResult r = communicator.begin_flushBatchRequests( (Ice.AsyncResult result) => { cb.completedAsync(result); }, cookie); r.whenSent( (Ice.AsyncResult result) => { cb.sentAsync(result); }); cb.check(); test(r.isSent()); // Exceptions are ignored! test(r.IsCompleted); test(p.waitForBatch(1)); } { // // AsyncResult exception - 2 connections - 2 failures. // // The sent callback should be invoked even if all connections fail. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway(); b2.ice_getConnection(); // Ensure connection is established. b1.opBatch(); b2.opBatch(); b1.ice_getConnection().close(false); b2.ice_getConnection().close(false); FlushCallback cb = new FlushCallback(cookie); Ice.AsyncResult r = communicator.begin_flushBatchRequests( (Ice.AsyncResult result) => { cb.completedAsync(result); }, cookie); r.whenSent( (Ice.AsyncResult result) => { cb.sentAsync(result); }); cb.check(); test(r.isSent()); // Exceptions are ignored! test(r.IsCompleted); test(p.opBatchCount() == 0); } { // // Type-safe - 1 connection. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); b1.opBatch(); FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = communicator.begin_flushBatchRequests(); r.whenCompleted( (Ice.Exception ex) => { cb.exception(ex); }); r.whenSent( (bool sentSynchronously) => { cb.sent(sentSynchronously); }); cb.check(); test(r.isSent()); test(r.IsCompleted); test(p.waitForBatch(2)); } { // // Type-safe exception - 1 connection. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); b1.ice_getConnection().close(false); FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = communicator.begin_flushBatchRequests(); r.whenCompleted( (Ice.Exception ex) => { cb.exception(ex); }); r.whenSent( (bool sentSynchronously) => { cb.sent(sentSynchronously); }); cb.check(); test(r.isSent()); // Exceptions are ignored! test(r.IsCompleted); test(p.opBatchCount() == 0); } { // // 2 connections. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway(); b2.ice_getConnection(); // Ensure connection is established. b1.opBatch(); b1.opBatch(); b2.opBatch(); b2.opBatch(); FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = communicator.begin_flushBatchRequests(); r.whenCompleted( (Ice.Exception ex) => { cb.exception(ex); }); r.whenSent( (bool sentSynchronously) => { cb.sent(sentSynchronously); }); cb.check(); test(r.isSent()); test(r.IsCompleted); test(p.waitForBatch(4)); } { // // Exception - 2 connections - 1 failure. // // All connections should be flushed even if there are failures on some connections. // Exceptions should not be reported. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway(); b2.ice_getConnection(); // Ensure connection is established. b1.opBatch(); b2.opBatch(); b1.ice_getConnection().close(false); FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = communicator.begin_flushBatchRequests(); r.whenCompleted( (Ice.Exception ex) => { cb.exception(ex); }); r.whenSent( (bool sentSynchronously) => { cb.sent(sentSynchronously); }); cb.check(); test(r.isSent()); // Exceptions are ignored! test(r.IsCompleted); test(p.waitForBatch(1)); } { // // Exception - 2 connections - 2 failures. // // The sent callback should be invoked even if all connections fail. // test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway(); b2.ice_getConnection(); // Ensure connection is established. b1.opBatch(); b2.opBatch(); b1.ice_getConnection().close(false); b2.ice_getConnection().close(false); FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = communicator.begin_flushBatchRequests(); r.whenCompleted( (Ice.Exception ex) => { cb.exception(ex); }); r.whenSent( (bool sentSynchronously) => { cb.sent(sentSynchronously); }); cb.check(); test(r.isSent()); // Exceptions are ignored! test(r.IsCompleted); test(p.opBatchCount() == 0); } } WriteLine("ok"); } Write("testing AsyncResult operations... "); Flush(); { { testController.holdAdapter(); Ice.AsyncResult r1; Ice.AsyncResult r2; try { r1 = p.begin_op(); byte[] seq = new byte[10024]; (new System.Random()).NextBytes(seq); while((r2 = p.begin_opWithPayload(seq)).sentSynchronously()); if(p.ice_getConnection() != null) { test(r1.sentSynchronously() && r1.isSent() && !r1.isCompleted_() || !r1.sentSynchronously() && !r1.isCompleted_()); test(!r2.sentSynchronously() && !r2.isCompleted_()); test(!r1.IsCompleted && !r1.CompletedSynchronously); test(!r2.IsCompleted && !r2.CompletedSynchronously); } } finally { testController.resumeAdapter(); } WaitHandle w1 = r1.AsyncWaitHandle; WaitHandle w2 = r2.AsyncWaitHandle; r1.waitForSent(); test(r1.isSent()); r2.waitForSent(); test(r2.isSent()); r1.waitForCompleted(); test(r1.isCompleted_()); w1.WaitOne(); r2.waitForCompleted(); test(r2.isCompleted_()); w2.WaitOne(); test(r1.getOperation().Equals("op")); test(r2.getOperation().Equals("opWithPayload")); } { Ice.AsyncResult r; // // Twoway // r = p.begin_ice_ping(); test(r.getOperation().Equals("ice_ping")); test(r.getConnection() == null); // Expected test(r.getCommunicator() == communicator); test(r.getProxy() == p); p.end_ice_ping(r); Test.TestIntfPrx p2; // // Oneway // p2 = p.ice_oneway() as Test.TestIntfPrx; r = p2.begin_ice_ping(); test(r.getOperation().Equals("ice_ping")); test(r.getConnection() == null); // Expected test(r.getCommunicator() == communicator); test(r.getProxy() == p2); // // Batch request via proxy // p2 = p.ice_batchOneway() as Test.TestIntfPrx; p2.ice_ping(); r = p2.begin_ice_flushBatchRequests(); test(r.getConnection() == null); // Expected test(r.getCommunicator() == communicator); test(r.getProxy() == p2); p2.end_ice_flushBatchRequests(r); if(p.ice_getConnection() != null) { // // Batch request via connection // Ice.Connection con = p.ice_getConnection(); p2 = p.ice_batchOneway() as Test.TestIntfPrx; p2.ice_ping(); r = con.begin_flushBatchRequests(); test(r.getConnection() == con); test(r.getCommunicator() == communicator); test(r.getProxy() == null); // Expected con.end_flushBatchRequests(r); // // Batch request via communicator // p2 = p.ice_batchOneway() as Test.TestIntfPrx; p2.ice_ping(); r = communicator.begin_flushBatchRequests(); test(r.getConnection() == null); // Expected test(r.getCommunicator() == communicator); test(r.getProxy() == null); // Expected communicator.end_flushBatchRequests(r); } } if(p.ice_getConnection() != null) { Ice.AsyncResult r1 = null; Ice.AsyncResult r2 = null; testController.holdAdapter(); try { Ice.AsyncResult r = null; byte[] seq = new byte[10024]; for(int i = 0; i < 200; ++i) // 2MB { r = p.begin_opWithPayload(seq); } test(!r.isSent()); r1 = p.begin_ice_ping(); r2 = p.begin_ice_id(); r1.cancel(); r2.cancel(); try { p.end_ice_ping(r1); test(false); } catch(Ice.InvocationCanceledException) { } try { p.end_ice_id(r2); test(false); } catch(Ice.InvocationCanceledException) { } } finally { testController.resumeAdapter(); p.ice_ping(); test(!r1.isSent() && r1.isCompleted_()); test(!r2.isSent() && r2.isCompleted_()); } testController.holdAdapter(); try { r1 = p.begin_op(); r2 = p.begin_ice_id(); r1.waitForSent(); r2.waitForSent(); r1.cancel(); r2.cancel(); try { p.end_op(r1); test(false); } catch(Ice.InvocationCanceledException) { } try { p.end_ice_id(r2); test(false); } catch(Ice.InvocationCanceledException) { } } finally { testController.resumeAdapter(); } } } WriteLine("ok"); if(p.ice_getConnection() != null) { Write("testing close connection with sending queue... "); Flush(); { byte[] seq = new byte[1024 * 10]; // // Send multiple opWithPayload, followed by a close and followed by multiple opWithPaylod. // The goal is to make sure that none of the opWithPayload fail even if the server closes // the connection gracefully in between. // int maxQueue = 2; bool done = false; while(!done && maxQueue < 50) { done = true; p.ice_ping(); List<Ice.AsyncResult> results = new List<Ice.AsyncResult>(); for(int i = 0; i < maxQueue; ++i) { results.Add(p.begin_opWithPayload(seq)); } if(!p.begin_close(false).isSent()) { for(int i = 0; i < maxQueue; i++) { Ice.AsyncResult r = p.begin_opWithPayload(seq); results.Add(r); if(r.isSent()) { done = false; maxQueue *= 2; break; } } } else { maxQueue *= 2; done = false; } foreach(Ice.AsyncResult q in results) { q.waitForCompleted(); try { q.throwLocalException(); } catch(Ice.LocalException) { test(false); } } } } WriteLine("ok"); } p.shutdown(); }