Skip to content

Tag: java

Java mutable byte array data structure

I’m trying to find an easy way to create a mutable byte array that can automatically append any primitive Java data type. I’ve been searching but could not find anything useful. I’m looking for something like this There is ByteByffer which is great, but you have to know the size of the buffe…

Mocking static methods with Mockito

I’ve written a factory to produce java.sql.Connection objects: I’d like to validate the parameters passed to DriverManager.getConnection, but I don’t know how to mock a static method. I’m using JUnit 4 and Mockito for my test cases. Is there a good way to mock/verify this specific use-…

Get Random Element from Collection

I have a Collection how do I get a random Obj from it? I’ve checked the docs and there doesn’t seem to be a way, since iterator is the only way to access the collection. Do I have to …