Example usage for junit.framework Assert fail

List of usage examples for junit.framework Assert fail

Introduction

In this page you can find the example usage for junit.framework Assert fail.

Prototype

static public void fail() 

Source Link

Document

Fails a test with no message.

Usage

From source file:configuration.field.array.ConfigurationArrayFieldTest.java

@Test
public void loadEmptyPrimitive() {
    try {/*from   ww  w.jav  a2 s .com*/
        propertiesNullConfig.getEmptyPrimitiveIntegers();
        Assert.fail();
    } catch (ConfigurationException cause) {
        assertEquals(ConversionException.class, cause.getCause().getClass());
    }
}

From source file:com.microsoft.windowsazure.mobileservices.sdk.testapp.test.LoginTests.java

private void testLoginOperation(final Object provider) throws Throwable {
    final ResultsContainer result = new ResultsContainer();

    // Create client
    MobileServiceClient client = null;/*from   w ww .ja  v  a  2s  .  com*/
    try {
        client = new MobileServiceClient(appUrl, appKey, getInstrumentation().getTargetContext());
    } catch (MalformedURLException e) {
    }

    // Add a new filter to the client
    client = client.withFilter(new ServiceFilter() {

        @Override
        public ListenableFuture<ServiceFilterResponse> handleRequest(ServiceFilterRequest request,
                NextServiceFilterCallback nextServiceFilterCallback) {

            result.setRequestUrl(request.getUrl());

            ServiceFilterResponseMock response = new ServiceFilterResponseMock();
            response.setContent("{authenticationToken:'123abc', user:{userId:'123456'}}");

            final SettableFuture<ServiceFilterResponse> resultFuture = SettableFuture.create();

            resultFuture.set(response);

            return resultFuture;
        }
    });

    try {

        MobileServiceUser user = null;

        if (provider.getClass().equals(MobileServiceAuthenticationProvider.class)) {
            user = client.login((MobileServiceAuthenticationProvider) provider, "{myToken:123}").get();

        } else {
            user = client.login((String) provider, "{myToken:123}").get();
        }

        assertEquals("123456", user.getUserId());
        assertEquals("123abc", user.getAuthenticationToken());

    } catch (Exception exception) {
        Assert.fail();
    }

    // Assert
    String expectedURL = appUrl + "login/" + provider.toString().toLowerCase(Locale.getDefault());
    assertEquals(expectedURL, result.getRequestUrl());
}

From source file:com.inmobi.grill.driver.impala.TestImpalaDriver.java

@Test
public void testExecute() {
    try {/*www .j  ava2  s  . co  m*/

        // configure before executing
        Configuration config = new Configuration();
        config.set("PORT", "123");
        config.set("HOST", "test.com");

        TSocket mockSocket = PowerMockito.mock(TSocket.class);

        TBinaryProtocol mockTProtocol = PowerMockito.mock(TBinaryProtocol.class);
        ImpalaService.Client mockClient = Mockito.mock(ImpalaService.Client.class);

        Query q = mock(Query.class);
        QueryHandle qh = mock(QueryHandle.class);
        ImpalaResultSet mockResultSet = mock(ImpalaResultSet.class);

        when(mockResultSet.hasNext()).thenReturn(true);
        whenNew(Query.class).withNoArguments().thenReturn(q);
        when(mockClient.query(q)).thenReturn(qh);
        when(mockClient.get_state(qh)).thenReturn(QueryState.FINISHED);

        whenNew(TSocket.class).withArguments(config.get("HOST"), config.getInt("PORT", 9999))
                .thenReturn(mockSocket);
        whenNew(TBinaryProtocol.class).withArguments(mockSocket).thenReturn(mockTProtocol);
        whenNew(ImpalaService.Client.class).withArguments(mockTProtocol).thenReturn(mockClient);
        whenNew(ImpalaResultSet.class).withArguments(mockClient, qh).thenReturn(mockResultSet);

        // actual run
        this.testInst.configure(config);
        GrillResultSet br = this.testInst.execute("query", null);

        // test and verify
        Assert.assertEquals(true, ((ImpalaResultSet) br).hasNext());
        Mockito.verify(mockClient).query(q);
        Mockito.verify(mockClient).get_state(qh);

    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail();
    }

}

From source file:com.onesite.sdk.test.api.SessionApiTest.java

@Test
public void testLogin() {
    SessionApi api = new SessionApi();
    try {/*w  ww  .java2s  . co m*/
        User testUser = new User();
        testUser.setId(userID);

        Session session = api.login(testUser, password, agent, ip, expiresFromNow);

        System.out.println("Active Session");
        System.out.println("coreU: " + session.getCoreU());
        System.out.println("coreX: " + session.getCoreU());
        System.out.println("Data:  " + session.getSessionDataSize());

        System.out.println("Login Successful");
        Assert.assertFalse(StringUtils.isEmpty(session.getCoreU()));

        System.out.println("Running session check against logged in coreU " + session.getCoreU());
        session = api.check(session);
        System.out.println("coreU: " + session.getCoreU());
        System.out.println("coreX: " + session.getCoreU());
        System.out.println("Data:  " + session.getSessionDataSize());
        if (session.isSetSessionData()) {
            System.out.println("User Status: " + session.getSessionData().get("STATUS"));
        }

        Assert.assertFalse(StringUtils.isEmpty(session.getCoreU()));
    } catch (Exception e) {
        Assert.fail();
    }
}

From source file:configuration.field.array.ConfigurationArrayFieldTest.java

@Test
public void loadEmptyWrapper() {
    try {/*from w  w w.  j  a  va2  s. co  m*/
        propertiesNullConfig.getEmptyWrapperIntegers();
        Assert.fail();
    } catch (ConfigurationException cause) {
        assertEquals(ConversionException.class, cause.getCause().getClass());
    }
}

From source file:org.opencastproject.remotetest.server.ComposerRestEndpointTest.java

@Test
public void testImageExtraction() throws Exception {
    HttpPost postEncode = new HttpPost(ComposerResources.getServiceUrl() + "image");
    List<NameValuePair> formParams = new ArrayList<NameValuePair>();
    formParams.add(new BasicNameValuePair("sourceTrack", SampleUtils.generateVideoTrack(BASE_URL)));
    formParams.add(new BasicNameValuePair("time", "1"));
    formParams.add(new BasicNameValuePair("profileId", "feed-cover.http"));
    postEncode.setEntity(new UrlEncodedFormEntity(formParams, "UTF-8"));

    // Grab the job from the response
    HttpResponse postResponse = client.execute(postEncode);
    String postResponseXml = EntityUtils.toString(postResponse.getEntity());
    String jobId = getJobId(postResponseXml);

    Assert.assertEquals(200, postResponse.getStatusLine().getStatusCode());
    Assert.assertTrue(postResponseXml.contains("job"));

    // Poll the service for the status of the job.
    while (!JobUtils.isJobInState(jobId, "FINISHED")) {
        Thread.sleep(2000); // wait and try again
        System.out.println("Waiting for image extraction job " + jobId + " to finish");
        if (JobUtils.isJobInState(jobId, "FAILED")) {
            Assert.fail();
        }/*  w w  w . j a v a  2s .com*/
    }
}

From source file:org.tritsch.android.chargefinder.CFService.java

/**
 * <code>getString</code> extract a/the string from the input stream.
 *
 * @param is an <code>InputStream</code> value
 * @return a <code>String</code> value
 *///  w  w w  . j  a  va  2 s  .c o m
private static String getString(final InputStream is) {
    if (Log.isLoggable(TAG, Log.DEBUG))
        Log.d(TAG, "Enter: getString()");
    Assert.assertNotNull(is);

    BufferedReader reader = new BufferedReader(new InputStreamReader(is));
    Assert.assertNotNull(reader);
    StringBuilder sb = new StringBuilder();
    String line = null;
    try {
        while ((line = reader.readLine()) != null) {
            sb.append(line + "\n");
        }
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail();
    } finally {
        try {
            is.close();
        } catch (Exception e) {
            e.printStackTrace();
            Assert.fail();
        }
    }

    if (Log.isLoggable(TAG, Log.DEBUG))
        Log.d(TAG, "Leave: getString()");
    return sb.toString();
}

From source file:configuration.field.array.ConfigurationArrayFieldTest.java

@Test
public void loadErrorTypeWrapper() {
    try {/*w ww  .j a v a 2 s  . co m*/
        propertiesNullConfig.getErrorTypeWrapperIntegers();
        Assert.fail();
    } catch (ConfigurationException cause) {
        assertEquals(ConversionException.class, cause.getCause().getClass());
    }
}

From source file:com.brienwheeler.lib.test.stepper.SteppableThreadTest.java

@Test
public void testJoinTimeout() {
    SteppableThread stepper = new SteppableOneStep();
    ReflectionTestUtils.setField(stepper, "joinDelay", 10L);
    stepper.start();/*from www.j  a v a  2 s.  c o  m*/

    try {
        stepper.releaseAndJoin();
        Assert.fail();
    } catch (RuntimeException e) {
        Assert.assertEquals(TimeoutException.class, e.getCause().getClass());
    }

    ReflectionTestUtils.setField(stepper, "joinDelay", 10000L);
    stepper.waitDone();
    stepper.releaseAndJoin();
}

From source file:com.onesite.sdk.test.api.SessionApiTest.java

@Test
public void testLoginCrossDomain() {
    SessionApi api = new SessionApi();
    try {/*w  w w  .  j  ava2s .c  om*/
        User testUser = new User();
        testUser.setId(userID);

        URL redirectUrl = api.loginCrossDomain(testUser, password, callbackUrl, ip, expiresFromNow);

        System.out.println("Login Cross Domain Redirect Url");
        System.out.println(redirectUrl.toString());

        Assert.assertFalse(StringUtils.isEmpty(redirectUrl.toString()));
    } catch (Exception e) {
        Assert.fail();
    }
}