Java Code Examples for junit.framework.Assert.assertTrue()

The following are Jave code examples for showing how to use assertTrue() of the junit.framework.Assert class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: dubbocloud   File: TelnetCodecTest.java   View Source Code Vote up 6 votes
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);
    }
}
 
Example 2
Project: guava-mock   File: NullPointerTester.java   View Source Code Vote up 6 votes
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;
}
 
Example 3
Project: OpenDiabetes   File: TestPeriodPredicates.java   View Source Code Vote up 6 votes
/**
 * (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));
}
 
Example 4
Project: GitHub   File: LoginViewStateTest.java   View Source Code Vote up 5 votes
@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());
  }
 
Example 5
Project: unlock-android   File: ConditionTests.java   View Source Code Vote up 5 votes
@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)));
}
 
Example 6
Project: flume-release-1.7.0   File: TestTransactionIDOracle.java   View Source Code Vote up 5 votes
@Test
public void testSetSeed() {
  long current = TransactionIDOracle.next();
  current += Integer.MAX_VALUE;
  TransactionIDOracle.setSeed(current);
  Assert.assertTrue(TransactionIDOracle.next() > System.currentTimeMillis());
}
 
Example 7
Project: mycat-src-1.6.1-RELEASE   File: GlobalTableUtilTest.java   View Source Code Vote up 5 votes
@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 '全局表保存修改时间戳的字段名'"));
}
 
Example 8
Project: oneops   File: WoExecutorTest.java   View Source Code Vote up 5 votes
@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());
}
 
Example 9
Project: Babler   File: TestLanguageIdentifier.java   View Source Code Vote up 5 votes
@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"));

}
 
Example 10
Project: dubbox-hystrix   File: AbstractClusterInvokerTest.java   View Source Code Vote up 5 votes
/**
     * 测试均衡.
     */
    @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());;
        
    }
 
Example 11
Project: dubbocloud   File: ReferenceConfigTest.java   View Source Code Vote up 5 votes
@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();
    }
}
 
Example 12
Project: gamesboard   File: DotsHelperTest.java   View Source Code Vote up 5 votes
@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));
}
 
Example 13
Project: sjk   File: AppMapperTest.java   View Source Code Vote up 5 votes
@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);
}
 
Example 14
Project: ZeroKit-Android-SDK   File: InstrumentedTest.java   View Source Code Vote up 4 votes
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());
}
 
Example 15
Project: Progetto-J   File: HandEvaluatorTest.java   View Source Code Vote up 4 votes
@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);
}
 
Example 16
Project: Pogamut3   File: Test04_AgentRunner_UtilityMethods.java   View Source Code Vote up 4 votes
@Test
public void test_start5AgentsWithDifferentParams() {		
	
	IAgentRunner runner = initAgentRunner();
	
	int NUM_AGENTS = 5;
	
	System.out.println("Starting " + NUM_AGENTS + " agents with different parameters...");
	
	TestAgentParams[] params = new TestAgentParams[NUM_AGENTS];
	for (int i = 0; i < NUM_AGENTS; ++i) {
		params[i] = new TestAgentParams(i);
	}		
	List<AbstractAgent> agents = runner.startAgents(params);		
	System.out.println("Checking agents classes...");		
	for (int i = 0; i < NUM_AGENTS; ++i) {
		Assert.assertTrue(agents.get(i) instanceof TestAgent1);
	}
	System.out.println("OK");
	
	System.out.println("Checking agents running...");
	for (int i = 0; i < NUM_AGENTS; ++i) {
		Assert.assertTrue(agents.get(i).getState().getFlag().isState(IAgentStateUp.class));
	}
	System.out.println("OK");
	
	System.out.println("Check agents' parameters...");
	for (int i = 0; i < NUM_AGENTS; ++i) {
		Assert.assertTrue(((TestAgent1)agents.get(i)).getParam() == i);
	}
	System.out.println("OK");
			
	System.out.println("Stopping " + NUM_AGENTS + " agents...");
	for (int i = 0; i < NUM_AGENTS; ++i) {
		agents.get(i).stop();
	}		
	System.out.println("Checking agents stopped...");
	for (int i = 0; i < NUM_AGENTS; ++i) {
		Assert.assertTrue(agents.get(i).getState().getFlag().isState(IAgentStateDown.class));
	}
	System.out.println("OK");
	
	checkAgentRunnerCalls(NUM_AGENTS);
	
	System.out.println("---/// TEST OK ///---");
}
 
Example 17
Project: Pogamut3   File: Test12_MultipleAgentRunner_UtilityMethods.java   View Source Code Vote up 4 votes
@Test
public void test_start5Agents() {		
	
	IMultipleAgentRunner runner = initMultipleAgentRunner();
	
	int NUM_AGENTS = 5;
	
	System.out.println("Starting " + NUM_AGENTS + " agents...");
	List<AbstractAgent> agents = runner.startAgents(initDescriptors(NUM_AGENTS));
	System.out.println("Checking agents classes...");		
	for (int i = 0; i < NUM_AGENTS; ++i) {
		Assert.assertTrue(agents.get(i) instanceof TestAgent1);
	}
	for (int i = NUM_AGENTS; i < 2*NUM_AGENTS; ++i) {
		Assert.assertTrue(agents.get(i) instanceof TestAgent2);
	}
	System.out.println("OK");
	
	System.out.println("Checking agents running...");
	for (int i = 0; i < 2*NUM_AGENTS; ++i) {
		Assert.assertTrue(agents.get(i).getState().getFlag().isState(IAgentStateUp.class));
	}
	System.out.println("OK");
	
	System.out.println("Check agents' parameters...");
	for (int i = 0; i < NUM_AGENTS; ++i) {
		Assert.assertTrue(((TestAgent1)agents.get(i)).getParam() == i);
	}
	for (int i = NUM_AGENTS; i < 2*NUM_AGENTS; ++i) {
		Assert.assertTrue(((TestAgent2)agents.get(i)).getParam() == i-NUM_AGENTS);
	}
	System.out.println("OK");
	
	System.out.println("Stopping " + (2*NUM_AGENTS) + " agents...");
	for (int i = 0; i < 2*NUM_AGENTS; ++i) {
		agents.get(i).stop();
	}
	System.out.println("Checking agents stopped...");
	for (int i = 0; i < 2*NUM_AGENTS; ++i) {
		Assert.assertTrue(agents.get(i).getState().getFlag().isState(IAgentStateDown.class));
	}
	System.out.println("OK");
	
	checkMultipleAgentRunnerCalls(2*NUM_AGENTS);				
	
	System.out.println("---/// TEST OK ///---");
}
 
Example 18
Project: ojAlgo-finance   File: TestUtils.java   View Source Code Vote up 4 votes
public static void assertStateNotLessThanFeasible(final Optimisation.Result actual) {
    Assert.assertTrue(actual.toString(), actual.getState().isFeasible());
}
 
Example 19
Project: GitHub   File: One2OneUniSaveTest.java   View Source Code Vote up 4 votes
private void assertFK(Teacher t, IdCard i) {
	Assert.assertTrue(isFKInsertCorrect(getTableName(t), getTableName(i), t.getId(), i.getId()));
}
 
Example 20
Project: ojAlgo-extensions   File: TestUtils.java   View Source Code Vote up 4 votes
public static void assertStateNotLessThanOptimal(final Optimisation.Result actual) {
    Assert.assertTrue(actual.toString(), actual.getState().isOptimal());
}