use of mockit.MockUp in project java-chassis by ServiceComb.
the class TestCseServerList method mockTestCases.
private void mockTestCases() {
final Microservice microService = new Microservice();
microService.setAppId("appId");
new MockUp<RegistryUtils>() {
@Mock
public Microservice getMicroservice() {
return microService;
}
@Mock
private Microservice createMicroserviceFromDefinition() {
return microService;
}
};
new MockUp<InstanceCacheManager>() {
@Mock
public InstanceCache getOrCreate(String appId, String microserviceName, String microserviceVersionRule) {
return null;
}
};
}
use of mockit.MockUp in project java-chassis by ServiceComb.
the class TestServerListCache method mockTestCases.
private void mockTestCases() {
final Microservice microService = new Microservice();
microService.setAppId("appId");
new MockUp<RegistryUtils>() {
@Mock
public Microservice getMicroservice() {
return microService;
}
@Mock
private Microservice createMicroserviceFromDefinition() {
return microService;
}
};
new MockUp<InstanceCacheManager>() {
@Mock
public InstanceCache getOrCreate(String appId, String microserviceName, String microserviceVersionRule) {
return null;
}
};
transport = Mockito.mock(Transport.class);
}
use of mockit.MockUp in project java-chassis by ServiceComb.
the class TestSessionSticknessRule method testServerWithoutTimeoutAndThreshold.
@Test
public void testServerWithoutTimeoutAndThreshold() {
boolean status = true;
SessionStickinessRule ss = new SessionStickinessRule();
Object key = new Object();
Server s = new Server("test");
Deencapsulation.setField(ss, "lastServer", s);
new MockUp<SessionStickinessRule>() {
@Mock
private boolean isTimeOut() {
return false;
}
};
new MockUp<SessionStickinessRule>() {
@Mock
private boolean isErrorThresholdMet() {
return false;
}
};
try {
ss.choose(key);
} catch (Exception e) {
status = false;
}
Assert.assertTrue(status);
}
use of mockit.MockUp in project java-chassis by ServiceComb.
the class TestSessionSticknessRule method testServerWithoutTimeoutAndWithThreshold.
@Test
public void testServerWithoutTimeoutAndWithThreshold() {
boolean status = true;
SessionStickinessRule ss = new SessionStickinessRule();
Object key = new Object();
Server s = new Server("test");
Deencapsulation.setField(ss, "lastServer", s);
new MockUp<SessionStickinessRule>() {
@Mock
private boolean isTimeOut() {
return false;
}
};
new MockUp<SessionStickinessRule>() {
@Mock
private boolean isErrorThresholdMet() {
return true;
}
};
try {
ss.choose(key);
} catch (Exception e) {
status = false;
}
Assert.assertTrue(status);
}
use of mockit.MockUp in project java-chassis by ServiceComb.
the class TestSessionSticknessRule method testServerWithTimeout.
@Test
public void testServerWithTimeout() {
boolean status = true;
SessionStickinessRule ss = new SessionStickinessRule();
Object key = new Object();
Server s = new Server("test");
Deencapsulation.setField(ss, "lastServer", s);
new MockUp<SessionStickinessRule>() {
@Mock
private boolean isTimeOut() {
return true;
}
};
try {
ss.choose(key);
} catch (Exception e) {
status = false;
}
Assert.assertTrue(status);
}
Aggregations