Java Examples for org.assertj.core.api.Assertions.fail

The following java examples will help you to understand the usage of org.assertj.core.api.Assertions.fail. These source code samples are taken from different open source projects.

Example 1
Project: camunda-bpm-assert-master  File: ProcessAssertTestCase.java View source code
protected void expect(Failure fail, Class<? extends Throwable>... exception) {
    try {
        fail.when();
    } catch (Throwable e) {
        for (int i = 0; i < exception.length; i++) {
            Class<? extends Throwable> t = exception[i];
            if (t.isAssignableFrom(e.getClass())) {
                System.out.println(String.format("caught " + e.getClass().getSimpleName() + " of expected type " + t.getSimpleName() + " with message '%s'", e.getMessage()));
                return;
            }
        }
        throw (RuntimeException) e;
    }
    fail("expected one of " + Lists.newArrayList(exception) + " to be thrown, but did not see any");
}
Example 2
Project: camunda-bpmn-model-master  File: EventBasedGatewayTest.java View source code
@Test
public void shouldFailSetAsyncAfterToEventBasedGateway() {
    // fetching should fail
    try {
        gateway.isCamundaAsyncAfter();
        fail("Expected: UnsupportedOperationException");
    } catch (UnsupportedOperationException ex) {
    }
    // set the attribute should fail to!
    try {
        gateway.setCamundaAsyncAfter(false);
        fail("Expected: UnsupportedOperationException");
    } catch (UnsupportedOperationException ex) {
    }
}
Example 3
Project: analytics-android-master  File: ProjectSettingsTest.java View source code
@Test
public void deserialization() throws IOException {
    Cartographer cartographer = Cartographer.INSTANCE;
    String projectSettingsJson = "{\n" + "  \"Amplitude\": {\n" + "    \"trackNamedPages\": true,\n" + "    \"trackCategorizedPages\": true,\n" + "    \"trackAllPages\": false,\n" + "    \"apiKey\": \"x\"\n" + "  },\n" + "  \"Flurry\": {\n" + "    \"apiKey\": \"x\",\n" + "    \"captureUncaughtExceptions\": false,\n" + "    \"useHttps\": true,\n" + "    \"sessionContinueSeconds\": 10\n" + "  },\n" + "  \"Mixpanel\": {\n" + "    \"people\": true,\n" + "    \"token\": \"x\",\n" + "    \"trackAllPages\": false,\n" + "    \"trackCategorizedPages\": true,\n" + "    \"trackNamedPages\": true,\n" + "    \"increments\": [\n" + "      \n" + "    ],\n" + "    \"legacySuperProperties\": false\n" + "  },\n" + "  \"Segment.io\": {\n" + "    \"apiKey\": \"x\"\n" + "  }\n" + "}";
    ProjectSettings projectSettings = ProjectSettings.create(cartographer.fromJson(projectSettingsJson));
    assertThat(projectSettings).hasSize(5).containsKey("timestamp").containsKey("Segment.io");
    try {
        projectSettings.put("foo", "bar");
        fail("projectSettings should be immutable");
    } catch (UnsupportedOperationException ignored) {
    }
}
Example 4
Project: mockito-master  File: DefaultAnswerValidatorTest.java View source code
@Test
public void should_fail_if_returned_value_of_answer_is_incompatible_with_return_type() throws Throwable {
    // given
    class AWrongType {
    }
    try {
        // when
        DefaultAnswerValidator.validateReturnValueFor(new InvocationBuilder().method("toString").toInvocation(), new AWrongType());
        fail("expected validation to fail");
    } catch (WrongTypeOfReturnValue e) {
        assertThat(e.getMessage()).containsIgnoringCase("Default answer returned a result with the wrong type").containsIgnoringCase("AWrongType cannot be returned by toString()").containsIgnoringCase("toString() should return String");
    }
}
Example 5
Project: storio-master  File: ObservableBehaviorCheckerTest.java View source code
@Test(expected = IllegalStateException.class)
public void assertThatObservableEmitsOnceNegative() {
    final Observable<Integer> testObservable = Observable.just(1, 2);
    new ObservableBehaviorChecker<Integer>().observable(testObservable).expectedNumberOfEmissions(1).testAction(new Action1<Integer>() {

        final AtomicInteger numberOfInvocations = new AtomicInteger(0);

        @Override
        public void call(Integer i) {
            if (numberOfInvocations.incrementAndGet() > 1) {
                fail("Should be called once");
            }
        }
    }).checkBehaviorOfObservable();
}
Example 6
Project: sonar-java-master  File: CheckRegistrarTest.java View source code
@Test
public void repository_key_is_mandatory() throws Exception {
    try {
        new CheckRegistrar.RegistrarContext().registerClassesForRepository("  ", Lists.<Class<? extends JavaCheck>>newArrayList(), Lists.<Class<? extends JavaCheck>>newArrayList());
        fail("");
    } catch (IllegalArgumentException e) {
        assertThat(e).hasMessage("Please specify a valid repository key to register your custom rules");
    } catch (Exception e) {
        fail("");
    }
}
Example 7
Project: webtoolkit-master  File: BugFreeUser.java View source code
@Test
public void constructors() {
    try {
        for (String BLANK : BLANKS) {
            new User(BLANK);
            fail("missing not empty check on name");
        }
    } catch (IllegalArgumentException x) {
        then(x).hasMessage("name can not be empty");
    }
    for (String name : new String[] { "a user", "another user" }) {
        User u = new User(name);
        then(u.getName()).isEqualTo(name);
    }
    for (String secret : new String[] { null, "", "a password", "  " }) {
        User u = new User("a user", secret);
        then(u.getSecret()).isEqualTo(secret);
    }
}
Example 8
Project: lettuce-core-master  File: PoolingProxyFactoryTest.java View source code
@Test
public void testCreate() throws Exception {
    RedisConnection<String, String> connection = PoolingProxyFactory.create(client.pool());
    connection.set("a", "b");
    connection.close();
    try {
        connection.set("x", "y");
        fail("missing exception");
    } catch (RedisException e) {
        assertThat(e.getMessage()).isEqualTo("Connection pool is closed");
    }
}
Example 9
Project: gwt-test-utils-master  File: MainGwtTest.java View source code
@Test
public void runAsync() {
    // Test
    GWT.runAsync(new RunAsyncCallback() {

        @Override
        public void onFailure(Throwable reason) {
            fail("GWT.runAsync() has called \"onFailure\" callback");
        }

        @Override
        public void onSuccess() {
            success = true;
        }
    });
    // Then
    assertThat(success).isTrue();
}
Example 10
Project: spring-security-master  File: ProtectPointcutPerformanceTests.java View source code
// Method for use with profiler
@Test
public void usingPrototypeDoesNotParsePointcutOnEachCall() {
    StopWatch sw = new StopWatch();
    sw.start();
    for (int i = 0; i < 1000; i++) {
        try {
            SessionRegistry reg = (SessionRegistry) ctx.getBean("sessionRegistryPrototype");
            reg.getAllPrincipals();
            fail("Expected AuthenticationCredentialsNotFoundException");
        } catch (AuthenticationCredentialsNotFoundException expected) {
        }
    }
    sw.stop();
// assertThat(sw.getTotalTimeMillis() < 1000).isTrue();
}
Example 11
Project: grappa-master  File: JoinMatcherTest.java View source code
@Test
public void joinMatcherYellsIfJoiningRuleMatchesEmpty() {
    final CharSequence input = "aaaabaaaaxaaa";
    final MyParser parser = Grappa.createParser(MyParser.class);
    final ParseRunner<Object> runner = new ParseRunner<>(parser.rule());
    final String expectedMessage = "joining rule (foo) of a JoinMatcher" + " cannot match an empty character sequence!";
    try {
        runner.run(input);
        fail("No exception thrown!!");
    } catch (GrappaException e) {
        assertThat(e).hasMessage(expectedMessage);
    }
}