本文整理汇总了Java中junit.framework.Assert.assertTrue方法的典型用法代码示例。如果您正苦于以下问题:Java Assert.assertTrue方法的具体用法?Java Assert.assertTrue怎么用?Java Assert.assertTrue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类junit.framework.Assert
的用法示例。
在下文中一共展示了Assert.assertTrue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDecode_PersonWithEnterByte
import junit.framework.Assert; //导入方法依赖的package包/类
private void testDecode_PersonWithEnterByte(byte[] enterbytes ,boolean isNeedmore) throws IOException{
//init channel
Channel channel = getServerSideChannel(url);
//init request string
Person request = new Person();
byte[] newbuf = join(objectToByte(request), enterbytes);
ChannelBuffer buffer = ChannelBuffers.wrappedBuffer(newbuf);
//decode
Object obj = codec.decode(channel, buffer);
if (isNeedmore){
Assert.assertEquals(Codec2.DecodeResult.NEED_MORE_INPUT , obj);
}else {
Assert.assertTrue("return must string ", obj instanceof String);
}
}
示例2: buildParamList
import junit.framework.Assert; //导入方法依赖的package包/类
private Object[] buildParamList(Invokable<?, ?> invokable, int indexOfParamToSetToNull) {
ImmutableList<Parameter> params = invokable.getParameters();
Object[] args = new Object[params.size()];
for (int i = 0; i < args.length; i++) {
Parameter param = params.get(i);
if (i != indexOfParamToSetToNull) {
args[i] = getDefaultValue(param.getType());
Assert.assertTrue(
"Can't find or create a sample instance for type '"
+ param.getType()
+ "'; please provide one using NullPointerTester.setDefault()",
args[i] != null || isNullable(param));
}
}
return args;
}
示例3: testFirstPeriodSucceedsSecondPeriodWithInterval
import junit.framework.Assert; //导入方法依赖的package包/类
/**
* (TIMESTAMP '2000-02-01 01:02:03', INTERVAL '31' DAY)
* SUCCEEDS
* (TIMESTAMP '2000-01-01 01:02:03', , INTERVAL '31' DAY)
* is true
*/
public void testFirstPeriodSucceedsSecondPeriodWithInterval() {
Object[] a = {
scanner.newTimestamp("2000-02-01 01:02:03"),
scanner.newInterval(
"31",
IntervalType.newIntervalType(Types.SQL_INTERVAL_DAY, 2, 0))
};
Object[] b = {
scanner.newTimestamp("2000-01-01 01:02:03"),
scanner.newInterval(
"31",
IntervalType.newIntervalType(Types.SQL_INTERVAL_DAY, 2, 0))
};
Type[] ta = {
new DateTimeType(Types.SQL_TIMESTAMP, Types.SQL_TIMESTAMP, 0),
IntervalType.newIntervalType(Types.SQL_INTERVAL_DAY, 2, 0)
};
Type[] tb = {
new DateTimeType(Types.SQL_TIMESTAMP, Types.SQL_TIMESTAMP, 0),
IntervalType.newIntervalType(Types.SQL_INTERVAL_DAY, 2, 0)
};
Assert.assertTrue(DateTimeType.succeeds(session, a, ta, b, tb));
}
示例4: testShowLoading
import junit.framework.Assert; //导入方法依赖的package包/类
@Test public void testShowLoading() {
final AtomicBoolean loadingCalled = new AtomicBoolean(false);
LoginView view = new LoginView() {
@Override public void showLoginForm() {
Assert.fail("showLoginForm() instead of showLoading()");
}
@Override public void showError() {
Assert.fail("showError() instead of showLoading()");
}
@Override public void showLoading() {
loadingCalled.set(true);
}
@Override public void loginSuccessful() {
Assert.fail("loginSuccessful() instead of showLoading()");
}
};
LoginViewState viewState = new LoginViewState();
viewState.setShowLoading();
viewState.apply(view, false);
Assert.assertTrue(loadingCalled.get());
}
示例5: testStartCondition
import junit.framework.Assert; //导入方法依赖的package包/类
@Test
public void testStartCondition() throws Exception {
final BaseCondition mockCondition = new BaseCondition();
mockCondition.startDate = TEST_DATE_FORMAT.parse("2016-02-01 18:00:00");
mockCondition.endDate = null;
mockCondition.newUsersOnly = false;
Assert.assertTrue(mockCondition.isSatisfied(new MockDateProvider(TEST_DATE_FORMAT.parse("2016-02-01 18:00:00"), null)));
Assert.assertTrue(mockCondition.isSatisfied(new MockDateProvider(TEST_DATE_FORMAT.parse("2016-02-01 18:00:01"), null)));
Assert.assertFalse(mockCondition.isSatisfied(new MockDateProvider(TEST_DATE_FORMAT.parse("2016-02-01 17:59:59"), null)));
}
示例6: testSetSeed
import junit.framework.Assert; //导入方法依赖的package包/类
@Test
public void testSetSeed() {
long current = TransactionIDOracle.next();
current += Integer.MAX_VALUE;
TransactionIDOracle.setSeed(current);
Assert.assertTrue(TransactionIDOracle.next() > System.currentTimeMillis());
}
示例7: addColumnIfCreate
import junit.framework.Assert; //导入方法依赖的package包/类
@Test
public void addColumnIfCreate() {
String sql = parseSql(originSql1);
System.out.println(sql);
boolean contains = sql.contains("_mycat_op_time ");
Assert.assertTrue(contains);
sql = parseSql(originSql2);
System.out.println(sql);
Assert.assertFalse(sql.contains("_mycat_op_time int COMMENT '全局表保存修改时间戳的字段名'"));
}
示例8: testExtraRunList4Wo
import junit.framework.Assert; //导入方法依赖的package包/类
@Test
public void testExtraRunList4Wo() {
List<String> classes = new ArrayList<>();
classes.add("cloud.compliance.Security");
classes.add("cloud.compliance.Security");
classes.add("cloud.compliance.Dummy");
classes.add("cloud.compliance.Dummy");
CmsWorkOrderSimple wo = new CmsWorkOrderSimple();
wo.putPayLoadEntry(InductorConstants.EXTRA_RUN_LIST,getRfcCiForExtraRunList(classes));
CmsRfcCISimple rfci = new CmsRfcCISimple();
rfci.setRfcAction("add");
wo.setRfcCi(rfci);
List<String> runList = woExecutor.getExtraRunListClasses(wo);
Assert.assertFalse(runList.isEmpty());
Assert.assertEquals(2, runList.size());
String securityRecipe = AbstractOrderExecutor.RUN_LIST_PREFIX + "security" + AbstractOrderExecutor.RUN_LIST_SEPARATOR +
"add" + AbstractOrderExecutor.RUN_LIST_SUFFIX;
String dummyRecipe = AbstractOrderExecutor.RUN_LIST_PREFIX + "dummy" + AbstractOrderExecutor.RUN_LIST_SEPARATOR +
"add" + AbstractOrderExecutor.RUN_LIST_SUFFIX;
Assert.assertTrue(runList.contains(securityRecipe));
Assert.assertTrue(runList.contains(dummyRecipe));
classes = null;
wo.putPayLoadEntry(InductorConstants.EXTRA_RUN_LIST,getRfcCiForExtraRunList(classes));
List<String> runList1 = woExecutor.getExtraRunListClasses(wo);
Assert.assertTrue(runList1.isEmpty());
}
示例9: testTextCat
import junit.framework.Assert; //导入方法依赖的package包/类
@Test
public void testTextCat() throws IOException, ClassNotFoundException {
String luo = "e kaka otimre e polo ka Nyasaye";
Result res = tc.detectLanguage(luo);
Assert.assertTrue(res.languageCode.equals("luo"));
String amh = "የሳውዲ ፖሊስ ለሃጃጅ ያለው ክብር ይህን ያህል ነው።";
res = tc.detectLanguage(amh);
Assert.assertTrue(res.languageCode.equals("amh"));
}
示例10: testSelectBalance
import junit.framework.Assert; //导入方法依赖的package包/类
/**
* 测试均衡.
*/
@Test
public void testSelectBalance(){
LoadBalance lb = ExtensionLoader.getExtensionLoader(LoadBalance.class).getExtension(RoundRobinLoadBalance.NAME);
initlistsize5();
Map<Invoker,AtomicLong> counter = new ConcurrentHashMap<Invoker,AtomicLong>();
for(Invoker invoker :invokers){
counter.put(invoker, new AtomicLong(0));
}
int runs = 1000;
for(int i=0;i<runs;i++){
selectedInvokers.clear();
Invoker sinvoker = cluster.select(lb, invocation, invokers, selectedInvokers);
counter.get(sinvoker).incrementAndGet();
}
for (Invoker minvoker :counter.keySet() ){
Long count = counter.get(minvoker).get();
// System.out.println(count);
if(minvoker.isAvailable())
Assert.assertTrue("count should > avg", count>runs/invokers.size());
}
Assert.assertEquals(runs, counter.get(invoker2).get()+counter.get(invoker4).get());;
}
示例11: testInjvm
import junit.framework.Assert; //导入方法依赖的package包/类
@Test
public void testInjvm() throws Exception {
ApplicationConfig application = new ApplicationConfig();
application.setName("test-protocol-random-port");
RegistryConfig registry = new RegistryConfig();
registry.setAddress("multicast://224.5.6.7:1234");
ProtocolConfig protocol = new ProtocolConfig();
protocol.setName("dubbo");
ServiceConfig<DemoService> demoService;
demoService = new ServiceConfig<DemoService>();
demoService.setInterface(DemoService.class);
demoService.setRef(new DemoServiceImpl());
demoService.setApplication(application);
demoService.setRegistry(registry);
demoService.setProtocol(protocol);
ReferenceConfig<DemoService> rc = new ReferenceConfig<DemoService>();
rc.setApplication(application);
rc.setRegistry(registry);
rc.setInterface(DemoService.class.getName());
rc.setInjvm(false);
try {
demoService.export();
rc.get();
Assert.assertTrue(!Constants.LOCAL_PROTOCOL.equalsIgnoreCase(
rc.getInvoker().getUrl().getProtocol()));
} finally {
demoService.unexport();
}
}
示例12: testCanMove
import junit.framework.Assert; //导入方法依赖的package包/类
@Test
public void testCanMove() {
Assert.assertTrue(DotsHelper.canMove(layer));
layer.set(1, 0, DotsHelper.MARK);
Assert.assertTrue(DotsHelper.canMove(layer));
layer.set(2, 1, DotsHelper.MARK);
Assert.assertTrue(DotsHelper.canMove(layer));
layer.set(0, 1, DotsHelper.MARK);
Assert.assertTrue(DotsHelper.canMove(layer));
layer.set(1, 2, DotsHelper.MARK);
Assert.assertFalse(DotsHelper.canMove(layer));
}
示例13: testgetByIds
import junit.framework.Assert; //导入方法依赖的package包/类
@Test
public void testgetByIds() {
List<Integer> ids = new ArrayList<Integer>(10);
String order = null;
String sortColumn = "id";
ids.add(1);
ids.add(2);
ids.add(3);
ids.add(10);
ids.add(11);
ids.add(12);
ids.add(10720);
List<MobileSearchApp> list = appMapper.getByIds(ids, sortColumn, order);
Assert.assertNotNull(list);
Assert.assertFalse(list.isEmpty());
sortColumn = "name";
order = "desc";
List<MobileSearchApp> list1 = appMapper.getByIds(ids, sortColumn, order);
Assert.assertNotNull(list);
Assert.assertFalse(list.isEmpty());
boolean notSame = false;
for (int i = 0; i < list1.size(); i++) {
MobileSearchApp app = list.get(i);
MobileSearchApp app1 = list1.get(i);
if (!app.equals(app1)) {
notSame = true;
break;
}
}
Assert.assertTrue(notSame);
}
示例14: acceptInvitationLinkFailedTest
import junit.framework.Assert; //导入方法依赖的package包/类
private void acceptInvitationLinkFailedTest(String url, String password) {
ResponseZerokitInvitationLinkInfo invitationLinkInfo = getInvitationLinkInfo(url.substring(1));
Response<String, ResponseZerokitError> response = acceptInvitationLink_noassert(invitationLinkInfo.getToken(), password);
Assert.assertTrue(response.isError());
}
示例15: testFull
import junit.framework.Assert; //导入方法依赖的package包/类
@Test
public void testFull() {
double first, second;
cards.clear();
cards.add(new Card(12, HEARTS));
cards.add(new Card(10, SPADES));
cards.add(new Card(10, HEARTS));
cards.add(new Card(10, CLUBS));
cards.add(new Card(8, CLUBS));
cards.add(new Card(8, DIAMONDS));
cards.add(new Card(4, CLUBS));
hand = HandEvaluator.evaluateFull(cards);
Assert.assertTrue(hand instanceof Full);
first = hand.getPoints();
cards.clear();
cards.add(new Card(12, HEARTS));
cards.add(new Card(9, SPADES));
cards.add(new Card(9, HEARTS));
cards.add(new Card(9, CLUBS));
cards.add(new Card(8, CLUBS));
cards.add(new Card(8, DIAMONDS));
cards.add(new Card(2, CLUBS));
hand = HandEvaluator.evaluateFull(cards);
Assert.assertTrue(hand instanceof Full);
second = hand.getPoints();
Assert.assertTrue(first > second);
cards.clear();
cards.add(new Card(12, HEARTS));
cards.add(new Card(10, SPADES));
cards.add(new Card(10, HEARTS));
cards.add(new Card(10, CLUBS));
cards.add(new Card(7, CLUBS));
cards.add(new Card(7, DIAMONDS));
cards.add(new Card(2, CLUBS));
hand = HandEvaluator.evaluateFull(cards);
Assert.assertTrue(hand instanceof Full);
second = hand.getPoints();
Assert.assertTrue(first > second);
cards.clear();
cards.add(new Card(12, HEARTS));
cards.add(new Card(9, SPADES));
cards.add(new Card(9, HEARTS));
cards.add(new Card(9, CLUBS));
cards.add(new Card(11, CLUBS));
cards.add(new Card(11, DIAMONDS));
cards.add(new Card(2, CLUBS));
hand = HandEvaluator.evaluateFull(cards);
Assert.assertTrue(hand instanceof Full);
second = hand.getPoints();
Assert.assertTrue(first > second);
cards.clear();
cards.add(new Card(11, SPADES));
cards.add(new Card(10, SPADES));
cards.add(new Card(10, HEARTS));
cards.add(new Card(10, CLUBS));
cards.add(new Card(8, CLUBS));
cards.add(new Card(8, DIAMONDS));
cards.add(new Card(2, CLUBS));
hand = HandEvaluator.evaluateFull(cards);
Assert.assertTrue(hand instanceof Full);
second = hand.getPoints();
Assert.assertTrue(first == second);
}