EasyMock Fundamentals Series — Part 3

Welcome to the third installment in my EasyMock Fundamentals series where I take you through the ins and outs of the open source Java library.

By |May 28th, 2013|General|0 Comments|

EasyMock Fundamentals Series — Part 2

Each way gives you a mock object with slightly different behaviors/restrictions. Consult the EasyMock API for specifics, but unless you have valid reason to not, the preferred method is createNiceMock().

By |May 21st, 2013|General|0 Comments|

EasyMock Fundamentals — Part 1

In my three-part EasyMock Fundamentals series, I will take you through the ins and outs of the open source Java library. EasyMock can be used in conjunction with a unit testing framework, such as JUnit or TestNG, to facilitate better unit testing without all the 2nd degree dependency issues. EasyMock provides the means (through the use of mock objects) to specify the response that will be returned when the code being tested makes calls to external methods. This will allow the result of the unit test to be isolated from variables outside of the scope of the unit test code.
An Introduction to EasyMock Fundamentals

Refer to the official EasyMock documentation for more detailed explanation of the tool (latest as of this writing EasyMock3.1 Docs) including download, setup, and a brief usage example.

Please note that, for the sake of simplicity, not all the details of the code examples have been included.
Stubs vs. Mocks
An alternative to using a mock object is to create a stub object; a lightweight implementation of the interface for the external methods, that just return the expected response. These two approaches are best illustrated with an example.

Let us say you want to write a unit test for an object Foo that does something cool, doSomethingCool(), and uses another object, Emailer, to send emails while doing something cool as follows:
package com.partnet.foo;
public class Foo {
  private Emailer emailer;
  public Foo(Emailer emailer) {
    this.emailer = emailer;
  public void doSomethingCool() {
    // something worthy of being unit tested
package com.partnet.foo;
public interface Emailer {
  boolean sendEmail(…) throw EmailerException;
If you’re trying to test the doSomethingCool() method, you don’t want to, shouldn’t have to, and thankfully don’t need to worry about what emailer.sendEmail() does (assuming the implementation of the call has no impact on the code you’re testing of […]

By |May 14th, 2013|General|0 Comments|

The History of Partnet

I wanted the first blog post of the year to give a little history of Partnet. We are a small business housed on the campus of the University of Utah, in the foothills of the Wasatch Mountains. The University of Utah is home to one of the first Computer Science Departments and ranks among the world’s top 20 academic programs.  The University of Utah was also one of the initial five sites for DARPANET—the predecessor of the Internet.

I’m not going to say we “Invented the Internet” or anything, but Partnet was there at the beginning. Before Netscape, Internet Explorer, or even Mosaic were around, Partnet developed its own web client to allow engineers to use the Internet to source parts located in remote databases. Partnet obtained a patent for searching distributed databases over the Internet. Today this patent is widely used by nearly all Internet companies that crawl the Web (this includes Google, Yahoo, Amazon, and many others).

In 1992, Dr. Don Brown was so impressed with the ideas of his students that he made a video of the capabilities and sent it to the Defense Advanced Research Projects Agency (DARPA). DARPA is an agency of the United States Department of Defense responsible for the development of new technology for use by the military. DARPA has been responsible for funding the development of many technologies that have had a major effect on the world.

Impressed with the idea of a distributed architecture that could search for spare parts from multiple databases, DARPA eagerly funded the project. The Defense Logistics Agency (DLA) soon joined the project. DLA provides supplies to the military services and supports their acquisition of weapon system repair parts and other materiel. DLA saw […]