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

The following are Jave code examples for showing how to use assertEquals() 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: ec4j   File: EditorConfigGlobTest.java   View Source Code Vote up 7 votes
@Test
public void utf_8_char() throws IOException {
    String content = "; test EditorConfig files with UTF-8 characters larger than 127\r\n" //
            + "\r\n" //

            + "root = true\r\n" //
            + "\r\n" //
            + "[中文.txt]\r\n" //
            + "key = value\r\n" //
            + "";

    final String testFile = "root/中文.txt";
    StringResourceTree tree = StringResourceTree.builder() //
            .resource("root/.editorconfig", content)//
            .touch(testFile) //
            .build();

    Collection<Property> properties = ResourcePropertiesService.default_()
            .queryProperties(tree.getResource(testFile)).getProperties().values();
    Assert.assertEquals(1, properties.size());
    Assert.assertEquals("key = value", properties.iterator().next().toString());
}
 
Example 2
Project: GitHub   File: PropertyFilter_long.java   View Source Code Vote up 6 votes
public void test_1() throws Exception {
    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            if ("id".equals(name)) {
                Assert.assertTrue(value instanceof Long);
                return true;
            }
            return false;
        }
    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getPropertyFilters().add(filter);

    A a = new A();
    serializer.write(a);

    String text = out.toString();
    Assert.assertEquals("{\"id\":0}", text);
}
 
Example 3
Project: ats-framework   File: Test_ExcelParser_xls.java   View Source Code Vote up 6 votes
@Test
@TestOptions( dataSheet = "TestLong")
public void longCellParsing() throws Exception {

    parser = new ExcelParser(IoUtils.readFile(EXCEL_FILE_PATH), "TestLong");

    Object[][] data = parser.getDataBlock(findMethodByNameOnly("longParseMethod"));

    Assert.assertEquals(data[0][0], 0L);
    Assert.assertEquals(data[1][0], 1234567890123456789L);
    Assert.assertEquals(data[2][0], 9223372036854775807L);
    Assert.assertEquals(data[3][0], 9223372036854775806L);
    Assert.assertEquals(data[4][0], -9223372036854775808L);
    Assert.assertEquals(data[5][0], -9223372036854775807L);
    Assert.assertEquals(data[6][0], 2L);

}
 
Example 4
Project: hadoop   File: TestQueueParsing.java   View Source Code Vote up 6 votes
@Test
public void testQueueParsingShouldTrimSpaces() throws Exception {
  CapacitySchedulerConfiguration csConf = 
    new CapacitySchedulerConfiguration();
  setupQueueConfigurationWithSpacesShouldBeTrimmed(csConf);
  YarnConfiguration conf = new YarnConfiguration(csConf);

  CapacityScheduler capacityScheduler = new CapacityScheduler();
  capacityScheduler.setConf(conf);
  capacityScheduler.setRMContext(TestUtils.getMockRMContext());
  capacityScheduler.init(conf);
  capacityScheduler.start();
  capacityScheduler.reinitialize(conf, TestUtils.getMockRMContext());
  
  CSQueue a = capacityScheduler.getQueue("a");
  Assert.assertNotNull(a);
  Assert.assertEquals(0.10, a.getAbsoluteCapacity(), DELTA);
  Assert.assertEquals(0.15, a.getAbsoluteMaximumCapacity(), DELTA);
  
  CSQueue c = capacityScheduler.getQueue("c");
  Assert.assertNotNull(c);
  Assert.assertEquals(0.70, c.getAbsoluteCapacity(), DELTA);
  Assert.assertEquals(0.70, c.getAbsoluteMaximumCapacity(), DELTA);
}
 
Example 5
Project: CorePatch   File: BsPatchTest.java   View Source Code Vote up 5 votes
@Test
public void testReadBsdiffLong_LongMaxValue() throws Exception {
  long expected = 0x7fffffffffffffffL;
  long actual =
      BsPatch.readBsdiffLong(
          new ByteArrayInputStream(
              new byte[] {
                (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
                (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0x7f
              }));
  Assert.assertEquals(expected, actual);
}
 
Example 6
Project: openjdk-systemtest   File: TestSuite049.java   View Source Code Vote up 5 votes
public void testItem_0068()
{
  boolean caught;
  caught = false;
  try {
    rc_BigDecimal = (new BigDecimal("3.2E-2147483646")).pow(-1);
  }
  catch (java.lang.ArithmeticException e) {
    caught = true;
  }
  Assert.assertEquals("91.94630872483222%", true, caught);
}
 
Example 7
Project: openjdk-systemtest   File: TestSuite001.java   View Source Code Vote up 5 votes
public void testItem_0526()
{
  boolean caught;
  caught = false;
  try {
    rc_BigDecimal = (new BigDecimal("0.0")).divide(new BigDecimal("1"), 1, -2147483648);
  }
  catch (java.lang.IllegalArgumentException e) {
    caught = true;
  }
  Assert.assertEquals("85.57046979865771%", true, caught);
}
 
Example 8
Project: LiQ   File: DefaultCommitLogTest.java   View Source Code Vote up 5 votes
@Test
public void recover() throws Exception {
    defaultCommitLog.recover();
    Message message = new Message();
    message.getMeta().setTopic("LiQTopic");
    TreeMap<Long, Integer> map = new TreeMap<>();
    for (int i = 0; i < 10; i++) {
        message.setData(("Hello LiQ! " + i).getBytes());
        PutMessageResult result = defaultCommitLog.putMessage(message);
        Assert.assertEquals(PutMessageStatus.PUT_OK,result.getStatus());
        map.put(result.getAppendResult().getWroteOffset(), result.getAppendResult().getWroteBytes());
    }
}
 
Example 9
Project: openjdk-systemtest   File: TestSuite014.java   View Source Code Vote up 5 votes
public void testItem_0853()
{
  boolean caught;
  caught = false;
  try {
    rc_BigDecimal = new BigDecimal("SY1?LJWPT2757;14VS=8Q5G3J5W>L2?6F2T6JKTOXM8K>3U4Y67V>86CT;7KB74WP1L9T4:[email protected]?K15T002N5WTL1S;938KE04", new MathContext("precision=0 roundingMode=HALF_EVEN"));
  }
  catch (java.lang.NumberFormatException e) {
    caught = true;
  }
  Assert.assertEquals("91.61073825503355%", true, caught);
}
 
Example 10
Project: openjdk-systemtest   File: TestSuite047.java   View Source Code Vote up 4 votes
public void testItem_0152()
{
  rc_BigDecimal = new BigDecimal(4.9E-324);
  Assert.assertEquals("4.940656458412465441765687928682213723650598026143247644255856825006755072702087518652998363616359923797965646954457177309266567103559397963987747960107818781263007131903114045278458171678489821036887186360569987307230500063874091535649843873124733972731696151400317153853980741262385655911710266585566867681870395603106249319452715914924553293054565444011274801297099995419319894090804165633245247571478690147267801593552386115501348035264934720193790268107107491703332226844753335720832431936092382893458368060106011506169809753078342277318329247904982524730776375927247874656084778203734469699533647017972677717585125660551199131504891101451037862738167250955837389733598993664809941164205702637090279242767544565229087538682506419718265533447265625E-324", rc_BigDecimal.toString());
}
 
Example 11
Project: openjdk-systemtest   File: TestSuite057.java   View Source Code Vote up 4 votes
public void testItem_0771()
{
  rc_BigDecimal = (new BigDecimal("-2E+9")).round(new MathContext("precision=1 roundingMode=HALF_UP"));
  Assert.assertEquals("-2E+9", rc_BigDecimal.toString());
}
 
Example 12
Project: openjdk-systemtest   File: TestSuite020.java   View Source Code Vote up 4 votes
public void testItem_0748()
{
  rc_BigDecimal = (new BigDecimal("-51200")).round(new MathContext("precision=2147483647 roundingMode=UP"));
  Assert.assertEquals("-51200", rc_BigDecimal.toString());
}
 
Example 13
Project: openjdk-systemtest   File: TestSuite006.java   View Source Code Vote up 4 votes
public void testItem_0293()
{
  rc_BigDecimal = (new BigDecimal("1")).abs();
  Assert.assertEquals("1", rc_BigDecimal.toString());
}
 
Example 14
Project: openjdk-systemtest   File: TestSuite021.java   View Source Code Vote up 4 votes
public void testItem_0429()
{
  rc_long = (new BigDecimal("9223372036854775807")).longValue();
  Assert.assertEquals(9223372036854775807L, rc_long);
}
 
Example 15
Project: openjdk-systemtest   File: TestSuite007.java   View Source Code Vote up 4 votes
public void testItem_0423()
{
  rc_BigDecimal = new BigDecimal(new java.math.BigInteger("32"), 0, new MathContext("precision=2147483647 roundingMode=HALF_UP"));
  Assert.assertEquals("32", rc_BigDecimal.toString());
}
 
Example 16
Project: openjdk-systemtest   File: TestSuite045.java   View Source Code Vote up 4 votes
public void testItem_0047()
{
  rc_BigDecimal = new BigDecimal(new java.math.BigInteger("32"), 0, new MathContext("precision=1 roundingMode=HALF_UP"));
  Assert.assertEquals("3E+1", rc_BigDecimal.toString());
}
 
Example 17
Project: openjdk-systemtest   File: TestSuite033.java   View Source Code Vote up 4 votes
public void testItem_0041()
{
  rc_int = (new BigDecimal("0.00")).signum();
  Assert.assertEquals(0, rc_int);
}
 
Example 18
Project: openjdk-systemtest   File: TestSuite052.java   View Source Code Vote up 4 votes
public void testItem_0723()
{
  rc_BigDecimal = (new BigDecimal("1")).max(new BigDecimal("1"));
  Assert.assertEquals("1", rc_BigDecimal.toString());
}
 
Example 19
Project: openjdk-systemtest   File: TestSuite016.java   View Source Code Vote up 4 votes
public void testItem_0321()
{
  rc_String = (new BigDecimal("1")).toEngineeringString();
  Assert.assertEquals("1", rc_String);
}
 
Example 20
Project: openjdk-systemtest   File: TestSuite011.java   View Source Code Vote up 4 votes
public void testItem_0820()
{
  rc_BigDecimal = new BigDecimal(new java.math.BigInteger("32"), 1);
  Assert.assertEquals("3.2", rc_BigDecimal.toString());
}