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
package com.fanruan.api.cluster.state; |
|
|
|
import com.fr.store.impl.accessor.FineStore; |
|
import com.fr.store.impl.accessor.FineStorePool; |
|
import com.fr.store.impl.accessor.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[]{})); |
|
} |
|
|
|
} |