/*
 * The Alluxio Open Foundation licenses this work under the Apache License, version 2.0
 * (the "License"). You may not use this work except in compliance with the License, which is
 * available at www.apache.org/licenses/LICENSE-2.0
 *
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 * either express or implied, as more fully set forth in the License.
 *
 * See the NOTICE file distributed with this work for information regarding copyright ownership.
 */

package alluxio;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

/**
 * Unit tests for {@link SessionInfo}.
 */
public final class SessionInfoTest {
  private static final int MIN_LEN = 1;
  private static final int MAX_LEN = 1000;
  private static final int DELTA = 50;

  private int mSessionTimeoutMs;

  /**
   * Sets up the configuration for Alluxio before a test runs.
   */
  @Before
  public final void before() {
    mSessionTimeoutMs = Configuration.getInt(PropertyKey.WORKER_SESSION_TIMEOUT_MS);
  }

  /**
   * Tests the {@link SessionInfo#SessionInfo(long, int)} constructor.
   */
  @Test
  public void constructor() {
    for (int k = MIN_LEN; k <= MAX_LEN; k += DELTA) {
      SessionInfo tSessionInfo = new SessionInfo(k, mSessionTimeoutMs);
      Assert.assertEquals(k, tSessionInfo.getSessionId());
    }
  }

  /**
   * Tests that an exception is thrown in the {@link SessionInfo#SessionInfo(long, int)} constructor
   * when using an invalid id for the session.
   */
  @Test(expected = RuntimeException.class)
  public void constructorWithException() {
    for (int k = 0; k >= -1000; k -= DELTA) {
      SessionInfo tSessionInfo = new SessionInfo(k, mSessionTimeoutMs);
      Assert.assertEquals(k, tSessionInfo.getSessionId());
      Assert.fail("SessionId " + k + " should be invalid.");
    }
  }

  /**
   * Tests the {@link SessionInfo#getSessionId()} method.
   */
  @Test
  public void getSessionId() {
    for (int k = MIN_LEN; k < MAX_LEN; k += 66) {
      SessionInfo tSessionInfo = new SessionInfo(k, mSessionTimeoutMs);
      Assert.assertEquals(k, tSessionInfo.getSessionId());
    }
  }

  /**
   * Tests the {@link SessionInfo#timeout()} method.
   */
  @Test
  public void timeout() {
    SessionInfo tSessionInfo = new SessionInfo(1, mSessionTimeoutMs);
    Assert.assertFalse(tSessionInfo.timeout());
  }
}

@@ -554,33 +554,8 @@
 rt;%0A
-import org.junit.Before;%0A
 impo
@@ -573,16 +573,16 @@
 t.Test;%0A
+
 %0A/**%0A * 
@@ -780,17 +780,16 @@
 A = 50;%0A
-%0A
   privat
@@ -794,212 +794,25 @@
 ate 
-int mSessionTimeoutMs;%0A%0A  /**%0A   * Sets up the configuration for Alluxio before a test runs.%0A   */%0A  @Before%0A  public final void before() %7B%0A    mSessionTimeoutMs = Configuration.getInt(PropertyKey.WORKER_
+static final int 
 SESS
@@ -825,22 +825,24 @@
 MEOUT_MS
-);%0A  %7D
+ = 1000;
 %0A%0A  /**%0A
@@ -1062,33 +1062,34 @@
 Info(k, 
-mSessionTimeoutMs
+SESSION_TIMEOUT_MS
 );%0A     
@@ -1497,33 +1497,34 @@
 Info(k, 
-mSessionTimeoutMs
+SESSION_TIMEOUT_MS
 );%0A     
@@ -1860,33 +1860,34 @@
 Info(k, 
-mSessionTimeoutMs
+SESSION_TIMEOUT_MS
 );%0A     
@@ -2104,25 +2104,26 @@
 (1, 
-mSessionTimeoutMs
+SESSION_TIMEOUT_MS
 );%0A 

Clean up test.