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

The following are Jave code examples for showing how to use assertFalse() 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: EatDubbo   File: HessianProtocolTest.java   View Source Code Vote up 7 votes
@Test
public void testHessianProtocol() {
    HessianServiceImpl server = new HessianServiceImpl();
    Assert.assertFalse(server.isCalled());
    ProxyFactory proxyFactory = ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension();
    Protocol protocol = ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension();
    URL url = URL.valueOf("hessian://127.0.0.1:5342/" + HessianService.class.getName() + "?version=1.0.0");
    Exporter<HessianService> exporter = protocol.export(proxyFactory.getInvoker(server, HessianService.class, url));
    Invoker<HessianService> invoker = protocol.refer(HessianService.class, url);
    HessianService client = proxyFactory.getProxy(invoker);
    String result = client.sayHello("haha");
    Assert.assertTrue(server.isCalled());
    Assert.assertEquals("Hello, haha", result);
    invoker.destroy();
    exporter.unexport();
}
 
Example 2
Project: mapbox-navigation-android   File: TriggerPropertyTest.java   View Source Code Vote up 6 votes
@Test
public void stepDistanceRemainingProperty_onlyPassesValidationWhenEqual() {
  double stepDistance = routeProgress.currentLegProgress().currentStepProgress().distanceRemaining();

  for (int i = 10; i > 0; i--) {
    Milestone milestone = new StepMilestone.Builder()
      .setTrigger(
        Trigger.eq(TriggerProperty.STEP_DISTANCE_REMAINING_METERS, (stepDistance / i))
      ).build();

    boolean result = milestone.isOccurring(routeProgress, routeProgress);
    if ((stepDistance / i) == stepDistance) {
      Assert.assertTrue(result);
    } else {
      Assert.assertFalse(result);
    }
  }
}
 
Example 3
Project: rate-limiting   File: EMARateCalculatorTest.java   View Source Code Vote up 6 votes
@Test
public void testPathRate_Exceed() throws IOException {

	double requestsPerTimeUnit = 100;
	Double timeConstant = 0.3;

	// settings = ConfigTest.loadTestSettings();
	final int hash = 487587236;
	EMARateCalculator calculator = new EMARateCalculator(rateRecordMap);

	RateLimit limit = new RateLimit(timeUnit, requestsPerTimeUnit, rateExceededResponse, timeConstant);

	boolean exceeded = false;
	for (int i = 0; i < 200; i++) {
		exceeded = exceeded || calculator.exceedsRate(hash, limit);

		if (i < 1)
			Assert.assertFalse("We are not supposed to exceed rate", exceeded);
	}
	Assert.assertTrue("We were supposed to exceed rate", exceeded);
}
 
Example 4
Project: MobileAppForPatient   File: ChangePasswordActivityTest.java   View Source Code Vote up 6 votes
@Test
public void testChangePassword_blankCurrentPassword() {
    EditText mEtCurrPassword = (EditText) activity.findViewById(R.id.editTextChangePassCurrPass);
    EditText mEtNewPassword = (EditText) activity.findViewById(R.id.editTextChangePassNewPass);
    EditText mEtConfirmNewPassword = (EditText) activity.findViewById(R.id.editTextConfirmPassNewPass);
    Button mBtnChange = (Button) activity.findViewById(R.id.change_pass_button);

    mEtCurrPassword.setText("");
    mEtNewPassword.setText("QWERTY");
    mEtConfirmNewPassword.setText("QWERTY");

    TextView label = (TextView) activity.findViewById(R.id.textViewChangePassCurrPassMessage);
    Assert.assertFalse("current password lable is been set before change password",label.getText().length()>1);
    mBtnChange.performClick();
    Assert.assertTrue("current password lable is not been set",label.getText().length()>1);
}
 
Example 5
Project: OpenDiabetes   File: TestPeriodPredicates.java   View Source Code Vote up 6 votes
/**
 * (TIMESTAMP '1999-12-01 01:02:03', TIMESTAMP '1999-12-02 01:02:03')
 * CONTAINS
 * TIMESTAMP '1999-12-01 01:02:03'
 * is false
 */
public void testFirstPeriodCannotContainsSecondPeriodIfTheyAreEquals() {

    Object[] a = {
        scanner.newTimestamp("1999-12-01 01:02:01"),
        scanner.newTimestamp("1999-12-01 01:02:03")
    };
    Object[] b = {
        scanner.newTimestamp("1999-12-01 01:02:03"),
        null
    };
    Type[] ta = {
        new DateTimeType(Types.SQL_TIMESTAMP, Types.SQL_TIMESTAMP, 0),
        new DateTimeType(Types.SQL_TIMESTAMP, Types.SQL_TIMESTAMP, 0)
    };
    Type[] tb = {
        new DateTimeType(Types.SQL_TIMESTAMP, Types.SQL_TIMESTAMP, 0),
        new DateTimeType(Types.SQL_TIMESTAMP, Types.SQL_TIMESTAMP, 0)
    };

    Assert.assertFalse(DateTimeType.contains(session, a, ta, b, tb,
            true));
}
 
Example 6
Project: unlock-android   File: ConditionTests.java   View Source Code Vote up 6 votes
@Test
public void testNewUsersCondition() throws Exception {
    final MockDateProvider dateProvider = new MockDateProvider(TEST_DATE_FORMAT.parse("2016-02-02 18:00:00"), TEST_DATE_FORMAT.parse("2010-01-01 18:00:00"));
    final MockDateProvider dateProviderAfterStart = new MockDateProvider(TEST_DATE_FORMAT.parse("2016-02-02 18:00:00"), TEST_DATE_FORMAT.parse("2016-02-02 18:00:00"));
    final BaseCondition mockCondition = new BaseCondition();

    mockCondition.startDate = TEST_DATE_FORMAT.parse("2016-02-02 18:00:00");
    mockCondition.endDate = null;
    mockCondition.newUsersOnly = false;

    Assert.assertTrue(mockCondition.isSatisfied(dateProvider));
    Assert.assertTrue(mockCondition.isSatisfied(dateProviderAfterStart));

    mockCondition.newUsersOnly = true;

    Assert.assertFalse(mockCondition.isSatisfied(dateProvider));
    Assert.assertTrue(mockCondition.isSatisfied(dateProviderAfterStart));
}
 
Example 7
Project: mapbox-navigation-android   File: TriggerTest.java   View Source Code Vote up 5 votes
@Test
public void greaterThanEqual_validatesToFalse() {
  Milestone milestone = new StepMilestone.Builder()
    .setTrigger(
      Trigger.gte(TriggerProperty.STEP_DISTANCE_TOTAL_METERS, 10000d)
    )
    .build();

  boolean result = milestone.isOccurring(routeProgress, routeProgress);
  Assert.assertFalse(result);
}
 
Example 8
Project: googles-monorepo-demo   File: ClassSanityTester.java   View Source Code Vote up 5 votes
private ImmutableList<Invokable<?, ?>> getFactoriesToTest() {
  ImmutableList.Builder<Invokable<?, ?>> builder = ImmutableList.builder();
  for (Invokable<?, ?> factory : factories) {
    if (returnTypeToTest.isAssignableFrom(factory.getReturnType().getRawType())) {
      builder.add(factory);
    }
  }
  ImmutableList<Invokable<?, ?>> factoriesToTest = builder.build();
  Assert.assertFalse("No " + factoryMethodsDescription + " that return "
          + returnTypeToTest.getName() + " or subtype are found in "
          + declaringClass + ".",
      factoriesToTest.isEmpty());
  return factoriesToTest;
}
 
Example 9
Project: GitHub   File: Many2OneUniSaveTest.java   View Source Code Vote up 5 votes
public void testSaveFast() {
    init();
    c1.getTeachers().add(t1);
    c1.getTeachers().add(t2);
    c1.saveFast();
    t1.saveFast();
    t2.saveFast();
    isDataExists(getTableName(c1), c1.get_id());
    isDataExists(getTableName(t1), t1.getId());
    isDataExists(getTableName(t2), t2.getId());
    Assert.assertFalse(isFKInsertCorrect(getTableName(c1), getTableName(t1), c1.get_id(),
            t1.getId()));
    Assert.assertFalse(isFKInsertCorrect(getTableName(c1), getTableName(t2), c1.get_id(),
            t2.getId()));
}
 
Example 10
Project: gamesboard   File: DotsControllerByMessagesTest.java   View Source Code Vote up 5 votes
@Test
public void testEndGame() throws NoSuchFieldException, SecurityException,
		IllegalArgumentException, IllegalAccessException,
		InvocationTargetException, NoSuchMethodException {

	the1000moves();
	
	Assert.assertTrue(gameEndedPigdroid);
	Assert.assertTrue(gameEndedEduyayo);
	Assert.assertFalse(pigdroidWinner);
	Assert.assertFalse(eduyayoWinner);
}
 
Example 11
Project: dubbox-hystrix   File: RegistryDirectoryTest.java   View Source Code Vote up 5 votes
/**
 * 测试override规则是否优先
 * 场景:推送的规则与provider的参数是一样的
 * 期望:不需要重新引用
 */
@Test
public void testNotifyoverrideUrls_Nouse(){
    RegistryDirectory registryDirectory = getRegistryDirectory();
    invocation = new RpcInvocation();
    
    List<URL> durls = new ArrayList<URL>();
    durls.add(SERVICEURL.addParameter("timeout", "1"));//一个一样,一个不一样
    durls.add(SERVICEURL2.addParameter("timeout", "1").addParameter("connections", "5"));
    registryDirectory.notify(durls);
    List<Invoker<?>> invokers = registryDirectory.list(invocation);
    Assert.assertEquals(2, invokers.size());
    Invoker<?> a1Invoker = invokers.get(0);
    Invoker<?> b1Invoker = invokers.get(1);
    
    durls = new ArrayList<URL>();
    durls.add(URL.valueOf("override://0.0.0.0?timeout=1&connections=5"));
    registryDirectory.notify(durls);
    Assert.assertEquals(true, registryDirectory.isAvailable());
    
    invokers = registryDirectory.list(invocation);
    Assert.assertEquals(2, invokers.size());
    
    Invoker<?> a2Invoker = invokers.get(0);
    Invoker<?> b2Invoker = invokers.get(1);
    //参数不一样,必须重新引用
    Assert.assertFalse("object not same",a1Invoker == a2Invoker);
    
    //参数一样,不能重新引用
    Assert.assertTrue("object same",b1Invoker == b2Invoker);
}
 
Example 12
Project: mapbox-navigation-android   File: TriggerTest.java   View Source Code Vote up 5 votes
@Test
public void triggerNone_onoConditionsTrue() {
  Milestone milestone = new StepMilestone.Builder()
    .setTrigger(Trigger.none(
      Trigger.gt(TriggerProperty.STEP_DURATION_REMAINING_SECONDS, 100d),
      Trigger.gt(TriggerProperty.STEP_DISTANCE_TOTAL_METERS, 100d)
    ))
    .build();

  boolean result = milestone.isOccurring(routeProgress, routeProgress);
  Assert.assertFalse(result);
}
 
Example 13
Project: parabuild-ci   File: LongExtraTypeTest.java   View Source Code Vote up 5 votes
public void testEquals() {
	LongExtraType otherLongExtra = new LongExtraType();
	BottomType bottom = new BottomType();

	Assert.assertEquals(longExtraType, otherLongExtra);
	Assert.assertFalse(longExtraType.equals(bottom));
}
 
Example 14
Project: ditb   File: TestHttpServer.java   View Source Code Vote up 5 votes
@Test
public void testHasAdministratorAccess() throws Exception {
  Configuration conf = new Configuration();
  conf.setBoolean(CommonConfigurationKeys.HADOOP_SECURITY_AUTHORIZATION, false);
  ServletContext context = Mockito.mock(ServletContext.class);
  Mockito.when(context.getAttribute(HttpServer.CONF_CONTEXT_ATTRIBUTE)).thenReturn(conf);
  Mockito.when(context.getAttribute(HttpServer.ADMINS_ACL)).thenReturn(null);
  HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
  Mockito.when(request.getRemoteUser()).thenReturn(null);
  HttpServletResponse response = Mockito.mock(HttpServletResponse.class);

  //authorization OFF
  Assert.assertTrue(HttpServer.hasAdministratorAccess(context, request, response));

  //authorization ON & user NULL
  response = Mockito.mock(HttpServletResponse.class);
  conf.setBoolean(CommonConfigurationKeys.HADOOP_SECURITY_AUTHORIZATION, true);
  Assert.assertFalse(HttpServer.hasAdministratorAccess(context, request, response));
  Mockito.verify(response).sendError(Mockito.eq(HttpServletResponse.SC_UNAUTHORIZED), Mockito.anyString());

  //authorization ON & user NOT NULL & ACLs NULL
  response = Mockito.mock(HttpServletResponse.class);
  Mockito.when(request.getRemoteUser()).thenReturn("foo");
  Assert.assertTrue(HttpServer.hasAdministratorAccess(context, request, response));

  //authorization ON & user NOT NULL & ACLs NOT NULL & user not in ACLs
  response = Mockito.mock(HttpServletResponse.class);
  AccessControlList acls = Mockito.mock(AccessControlList.class);
  Mockito.when(acls.isUserAllowed(Mockito.<UserGroupInformation>any())).thenReturn(false);
  Mockito.when(context.getAttribute(HttpServer.ADMINS_ACL)).thenReturn(acls);
  Assert.assertFalse(HttpServer.hasAdministratorAccess(context, request, response));
  Mockito.verify(response).sendError(Mockito.eq(HttpServletResponse.SC_UNAUTHORIZED), Mockito.anyString());

  //authorization ON & user NOT NULL & ACLs NOT NULL & user in in ACLs
  response = Mockito.mock(HttpServletResponse.class);
  Mockito.when(acls.isUserAllowed(Mockito.<UserGroupInformation>any())).thenReturn(true);
  Mockito.when(context.getAttribute(HttpServer.ADMINS_ACL)).thenReturn(acls);
  Assert.assertTrue(HttpServer.hasAdministratorAccess(context, request, response));

}
 
Example 15
Project: dble   File: DruidMysqlCreateTableTest.java   View Source Code Vote up 5 votes
@Test
public void testCreate() throws SQLException {

    SchemaConfig schema = schemaMap.get("mysqldb");
    RouteResultset rrs = routeStrategy.route(schema, -1, originSql1, sc, cachePool);
    Assert.assertEquals(2, rrs.getNodes().length);
    String sql = rrs.getNodes()[0].getStatement();

    //Assert.assertTrue(parseSql(sql));
    Assert.assertFalse(parseSql(sql));
}
 
Example 16
Project: NoteBuddy   File: StringGeneratorTest.java   View Source Code Vote up 4 votes
@Test
public void generateString_runWithRandom_expectInvalidRandomString() {
    String generatedString = StringGenerator.generateString(new Random(), m_charsString, m_length);
    Assert.assertFalse(generatedString.equals(EXPECTED_GENERATED_STRING));
}
 
Example 17
Project: sjk   File: CatalogMapperTest.java   View Source Code Vote up 4 votes
@Test
public void testlistNoParameters() {
    List<Catalog> list = catalogMapper.list();
    Assert.assertNotNull(list);
    Assert.assertFalse(list.isEmpty());
}
 
Example 18
Project: ojAlgo-finance   File: TestUtils.java   View Source Code Vote up 4 votes
public static void assertFalse(final boolean condition) {
    Assert.assertFalse(condition);
}
 
Example 19
Project: parabuild-ci   File: LongExtraTypeTest.java   View Source Code Vote up 4 votes
public void testNotValidArrayBaseType() {
	Assert.assertFalse(longExtraType.isValidArrayBaseType());
}
 
Example 20
Project: parabuild-ci   File: NullTypeTest.java   View Source Code Vote up 4 votes
public void testNotValidArrayElementType() {
	Assert.assertFalse(nullType.isValidArrayElementType());
}