/// <exception cref="System.Exception"/> public virtual T Answer(InvocationOnMock invocation) { // Don't want to inject an error on close() since that isn't // actually an IPC call! if (!typeof(IDisposable).Equals(invocation.GetMethod().DeclaringType)) { BeforeCall(invocation); } bool success = false; try { T ret = (T)invocation.GetMethod().Invoke(realObj, invocation.GetArguments()); success = true; return(ret); } catch (TargetInvocationException ite) { throw ite.InnerException; } finally { AfterCall(invocation, success); } }
/// <exception cref="System.Exception"/> internal override void BeforeCall(InvocationOnMock invocation) { if (this._enclosing.random.NextFloat() < this._enclosing.injectionProbability) { this._enclosing.isUp = !this._enclosing.isUp; TestQJMWithFaults.Log.Info("transitioned " + this._enclosing.addr + " to " + (this ._enclosing.isUp ? "up" : "down")); } if (!this._enclosing.isUp) { throw new IOException("Injected - faking being down"); } if (invocation.GetMethod().Name.Equals("acceptRecovery")) { if (this._enclosing.random.NextFloat() < this._enclosing.injectionProbability) { Org.Mockito.Mockito.DoThrow(new IOException("Injected - faking fault before persisting paxos data" )).When(TestQJMWithFaults.faultInjector).BeforePersistPaxosData(); } else { if (this._enclosing.random.NextFloat() < this._enclosing.injectionProbability) { Org.Mockito.Mockito.DoThrow(new IOException("Injected - faking fault after persisting paxos data" )).When(TestQJMWithFaults.faultInjector).AfterPersistPaxosData(); } } } }
Answer(InvocationOnMock invocation) { object[] args = invocation.GetArguments(); NUnit.Framework.Assert.AreEqual(2, args.Length); ClientDatanodeProtocolProtos.GetReplicaVisibleLengthRequestProto req = (ClientDatanodeProtocolProtos.GetReplicaVisibleLengthRequestProto )args[1]; ICollection <TokenIdentifier> tokenIds = UserGroupInformation.GetCurrentUser().GetTokenIdentifiers (); NUnit.Framework.Assert.AreEqual("Only one BlockTokenIdentifier expected", 1, tokenIds .Count); long result = 0; foreach (TokenIdentifier tokenId in tokenIds) { BlockTokenIdentifier id = (BlockTokenIdentifier)tokenId; Log.Info("Got: " + id.ToString()); NUnit.Framework.Assert.IsTrue("Received BlockTokenIdentifier is wrong", ident.Equals (id)); sm.CheckAccess(id, null, PBHelper.Convert(req.GetBlock()), BlockTokenSecretManager.AccessMode .Write); result = id.GetBlockId(); } return((ClientDatanodeProtocolProtos.GetReplicaVisibleLengthResponseProto)ClientDatanodeProtocolProtos.GetReplicaVisibleLengthResponseProto .NewBuilder().SetLength(result).Build()); }
/// <exception cref="System.IO.IOException"/> public HistoryEvent Answer(InvocationOnMock invocation) { int eventId = numEventsRead.GetAndIncrement(); TaskID tid = tids[eventId & unchecked ((int)(0x1))]; if (eventId < 2) { return(new TaskStartedEvent(tid, 0, taskType, string.Empty)); } if (eventId < 4) { TaskFailedEvent tfe = new TaskFailedEvent(tid, 0, taskType, "failed", "FAILED", null , new Counters()); tfe.SetDatum(tfe.GetDatum()); return(tfe); } if (eventId < 5) { JobUnsuccessfulCompletionEvent juce = new JobUnsuccessfulCompletionEvent(jid, 100L , 2, 0, "JOB_FAILED", Sharpen.Collections.SingletonList("Task failed: " + tids[0 ].ToString())); return(juce); } return(null); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("ThrowableResultOfMethodCallIgnored") void log(org.neo4j.consistency.report.PendingReferenceCheck<?> check, org.mockito.invocation.InvocationOnMock invocation) internal virtual void Log <T1>(PendingReferenceCheck <T1> check, InvocationOnMock invocation) { System.Reflection.MethodInfo method = invocation.Method; if (typeof(object) == method.DeclaringClass && "finalize".Equals(method.Name)) { /* skip invocations to finalize - they are not of interest to us, * and GC is not predictable enough to reliably trace this. */ return; } StringBuilder entry = (new StringBuilder(method.Name)).Append('('); entry.Append(check); foreach (object arg in invocation.Arguments) { if (arg is AbstractBaseRecord) { AbstractBaseRecord record = ( AbstractBaseRecord )arg; entry.Append(',').Append(record.GetType().Name).Append('[').Append(record.Id).Append(']'); } } string message = entry.Append(')').ToString(); if (null != Data[message] = new Exception(message)) { int?cur = Duplicates[message]; if (cur == null) { cur = 1; } Duplicates[message] = cur + 1; } }
/// <exception cref="System.Exception"/> public Void Answer(InvocationOnMock invocation) { object[] args = invocation.GetArguments(); journalSet.SelectInputStreams((ICollection <EditLogInputStream>)args[0], (long)args [1], (bool)args[2]); return(null); }
/// <exception cref="System.Exception"/> public CSAssignment Answer(InvocationOnMock invocation) { try { throw new Exception(); } catch (Exception) { TestChildQueueOrder.Log.Info("FOOBAR q.assignContainers q=" + queue.GetQueueName( ) + " alloc=" + allocation + " node=" + node.GetNodeName()); } Org.Apache.Hadoop.Yarn.Api.Records.Resource allocatedResource = Resources.CreateResource (allocation); if (queue is ParentQueue) { ((ParentQueue)queue).AllocateResource(clusterResource, allocatedResource, null); } else { FiCaSchedulerApp app1 = this._enclosing.GetMockApplication(0, string.Empty); ((LeafQueue)queue).AllocateResource(clusterResource, app1, allocatedResource, null ); } if (allocation > 0) { Org.Mockito.Mockito.DoReturn(new CSAssignment(Resources.None(), type)).When(queue ).AssignContainers(Matchers.Eq(clusterResource), Matchers.Eq(node), Matchers.Any <ResourceLimits>()); Org.Apache.Hadoop.Yarn.Api.Records.Resource available = node.GetAvailableResource (); Org.Mockito.Mockito.DoReturn(Resources.SubtractFrom(available, allocatedResource) ).When(node).GetAvailableResource(); } return(new CSAssignment(allocatedResource, type)); }
/// <exception cref="System.Exception"/> public object Answer(InvocationOnMock invocationOnMock) { Path dest = (Path)invocationOnMock.GetArguments()[1]; if (dest.ToString().Contains(firstDir.ToString())) { throw new IOException("No space on this drive " + dest.ToString()); } else { DataOutputStream tokenOut = null; try { Credentials credentials = new Credentials(); tokenOut = mockLfs.Create(dest, EnumSet.Of(CreateFlag.Create, CreateFlag.Overwrite )); credentials.WriteTokenStorageToStream(tokenOut); } finally { if (tokenOut != null) { tokenOut.Close(); } } } return(null); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public Void answer(org.mockito.invocation.InvocationOnMock invocationOnMock) throws Throwable public override Void answer(InvocationOnMock invocationOnMock) { RequestMessage msg = invocationOnMock.getArgument(0); _messages.Add(msg); return(null); }
public DatanodeProtocolProtos.BlockReportResponseProto Answer(InvocationOnMock invocation ) { object[] args = invocation.GetArguments(); request.Set((DatanodeProtocolProtos.BlockReportRequestProto)args[1]); return((DatanodeProtocolProtos.BlockReportResponseProto)DatanodeProtocolProtos.BlockReportResponseProto .NewBuilder().Build()); }
/// <exception cref="System.IO.IOException"/> public Void Answer(InvocationOnMock ignore) { if ((Time.MonotonicNow() - retryTime) <= 3000) { throw new InternalError(); } return(null); }
/// <exception cref="System.Exception"/> public Resource Answer(InvocationOnMock invocation) { lock (client) { Sharpen.Thread.Sleep(10); } return(null); }
/// <exception cref="System.Exception"/> public Void Answer(InvocationOnMock invocation) { if (true) { Sharpen.Thread.Sleep(sleepMs * 2); } return(null); }
/// <exception cref="System.Exception"/> public virtual ListenableFuture <T> Answer(InvocationOnMock invocation) { if (this._enclosing.r.NextFloat() < this.faultProbability) { return(Futures.ImmediateFailedFuture(new IOException("Injected fault"))); } return((ListenableFuture <T>)invocation.CallRealMethod()); }
/// <exception cref="System.Exception"/> public object Answer(InvocationOnMock invocationOnMock) { string diagnostics = (string)invocationOnMock.GetArguments()[0]; NUnit.Framework.Assert.IsTrue("Invalid Diagnostics message: " + diagnostics, diagnostics .Contains("No such file or directory")); return(null); }
public Org.Apache.Hadoop.Security.Token.Token <object>[] Answer(InvocationOnMock invocation ) { Credentials creds = (Credentials)invocation.GetArguments()[1]; creds.AddToken(service, t); return(new Org.Apache.Hadoop.Security.Token.Token <object>[] { t }); }
/// <exception cref="System.Exception"/> public Org.Apache.Hadoop.Security.Token.Token <object> Answer(InvocationOnMock invocation ) { Org.Apache.Hadoop.Security.Token.Token <object> token = new Org.Apache.Hadoop.Security.Token.Token <TokenIdentifier>(); token.SetService(service); return(token); }
/// <exception cref="System.Exception"/> public object Answer(InvocationOnMock invocation) { object[] args = invocation.GetArguments(); FsPermission perm = (FsPermission)args[0]; return(new PermissionStatus(TestFSPermissionChecker.Superuser, TestFSPermissionChecker .Supergroup, perm)); }
public Void Answer(InvocationOnMock invocation) { object[] args = invocation.GetArguments(); DataInputBuffer key = (DataInputBuffer)args[0]; key.Reset(Sharpen.Runtime.GetBytesForString(("Segment Value " + segmentName + this .i)), 20); return(null); }
/// <exception cref="System.Exception"/> public Void Answer(InvocationOnMock invocation) { INodesInPath iip = fsd.GetINodesInPath(TestGetBlockLocations.FilePath, true); FSDirDeleteOp.Delete(fsd, iip, new INode.BlocksMapUpdateInfo(), new AList <INode>( ), Time.Now()); invocation.CallRealMethod(); return(null); }
/// <exception cref="System.Exception"/> public object Answer(InvocationOnMock invocationOnMock) { ContainerDiagnosticsUpdateEvent @event = (ContainerDiagnosticsUpdateEvent)invocationOnMock .GetArguments()[0]; NUnit.Framework.Assert.IsTrue("Invalid Diagnostics message: " + @event.GetDiagnosticsUpdate (), @event.GetDiagnosticsUpdate().Contains("No such file or directory")); return(null); }
/// <exception cref="System.Exception"/> public Org.Apache.Hadoop.Security.Token.Token <object> Answer(InvocationOnMock invocation ) { Org.Apache.Hadoop.Security.Token.Token <object> token = new Org.Apache.Hadoop.Security.Token.Token <TokenIdentifier>(); token.SetService(new Text(service)); token.SetKind(new Text("token" + this.unique++)); return(token); }
/// <exception cref="System.Exception"/> public virtual object Answer(InvocationOnMock invocation) { if (r.NextBoolean()) { Log.Info("Throwing an exception for svc " + svcIdx); throw new HealthCheckFailedException("random failure"); } return(invocation.CallRealMethod()); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public Object answer(org.mockito.invocation.InvocationOnMock invocation) throws Throwable public override object Answer(InvocationOnMock invocation) { //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: if (!(reference instanceof org.neo4j.consistency.store.RecordReference_SkippingReference<?>)) if (!(Reference is Org.Neo4j.Consistency.store.RecordReference_SkippingReference <object>)) { Log.log(Reporter, invocation); } return(invocation.callRealMethod()); }
/// <exception cref="System.Exception"/> public Void Answer(InvocationOnMock invocation) { if (count.GetAndIncrement() == 0) { throw new IOException("faked initBlockPool exception"); } Org.Mockito.Mockito.DoReturn(this._enclosing.mockFSDataset).When(mockDn).GetFSDataset (); return(null); }
/// <exception cref="System.Exception"/> public Future <Path> Answer(InvocationOnMock invoc) { Future <Path> done = Org.Mockito.Mockito.Mock <Future>(); Org.Mockito.Mockito.When(done.IsDone()).ThenReturn(true); TestContainerLocalizer.FakeDownload d = (TestContainerLocalizer.FakeDownload)invoc .GetArguments()[0]; Org.Mockito.Mockito.When(done.Get()).ThenReturn(d.Call()); return(done); }
/// <exception cref="System.Exception"/> public Void Answer(InvocationOnMock invocation) { FSImageStorageInspector inspector = (FSImageStorageInspector)invocation.GetArguments ()[0]; foreach (Storage.StorageDirectory sd in mockDirs) { inspector.InspectDirectory(sd); } return(null); }
/// <exception cref="System.Exception"/> protected override object PassThrough(InvocationOnMock invocation) { try { return(base.PassThrough(invocation)); } finally { brFinished.CountDown(); } }
/// <exception cref="System.Exception"/> public Void Answer(InvocationOnMock invocation) { invocation.CallRealMethod(); if (!renamed[0]) { FSDirRenameOp.RenameTo(fsd, fsd.GetPermissionChecker(), TestGetBlockLocations.FilePath , DstPath, new INode.BlocksMapUpdateInfo(), false); renamed[0] = true; } return(null); }
/// <exception cref="System.Exception"/> public object Answer(InvocationOnMock invocation) { t.SetStackTrace(Thread.CurrentThread().GetStackTrace()); foreach (StackTraceElement elem in t.GetStackTrace()) { if (elem.ToString().Matches(pattern)) { throw t; } } return(invocation.CallRealMethod()); }