// Path: src/main/java/org/arbeitspferde/groningen/utility/logstream/OutputLogStream.java
// @NotThreadSafe
// public interface OutputLogStream extends Flushable, Closeable {
//   public void write(final Message message) throws IOException;
// }
// 
// Path: src/main/java/org/arbeitspferde/groningen/utility/logstream/format/open/DelimitedFactory.java
// @ThreadSafe
// public class DelimitedFactory implements OutputLogStreamFactory {
//   @Override
//   public OutputLogStream forStream(final OutputStream stream) throws IOException {
//     return new Delimited(stream);
//   }
// 
//   @Override
//   public OutputLogStream rotatingStreamForSpecification(final Specification specification)
//       throws IOException {
//     final String baseName = String.format("%s.on_port_%s.log",
//         specification.getFilenamePrefix(), specification.getServingPort());
//     final FileOutputStream outputStream = new FileOutputStream(baseName);
// 
//     return new Delimited(outputStream);
//   }
// }


import java.io.IOException;
import java.io.OutputStream;
import java.util.Timer;
import java.util.TimerTask;
import java.util.logging.Logger;
import com.google.inject.Provider;
import org.arbeitspferde.groningen.Helper;
import org.arbeitspferde.groningen.proto.Event;
import org.arbeitspferde.groningen.utility.logstream.OutputLogStream;
import org.arbeitspferde.groningen.utility.logstream.OutputLogStreamFactory;
import org.arbeitspferde.groningen.utility.logstream.format.open.DelimitedFactory;
import junit.framework.TestCase;
import org.apache.commons.io.FileUtils;
import org.easymock.EasyMock;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
/* 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.eventlog;





/**
 * Tests for {@link SafeProtoLoggerFactory}.
 */
public class SafeProtoLoggerFactoryTest extends TestCase {
  private static final Logger log = Logger.getLogger(SafeProtoLoggerTest.class.getCanonicalName());

  private DelimitedFactory delimitedFactory;
  private SafeProtoLoggerFactory factory;
  private Provider<Timer> mockDaemonTimerProvider;
  private Timer mockTimer;
  private OutputLogStreamFactory fakeOutputLogStreamFactory;
  private File temporaryDirectory;
  private File temporaryLogFile;

  @SuppressWarnings("unchecked")
  @Override
  protected void setUp() throws Exception {
    super.setUp();

    temporaryDirectory = Helper.getTestDirectory();
    temporaryLogFile = File.createTempFile("log", "", temporaryDirectory);

    mockDaemonTimerProvider = EasyMock.createMock(Provider.class);
    mockTimer = EasyMock.createMock(Timer.class);

    delimitedFactory = new DelimitedFactory();
    fakeOutputLogStreamFactory = new OutputLogStreamFactory() {

      @Override
// Path: src/main/java/org/arbeitspferde/groningen/utility/logstream/OutputLogStream.java
// @NotThreadSafe
// public interface OutputLogStream extends Flushable, Closeable {
//   public void write(final Message message) throws IOException;
// }
// 
// Path: src/main/java/org/arbeitspferde/groningen/utility/logstream/format/open/DelimitedFactory.java
// @ThreadSafe
// public class DelimitedFactory implements OutputLogStreamFactory {
//   @Override
//   public OutputLogStream forStream(final OutputStream stream) throws IOException {
//     return new Delimited(stream);
//   }
// 
//   @Override
//   public OutputLogStream rotatingStreamForSpecification(final Specification specification)
//       throws IOException {
//     final String baseName = String.format("%s.on_port_%s.log",
//         specification.getFilenamePrefix(), specification.getServingPort());
//     final FileOutputStream outputStream = new FileOutputStream(baseName);
// 
//     return new Delimited(outputStream);
//   }
// }


// Path: src/test/java/org/arbeitspferde/groningen/eventlog/SafeProtoLoggerFactoryTest.java
import java.io.IOException;
import java.io.OutputStream;
import java.util.Timer;
import java.util.TimerTask;
import java.util.logging.Logger;
import com.google.inject.Provider;
import org.arbeitspferde.groningen.Helper;
import org.arbeitspferde.groningen.proto.Event;
import org.arbeitspferde.groningen.utility.logstream.OutputLogStream;
import org.arbeitspferde.groningen.utility.logstream.OutputLogStreamFactory;
import org.arbeitspferde.groningen.utility.logstream.format.open.DelimitedFactory;
import junit.framework.TestCase;
import org.apache.commons.io.FileUtils;
import org.easymock.EasyMock;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;

/* 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.eventlog;





/**
 * Tests for {@link SafeProtoLoggerFactory}.
 */
public class SafeProtoLoggerFactoryTest extends TestCase {
  private static final Logger log = Logger.getLogger(SafeProtoLoggerTest.class.getCanonicalName());

  private DelimitedFactory delimitedFactory;
  private SafeProtoLoggerFactory factory;
  private Provider<Timer> mockDaemonTimerProvider;
  private Timer mockTimer;
  private OutputLogStreamFactory fakeOutputLogStreamFactory;
  private File temporaryDirectory;
  private File temporaryLogFile;

  @SuppressWarnings("unchecked")
  @Override
  protected void setUp() throws Exception {
    super.setUp();

    temporaryDirectory = Helper.getTestDirectory();
    temporaryLogFile = File.createTempFile("log", "", temporaryDirectory);

    mockDaemonTimerProvider = EasyMock.createMock(Provider.class);
    mockTimer = EasyMock.createMock(Timer.class);

    delimitedFactory = new DelimitedFactory();
    fakeOutputLogStreamFactory = new OutputLogStreamFactory() {

      @Override
      public OutputLogStream forStream(final OutputStream stream) throws IOException {