Java Code Examples for org.junit.Assert.assertNotEquals()

The following are Jave code examples for showing how to use assertNotEquals() of the org.junit.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: MybatisGeneatorUtil   File: TestBasicAble.java   View Source Code Vote up 6 votes
/**
 * 根据主键全更新
 */
@Test
public void testUpdateByPrimaryKey() {
    SqlSession sqlSession = MybatisHelper.getSqlSession();
    try {
        UserInfoAbleMapper mapper = sqlSession.getMapper(UserInfoAbleMapper.class);
        UserInfoAble userInfo = mapper.selectByPrimaryKey(2);
        Assert.assertNotNull(userInfo);
        userInfo.setUsertype(null);
        userInfo.setEmail("[email protected]");
        userInfo.setAddress("这个地址不会更新进去");//update=false
        //不会更新username
        Assert.assertEquals(1, mapper.updateByPrimaryKey(userInfo));

        userInfo = mapper.selectByPrimaryKey(userInfo);
        Assert.assertNull(userInfo.getUsertype());
        Assert.assertNotEquals("这个地址不会更新进去", userInfo.getAddress());
        Assert.assertEquals("[email protected]", userInfo.getEmail());
    } finally {
        sqlSession.rollback();
        sqlSession.close();
    }
}
 
Example 2
Project: java-stack   File: LombokTest.java   View Source Code Vote up 6 votes
@Test
public void testEqualsAndHashCode() {
    Person person = new Person();
    person.setName("张三");
    person.setAge(20);
    person.setSex("男");

    Person person2 = new Person();
    person2.setName("张三");
    person2.setAge(18);
    person2.setSex("男");

    Person person3 = new Person();
    person3.setName("李四");
    person3.setAge(20);
    person3.setSex("男");

    Assert.assertEquals(person, person2);
    Assert.assertNotEquals(person, person3);
}
 
Example 3
Project: training-sample   File: BeanTest.java   View Source Code Vote up 6 votes
@Test
public void testScopeBean() {
	ExampleScopeBean singletonBean1 = context.getBean("singletonBean", ExampleScopeBean.class);
	ExampleScopeBean singletonBean2 = context.getBean("singletonBean", ExampleScopeBean.class);
	ExampleScopeBean prototypeBean1 = context.getBean("prototypeBean", ExampleScopeBean.class);
	ExampleScopeBean prototypeBean2 = context.getBean("prototypeBean", ExampleScopeBean.class);

	Assert.assertEquals(singletonBean1, singletonBean2);
	Assert.assertNotEquals(prototypeBean1, prototypeBean2);

	//test singleton
	// check message
	Assert.assertEquals(singletonBean1.getMessage(), singletonBean2.getMessage());
	// update message
	singletonBean1.setMessage("new hello");
	// recheck message
	Assert.assertEquals(singletonBean1.getMessage(), singletonBean2.getMessage());

	//test prototype
	// check message
	Assert.assertEquals(prototypeBean1.getMessage(), prototypeBean2.getMessage());
	// update message
	prototypeBean1.setMessage("new hello");
	// recheck message
	Assert.assertNotEquals(prototypeBean1.getMessage(), prototypeBean2.getMessage());
}
 
Example 4
Project: incubator-servicecomb-java-chassis   File: TestConfigUtil.java   View Source Code Vote up 6 votes
@Test
public void testCreateDynamicConfigNoConfigCenterSPI() {
  new Expectations(SPIServiceUtils.class) {
    {
      SPIServiceUtils.getTargetService(ConfigCenterConfigurationSource.class);
      result = null;
    }
  };

  AbstractConfiguration dynamicConfig = ConfigUtil.createDynamicConfig();
  MicroserviceConfigLoader loader = ConfigUtil.getMicroserviceConfigLoader(dynamicConfig);
  List<ConfigModel> list = loader.getConfigModels();
  Assert.assertEquals(loader, ConfigUtil.getMicroserviceConfigLoader(dynamicConfig));
  Assert.assertEquals(1, list.size());
  Assert.assertNotEquals(DynamicWatchedConfiguration.class,
      ((ConcurrentCompositeConfiguration) dynamicConfig).getConfiguration(0).getClass());
}
 
Example 5
Project: africastalking-java   File: TokenTest.java   View Source Code Vote up 5 votes
@Test
public void testCreateCheckoutToken() {
    TokenService service = AfricasTalking.getService(TokenService.class);
    try {
        final CheckoutTokenResponse response = service.createCheckoutToken("0718769882");
        Assert.assertNotEquals("None", response.token);

    } catch (IOException e) {
        Assert.fail(e.getMessage());
    }
}
 
Example 6
Project: eadlsync   File: PullCommandTest.java   View Source Code Vote up 5 votes
@Test
public void testPullRemoteChangesOnlyResultsInModifiedLocalDecisions() throws Exception {
    seRepoTestServer.createCommit(TestDataProvider.createChangedTestSeItemsWithContentModified(),
            CommitMode.ADD_UPDATE);

    PULL_COMMAND.pull();

    Assert.assertNotEquals(commitId, COMMIT_COMMAND.readCommitId());
}
 
Example 7
Project: NiuBi   File: TestBasics.java   View Source Code Vote up 5 votes
@Test
public void testString() {
    Json s1 = Json.make("");
    Assert.assertEquals("", s1.getValue());
    Json s1dup = s1.dup();
    Assert.assertFalse(s1dup == s1);
    Assert.assertEquals(s1, s1dup);
    Json s2 = Json.make("string1");
    Json s2again = Json.factory().string("string1");
    Assert.assertEquals(s2, s2again);
    Json s3 = Json.make("Case Sensitive");
    Json s3_lower = Json.make("Case Sensitive".toLowerCase());
    Assert.assertNotEquals(s3, s3_lower);
}
 
Example 8
Project: azure-libraries-for-java   File: TestSearchService.java   View Source Code Vote up 5 votes
@Override
public SearchService updateResource(SearchService resource) throws Exception {
    resource.createQueryKey("testKey1");

    resource = resource.update()
        .withTag("tag2", "value2")
        .withTag("tag3", "value3")
        .withoutTag("tag1")
        .withReplicaCount(1)
        .withPartitionCount(1)
        .apply();
    Assert.assertTrue(resource.tags().containsKey("tag2"));
    Assert.assertTrue(!resource.tags().containsKey("tag1"));
    Assert.assertEquals(1, resource.replicaCount());
    Assert.assertEquals(1, resource.partitionCount());
    Assert.assertEquals(2, resource.listQueryKeys().size());

    String adminKeyPrimary = resource.getAdminKeys().primaryKey();
    String adminKeySecondary = resource.getAdminKeys().secondaryKey();

    resource.deleteQueryKey(resource.listQueryKeys().get(1).key());
    resource.regenerateAdminKeys(AdminKeyKind.PRIMARY);
    resource.regenerateAdminKeys(AdminKeyKind.SECONDARY);
    Assert.assertEquals(1, resource.listQueryKeys().size());
    Assert.assertNotEquals(adminKeyPrimary, resource.getAdminKeys().primaryKey());
    Assert.assertNotEquals(adminKeySecondary, resource.getAdminKeys().secondaryKey());

    return resource;
}
 
Example 9
Project: spanner-jdbc   File: MetaDataStoreTest.java   View Source Code Vote up 5 votes
@Test
public void testClear() throws SQLException, NoSuchFieldException, SecurityException, IllegalArgumentException,
		IllegalAccessException
{
	for (int i = 0; i < 2; i++)
	{
		MetaDataStore subject = new MetaDataStore(CloudSpannerTestObjects.createConnection());
		TableKeyMetaData fooUpperCase = subject.getTable("FOO");
		TableKeyMetaData fooLowerCase = subject.getTable("foo");
		TableKeyMetaData bar = subject.getTable("Bar");
		assertNotNull(fooLowerCase);
		assertNotNull(fooUpperCase);
		assertNotNull(bar);
		assertEquals(fooLowerCase, fooUpperCase);
		Assert.assertNotEquals(fooLowerCase, bar);

		Field field = MetaDataStore.class.getDeclaredField("tables");
		field.setAccessible(true);
		@SuppressWarnings("unchecked")
		Map<String, TableKeyMetaData> map = (Map<String, TableKeyMetaData>) field.get(subject);
		assertEquals(map.size(), 2);
		subject.clearTable("Foo");
		assertEquals(map.size(), 1);
		subject.clear();
		assertEquals(map.size(), 0);
	}
}
 
Example 10
Project: CorePatch   File: DeflateUncompressorTest.java   View Source Code Vote up 5 votes
@Test
public void testSetInputBufferSize() throws IOException {
  Assert.assertNotEquals(17, uncompressor.getInputBufferSize()); // Ensure test is valid
  uncompressor.setInputBufferSize(17); // Arbitrary non-default value
  Assert.assertEquals(17, uncompressor.getInputBufferSize());
  uncompressor.uncompress(compressedContentIn, uncompressedContentOut);
  Assert.assertArrayEquals(CONTENT, uncompressedContentOut.toByteArray());
}
 
Example 11
Project: jigsaw-payment   File: TestJdbcSharder.java   View Source Code Vote up 5 votes
/**
 * 验证按照算法计算出来的ID属于同一个数据库;
 */
@Test
public void TestGetTemplateByUserIdEquals() {
	Assert.assertEquals(sharder.getTemplateByUserId(1081l),sharder.getTemplateByUserId(1063l));
	Assert.assertEquals(sharder.getTemplateByUserId(1081l),sharder.getTemplateByUserId(1049l));
	Assert.assertNotEquals(sharder.getTemplateByUserId(1081l),sharder.getTemplateByUserId(1079l));
}
 
Example 12
Project: jetcache   File: ProxyUtilTest.java   View Source Code Vote up 5 votes
@Test
//with super interface
public void testGetProxyByAnnotation4() {
    I4_1 c1 = new C4();
    I4_1 c2 = ProxyUtil.getProxyByAnnotation(c1, globalCacheConfig);
    Assert.assertNotEquals(c1.count(), c1.count());
    Assert.assertNotEquals(c1.countWithoutCache(), c1.countWithoutCache());
    Assert.assertEquals(c2.count(), c2.count());
    Assert.assertNotEquals(c2.countWithoutCache(), c2.countWithoutCache());
}
 
Example 13
Project: SpringBoot_Wechat_Sell   File: ProductCategoryRepositoryTest.java   View Source Code Vote up 5 votes
@Test
public void findByCategoryTypeIn() {
    List<Integer> list = Arrays.asList(2, 3, 4);

    List<ProductCategory> productCategoryList = productCategoryRepository.findByCategoryTypeIn(list);
    Assert.assertNotEquals(0, productCategoryList.size());
}
 
Example 14
Project: devops-blockchain-jenkins   File: BankAccountSmartContractTests.java   View Source Code Vote up 5 votes
@Before
public void before() throws IOException, InterruptedException, ExecutionException {
	web3j = Web3j.build(new HttpService());

	EthAccounts accounts = web3j.ethAccounts().send();
	Assert.assertNotEquals(0, accounts.getAccounts().size());

	// use the first account as the main account for the tests
	mainAccountAddress = accounts.getAccounts().get(0);

	// deploy the contract
	txManager = new ClientTransactionManager(web3j, mainAccountAddress);
	bankAccountContract = BankAccount.deploy(web3j, txManager, GAS_PRICE, GAS_LIMIT, BigInteger.valueOf(0))
			.get();
}
 
Example 15
Project: NGB-master   File: ApplicationTest.java   View Source Code Vote up 4 votes
@Test
public void runEmpty() throws Exception {
    Application application = new TestApplication();
    Assert.assertNotEquals(RUN_STATUS_OK, application.run(new String[]{}));
}
 
Example 16
Project: support-optional   File: OptionalIntTest.java   View Source Code Vote up 4 votes
@Test
public void equalsOfValueDoesNotEqualsAnother() throws Exception {
    Assert.assertNotEquals(OptionalInt.of(1), OptionalInt.of(2));
}
 
Example 17
Project: GitHub   File: FastJsonHttpMessageConverterTest.java   View Source Code Vote up 4 votes
@Test
public void test3() throws Exception {
    List<Object> list = this.mockMvc.perform(post("/fastjson/test3"))
            .andReturn().getResponse().getHeaderValues("Content-Length");
    Assert.assertNotEquals(list.size(), 0);
}
 
Example 18
Project: sell   File: CategoryServiceImplTest.java   View Source Code Vote up 4 votes
@Test
public void findAll() throws Exception {
    List<ProductCategory> productCategoryList = categoryService.findAll();
    Assert.assertNotEquals(0, productCategoryList.size());
}
 
Example 19
Project: yunikov-commons   File: EnumValuesTest.java   View Source Code Vote up 4 votes
@Test
public void supportsEquals() {
    Assert.assertEquals(fakeEnumValue(), fakeEnumValue());
    Assert.assertNotEquals(fakeEnumValue(), null);
    Assert.assertNotEquals(fakeEnumValue(), fakeAnotherEnumValue());
}
 
Example 20
Project: sell   File: ProductInfoRepositoryTest.java   View Source Code Vote up 3 votes
@Test
public void findByProductStatus() throws Exception {

    List<ProductInfo> result = repository.findByProductStatus(0);
    Assert.assertNotEquals(0, result.size());

}