???????????????
???????????? ???????[ 2016/5/16 11:16:00 ] ??????????????? ???????
????????????????δ?????????????????????????????????????е?K-V????????С?????????????????1??С????????????????????1??С?????????????????????System.currentTimeMillis() ??JDK???????????????????????????????????????????????????????ж??????1??С??????????????????????????????????????????????????????????μ?????
// ????????
public interface SystemClock {
public long getCurrentTime();
}
// ???????е????
public class SystemClockImpl implements SystemClock {
@Override
public long getCurrentTime() {
return System.currentTimeMillis();
}
}
// ?????? ShortLifeMemoCache<T>
public class ShortLifeMemoCache<T> implements CacheService<T> {
private static final long DEFAULT_TTL = 1L*60*60*1000;
/**
* ???????λ:????
*/
private SystemClock systemClock;
/**
* ???????(Time to live)????λ:????
*/
private long ttl = DEFAULT_TTL;
private final Map<String?? Value<T>> cache = new HashMap<String?? Value<T>>();
@Override
public void put(String key?? T t) {
long life = systemClock.getCurrentTime() + ttl;
cache.put(key?? new Value<T>(t?? life));
}
@Override
public T get(String key) {
Value<T> v = cache.get(key);
if (v != null){
if(v.getLife() > systemClock.getCurrentTime()) {
return v.getValue();
} else {
cache.remove(key);
}
}
return null;
}
}
???????????????????????????????????????????????????????д???????????????????????????????
// ??????????????ttl=10???????FakeSystemClock????
public void testValueTimeout() {
long timeToLive = 10;
FakeSystemClock systemClock = new FakeSystemClock();
systemClock.setCurTime(0);
ShortLifeMemoCache<String> cacheService = new ShortLifeMemoCache<String>();
cacheService.setSystemClock(systemClock);
cacheService.setTtl(timeToLive);
cacheService.put("key1"?? "value1");
// after 10 seconds
systemClock.setCurTime(10);
assertNull(cacheService.get("key1"));
}
// Mock ?????
static class FakeSystemClock implements SystemClock {
private long curTime;
@Override
public long getCurrentTime() {
return curTime;
}
public long getCurTime() {
return curTime;
}
public void setCurTime(long curTime) {
this.curTime = curTime;
}
}
???????????????????????? - ??????????????????????????????????????????????????????????????????????????????????У???????????????????????????????????????????????????????ЩAndroid????????????????MVP??????? - ??????????MVP???????????View??Presenter??????????????????????MVP??????????????ù?????MVP????90?????????????10??????????????????鼮???棬???????????????MVP?????????????????????????MVP???????PassiveView-MVP????????????MVP???????????UI???С?3????
????????????????????б?????????y????????????????????????Щ???????????????????Mock?Щ????????API??????????????ЩMock????????? EasyMock??mockito ?????????Mock???????????????????jUnit??UI??????????? Robotium ??.
????????Android??UI?????????????????????????????????UI????/Ч????UI/????????????????????2????????С?????????????????????????UI???????????????????Model???棨Model???????????ModelingTheWorld????Model?????????????????????
????PS?????????
???????????????????????????? getter ?? setter ??????????????????????е???????????????????????“???????”???????????????????????????δ???
public class Foo {
private String message = "Hello World";
private String View view = new View();
public void print() {
System.out.println(message);
}
public void showMessage() {
view.display(message);
}
}
??????δ????? message ?? view ??????Foo??????????????????????? - ???????? ?????????? ?????????????к????????磺
//???????????ε??????
publicFoo(Stringmessage??Viewview){
this.message=message;
this.view=view;
}
//??????setter????
publicvoidsetMessage(Stringmessage){
this.message=message;
}
publicvoidsetView(Viewview){
this.view=view;
}
?????????????????????????????????????????????????????д?????????£???????????к??????????????Ioc?????????????Spring????????????????????????Android???????е?Dagger????
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
iOS???????mocha??chai??sinon??istanbul???????????????????????????????????????д?????Java????????7??????Android?????????Robolectric3.0????(?)???Kiwi?????????????????????????????????Python?????????????????????????????????????Controller????????д?????????10???????????????????Angular????????????Component??Directive??Pipe ???ServiceAndroid????????????????????????????????--Mockito??????iOS UnitTest???????Vue?????????????????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????