use of io.servicecomb.core.executor.ReactiveExecutor in project java-chassis by ServiceComb.
the class TestExecutors method testFixedThreadExecutor.
@Test
public void testFixedThreadExecutor() {
FixedThreadExecutor oFixedThreadExecutor = new FixedThreadExecutor();
oFixedThreadExecutor.execute(new Runnable() {
@Override
public void run() {
}
});
Map<Long, Executor> threadExectorMap = Deencapsulation.getField(oFixedThreadExecutor, "threadExectorMap");
Assert.assertEquals(true, (threadExectorMap.size() > 0));
List<Executor> executorList = Deencapsulation.getField(oFixedThreadExecutor, "executorList");
Assert.assertEquals(true, (executorList.size() > 1));
ReactiveExecutor oReactiveExecutor = new ReactiveExecutor();
oReactiveExecutor.execute(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
strThreadTest = "thread Ran";
}
});
Assert.assertEquals("thread Ran", strThreadTest);
}
use of io.servicecomb.core.executor.ReactiveExecutor in project java-chassis by ServiceComb.
the class TestHighwayServerInvoke method test.
@Test
public void test() {
MockUtil.getInstance().mockHighwayCodec();
SchemaMeta schemaMeta = unitTestMeta.getOrCreateSchemaMeta(Impl.class);
OperationMeta operationMeta = schemaMeta.ensureFindOperation("add");
operationMeta.setExecutor(new ReactiveExecutor());
HighwayServerInvoke highwayServerInvoke = new HighwayServerInvoke();
highwayServerInvoke.setMicroserviceMetaManager(unitTestMeta.getMicroserviceMetaManager());
RequestHeader requestHeader = MockUtil.getInstance().requestHeader;
// 初始化失败
requestHeader.setDestMicroservice(null);
Assert.assertFalse(highwayServerInvoke.init(netSocket, 0, null, null));
// 初始化成功
requestHeader.setDestMicroservice(schemaMeta.getMicroserviceName());
requestHeader.setSchemaId(schemaMeta.getSchemaId());
requestHeader.setOperationName(operationMeta.getOperationId());
Assert.assertTrue(highwayServerInvoke.init(netSocket, 0, requestHeader, null));
// exe成功
netSocketBuffer = null;
highwayServerInvoke.execute();
Assert.assertEquals(null, netSocketBuffer);
// exe失败
MockUtil.getInstance().decodeRequestSucc = false;
highwayServerInvoke.execute();
Assert.assertEquals(true, netSocketBuffer.toString().startsWith("CSE.TCP"));
}
Aggregations