Java Projects You Should Know About (vol. 2)

Dumbster:

The Dumbster is a very simple fake SMTP server designed for unit and system testing applications that send email messages. It responds to all standard SMTP commands but does not deliver messages to the user. The messages are stored within the Dumbster for later extraction and verification.
...


public class SimpleSmtpServerTest extends TestCase {
...
  public void testSend() {
    SimpleSmtpServer server = SimpleSmtpServer.start();

    try {
      // Submits an email using javamail to the email server listening on port 25 
      // (method not shown here). Replace this with a call to your app logic.
      sendMessage(25, "sender@here.com", "Test", "Test Body", "receiver@there.com");
    } catch(Exception e) {
      e.printStackTrace();
      fail("Unexpected exception: "+e);
    }

    server.stop();

    assertTrue(server.getReceivedEmailSize() == 1);
    Iterator emailIter = server.getReceivedEmail();
    SmtpMessage email = (SmtpMessage)emailIter.next();
    assertTrue(email.getHeaderValue("Subject").equals("Test"));
    assertTrue(email.getBody().equals("Test Body"));	
  }
...  
}

Dumbster has been great for me lately. This falls into the category of "Software that Just Works". My one criticism is that it doesn't do boundary checking for alt content emails, which means your test cases have to be crudely regex based.

Dozer:

Dozer is a Java Bean to Java Bean mapper that recursively copies data from one object to another. Typically, these Java Beans will be of different complex types.

Dozer supports simple property mapping, complex type mapping, bi-directional mapping, implicit-explicit mapping, as well as recursive mapping. This includes mapping collection attributes that also need mapping at the element level.

People who know me know Dozer. We even talk about it in GWT in Practice. In the modern "Enterprise" world where you constantly have to shovel data from different genned or built APIs (think ROME/Abdera ATOM to SOAP to JPA), Dozer is a must have tool.

JExcelAPI:

Java Excel API is a mature, open source java API enabling developers to read, write, and modifiy Excel spreadsheets dynamically. Now java developers can read Excel spreadsheets, modify them with a convenient and simple API, and write the changes to any output stream (e.g. disk, HTTP, database, or any socket).

I have been using this off and on for years, and it also falls into the category of "Just Works." If you need this, you likely know about it anyway. The reason I bring it up, is the dev team just stays on top of it after all these years and it is still a hammer when you have a nail.

Google Collections:

The Google Collections Library 0.8 (ALPHA) is a suite of new collections and collection-related goodness for Java 5.0, brought to you by Google.

This library is a natural extension of the Java Collections Framework you already know and love.

The major new types are:

* BiMap. A Map that guarantees unique values, and supports an inverse view.
* Multiset. A Collection that may contain duplicate values like a List, yet has order-independent equality like a Set. Often used to represent a histogram.
* Multimap. Similar to Map, but may contain duplicate keys. Has subtypes SetMultimap and ListMultimap providing more specific behavior.

There are also more than a dozen collection implementations, mostly of the interfaces above, but not all. ReferenceMap, for example, is a ConcurrentMap implementation which easily handles any combination of strong, soft or weak keys with strong, soft or weak values.

Static utility classes include:

* Comparators. Natural order, compound, null-friendly, ad-hoc . . .
* Iterators and Iterables. Element-based equality, cycle, concat, partition, filter with predicate, transform with function ...
* Lists, Sets and Maps. A plethora of convenient factory methods and much more.
* PrimitiveArrays: "boxing"/"unboxing" of primitive arrays

Again, anyone who knows me knows I love this one. They just re-revved a few days ago, but this is some top-notch software and if you aren't using this along with Cliff's High Scale Lib project, you are doing Java wrong.

warp:

What is Wideplay's Warp?

Warp is an eco-system for Google Guice. Warp comprises thin, lightweight modules for Guice applications using persistence, transactions, servlets, and so on.

* warp-persist 1.0 - Drop-in support for Hibernate, JPA, db4o; and Dynamic Finders (type-safe query automation).

* warp-servlet 0.9 - Injected Filters or Servlets; flash and conversation scopes

In the worlld of a jillion web frameworks, it is hard to bring up another. Warp, however, along with a killer project name ("Warp Core") has all kinds of goodies lurking under the covers. If it suffers from anything it is a certain level of wheel reinventing on things like an @Transactional annotation. Moreover it is based on Guice and for those of us still in spring hell, that is definitely a greener shade of grass.

Comments

warp-widgets + warp-persist

Good Post! Dumbster is terrific.

Actually, we don't reinvent the wheel with @Transactional. I was cognizant early on of this very problem, so warp-persist *does* work with Spring's @Transactional or basically with any annotation or even methods that aren't marked with any annotation.

This is done using Guice's excellent, type-safe matcher API: http://www.wideplay.com/transactionsemantics

We only provide an @Transactional as a canonical case, and as a convenience for green-fields use cases.

Appreciate the kind words about [Warp-core] now, "warp-widgets". We also have several features that sets us apart from most current gen web frameworks (like statically-typed templates and RESTful URL matching): http://code.google.com/p/warp-core/

Dhanji. =)

Another good option to add mail handling to your tests...

... is GreenMail. It supports not only SMTP, but also POP3 and IMAP with or without SSL support.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.