|
|
|
package com.fanruan.api.cluster.state;
|
|
|
|
|
|
|
|
import com.fr.store.impl.accessor.FineStorePool;
|
|
|
|
import com.fr.store.impl.accessor.api.FineStore;
|
|
|
|
import com.fr.store.impl.accessor.api.FineStoreWrapper;
|
|
|
|
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 FineStoreWrapper() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public FineStore getResource() {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void destroy() {
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Assert.assertNull(FineStorePool.getInstance().getResource());
|
|
|
|
|
|
|
|
final FineStore mockFineJedis = mock(FineStore.class);
|
|
|
|
expect(mockFineJedis.type((byte[]) anyObject())).andReturn("TestFineJedis");
|
|
|
|
EasyMock.replay(mockFineJedis);
|
|
|
|
|
|
|
|
FineJedisPoolKit.setRealClient(new FineStoreWrapper() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public FineStore getResource() {
|
|
|
|
return mockFineJedis;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void destroy() {
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Assert.assertEquals("TestFineJedis", FineStorePool.getInstance().getResource().type(new byte[]{}));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|