Posts

Showing posts from 2015

Thread dump on linux

To take thread dump on linux machine , use  kill -3 <PID>.  It will send thread dump to stdout for the process. It won't kill the process  and if the process is running as service , typically there is a directory created under  /var/log. The stdout of service goes there.

Unit Testing

Mockito  spy vs. mock There is couple important difference between the two. 1. With spy , if you are not careful , you may end up calling the real code , while your intention is to mock it. Mockito.when(spy.methodToMock()).thenReturn(true); This will end up calling the real method on spy.   if you want , not to call the real code,  use different syntax. Mockito.doReturn(true).when(spy).methodToMock(); 2.  Usage of assertThat([value], [matcher statement]); assertThat(x, is(3)); assertThat(x, is(not(4))); assertThat(responseString, either(containsString("color")).or(containsString("colour"))); assertThat(myList, hasItem("3")); Useful Links: https://www.springboottutorial.com/unit-testing-for-spring-boot-rest-services

Continuous Integration - Maven

Properties for Maven You can  reference a property value in pom.xml  using ${propertyName} notation.  The value can either be passed in command line as "mvn clean install -DpropertyName=value   or can be defined inside pom.xml  inside <properties><propertyName>value</propertyName></properties>  node. If you are using Jenkins for CI, then you can also define properties either via Global Properties -> Environment Variables or by specifying settings.xml  under "Maven Configuration". These configurations are  available under "Manage Jenkins"  menu option. How to reference dependencies from Parent project The dependencies in parent project don't automatically get included in child project. You need to at least include <groupId> and <artifactId>  in the child project's pom file <dependency> element. settings.xml  The <localRepository>  value in settings.xml is very ...

Apache Directory Studio JVM Path

I was having issue launching Apache Directory Studio. It was complaining that there was no JVM found in a given path. But I did not know where that path was set.  Finally I figured that there is "Apache Directory Studio.ini" file which had the jvm path it was looking for.

Windows

Image
  Admin privileges At times your account esp. on office laptops directly don't have admin privileges. So you can not do lots of tasks which are restricted to admins, esp the configuration settings like editing hosts file, changing proxy settings etc.. But there will be a way to launch application( notepad, browser)  as an administrator and then you can do the restricted activities.   Click Windows(Left Bottom Corner of Screen ) Icon  -> Search Programs and Files -> Type the app name and you will see one option of running the app as Administrator ( if you were assigned that  privilege ) How to find what is running at a port netstat - o -b -a   ( you will need to run command as admin , you can always run the cmd.exe as Administrator , provided you given that privilege )  WinSCP batch scripts You can write winscp script to run in non-interactive mode.  There are two good articles on this topic. http://www.robvanderwoude.com/ft...

Java

1)The runtime system guarantees that static initialization blocks are called in the order that they appear in the source code. 2) To debug Java XML Parsers set jaxp.debug system property to 1 or true. It will print lots of messages regrading which parser classes/properties JAXP is picking up etc. 3)  JTDS/SQL Server While querying a IMAGE type column, if you are expecting getObject() to return byte[], pass useLOBs=false in the JDBC url. 4) static import Use it if you want unqualified access to static member of a  type without inheriting from the type. import static  x.y.z.StaticMemeber; .... access StaticMember  here without qualifying it .... real life example of this is importing the Matchers in junit. import static org.hamcrest.CoreMatchers.is; or: import static org.hamcrest.CoreMatchers.*; and then you can call is() as if it is a function defined in same class where it is being used. 5) FTPClient I was using FTPClient to uplo...