About Olga

  • Website: or email
  • Biography:

Posts by Olga:

 
No Comments

EasyMock

on May 23, 2010 in Development

Mock Objects

A unit test should verify just the behaviour of the tested object. But you’ll often find yourself  writing unit tests for classes that relay on other classes or methods’ results. That’s why you need a way of simulate these classes behaviour, that’s called mocking objects. This way you can assure you are testing an specific functionality avoiding dependencies with other classes.
Mock object is an object that mimic the behavior of real objects in controlled ways.

EasyMock

EasyMock is a library that provides an easy way to use Mock Objects for given interfaces or classes.

EasyMock 3.0

Allows you not only to mock interfaces but also classes. Also, you can capture mocked method’s parameters, to be able to check later the values, this way you can check just some of the attributes of the objects, instead of building the whole object to compare.

Sample Code:

Create mock object, you have to pass the class of the object mocked. You can also use an interface.
MyClass mockObj = EasyMock.createStrictMock(MyClass.class);
Set up expectations for the mocked object.
Without parameters or return
mockObj.myMethod1();
EasyMock.expectLastCall();
Without parameters
mockObj.myMethod2();
EasyMock.expectLastCall().andReturn(true);
EasyMock.expect(mockObj.myMethod3()).andReturn(true);
With parameters and return
EasyMock.expect(mockObj.myMethod4(1)).andReturn(2);
If you don’t know the parameters and you don’t care, you can user EasyMock comparison, but you have to use it for every parameter.
EasyMock.expect(mockObj.myMethod5(EasyMock.isA(MyParameter.class), EasyMock.eq(1))).andReturn(2);
Finally, if you don’t know the parameters but you want to check it later. You need a capture object
Define the capture object
Capture<MyParameter> captureObj = new Capture<MyParameter>();
Set up expectations
mockObj.myMethod5(EasyMock.capture(captureObj), EasyMock.eq(1));
EasyMock.expectLastCall();
After setting the expectations replay the mock objects.
EasyMock.replay(mockObj);
Execute Test calls that will make these expectations to carry out.
Verify the expectations
EasyMock.verify(MockObj);
Check captured parameters
assertTrue("MyParameter captured", captureObj.hasCaptured());
MyParameter param = (MyParameter) captureObj.getValue()
Check param.

References

Wikipedia.

EasyMock Documentation.

Tags: , , ,

 
No Comments

DBUnit

on May 13, 2010 in Development

When testing code that access and modify the database, you’ll need to insert the initial data into the database, execute your code, and check if the data in the database is exactly what you expected after executing your code. To automate this kind of testing you’ll need any kind of tool that can do all [...]

Tags: , , , , , ,

 
No Comments

Maven

on May 7, 2010 in Uncategorized

Apache Maven is a software project management tool that  provides a standard way to build the project. It bases on project object model (POM) to describe how the project is build, order and dependencies with other modules. It also specify some development guidelines as keeping your testing and source code in a separate structure. Maven [...]

Tags: , , , , ,

 
No Comments

JUnit

on April 29, 2010 in Development

JUnit is a simple, open source framework to write and run repeatable tests. Installing JUnit 1. Download the latest version of JUnit, from junit.org. 2. Then install JUnit on your platform: Windows 1.Unzip the junit.zip distribution file to a directory referred to as %JUNIT_HOME%. 2. Add JUnit to the classpath: set CLASSPATH=%CLASSPATH%;%JUNIT_HOME%\junit.jar Unix (bash) 1.Unzip [...]

Tags: , , , ,

 
No Comments

Unit testing

on April 28, 2010 in Development

Real stupidity beats artificial intelligence every time. Terry Pratchett. Testing your application cannot be reduced to test that your application normal use would work, you have to test that every piece of code works at it should. Unit testing consist on identifying and consistently verifying each software unit, checking  inputs, state and outputs of an [...]

Tags: , , , ,

 
No Comments

Oracle Identity Manager: Provisioning to a Database Table

on February 16, 2010 in Identity Management

Provisioning a User to a Database Table More information in the Provisioning a User to a Database Table tutorial. Create or configure the database table 1.Creating the table You can work with a already configured table or you can create your table of user data as follows: CREATE TABLE “XLADM”.”USER_DATA” ( “USER_ID” VARCHAR2(20 BYTE) NOT [...]

Tags: , , ,

 
No Comments

Oracle Identity Manager – Flat File Reconciliation

on February 11, 2010 in Identity Management

Performing Flat-File Reconciliation. This guide uses the following tutorial. Create the flat file. 1. Shut down Oracle Identity Manager Server Administrative and User Console Design Console. 2. Create the flat file. Within the stage dir /GTC/External Files directory, create the flat file and call it . Example: D:\Oracle\xellerate\GTC\External Files\users 20100101.txt #GTC Trusted Source login,firstName,lastName,eMail,organization USERTEST,usu_name,usu_lastname,usutest@example.com,Xellerate [...]

Tags: , ,

 
No Comments

HTC Tattoo: Other Applications

on February 6, 2010 in Devices

TasKiller The HTC Tattoo has a problem, open applications never close or have an option to get close. That’s no so bad because it makes the applications to show the last state you left, this way, the browser will be open in the last page you visited. But you’ll eventually want to close applications, to [...]

Tags: , , , ,

 
No Comments

HTC Tattoo

on January 19, 2010 in Devices

Due to the recent lost of my mobile, I decided to have a new one, a better one. The HTC Tattoo is an Android based smartphone, smaller than the other HTC in the market, with a resistive touchscreen. The first thing you have to do is link your google account, it will be used for [...]

Tags: ,

 
No Comments

Sun Identity Manager: User Functions

on February 27, 2009 in Identity Management

Now I’ve explained the objects used within an identity enviroment, I am going to detail the functions related to the users. For more information about the users or accounts, you can read previous post. User Users and related accounts are shown on Identity Manager as an unique identity, that allows the user to be modified [...]

Tags:

Copyright © 2006-2012 Too weak to give in All rights reserved.
Shades v1.5.1 theme from BuyNowShop.com.