home | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Java example source code file (ModuleTest.java)

This example Java source code file (ModuleTest.java) is included in the alvinalexander.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Learn more about this Java project at its project page.

Java - Java tags/keywords

exception, module, moduletest, override, testcase

The ModuleTest.java Java example source code

// Copyright 2007 Google Inc. All Rights Reserved.

package com.google.inject;

import junit.framework.TestCase;

 * Tests relating to modules.
 * @author kevinb
public class ModuleTest extends TestCase {

  static class A implements Module {
    public void configure(Binder binder) {
      binder.install(new B());
      binder.install(new C());

  static class B implements Module {
    public void configure(Binder binder) {
      binder.install(new D());

  static class C implements Module {
    public void configure(Binder binder) {
      binder.install(new D());

  static class D implements Module {
    public void configure(Binder binder) {
    @Override public boolean equals(Object obj) {
      return obj.getClass() == D.class; // we're all equal in the eyes of guice
    @Override public int hashCode() {
      return D.class.hashCode();

  static class X {}
  static class Y {}
  static class Z {}
  static class W {}

  public void testDiamond() throws Exception {
    Guice.createInjector(new A());

Other Java examples (source code examples)

Here is a short list of links related to this Java ModuleTest.java source code file:

my book on functional programming


new blog posts


Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.