public virtual void testGetAndCheckConnection() { Url addr = new Url(ip, port); const int connNum = 1; const bool warmup = false; for (int i = 0; i < 10; ++i) { Thread thread = new Thread(() => { try { new RpcAddressParser().initUrlArgs(addr); addr.ConnNum = connNum; addr.ConnWarmup = warmup; Connection conn = cm.getAndCreateIfAbsent(addr); Assert.NotNull(conn); Assert.True(conn.Fine); } catch (RemotingException e) { logger.LogError("error!", e); Assert.True(false); } catch (Exception e) { logger.LogError("error!", e); Assert.True(false); } }); thread.Start(); } try { Thread.Sleep(1000); } catch (ThreadInterruptedException e) { logger.LogError("", e); } Assert.Equal(1, serverConnectProcessor.ConnectTimes); }
public virtual void testGetAndCreateIfAbsent() { try { Connection conn = cm.getAndCreateIfAbsent(url); Assert.NotNull(conn); } catch (RemotingException) { Assert.Null("should not reach here!"); } catch (ThreadInterruptedException) { Assert.Null("should not reach here!"); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: @Override public Connection getConnection(Url url, int connectTimeout) throws exception.RemotingException, ThreadInterruptedException public override Connection getConnection(Url url, int connectTimeout) { url.ConnectTimeout = connectTimeout; return(connectionManager.getAndCreateIfAbsent(url)); }