APISonar


org.junit.Assert.assertEquals

> org > junit > Assert > assertEquals
org APIs junit APIs Assert APIs assertEquals APIs

Example 1
public void testGetStartAndStop() {
        Range myRange = new Range(1, 2);

        Assert.assertEquals(1, myRange.getStart());
        Assert.assertEquals(2, myRange.getStop());
    }
Example 2
protected void assertEquals(String message, long expected, long actual) {
    checkThread();
    try {
      Assert.assertEquals(message, expected, actual);
    } catch (AssertionError e) {
      handleThrowable(e);
    }
  }
Example 3
public void testGet() throws Exception {
      String s = proxy.get();
      Assert.assertEquals("x", s);
   }
Example 4
public void testCase() throws Exception {
        StringReader sr = new StringReader("type/sub-type;a=1;B=2");
        MediaType m = HttpParser.parseMediaType(sr);

        Assert.assertEquals("1", m.getParameterValue("A"));
        Assert.assertEquals("1", m.getParameterValue("a"));
        Assert.assertEquals("2", m.getParameterValue("B"));
        Assert.assertEquals("2", m.getParameterValue("b"));
    }
Example 5
public void fieldsTest() {
        Point point = new Point(1, 2);
        Assert.assertEquals(1, point.x, 0);
        Assert.assertEquals(2, point.y, 0);
    }
Example 6
private void assertAttributeDescription(MBeanAttributeInfo attribute, String name, String type, String description, boolean readable,
            boolean writable) {
        Assert.assertEquals(name, attribute.getName());
        Assert.assertEquals(description, attribute.getDescription());
        Assert.assertEquals(type, attribute.getType());
        Assert.assertEquals(readable, attribute.isReadable());
        Assert.assertEquals(writable, attribute.isWritable());
    }
Example 7
public void testEdgeCase() {
    List<Integer> res = t.topKFrequent(new int[]{1}, 1);
    Assert.assertEquals(1, res.size());
    Assert.assertEquals(1, res.get(0).intValue());
  }
Example 8
public void should_list_success(){
        List<Node> flows = flowDao.list();
        Assert.assertEquals(1, flows.size());
        Assert.assertEquals(flow, flows.get(0));
    }
Example 9
public void testAddSingleURLPattern() {
		String urlPattern = "/o/module";

		_servletDefinition.addURLPattern(urlPattern);

		List<String> urlPatterns = _servletDefinition.getURLPatterns();

		Assert.assertEquals(1, urlPatterns.size());
		Assert.assertEquals(urlPattern, urlPatterns.get(0));
	}
Example 10
public void testGetRow() throws Exception {
    IndexedInts row = selector.getRow();
    Assert.assertEquals(1, row.size());
    Assert.assertEquals(0, row.get(0));

    Iterator<Integer> iter = row.iterator();
    Assert.assertEquals(true, iter.hasNext());
    Assert.assertEquals(0, iter.next().intValue());
    Assert.assertEquals(false, iter.hasNext());
  }
Example 11
public void shouldSpringBootTestAnnotation_overridePropertyValues() {
        final String firstProperty = propertySourceResolver.getFirstProperty();
        final String secondProperty = propertySourceResolver.getSecondProperty();

        Assert.assertEquals("annotation", firstProperty);
        Assert.assertEquals("file", secondProperty);
    }
Example 12
public void testInverse() throws Exception
  {
    Comparator<Integer> normal = Comparators.comparable();
    Comparator<Integer> inverted = Comparators.inverse(normal);

    Assert.assertEquals(-1, normal.compare(0, 1));
    Assert.assertEquals(1, normal.compare(1, 0));
    Assert.assertEquals(0, normal.compare(1, 1));
    Assert.assertEquals(1, inverted.compare(0, 1));
    Assert.assertEquals(-1, inverted.compare(1, 0));
    Assert.assertEquals(0, inverted.compare(1, 1));
  }
Example 13
public void should_update_success(){
        Assert.assertEquals(1, flowDao.list().size());

        flow.setName("flow1");
        flowDao.update(flow);
        Assert.assertEquals(1, flowDao.list().size());

        Node flowCp = flowDao.get(flow.getPath());
        Assert.assertEquals(flow.getName(), flowCp.getName());
    }
Example 14
public void testQ() {
        CharsetParameter c = new CharsetParameter();
        c.setClientEncoding("1");
        c.setServerEncoding("2");
        Assert.assertEquals("1", c.getClientEncoding());
        Assert.assertEquals("2", c.getServerEncoding());

    }
Example 15
public void checkEquality(WorkerNetAddress a, WorkerNetAddress b) {
    Assert.assertEquals(a.getHost(), b.getHost());
    Assert.assertEquals(a.getRpcPort(), b.getRpcPort());
    Assert.assertEquals(a.getDataPort(), b.getDataPort());
    Assert.assertEquals(a.getWebPort(), b.getWebPort());
    Assert.assertEquals(a, b);
  }
Example 16
public void testMinus() throws Exception {
		Vector d = v2.minus(v1);
		Assert.assertEquals(d.get(0), 0.0, TOL);
		Assert.assertEquals(d.get(1), -2.0, TOL);
		Assert.assertEquals(d.get(2), 0.0, TOL);
		Assert.assertEquals(d.get(3), -1.0, TOL);
		Assert.assertEquals(d.get(4), 1.0, TOL);
	}
Example 17
private void assertBufferContains(String expected)
    {
        Assert.assertEquals(expected, this.buffer.toString());
    }
Example 18
public void accept(Boolean active) {
        Assert.assertEquals(true, active);
        listenerCalls.incrementAndGet();
    }
Example 19
public void testAllowedOriginis() {
        String result = sofaBootRpcProperties.getRestAllowedOrigins();
        Assert.assertEquals("a.com", result);
    }
Example 20
public void testShutdown() throws Exception {

        Map<String, Object> value = dubboShutdownEndpoint.shutdown();

        Map<String, Object> shutdownCounts = (Map<String, Object>) value.get("shutdown.count");

        Assert.assertEquals(0, shutdownCounts.get("registries"));
        Assert.assertEquals(1, shutdownCounts.get("protocols"));
        Assert.assertEquals(1, shutdownCounts.get("services"));
        Assert.assertEquals(0, shutdownCounts.get("references"));

    }
Example 21
public void sampler_should_return_default_value() {
        // Given
        final List<T> samples = Collections.emptyList();
        // When
        T min = sampler.sampleMin(samples);
        T max = sampler.sampleMax(samples);
        double avg = sampler.sampleAvg(samples);
        double roundedAvg = sampler.sampleAvg(samples, NUM_DECIMALS_FOR_ROUNDED_AVG);
        // Then
        Assert.assertEquals(DEFAULT_VALUE, min.intValue());
        Assert.assertEquals(DEFAULT_VALUE, max.intValue());
        Assert.assertEquals(DEFAULT_VALUE, avg, DOUBLE_COMPARISON_DELTA);
        Assert.assertEquals(DEFAULT_VALUE, roundedAvg, NUM_DECIMALS_FOR_ROUNDED_AVG);
    }
Example 22
public void testMultiLinesInSingleLine() {
        String comment = "/* single line. */";
        String filtered = filter(comment);
        Assert.assertEquals(1, lineCount(filtered));
        Assert.assertEquals("single line.", filtered);
    }
Example 23
public void whenGetProperty1WithCorrectStringType_thenReturnExpectedResult() {
		beanCursor.moveToFirst();
		String property1 = beanCursor.getString(property1ColumnIndex());

		Assert.assertEquals(expectedProperty1OfBean1(), property1);
	}
Example 24
public void helpNotExist() throws IOException {
    Assert.assertEquals(-1, mFsShell.run("help", "notExistTestCommand"));
    String expected = "notExistTestCommand is an unknown command.\n";
    Assert.assertEquals(expected, mOutput.toString());
  }
Example 25
public void whenModifyingObjects_thenOriginalObjectChanged() {
        Foo a = new Foo(1);
        Foo b = new Foo(1);

        // Before Modification
        Assert.assertEquals(a.num, 1);
        Assert.assertEquals(b.num, 1);
        
        modify(a, b);
        
        // After Modification
        Assert.assertEquals(a.num, 2);
        Assert.assertEquals(b.num, 1);
    }