1 package org.dbunit.dataset.csv.handlers; 2 3 import com.mockobjects.ExpectationCounter; 4 import com.mockobjects.ExpectationList; 5 import mockmaker.ExceptionalReturnValue; 6 import mockmaker.ReturnValues; 7 import mockmaker.VoidReturnValues; 8 import org.dbunit.dataset.csv.IllegalInputCharacterException; 9 10 import java.util.List ; 11 public class MockHandler extends AbstractPipelineComponent{ 12 private ExpectationCounter mySetSuccessorCalls = new ExpectationCounter("org.dbunit.dataset.csv.handlers.AbstractPipelineComponent SetSuccessorCalls"); 13 private ReturnValues myActualSetSuccessorReturnValues = new VoidReturnValues(false); 14 private ExpectationList mySetSuccessorParameter0Values = new ExpectationList("org.dbunit.dataset.csv.handlers.AbstractPipelineComponent org.dbunit.dataset.csv.handlers.Handler"); 15 private ExpectationCounter myGetSinkCalls = new ExpectationCounter("org.dbunit.dataset.csv.handlers.AbstractPipelineComponent GetSinkCalls"); 16 private ReturnValues myActualGetSinkReturnValues = new ReturnValues(false); 17 private ExpectationCounter myHandleCalls = new ExpectationCounter("org.dbunit.dataset.csv.handlers.AbstractPipelineComponent HandleCalls"); 18 private ReturnValues myActualHandleReturnValues = new VoidReturnValues(false); 19 private ExpectationList myHandleParameter0Values = new ExpectationList("org.dbunit.dataset.csv.handlers.AbstractPipelineComponent char"); 20 public void setExpectedSetSuccessorCalls(int calls){ 21 mySetSuccessorCalls.setExpected(calls); 22 } 23 public void addExpectedSetSuccessorValues(Handler arg0){ 24 mySetSuccessorParameter0Values.addExpected(arg0); 25 } 26 public void setSuccessor(PipelineComponent arg0){ 27 super.setSuccessor(arg0); 28 mySetSuccessorCalls.inc(); 29 mySetSuccessorParameter0Values.addActual(arg0); 30 Object nextReturnValue = myActualSetSuccessorReturnValues.getNext(); 31 if (nextReturnValue instanceof ExceptionalReturnValue && ((ExceptionalReturnValue)nextReturnValue).getException() instanceof RuntimeException ) 32 throw (RuntimeException )((ExceptionalReturnValue)nextReturnValue).getException(); 33 } 34 public void setupExceptionSetSuccessor(Throwable arg){ 35 myActualSetSuccessorReturnValues.add(new ExceptionalReturnValue(arg)); 36 } 37 public void setExpectedGetSinkCalls(int calls){ 38 myGetSinkCalls.setExpected(calls); 39 } 40 public void setupExceptionGetSink(Throwable arg){ 41 myActualGetSinkReturnValues.add(new ExceptionalReturnValue(arg)); 42 } 43 public void setupGetSink(List arg){ 44 myActualGetSinkReturnValues.add(arg); 45 } 46 public void setExpectedHandleCalls(int calls){ 47 myHandleCalls.setExpected(calls); 48 } 49 public void addExpectedHandleValues(char arg0){ 50 myHandleParameter0Values.addExpected(new Character (arg0)); 51 } 52 public void handle(char arg0) throws IllegalInputCharacterException, PipelineException{ 53 myHandleCalls.inc(); 54 myHandleParameter0Values.addActual(new Character (arg0)); 55 Object nextReturnValue = myActualHandleReturnValues.getNext(); 56 if (nextReturnValue instanceof ExceptionalReturnValue && ((ExceptionalReturnValue)nextReturnValue).getException() instanceof IllegalInputCharacterException) 57 throw (IllegalInputCharacterException)((ExceptionalReturnValue)nextReturnValue).getException(); 58 if (nextReturnValue instanceof ExceptionalReturnValue && ((ExceptionalReturnValue)nextReturnValue).getException() instanceof RuntimeException ) 59 throw (RuntimeException )((ExceptionalReturnValue)nextReturnValue).getException(); 60 super.handle(arg0); 61 } 62 public void setupExceptionHandle(Throwable arg){ 63 myActualHandleReturnValues.add(new ExceptionalReturnValue(arg)); 64 } 65 public void verify(){ 66 mySetSuccessorCalls.verify(); 67 mySetSuccessorParameter0Values.verify(); 68 myGetSinkCalls.verify(); 69 myHandleCalls.verify(); 70 myHandleParameter0Values.verify(); 71 } 72 public boolean canHandle(char c) throws IllegalInputCharacterException { 73 return false; 74 } 75 76 } 77 | Popular Tags |