14 Ekim 2011 Cuma

mockito argument capture

Here ise a good article about argument capture property of mockito: http://blog.james-carr.org/2009/09/28/mockito-verifying-details-of-an-object-passed-to-a-collaborator/

.. and here is more: http://docs.mockito.googlecode.com/hg/org/mockito/ArgumentCaptor.html
http://mockito.googlecode.com/svn/branches/1.8.0/javadoc/org/mockito/Mockito.html#15

when i have enough time, i will publish my own test examples..until then, i must say, unit testing with mockito framework is a great way of doing white box testing and this experience leads you to review & refactor your code accordingly..

7 Ekim 2011 Cuma

modifying latex margins

modify latex margins as follows:

\usepackage[left=0.5cm,top=0.5cm,right=1.0cm,nohead,nofoot]{geometry}


I use those margin values (for informal personal reports) to reduce my printing costs :)

increase tomcat 6.x memory in linux environment

Change CATALINA_OPTS as follows:
export CATALINA_OPTS="-Xms512m -Xmx2048m -XX:MaxPermSize=256m"

and restart tomcat.

endorse tomcat 6.x

In order to endorse tomcat 6.x, make a directory named endorsed under $CATALINA_HOME, and put your .jar files there.

ant create database(sql) task

here is an ant target to create the specified database... unfortunately, sql does not close the connection properly..



<target name="create-db" >
<sql driver="org.postgresql.Driver" classpath="${build.lib}/postgresql-8.4-702.jdbc4.jar" url="jdbc:postgresql://localhost:5432/template1" userid="userid" password="password" autocommit="true" onerror="continue">


         CREATE DATABASE ${database.prefix}_mydatabase;
       </sql>
</target>

lowercase ant task

here is ant task to lowercase a property:


<target name="lowercase-NAME" depends="init">
    <taskdef name="stringutil" classname="ise.antelope.tasks.StringUtilTask">
<classpath path="${build.lib}/antelopetasks-3.2.10.jar" />
  </taskdef>
    <property name="NAME.lowercase" value="${NAME}" />
  <stringutil string="${NAME.lowercase}" property="SURUM.lowercase">
  <lowercase />
  </stringutil>
</target>

tomcat deploy ant task

here is tomcat deploy-undeploy targets:


<target name="tomcat-start">
<exec executable="${tomcat.dir}/bin/startup.sh">
<env key="CATALINA_PID" value="${tomcat.pidfile}" />
</exec>
<sleep seconds="2" />
</target>


<target name="tomcat-deploy" depends="war">
<taskdef resource="org/apache/catalina/ant/catalina.tasks" classpathref="tomcat.classpath" />
<deploy url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" 
war="file:${build.dir}/${name}.war" path="/${name}}" failonerror="true" />
<sleep seconds="2" />
</target>


<target name="tomcat-undeploy">
<taskdef resource="org/apache/catalina/ant/catalina.tasks" classpathref="tomcat.classpath" />
<undeploy url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" 
path="/${name}" failonerror="false" />
</target>


<target name="tomcat-stop" depends="tomcat-undeploy">
<exec executable="${tomcat.dir}/bin/shutdown.sh">
<env key="CATALINA_PID" value="${tomcat.pidfile}" />
</exec>
<delete file="${tomcat.pidfile}" />
</target>