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:net.i2cat.netconf.test.ClassLoaderResourceTest.java

@Test
public void readMockFiles() {
    String file = "/test/example.txt";
    try {//  w ww .  ja  va2  s  . com
        String information = readStringFromFile(file);
    } catch (Exception e) {
        log.error(e.getMessage());
        e.printStackTrace();
        Assert.fail();
    }

    // log.info("info: " + '\n' + information + '\n');
}

From source file:com.liferay.mobile.push.DeviceRegistrationTest.java

@Test
public void registerWithRegistrationId() throws Exception {
    final String registrationId = "123";

    push.onSuccess(new Push.OnSuccess() {

        @Override/*from   w w  w  .  ja v  a  2s.  co  m*/
        public void onSuccess(JSONObject device) {
            try {
                Assert.assertNotNull(device);
                Assert.assertEquals(Push.ANDROID, device.getString("platform"));
                Assert.assertEquals(registrationId, device.getString("token"));
            } catch (JSONException je) {
                Assert.fail();
            }
        }

    }).onFailure(new Push.OnFailure() {

        @Override
        public void onFailure(Exception e) {
            Assert.fail(e.getMessage());
        }

    }).register(registrationId);

    Robolectric.runBackgroundTasks();
}

From source file:com.nestlabs.sdk.CameraAndroidTest.java

@Test
public void testCameraToParcel() {
    try {/*from  w  ww  .j a  v  a  2  s .c o  m*/
        String json = IOUtils.toString(this.getClass().getResourceAsStream(TEST_CAMERA_JSON), "utf-8");
        Camera camera = mapper.readValue(json, Camera.class);

        Parcel parcel = Parcel.obtain();
        camera.writeToParcel(parcel, 0);

        parcel.setDataPosition(0);

        Camera cameraFromParcel = Camera.CREATOR.createFromParcel(parcel);
        assertEquals(camera, cameraFromParcel);
    } catch (IOException e) {
        e.printStackTrace();
        Assert.fail();
    }
}

From source file:com.nestlabs.sdk.DeviceAndroidTest.java

@Test
public void testNestDeviceToParcel() {
    try {//from   w w  w  .  ja v a  2 s .com
        String json = IOUtils.toString(this.getClass().getResourceAsStream(TEST_DEVICE_JSON), "utf-8");
        Device device = mapper.readValue(json, Device.class);

        Parcel parcel = Parcel.obtain();
        device.writeToParcel(parcel, 0);

        parcel.setDataPosition(0);

        Device deviceFromParcel = Device.CREATOR.createFromParcel(parcel);
        assertEquals(device, deviceFromParcel);
    } catch (IOException e) {
        e.printStackTrace();
        Assert.fail();
    }
}

From source file:com.nestlabs.sdk.MetadataAndroidTest.java

@Test
public void testMetadataToParcel() {
    try {/*from  w ww.jav a2 s .co  m*/
        String json = IOUtils.toString(this.getClass().getResourceAsStream(TEST_METADATA_JSON), "utf-8");
        Metadata metadata = mapper.readValue(json, Metadata.class);

        Parcel parcel = Parcel.obtain();
        metadata.writeToParcel(parcel, 0);

        parcel.setDataPosition(0);

        Metadata metadataFromParcel = Metadata.CREATOR.createFromParcel(parcel);
        assertEquals(metadata, metadataFromParcel);
    } catch (IOException e) {
        e.printStackTrace();
        Assert.fail();
    }
}

From source file:com.nestlabs.sdk.ThermostatAndroidTest.java

@Test
public void testThermostatToParcel() {
    try {//from w  w  w.  j  a  v  a 2 s .  c  o  m
        String json = IOUtils.toString(this.getClass().getResourceAsStream(TEST_THERMOSTAT_JSON), "utf-8");
        Thermostat thermostat = mapper.readValue(json, Thermostat.class);

        Parcel parcel = Parcel.obtain();
        thermostat.writeToParcel(parcel, 0);

        parcel.setDataPosition(0);

        Thermostat thermostatFromParcel = Thermostat.CREATOR.createFromParcel(parcel);
        assertEquals(thermostat, thermostatFromParcel);

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

From source file:com.nestlabs.sdk.SmokeCOAlarmAndroidTest.java

@Test
public void testSmokeCoAlarmToParcel() {
    try {//from  w w  w.j  a va2 s  .co m
        String json = IOUtils.toString(this.getClass().getResourceAsStream(TEST_SMOKE_ALARM_JSON), "utf-8");
        SmokeCOAlarm smokeCOAlarm = mapper.readValue(json, SmokeCOAlarm.class);

        Parcel parcel = Parcel.obtain();
        smokeCOAlarm.writeToParcel(parcel, 0);

        parcel.setDataPosition(0);

        SmokeCOAlarm cameraFromParcel = SmokeCOAlarm.CREATOR.createFromParcel(parcel);
        assertEquals(smokeCOAlarm, cameraFromParcel);
    } catch (IOException e) {
        e.printStackTrace();
        Assert.fail();
    }
}

From source file:org.cloudfoundry.maven.common.UiUtilsTest.java

@Test
public void testRenderTextTable() {
    final List<String> services = new ArrayList<String>();

    services.add("mysql");
    services.add("MyMongoInstance");

    final List<String> uris = new ArrayList<String>();

    uris.add("cf-rocks.api.run.pivotal.io");
    uris.add("spring-rocks.api.run.pivotal.io");

    String expectedTableAsString = null;

    try {/*w w w  . jav  a  2  s.c om*/
        expectedTableAsString = FileCopyUtils.copyToString(new InputStreamReader(
                UiUtilsTest.class.getResourceAsStream("testRenderTextTable-expected-output.txt")));
    } catch (IOException e) {
        e.printStackTrace();
        Assert.fail();
    }

    Assert.assertNotNull(expectedTableAsString);

    final CloudApplication app1 = new CloudApplication("first", "command", "buildpack", 512, 1, uris, services,
            AppState.STARTED);
    final CloudApplication app2 = new CloudApplication("second", "command", "buildpack", 1024, 2, uris,
            services, AppState.STOPPED);

    final List<CloudApplication> applications = Arrays.asList(app1, app2);

    final String renderedTableAsString = UiUtils.renderCloudApplicationsDataAsTable(applications);

    LOGGER.info("\n" + renderedTableAsString);

    Assert.assertEquals(expectedTableAsString, renderedTableAsString);
}

From source file:com.safedocs.testcase.TestFoo.java

@Test
public void testFind() {

    SafeDocsLicenseModel model = new SafeDocsLicenseModel();
    try {/*from w ww . j a  v  a  2  s  .c  om*/
        model.setUuid("8608ef88-a797-4061-99fd-567becf32e2c");
        licenseService.findLicenseData(model);
        System.out.println(model);

    } catch (Exception e) {
        Assert.fail();
        e.printStackTrace();
    } finally {
        //licenseService.delete(model);

    }

}

From source file:org.jrecruiter.service.UserServiceTest.java

@Test
public void testAddUserTest() {

    final User user = getUser();
    final User user2 = getUser();

    try {//from  w ww.  j  av  a2 s  . c o  m
        userService.addUser(user);
        entityManager.flush();
    } catch (DuplicateUserException e) {
        Assert.fail();
    }
    try {
        userService.addUser(user2);
        entityManager.flush();
    } catch (DuplicateUserException e) {
        Assert.assertNotNull(e.getMessage());
        return;
    }
    Assert.fail();
}