forked from fanruan/finekit
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.4 KiB
57 lines
1.4 KiB
6 years ago
|
package com.fanruan.api.cluster.state;
|
||
|
|
||
|
import com.fr.store.impl.redis.accessor.FineJedis;
|
||
|
import com.fr.store.impl.redis.accessor.FineJedisPool;
|
||
|
import com.fr.store.impl.redis.accessor.FineJedisWrapper;
|
||
|
import org.easymock.EasyMock;
|
||
|
import org.junit.Assert;
|
||
|
import org.junit.Test;
|
||
|
|
||
|
import static org.easymock.EasyMock.anyObject;
|
||
|
import static org.easymock.EasyMock.expect;
|
||
|
import static org.easymock.EasyMock.mock;
|
||
|
|
||
|
/**
|
||
|
* @author Dylan.Liu
|
||
|
* @version 10.0
|
||
|
* Created by Dylan.Liu on 2019/12/3
|
||
|
*/
|
||
|
public class FineJedisPoolKitTest {
|
||
|
|
||
|
@Test
|
||
|
public void TestSetRealClient() {
|
||
|
|
||
|
FineJedisPoolKit.setRealClient(new FineJedisWrapper() {
|
||
|
|
||
|
@Override
|
||
|
public FineJedis getResource() {
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void destroy() {
|
||
|
|
||
|
}
|
||
|
});
|
||
|
Assert.assertNull(FineJedisPool.getInstance().getResource());
|
||
|
|
||
|
FineJedis mockFineJedis = mock(FineJedis.class);
|
||
|
expect(mockFineJedis.type(anyObject())).andReturn("TestFineJedis");
|
||
|
EasyMock.replay(mockFineJedis);
|
||
|
|
||
|
FineJedisPoolKit.setRealClient(new FineJedisWrapper() {
|
||
|
|
||
|
@Override
|
||
|
public FineJedis getResource() {
|
||
|
return mockFineJedis;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void destroy() {
|
||
|
|
||
|
}
|
||
|
});
|
||
|
Assert.assertEquals("TestFineJedis", FineJedisPool.getInstance().getResource().type(new byte[]{}));
|
||
|
}
|
||
|
|
||
|
}
|