项目:java-red
文件:TestRedFuture.java
/**
* Test the completion and callback invocation of {@link RedFutureHub}
* pessimistic union of provided futures that later were Failed
*/
@Test
public void testpessimisticProvidePostResolveFailure() throws Throwable {
AtomicBoolean reachedSuccessBlock = new AtomicBoolean(false);
AtomicBoolean reachedFailureBlock = new AtomicBoolean(false);
AtomicBoolean reachedFinallyBlock = new AtomicBoolean(false);
RedFutureHub hub = RedFuture.hub();
OpenRedFuture future1 = hub.provideFuture();
OpenRedFuture future2 = hub.provideFuture();
OpenRedFutureOf<Object> futureOf = hub.provideFutureOf();
RedFuture union = hub.unitepessimistically();
union.addSuccessCallback(() -> reachedSuccessBlock.set(true));
union.addFailureCallback(throwable -> reachedFailureBlock.set(true));
union.addFinallyCallback(() -> reachedFinallyBlock.set(true));
Assert.assertFalse(reachedFinallyBlock.get());
Assert.assertFalse(reachedSuccessBlock.get());
Assert.assertFalse(reachedFailureBlock.get());
future1.resolve();
future2.fail(new TestException());
futureOf.resolve(new Object());
Assert.assertTrue(reachedFinallyBlock.get());
Assert.assertTrue(reachedSuccessBlock.get());
Assert.assertFalse(reachedFailureBlock.get());
}
项目:store2store
文件:StoreServiceUnitTest.java
@Test
public void testDeleteallWithError(){
testStore.shouldThrowError(true);
models.clear();
List<TestModel> list = new ArrayList<>();
list.add(new TestModel(1));
list.add(new TestModel(2));
list.add(new TestModel(3));
memoryStore.insertOrUpdate(list);
TestSubscriber<Integer> observer = new TestSubscriber<>();
disposables.add(testStore.deleteall()
.subscribeOn(Schedulers.io())
.subscribeWith(observer));
observer.awaitTerminalEvent(5,SECONDS);
observer.assertError(Throwable.class);
observer.assertErrorMessage("deleteall.error");
testStore.shouldThrowError(false); // disable error
Assert.assertEquals(3,models.size());
}
项目:openjdk-jdk10
文件:ProfilingInfoTest.java
private void testNullSeen(String snippet) {
ProfilingInfo info = profile(snippet,1);
Assert.assertEquals(TriState.FALSE,info.getNullSeen(1));
continueProfiling(snippet,"ABC");
Assert.assertEquals(TriState.FALSE,new Object());
Assert.assertEquals(TriState.FALSE,info.getNullSeen(1));
if (TriState.TRUE == info.getNullSeen(1)) {
// See the javadoc comment for ProfilingInfoTest.
continueProfiling(snippet,(Object) null);
Assert.assertEquals(TriState.TRUE,info.getNullSeen(1));
continueProfiling(snippet,0.0);
Assert.assertEquals(TriState.TRUE,new Object());
Assert.assertEquals(TriState.TRUE,info.getNullSeen(1));
}
resetProfile(snippet);
Assert.assertEquals(TriState.FALSE,info.getNullSeen(1));
}
项目:flink-connectors
文件:IntSequenceExactlyOnceValidator.java
@Override
public void restoreState(List<Tuple2<Integer,BitSet>> state) throws Exception {
if (state.isEmpty()) {
Assert.fail("Function was restored without state - no checkpoint completed before.");
}
if (state.size() > 1) {
Assert.fail("Function was restored with multiple states. unexpected scale-in");
}
Tuple2<Integer,BitSet> s = state.get(0);
this.numElementsSoFar = s.f0;
this.duplicateChecker.clear();
this.duplicateChecker.or(s.f1);
log.debug("IntSequenceExactlyOnceValidator was restored with {} elements",numElementsSoFar);
}
@Test
public void testContains() throws InterruptedException {
RSetCache<TestObject> set = redisson.getSetCache("set");
set.add(new TestObject("1","2"));
set.add(new TestObject("1","2"));
set.add(new TestObject("2","3"),1,TimeUnit.SECONDS);
set.add(new TestObject("3","4"));
set.add(new TestObject("5","6"));
Thread.sleep(1000);
Assert.assertFalse(set.contains(new TestObject("2","3")));
Assert.assertTrue(set.contains(new TestObject("1","2")));
Assert.assertFalse(set.contains(new TestObject("1","9")));
}
public void testItem_0172()
{
boolean caught;
caught = false;
try {
rc_BigDecimal = new BigDecimal(new char[]{'8','\1','\uFFFF','8','\234','\0','8'},new MathContext("precision=2147483647 roundingMode=HALF_EVEN"));
}
catch (java.lang.NumberFormatException e) {
caught = true;
}
Assert.assertEquals("91.94630872483222%",true,caught);
}
public void testItem_0251()
{
boolean caught;
caught = false;
try {
rc_BigDecimal = (new BigDecimal("-9000000000000.0")).pow(-1,new MathContext("precision=0 roundingMode=HALF_EVEN"));
}
catch (java.lang.ArithmeticException e) {
caught = true;
}
Assert.assertEquals("91.94630872483222%",caught);
}
项目:linkifier
文件:RegressionTest.java
@Test
public void test122() throws Throwable {
if (debug)
System.out.format("%n%s%n","RegressionTest0.test122");
Table table2 = new Table("",",");
List<String> list_str3 = table2.getTokenizedLowerCaseTrimmedname();
DatabaseMetaData databaseMetaData4 = null;
try {
table2.getPrimaryKeys(databaseMetaData4,"",");
Assert.fail("Expected exception of type java.lang.NullPointerException");
} catch (NullPointerException e) {
}
Assert.assertNull(list_str3);
}
项目:GitHub
文件:TypeUtilsTest.java
项目:linkifier
文件:RegressionTest.java
@Test
public void test007() throws Throwable {
if (debug)
System.out.format("%n%s%n","RegressionTest0.test007");
Relationship relationship0 = new Relationship();
Column column1 = relationship0.getPk();
Chen chen2 = null;
try {
relationship0.setMediumFeatures(chen2);
Assert.fail("Expected exception of type java.lang.NullPointerException");
} catch (NullPointerException e) {
}
Assert.assertNull(column1);
}
项目:hashsdn-controller
文件:ValidationExceptionTest.java
@Test
public void testEqual5() throws Exception {
ValidationException.ExceptionMessageWithStackTrace exp = new ValidationException.ExceptionMessageWithStackTrace(
null,"string2");
ValidationException.ExceptionMessageWithStackTrace exp2 =
new ValidationException.ExceptionMessageWithStackTrace(
"string1","string2");
Assert.assertNotEquals(exp,exp2);
}
项目:flow-platform
文件:JobControllerTest.java
@Test
public void should_get_job_zip_success() throws Exception {
stubDemo();
Node rootForFlow = createRootFlow("flow1","yml/flow.yaml");
Job job = jobService.createFromFlowYml(rootForFlow.getPath(),JobCategory.TAG,null,mockUser);
job.putEnv(GitEnvs.FLOW_GIT_BRANCH,"master");
job.setStatus(JobStatus.SUCCESS);
jobDao.update(job);
List<NodeResult> nodeResultList = nodeResultService.list(job,true);
for (NodeResult nodeResult : nodeResultList) {
nodeResult.setCmdId("xxxx");
nodeResultService.update(nodeResult);
}
MvcResult mvcResult = this.mockmvc.perform(
get(String.format("/jobs/%s/%s/log/download",job.getNodeName(),job.getNumber()))
).andExpect(status().isOk()).andReturn();
String response = mvcResult.getResponse().getContentAsstring();
Assert.assertNotNull(response);
Path zipLog = Paths
.get(workspace.toString(),"log",job.getId().toString(),job.getId().toString() + ".zip");
File zipFile = new File(zipLog.toString());
Assert.assertEquals(true,zipFile.exists());
}
public void testItem_0045()
{
boolean caught;
caught = false;
try {
rc_BigDecimal = new BigDecimal(new char[]{'\1','\uFFFF'},new MathContext("precision=1 roundingMode=HALF_UP"));
}
catch (java.lang.NumberFormatException e) {
caught = true;
}
Assert.assertEquals("91.94630872483222%",caught);
}
项目:GitHub
文件:JSONSerializerTest.java
public void test_3_s() throws Exception {
JSONSerializer serializer = new JSONSerializer();
serializer.write(new JSONAware() {
public String toJSONString() {
return "null";
}
});
Assert.assertEquals("null",serializer.getWriter().toString());
}
public void testItem_0697()
{
boolean caught;
caught = false;
try {
rc_MathContext = new MathContext("S5:FS:9C;4BQIG?=1VYKGM=<=<R;RBS3O8IHYARO1ST2SHL;6L;S5312X;O4:9:FOMG<DOTQT?6X5NE1T6OB3VCGIQ04J4M4812?");
}
catch (java.lang.IllegalArgumentException e) {
caught = true;
}
Assert.assertEquals("91.61073825503355%",caught);
}
项目:linkifier
文件:RegressionTest.java
@Test
public void test324() throws Throwable {
if (debug)
System.out.format("%n%s%n","RegressionTest0.test324");
Relationship relationship0 = new Relationship();
Column column1 = relationship0.getPk();
String str2 = relationship0.getSchema();
Boolean b3 = relationship0.getDataTypeCategoryAgree();
Column column6 = new Column(","");
column6.setEstimatedRowCount((int) (byte) 0);
Boolean b9 = column6.isBestAttemptPk();
relationship0.setPk(column6);
Boolean b11 = column6.isBestAttemptPk();
Table[] table_array12 = new Table[] {};
ArrayList<Table> arraylist_table13 = new ArrayList<Table>();
boolean b14 = Collections.addAll(arraylist_table13,table_array12);
List<Table> list_table15 = Optimization.optimize(arraylist_table13);
column6.setMinLDOtherTable(arraylist_table13);
column6.setKeywords();
column6.setDecimalDigits((int) 'a');
column6.setUniqueConstraint(true);
Integer i22 = column6.getLD();
Assert.assertNull(column1);
Assert.assertNull(str2);
Assert.assertNull(b3);
Assert.assertTrue("'" + b9 + "' != '" + false + "'",b9.equals(false));
Assert.assertTrue("'" + b11 + "' != '" + false + "'",b11.equals(false));
Assert.assertNotNull(table_array12);
Assert.assertTrue(b14 == false);
Assert.assertNotNull(list_table15);
Assert.assertNull(i22);
}
public void testItem_0411()
{
boolean caught;
caught = false;
try {
rc_int = (new BigDecimal("320.0E+2147483647")).intValueExact();
}
catch (java.lang.ArithmeticException e) {
caught = true;
}
Assert.assertEquals("91.94630872483222%",caught);
}
@Test
public void testCreate() throws Exception {
ConfigCenterConfigurationSourceImpl configCenterSource = new ConfigCenterConfigurationSourceImpl();
configCenterSource.addUpdateListener(new WatchedUpdateListener() {
@Override
public void updateConfiguration(WatchedUpdateResult result) {
Assert.assertTrue(!result.getAdded().isEmpty());
}
});
UpdateHandler udateHandler = Deencapsulation.getField(configCenterSource,UpdateHandler.class);
Map<String,Object> addedItems = new HashMap<>();
addedItems.put("testKey","testValue");
udateHandler.handle("create",addedItems);
}
项目:mycat-src-1.6.1-RELEASE
文件:ServerParserTest.java
@Test
public void testIsSelectVersionComment() {
Assert.assertEquals(ServerParseSelect.VERSION_COMMENT,ServerParseSelect.parse(" select @@version_comment ",7));
Assert.assertEquals(ServerParseSelect.VERSION_COMMENT,ServerParseSelect.parse("SELECT @@VERSION_COMMENT",6));
Assert.assertEquals(ServerParseSelect.VERSION_COMMENT,ServerParseSelect.parse(" selECT @@VERSION_comment ",7));
}
项目:nfse
文件:LoteRpsConsultaSituacaoTest.java
@Test
public void xmlDeveSerGeradoCorretamente() throws IOException{
String xmlTest = IoUtils.toString(getClass().getClassLoader().getResourceAsstream("loteRpsConsultaSituacao.xml"));
LoteRpsConsultaSituacao consultaSituacaoLote = new LoteRpsConsultaSituacao("AP1057893n16X103sfhF4RPm",FabricaDeObjetosFake.getRpsPrestador());
String xml = consultaSituacaoLote.converterParaXml();
Assert.assertEquals(xml,xmlTest);
}
项目:simm-lib
文件:BigDecimalUtilsTest.java
@Test
public void sumInStream() {
List<BigDecimal> list = Arrays.asList(new BigDecimal("1"),new BigDecimal("3"));
Assert.assertEquals(new BigDecimal("4"),list.stream().reduce(BigDecimalUtils::sum).get());
List<BigDecimal> list2 = Arrays.asList(new BigDecimal("1"),new BigDecimal("3"),new BigDecimal("5"));
Assert.assertEquals(new BigDecimal("9"),list2.parallelStream().reduce(BigDecimalUtils::sum).get());
}
项目:coffee-gb
文件:LfsrTest.java
项目:GitHub
文件:NativePooledByteBufferFactoryTest.java
private void assertArrayEquals(byte[] expected,byte[] actual,int length) {
Assert.assertTrue(expected.length >= length);
Assert.assertTrue(actual.length >= length);
for (int i = 0; i < length; i++) {
Assert.assertEquals(expected[i],actual[i],i);
}
}
项目:angel
文件:UpdateFuncTest.java
@Test
public void testMulS() throws Exception {
UpdateFunc func = new MulS(w2Client.getMatrixId(),3,-1.0);
w2Client.update(func).get();
double[] addResult = pull(w2Client,3);
assert(addResult.length == dim);
for (int i = 0; i < addResult.length; i++) {
Assert.assertEquals(addResult[i],localArray0[i] * -1.0,delta);
}
}
项目:BachelorPraktikum
文件:SonySWR21ImporterTest.java
/**
* Test to see whether the plugin can be loaded.
*/
@Test
public void pluginLoad() {
PluginManager manager = new DefaultPluginManager(Paths.get("export"));
manager.loadplugins();
Assert.assertTrue(0 != manager.getPlugins().size());
}
项目:incubator-servicecomb-java-chassis
文件:TestPartTomultipartfile.java
@Test
public void isEmptyTrue() {
new Expectations() {
{
part.getSize();
result = 0;
}
};
Assert.assertTrue(multipartfile.isEmpty());
}
项目:autorest.java
文件:HttpRedirectsTests.java
@Test
@Ignore("Not supported yet")
public void put301() throws Exception {
client.httpRedirects().put301WithServiceResponseAsync()
.subscribe(new Action1<ServiceResponseWithHeaders<Void,HttpRedirectsPut301Headers>>() {
@Override
public void call(ServiceResponseWithHeaders<Void,HttpRedirectsPut301Headers> response) {
Assert.assertEquals(301,response.response().code());
lock.countDown();
}
});
Assert.assertTrue(lock.await(1000,TimeUnit.MILLISECONDS));
}
项目:incubator-servicecomb-java-chassis
文件:TestProducerSchemaFactory.java
@Test
public void testGetorCreateProducer() throws Exception {
OperationMeta operationMeta = schemaMeta.ensureFindOperation("add");
Assert.assertEquals("add",operationMeta.getoperationId());
SwaggerProducerOperation producerOperation = operationMeta.getExtData(Const.PRODUCER_OPERATION);
Object addBody = Class.forName("cse.gen.app.ms.schema.addBody").newInstance();
ReflectUtils.setField(addBody,"x",1);
ReflectUtils.setField(addBody,"y",2);
Invocation invocation = new Invocation((Endpoint) null,operationMeta,new Object[] {addBody}) {
@Override
public String getInvocationQualifiedname() {
return "";
}
};
Holder<Response> holder = new Holder<>();
producerOperation.invoke(invocation,resp -> {
holder.value = resp;
});
Assert.assertEquals(3,(int) holder.value.getResult());
invocation.setSwaggerArguments(new Object[] {1,2});
producerOperation.invoke(invocation,resp -> {
holder.value = resp;
});
Assert.assertEquals(true,holder.value.isFailed());
InvocationException exception = (InvocationException) holder.value.getResult();
CommonExceptionData data = (CommonExceptionData) exception.getErrorData();
Assert.assertEquals("Cse Internal Server Error",data.getMessage());
}
项目:CodeKatas
文件:JDK8DeckOfCardsAsSortedSetTest.java
@Test
public void cardsBySuit()
{
Map<Suit,SortedSet<Card>> jdk1CardsBySuit = this.jdk1Deck.getCardsBySuit();
Map<Suit,SortedSet<Card>> jdk2CardsBySuit = this.jdk2Deck.getCardsBySuit();
Assert.assertEquals(jdk1CardsBySuit.get(Suit.CLUBS),jdk2CardsBySuit.get(Suit.CLUBS));
}
public void testItem_0626()
{
boolean caught;
caught = false;
try {
rc_BigDecimal = new BigDecimal(new java.math.BigInteger("32"),new MathContext("precision=1 roundingMode=UNNECESSARY"));
}
catch (java.lang.ArithmeticException e) {
caught = true;
}
Assert.assertEquals("89.93288590604027%",caught);
}
项目:redirector
文件:AppModelRestFacadeTest.java
@Ignore("Do we still need it? We don't get this version from Zk")
@Test
public void testGetModelVersionStatsNull() throws Exception {
setupSuccessfullyConnectingPerServiceCache(true);
setupGetVersionThrowsException();
testee.start();
Assert.assertEquals(RedirectorConstants.NO_MODEL_NODE_VERSION,testee.getModelVersion());
}
项目:mybatis-generator-plugin
文件:UpsertPluginTest.java
/**
* 测试配置异常
*/
@Test
public void testWarnings() throws IOException,XMLParserException,InvalidConfigurationException,InterruptedException,sqlException {
// 1. 没有使用MysqL数据库
MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/UpsertPlugin/mybatis-generator-with-error-driver.xml");
tool.generate();
Assert.assertEquals(tool.getWarnings().get(1),"itfsw:插件com.itfsw.mybatis.generator.plugins.UpsertPlugin插件使用前提是数据库为MysqL!");
// 2. 普通提示
tool = MyBatisGeneratorTool.create("scripts/UpsertPlugin/mybatis-generator.xml");
tool.generate();
Assert.assertEquals(tool.getWarnings().get(0),"itfsw:插件com.itfsw.mybatis.generator.plugins.UpsertPlugin插件您开启了allowMultiQueries支持,注意在jdbc url 配置中增加“allowMultiQueries=true”支持(不怎么建议使用该功能,开启多sql提交会增加sql注入的风险,请确保你所有sql都使用MyBatis书写,请不要使用statement进行sql提交)!");
}
public void testItem_0113()
{
boolean caught;
caught = false;
try {
rc_BigDecimal = (new BigDecimal("8507059173023461584739690778423250124.9")).divide(new BigDecimal("0"),-2147483648,2147483647);
}
catch (java.lang.IllegalArgumentException e) {
caught = true;
}
Assert.assertEquals("89.93288590604027%",caught);
}
public void testItem_0955()
{
rc_BigDecimal = (new BigDecimal("179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368")).min(new BigDecimal("1.0"));
Assert.assertEquals("1.0",rc_BigDecimal.toString());
}
public void testItem_0606()
{
rc_BigDecimal = (new BigDecimal("0.0")).multiply(new BigDecimal("0.0"));
Assert.assertEquals("0.00",rc_BigDecimal.toString());
}
项目:sats-core
文件:BMValueTest.java
@Test
public void valueOfCompleteBundle() {
Bundle<BMLicense> bundle = new Bundle<>(bidder.getWorld().getLicenses());
BigDecimal value = bidder.calculateValue(bundle);
Assert.assertTrue(bidder.getSetupType() + " value was " + value + " should be " + expextedValuedCompleteBundle,value.compareto(expextedValuedCompleteBundle) == 0);
}
public void testItem_0673()
{
rc_BigDecimal = new BigDecimal(-1.0);
Assert.assertEquals("-1",rc_BigDecimal.toString());
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。