Commit 7ffe731a by Jason Song

Revert "add DataSourceValidatorTest"

This reverts commit 037e0036.
parent 81fd3f07
package com.ctrip.framework.apollo.common;
import com.ctrip.framework.apollo.common.utils.DataSourceValidatorTest;
import com.ctrip.framework.apollo.common.utils.InputValidatorTest;
import org.junit.runner.RunWith;
......@@ -9,7 +8,7 @@ import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
@SuiteClasses({
InputValidatorTest.class, DataSourceValidatorTest.class
InputValidatorTest.class
})
public class AllTests {
......
package com.ctrip.framework.apollo.common.utils;
import org.junit.Before;
import org.junit.Test;
import java.sql.Connection;
import static org.junit.Assert.*;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
/**
* @author Jason Song(song_s@ctrip.com)
*/
public class DataSourceValidatorTest {
private DataSourceValidator datasourceValidator;
@Before
public void setUp() throws Exception {
datasourceValidator = new DataSourceValidator();
}
@Test
public void testValidateSuccessfully() throws Exception {
Connection someConnection = mock(Connection.class);
int someValidationAction = 1;
when(someConnection.isValid(anyInt())).thenReturn(true);
assertTrue(datasourceValidator.validate(someConnection, someValidationAction));
}
@Test
public void testValidateFailed() throws Exception {
Connection someConnection = mock(Connection.class);
int someValidationAction = 1;
when(someConnection.isValid(anyInt())).thenReturn(false);
assertFalse(datasourceValidator.validate(someConnection, someValidationAction));
}
@Test
public void testValidateWithException() throws Exception {
Connection someConnection = mock(Connection.class);
int someValidationAction = 1;
when(someConnection.isValid(anyInt())).thenThrow(new RuntimeException("error"));
assertFalse(datasourceValidator.validate(someConnection, someValidationAction));
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment