APISonar


org.junit.Assert.assertThat

> org > junit > Assert > assertThat
org APIs junit APIs Assert APIs assertThat APIs

Example 1
protected <T> void assertThat(T actual, Matcher<T> matcher) {
    checkThread();
    try {
      Assert.assertThat(actual, matcher);
    } catch (AssertionError e) {
      handleThrowable(e);
    }
  }
Example 2
private <S> void checkThat(S item, Matcher<S> matcher)
    {
        try
        {
            Assert.assertThat(item,matcher);
        }
        catch(Throwable th)
        {
            failures.add(th);
        }
    }
Example 3
public void assertContainsLine(String line)
    {
        Assert.assertThat(output.toString(),containsString(line));
    }
Example 4
public void givenService_whenServiceAndAspectExecuted_thenOk() {
        String code = "123456";
        String result = springSuperService.getInfoFromService(code);

        Assert.assertThat(accumulator.size(), is(2));
        Assert.assertThat(accumulator.get(0), is("Call to getInfoFromService"));
        Assert.assertThat(accumulator.get(1), is("Method called successfully: getInfoFromService"));
    }
Example 5
private void checkThrowsAndNoInteraction(Runnable thrower,
            Class<? extends Exception> exception,
            String errorMessage) {
        try {
            thrower.run();
            Assert.fail();
        } catch (Exception e) {
            Assert.assertThat(e, is(instanceOf(exception)));
            Assert.assertThat(e.getMessage(), containsString(errorMessage));
            verifyZeroInteractions(delegateTransaction);
        }
    }
Example 6
private void assertCloseReason(String expectedReason)
    {
        Assert.assertThat("Close Reason",closeReason.getReasonPhrase(),is(expectedReason));
    }
Example 7
public void shouldCreateAndDropExistenceConstraints()
    {
        Result create = db.execute( "CREATE CONSTRAINT ON (n:L) ASSERT exists(n.prop)" );
        Result drop = db.execute( "DROP CONSTRAINT ON (n:L) ASSERT exists(n.prop)" );

        Assert.assertThat( create.getQueryStatistics().getConstraintsAdded(), equalTo( 1 ) );
        Assert.assertThat( create.getQueryStatistics().getConstraintsRemoved(), equalTo( 0 ) );
        Assert.assertThat( drop.getQueryStatistics().getConstraintsAdded(), equalTo( 0 ) );
        Assert.assertThat( drop.getQueryStatistics().getConstraintsRemoved(), equalTo( 1 ) );
    }
Example 8
public void testNoContext() throws Throwable {

        Thread thread = baseTest();
        thread.join();

        Assert.assertThat(segmentStorage.getTraceSegments().size(), is(0));

        verify(requestWrapper, times(0)).setHeader(anyString(), anyString());

    }
Example 9
public void givenURL_whenAnalyze_thenCorrect() throws Exception {
        URL url = new URL(testUrl);

        Assert.assertThat(url.getProtocol(), is("http"));
        Assert.assertThat(url.getHost(), is("www.baeldung.com"));
        Assert.assertThat(url.getQuery(), is("key1=value+1&key2=value%40%21%242&key3=value%253"));
    }
Example 10
private void assertSplitAt(Iterator<String> iter, String... expectedParts)
    {
        int len = expectedParts.length;
        for (int i = 0; i < len; i++)
        {
            String expected = expectedParts[i];
            Assert.assertThat("Split[" + i + "].hasNext()",iter.hasNext(),is(true));
            Assert.assertThat("Split[" + i + "].next()",iter.next(),is(expected));
        }
    }
Example 11
private void assertURI(URI actual, URI expected)
    {
        Assert.assertThat(actual.toASCIIString(),is(expected.toASCIIString()));
    }
Example 12
public void testAsyncNotSupportedNoAsync() throws Exception
    {
        _expectedCode="200 ";
        String response=process("noasync","",null);
        Assert.assertThat(response,Matchers.startsWith("HTTP/1.1 200 OK"));
        assertThat(__history,contains(
            "REQUEST /ctx/noasync/info",
            "initial"
            ));

        assertContains("NORMAL",response);
    }
Example 13
private void assertDummyRequestReceived(Vector<String> assertionItems) {
        Assert.assertThat("should return only one single response", assertionItems.size(), is(1));
        String element = assertionItems.firstElement();
        Assert.assertThat("should write dummy-response as a side-effect", element, containsString("DUMMY_RESPONSE"));
        Assert.assertThat("should write dummy-response with correct status code", element, containsString("HTTP/1.1 301 Moved Permanently"));
    }
Example 14
public void testSimple() throws Exception
    {
        String response=_connector.getResponses("PROXY TCP 1.2.3.4 5.6.7.8 111 222\r\n"+
                "GET /path HTTP/1.1\n"+
                "Host: server:80\n"+
                "Connection: close\n"+
                "\n");
        
        Assert.assertThat(response,Matchers.containsString("HTTP/1.1 200"));
        Assert.assertThat(response,Matchers.containsString("pathInfo=/path"));
        Assert.assertThat(response,Matchers.containsString("local=5.6.7.8:222"));
        Assert.assertThat(response,Matchers.containsString("remote=1.2.3.4:111"));
    }
Example 15
public void assertNotContains(String unexpectedString)
    {
        err.flush();
        String output = new String(test.toByteArray());
        Assert.assertThat(output,not(containsString(unexpectedString)));
    }
Example 16
protected void assertExceptionIsInChain(final Class exceptionClass, Throwable t) {
        Assert.assertThat("Assert " + exceptionClass.getName() + "  is in Exception chain.",
                          t,
                          getExceptionChainMatcher(exceptionClass));
    }
Example 17
private void assertEquals(List<String> expected, List<String> actual)
    {
        Assert.assertThat("Expected Line Count",actual.size(),is(expected.size()));
        int len = expected.size();
        for (int i = 0; i < len; i++)
        {
            String expectedLine = expected.get(i);
            String actualLine = actual.get(i);

            Assert.assertThat("Line[" + i + "]",actualLine,is(expectedLine));
        }
    }
Example 18
public void testSubProtocols() throws Exception
    {
        List<String> subprotocols = ceconfig.getPreferredSubprotocols();
        Assert.assertThat("Client Preferred SubProtocols",subprotocols,contains("chat","echo"));
    }
Example 19
private void assertBufferLengths(List<ByteBuffer> bytes, int... expectedLengths)
    {
        for (int i = 0; i < expectedLengths.length; i++)
        {
            Assert.assertThat("Buffer[" + i + "].remaining",bytes.get(i).remaining(),is(expectedLengths[i]));
        }
    }
Example 20
public static void assertEquals(String message, byte[] expected, byte[] actual)
    {
        Assert.assertThat(message + " byte[].length",actual.length,is(expected.length));
        int len = expected.length;
        for (int i = 0; i < len; i++)
        {
            Assert.assertThat(message + " byte[" + i + "]",actual[i],is(expected[i]));
        }
    }
Example 21
public void canGetActiveDisconnectedAgentJobs() {
        final Set<String> jobs = this.service.getActiveDisconnectedAgentJobs();
        Assert.assertThat(jobs.size(), Matchers.is(1));
        Assert.assertThat(jobs, Matchers.contains("agentJob1"));
    }
Example 22
protected void assertRetries(List<String> allJobIds, int i) {
    for (String id : allJobIds) {
      Assert.assertThat(managementService.createJobQuery().jobId(id).singleResult().getRetries(), is(i));
    }
  }
Example 23
public void testCorrectClassNameEmptyPart() {
    String result = ClassUtils.correctClassName("..a..a..");
    Assert.assertThat(result, is("_._.a._.a._._"));
  }
Example 24
public void testDefault() throws IOException
    {
        BaseHome bh = new BaseHome();
        Assert.assertThat("Home",bh.getHome(),notNullValue());
        Assert.assertThat("Base",bh.getBase(),notNullValue());
    }
Example 25
public void pump_error(Context context) {
    try {
      run(context, true);
      Assert.fail("must throw exception");
    } catch (Throwable e) {
      Assert.assertThat(e, Matchers.instanceOf(ExecutionException.class));
      Assert.assertThat(e.getCause(), Matchers.sameInstance(error));
    }

    Assert.assertTrue(inputStreamClosed);
    Assert.assertTrue(outputStreamClosed);
  }