author profile image

Matt Reid

Lead Software Architect. Java, Node.js and TypeScript enthusiast.

A note to anyone getting the following message java.lang.VerifyError: class net.sf.cglib.core.DebuggingClassWriter overrides final method visit  The problem is a mismatch in the versions of asm and cglib in your webapp. cglib 2.2 pulls in asm version 3.1 (there should not be a higher version in your classpath) cglib cglib 2.2 compile...

Just a quick one, here is a simple command for adding a file to an existing jar jar -uvf JARNAME.jar NEWFILENAME  

Mockito provides a nice way to capture the arguments passed into your mocks. This works a treat when verifying the contents of an email send via a mocked JavaMailSender ArgumentCaptor messageCapture = ArgumentCaptor.forClass(Multipart.class); Mockito.verify(mockMimeMessage).setContent(messageCapture.capture()); //this is a multipart message so read all parts and verify StringWriter writer = new StringWriter();...

Just a quick one that I forgot to note down. If you want to count rows using a hibernate query, here is the bit of magic that you need. return (Number) session.createCriteria(Bananas.class).setProjection(Projections.rowCount()).uniqueResult();