throw checked Exceptions from mocks with Mockito

Check the Java API for List.The get(int index) method is declared to throw only the IndexOutOfBoundException which extends RuntimeException.You are trying to tell Mockito to throw an exception SomeException() that is not valid to be thrown by that particular method call. To clarify further.The List interface does not provide for a checked Exception to be thrown from the get(int index) method and that is why Mockito is failing.When … Read more

Change CSS of class in Javascript?

You can do that — actually change style rules related to a class — using the styleSheets array (MDN link), but frankly you’re probably better off (as changelog said) having a separate style that defines the display: none and then removing that style from elements when you want them no longer hidden.

Why cannot the JVM auto expand heap memory to the configured Xmx3072m in linux & jdk1.6.0_32, and FullGC occurs very frequently

The RES value isn’t how much memory the process is using, but how much actual RAM it uses. This doesn’t include swapped pages and allocated but unmapped pages. Make sure you have enough free memory on the system itself, you can run free, or even top should print above how much memory is in use. The output of top suggests that the … Read more

Why does pycharm propose to change method to static

PyCharm “thinks” that you might have wanted to have a static method, but you forgot to declare it to be static (using the @staticmethod decorator). PyCharm proposes this because the method does not use self in its body and hence does not actually change the class instance. Hence the method could be static, i.e. callable without passing a class instance or without even … Read more

Quicksort vs heapsort

This paper has some analysis. Also, from Wikipedia: The most direct competitor of quicksort is heapsort. Heapsort is typically somewhat slower than quicksort, but the worst-case running time is always Θ(nlogn). Quicksort is usually faster, though there remains the chance of worst case performance except in the introsort variant, which switches to heapsort when a bad … Read more