This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| StringBuilder buffer = new StringBuilder(); | |
| JspWriter jspWriterMock = mock(JspWriter.class); | |
| Answer<JspWriter> answer = new Answer<JspWriter>() { | |
| @Override | |
| public JspWriter answer(final InvocationOnMock theInvocation) throws Throwable { | |
| Method method = theInvocation.getMethod(); | |
| Method methodImpl = StringBuilder.class.getMethod(method.getName(), method.getParameterTypes()); | |
| methodImpl.invoke(buffer, theInvocation.getArguments()); | |
| return (JspWriter) theInvocation.getMock(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static <T> T deepCopy(T o) throws Exception { | |
| ByteArrayOutputStream baos = new ByteArrayOutputStream(); | |
| new ObjectOutputStream(baos).writeObject(o); | |
| ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); | |
| return (T) new ObjectInputStream(bais).readObject(); | |
| } |
NewerOlder