// Path: src/main/java/com/stackify/api/common/http/HttpException.java
// public class HttpException extends Exception {
// 
// 	/**
// 	 * Serial version UID
// 	 */
// 	private static final long serialVersionUID = -6349485370575426368L;
// 	
// 	/**
// 	 * HTTP status code
// 	 */
// 	private final int statusCode;
// 	
// 	/**
// 	 * Constructor
// 	 * @param statusCode HTTP status code
// 	 */
// 	public HttpException(int statusCode) {
// 		this.statusCode = statusCode;
// 	}
// 
// 	/**
// 	 * @return the statusCode
// 	 */
// 	public int getStatusCode() {
// 		return statusCode;
// 	}
// 	
// 	/**
// 	 * @return True if 4xx status code
// 	 */
// 	public boolean isClientError() {
// 		return (HttpURLConnection.HTTP_BAD_REQUEST <= statusCode) && (statusCode < HttpURLConnection.HTTP_INTERNAL_ERROR);
// 	}
// }


import java.net.HttpURLConnection;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import com.stackify.api.common.http.HttpException;
/*
 * Copyright 2014 Stackify
 *
 * 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 com.stackify.api.common.log;




/**
 * LogBackgroundServiceScheduler JUnit Test
 * 
 * @author Eric Martin
 */
@RunWith(PowerMockRunner.class)
@PrepareForTest({LogBackgroundServiceScheduler.class, System.class})
public class LogBackgroundServiceSchedulerTest {

	/**
	 * testUpdateOk
	 */
	@Test
	public void testNoUpdate() {
		LogBackgroundServiceScheduler scheduler = new LogBackgroundServiceScheduler();
		
		Assert.assertEquals(0, scheduler.getLastHttpError());
		Assert.assertEquals(1000, scheduler.getScheduleDelay());
	}
	
	/**
	 * testUpdateOk
	 */
	@Test
	public void testUpdateOk() {
		LogBackgroundServiceScheduler scheduler = new LogBackgroundServiceScheduler();

		scheduler.update(50);
		
		Assert.assertEquals(0, scheduler.getLastHttpError());
		Assert.assertEquals(1000, scheduler.getScheduleDelay());
	}
	
	/**
	 * testUpdateOkButLow
	 */
	@Test
	public void testUpdateOkButLow() {
		LogBackgroundServiceScheduler scheduler = new LogBackgroundServiceScheduler();

		scheduler.update(5);
		
		Assert.assertEquals(0, scheduler.getLastHttpError());
		Assert.assertEquals(1250, scheduler.getScheduleDelay());
	}
	
	/**
	 * testUpdateUnauthorized
	 */
	@Test
	public void testUpdateUnauthorized() {
		LogBackgroundServiceScheduler scheduler = new LogBackgroundServiceScheduler();		
		
		long beforeUpdate = System.currentTimeMillis();
// Path: src/main/java/com/stackify/api/common/http/HttpException.java
// public class HttpException extends Exception {
// 
// 	/**
// 	 * Serial version UID
// 	 */
// 	private static final long serialVersionUID = -6349485370575426368L;
// 	
// 	/**
// 	 * HTTP status code
// 	 */
// 	private final int statusCode;
// 	
// 	/**
// 	 * Constructor
// 	 * @param statusCode HTTP status code
// 	 */
// 	public HttpException(int statusCode) {
// 		this.statusCode = statusCode;
// 	}
// 
// 	/**
// 	 * @return the statusCode
// 	 */
// 	public int getStatusCode() {
// 		return statusCode;
// 	}
// 	
// 	/**
// 	 * @return True if 4xx status code
// 	 */
// 	public boolean isClientError() {
// 		return (HttpURLConnection.HTTP_BAD_REQUEST <= statusCode) && (statusCode < HttpURLConnection.HTTP_INTERNAL_ERROR);
// 	}
// }


// Path: src/test/java/com/stackify/api/common/log/LogBackgroundServiceSchedulerTest.java
import java.net.HttpURLConnection;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import com.stackify.api.common.http.HttpException;

/*
 * Copyright 2014 Stackify
 *
 * 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 com.stackify.api.common.log;




/**
 * LogBackgroundServiceScheduler JUnit Test
 * 
 * @author Eric Martin
 */
@RunWith(PowerMockRunner.class)
@PrepareForTest({LogBackgroundServiceScheduler.class, System.class})
public class LogBackgroundServiceSchedulerTest {

	/**
	 * testUpdateOk
	 */
	@Test
	public void testNoUpdate() {
		LogBackgroundServiceScheduler scheduler = new LogBackgroundServiceScheduler();
		
		Assert.assertEquals(0, scheduler.getLastHttpError());
		Assert.assertEquals(1000, scheduler.getScheduleDelay());
	}
	
	/**
	 * testUpdateOk
	 */
	@Test
	public void testUpdateOk() {
		LogBackgroundServiceScheduler scheduler = new LogBackgroundServiceScheduler();

		scheduler.update(50);
		
		Assert.assertEquals(0, scheduler.getLastHttpError());
		Assert.assertEquals(1000, scheduler.getScheduleDelay());
	}
	
	/**
	 * testUpdateOkButLow
	 */
	@Test
	public void testUpdateOkButLow() {
		LogBackgroundServiceScheduler scheduler = new LogBackgroundServiceScheduler();

		scheduler.update(5);
		
		Assert.assertEquals(0, scheduler.getLastHttpError());
		Assert.assertEquals(1250, scheduler.getScheduleDelay());
	}
	
	/**
	 * testUpdateUnauthorized
	 */
	@Test
	public void testUpdateUnauthorized() {
		LogBackgroundServiceScheduler scheduler = new LogBackgroundServiceScheduler();		
		
		long beforeUpdate = System.currentTimeMillis();
		scheduler.update(new HttpException(HttpURLConnection.HTTP_UNAUTHORIZED));