// Path: src/main/java/org/arbeitspferde/groningen/open/OpenModule.java
// public class OpenModule extends AbstractModule {
//   private static final Logger log = Logger.getLogger(OpenModule.class.getCanonicalName());
// 
//   @Override
//   protected void configure() {
//     log.info("Binding open injectables.");
// 
//     MapBinder<String, Datastore> datastoreBinder = MapBinder.newMapBinder(binder(), String.class,
//         Datastore.class);
//     datastoreBinder.addBinding(InMemoryDatastore.class.getCanonicalName())
//       .to(InMemoryDatastore.class);
// 
//     MapBinder<String, HistoryDatastore> historyDatastoreBinder =
//         MapBinder.newMapBinder(binder(), String.class, HistoryDatastore.class);
//     historyDatastoreBinder.addBinding(
//         MemoryHistoryDatastore.class.getCanonicalName()).to(MemoryHistoryDatastore.class);
// 
//     bind(MetricExporter.class).to(NullMetricExporter.class);
//     bind(SupplementalSettingsProcessor.class).to(NullSupplementalSettingsProcessor.class);
//     bind(SubjectInterrogator.class).to(NullSubjectInterrogator.class);
//     bind(FileFactory.class).to(LocalFileFactory.class);
//     bind(FileEventNotifierFactory.class).to(NullFileEventNotifierFactory.class);
//     bind(InputLogStreamFactory.class).to(NullInputLogStreamFactory.class);
//     bind(OutputLogStreamFactory.class).to(FileOutputLogStreamFactory.class);
//     bind(HealthQuerier.class).to(ProcessHealthQuerier.class);
//     bind(SubjectManipulator.class).to(ProcessManipulator.class);
//     bind(VendorSecurityManager.class).to(NullSecurityManager.class);
//     bind(ServingAddressGenerator.class).to(ProcessServingAddressGenerator.class);
//     bind(LegacyProgramConfigurationMediator.class)
//         .to(NullLegacyProgramConfigurationMediator.class);
//     bind(CollectionLogAddressor.class).to(NullCollectionLogAddressor.class);
//   }
// 
//   /*
//    * This is merely a short-term hack, as it will require inclusion of the <em>appropriate</em>
//    * serving port.
//    */
//   @Provides
//   @Singleton
//   @Named("servingAddress")
//   public String produceServingAddress() {
//     try {
//       final Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
// 
//       while (interfaces.hasMoreElements()) {
//         final NetworkInterface currentInterface = interfaces.nextElement();
// 
//         if (currentInterface.isLoopback()) {
//           continue;
//         }
// 
//         final Enumeration<InetAddress> addresses = currentInterface.getInetAddresses();
// 
//         while (addresses.hasMoreElements()) {
//           final InetAddress address = addresses.nextElement();
//           final String canonicalName = address.getCanonicalHostName();
// 
//           if (!canonicalName.equalsIgnoreCase(address.getHostAddress())) {
//             return canonicalName;
//           }
//         }
//       }
//     } catch (final SocketException e) {
//       log.log(Level.SEVERE, "Error acquiring hostname due to networking stack problems.", e);
//     }
// 
//     log.severe("Could not acquire hostname due to unknown reasons.");
// 
//     return "localhost";
//   }
// 
//   @Provides
//   @Singleton
//   public HashFunction getHashFunction() {
//     return Hashing.md5();
//   }
// 
//   @Provides
//   @Singleton
//   public Server getJettyServer(Settings settings) {
//     return new Server(settings.getPort());
//   }
// }


import com.google.inject.Guice;
import com.google.inject.Injector;
import org.arbeitspferde.groningen.eventlog.EventLoggerService;
import org.arbeitspferde.groningen.open.OpenModule;
import junit.framework.TestCase;
/* Copyright 2012 Google, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.arbeitspferde.groningen;




/**
 * Tests for {@link ServicesModule}.
 */
public class ServicesModuleTest extends TestCase {
  private Injector injector;

  @Override
  protected void setUp() throws Exception {
    // Use the testing infrastructure's temporary directory management infrastructure.
    final String[] args = new String[] {};

    injector = Guice.createInjector(
        new BaseModule(args), new GroningenConfigParamsModule(),
// Path: src/main/java/org/arbeitspferde/groningen/open/OpenModule.java
// public class OpenModule extends AbstractModule {
//   private static final Logger log = Logger.getLogger(OpenModule.class.getCanonicalName());
// 
//   @Override
//   protected void configure() {
//     log.info("Binding open injectables.");
// 
//     MapBinder<String, Datastore> datastoreBinder = MapBinder.newMapBinder(binder(), String.class,
//         Datastore.class);
//     datastoreBinder.addBinding(InMemoryDatastore.class.getCanonicalName())
//       .to(InMemoryDatastore.class);
// 
//     MapBinder<String, HistoryDatastore> historyDatastoreBinder =
//         MapBinder.newMapBinder(binder(), String.class, HistoryDatastore.class);
//     historyDatastoreBinder.addBinding(
//         MemoryHistoryDatastore.class.getCanonicalName()).to(MemoryHistoryDatastore.class);
// 
//     bind(MetricExporter.class).to(NullMetricExporter.class);
//     bind(SupplementalSettingsProcessor.class).to(NullSupplementalSettingsProcessor.class);
//     bind(SubjectInterrogator.class).to(NullSubjectInterrogator.class);
//     bind(FileFactory.class).to(LocalFileFactory.class);
//     bind(FileEventNotifierFactory.class).to(NullFileEventNotifierFactory.class);
//     bind(InputLogStreamFactory.class).to(NullInputLogStreamFactory.class);
//     bind(OutputLogStreamFactory.class).to(FileOutputLogStreamFactory.class);
//     bind(HealthQuerier.class).to(ProcessHealthQuerier.class);
//     bind(SubjectManipulator.class).to(ProcessManipulator.class);
//     bind(VendorSecurityManager.class).to(NullSecurityManager.class);
//     bind(ServingAddressGenerator.class).to(ProcessServingAddressGenerator.class);
//     bind(LegacyProgramConfigurationMediator.class)
//         .to(NullLegacyProgramConfigurationMediator.class);
//     bind(CollectionLogAddressor.class).to(NullCollectionLogAddressor.class);
//   }
// 
//   /*
//    * This is merely a short-term hack, as it will require inclusion of the <em>appropriate</em>
//    * serving port.
//    */
//   @Provides
//   @Singleton
//   @Named("servingAddress")
//   public String produceServingAddress() {
//     try {
//       final Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
// 
//       while (interfaces.hasMoreElements()) {
//         final NetworkInterface currentInterface = interfaces.nextElement();
// 
//         if (currentInterface.isLoopback()) {
//           continue;
//         }
// 
//         final Enumeration<InetAddress> addresses = currentInterface.getInetAddresses();
// 
//         while (addresses.hasMoreElements()) {
//           final InetAddress address = addresses.nextElement();
//           final String canonicalName = address.getCanonicalHostName();
// 
//           if (!canonicalName.equalsIgnoreCase(address.getHostAddress())) {
//             return canonicalName;
//           }
//         }
//       }
//     } catch (final SocketException e) {
//       log.log(Level.SEVERE, "Error acquiring hostname due to networking stack problems.", e);
//     }
// 
//     log.severe("Could not acquire hostname due to unknown reasons.");
// 
//     return "localhost";
//   }
// 
//   @Provides
//   @Singleton
//   public HashFunction getHashFunction() {
//     return Hashing.md5();
//   }
// 
//   @Provides
//   @Singleton
//   public Server getJettyServer(Settings settings) {
//     return new Server(settings.getPort());
//   }
// }


// Path: src/test/java/org/arbeitspferde/groningen/ServicesModuleTest.java
import com.google.inject.Guice;
import com.google.inject.Injector;
import org.arbeitspferde.groningen.eventlog.EventLoggerService;
import org.arbeitspferde.groningen.open.OpenModule;
import junit.framework.TestCase;

/* Copyright 2012 Google, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.arbeitspferde.groningen;




/**
 * Tests for {@link ServicesModule}.
 */
public class ServicesModuleTest extends TestCase {
  private Injector injector;

  @Override
  protected void setUp() throws Exception {
    // Use the testing infrastructure's temporary directory management infrastructure.
    final String[] args = new String[] {};

    injector = Guice.createInjector(
        new BaseModule(args), new GroningenConfigParamsModule(),
        new ServicesModule(), new OpenModule());