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(String message) 

Source Link

Document

Fails a test with the given message.

Usage

From source file:com.mnxfst.testing.server.cfg.TestPTestServerConfigurationParser.java

@Test
public void testParserServeConfigurationWithNullFilename() {

    try {//  w  w  w  . j  a va 2  s.  com
        String filename = null;
        new PTestServerConfigurationParser().parseServerConfiguration(filename);
        Assert.fail("Missing required file name");
    } catch (ServerConfigurationFailedException e) {
        //
    }
}

From source file:eu.stratosphere.pact.runtime.task.CrossTaskTest.java

@Test
public void testBlockEmptyInnerCrossTask() {

    int keyCnt1 = 10;
    int valCnt1 = 1;

    int keyCnt2 = 0;
    int valCnt2 = 0;

    super.initEnvironment(1 * 1024 * 1024);
    super.addInput(new UniformPactRecordGenerator(keyCnt1, valCnt1, false), 0);
    super.addInput(new UniformPactRecordGenerator(keyCnt2, valCnt2, false), 1);
    super.addOutput(this.outList);

    CrossTask<PactRecord, PactRecord, PactRecord> testTask = new CrossTask<PactRecord, PactRecord, PactRecord>();
    super.getTaskConfig().setLocalStrategy(LocalStrategy.NESTEDLOOP_BLOCKED_OUTER_FIRST);
    super.getTaskConfig().setMemorySize(1 * 1024 * 1024);

    super.registerTask(testTask, MockCrossStub.class);

    try {/*from www . j  av a  2 s . c o m*/
        testTask.invoke();
    } catch (Exception e) {
        LOG.debug(e);
        Assert.fail("Invoke method caused exception.");
    }

    int expCnt = keyCnt1 * valCnt1 * keyCnt2 * valCnt2;

    Assert.assertTrue("Resultset size was " + this.outList.size() + ". Expected was " + expCnt,
            this.outList.size() == expCnt);

    this.outList.clear();

}

From source file:byps.test.TestSerializerSet.java

/**
 * A List<Object> can contain only BSerializable objects.
 * @throws BException //from  w  w  w .  j a v a  2  s .  co  m
 */
@Test
public void testSetOfObject() throws BException {
    log.info("testSetOfObject(");

    try {
        SetTypes obj = new SetTypes();
        obj.obj1 = new HashSet<Object>();
        obj.obj1.add("string must fail");
        internaltestSet(obj);
        Assert.fail("Exception expected for List<Object> containing Strings");
    } catch (BException e) {
        Assert.assertTrue(e.toString().startsWith("[BYPS:" + BExceptionC.CORRUPT));
    }

    SetTypes obj = new SetTypes();
    obj.obj1 = new HashSet<Object>();
    obj.obj1.add(TestUtils.createObjectPrimitiveTypes());
    internaltestSet(obj);

    log.info(")testSetOfObject");
}

From source file:com.mnxfst.testing.server.cfg.TestPTestServerConfigurationParser.java

@Test
public void testParserServeConfigurationWithEmptyFilename() {

    try {/* w w w  .j  a v a 2  s.  c  o  m*/
        new PTestServerConfigurationParser().parseServerConfiguration("");
        Assert.fail("Missing required file name");
    } catch (ServerConfigurationFailedException e) {
        //
    }
}

From source file:BQJDBC.QueryResultTest.BQForwardOnlyResultSetFunctionTest.java

@Test
public void TestResultSetgetString() {
    try {/*from  ww  w  .  ja  v  a  2s .c o  m*/
        Assert.assertTrue(Result.next());
        Assert.assertEquals("you", BQForwardOnlyResultSetFunctionTest.Result.getString(1));
    } catch (SQLException e) {
        this.logger.error("SQLexception" + e.toString());
        Assert.fail("SQLException" + e.toString());
    }
}

From source file:com.mnxfst.testing.server.cfg.TestPTestServerConfigurationParser.java

@Test
public void testParserServeConfigurationWithInvalidFilename() {

    try {/*from   w  w w .java  2s . co  m*/
        new PTestServerConfigurationParser().parseServerConfiguration("wtf-no-such-file");
        Assert.fail("Invalid file name");
    } catch (ServerConfigurationFailedException e) {
        //
    }
}

From source file:com.cubusmail.server.user.UserAccountDaoTest.java

@Test
public void testUpdateAddress() {

    try {/*from  ww  w  .  j a va2s .co  m*/
        List<AddressFolder> folders = (List<AddressFolder>) this.applicationContext
                .getBean("testAddressFolders");
        folders.get(0).setUserAccount(this.testUserAccount);
        this.userAccountDao.saveAddressFolder(folders.get(0));

        List<Address> testAddressList = (List<Address>) this.applicationContext.getBean("testAddresses");
        for (Address address : testAddressList) {
            address.setAddressFolder(folders.get(0));
            this.userAccountDao.saveAddress(address);
        }

        List<Address> savedAddressList = this.userAccountDao.retrieveAddressList(folders.get(0));
        Assert.assertNotNull(savedAddressList);
        Assert.assertTrue(savedAddressList.size() > 0);
        Assert.assertEquals(testAddressList.get(0), savedAddressList.get(0));

        Address savedAddress = savedAddressList.get(0);
        Address testAddress2 = testAddressList.get(1);

        // copy modify properties
        Long saveId = savedAddress.getId();
        AddressFolder savedFolder = savedAddress.getAddressFolder();
        BeanUtils.copyProperties(savedAddress, testAddress2);
        savedAddress.setId(saveId);
        savedAddress.setAddressFolder(savedFolder);
        this.userAccountDao.saveAddress(savedAddress);

        List<Address> savedAddressList2 = this.userAccountDao.retrieveAddressList(folders.get(0));
        Assert.assertNotNull(savedAddressList2);
        Assert.assertTrue(savedAddressList2.size() > 0);
        Assert.assertEquals(savedAddress, savedAddressList2.get(0));

    } catch (Exception e) {
        log.error(e.getMessage(), e);
        Assert.fail(e.getMessage());
    }
}

From source file:eu.stratosphere.pact.runtime.task.CoGroupTaskTest.java

@Test
public void testMergeCoGroupTask() {

    int keyCnt1 = 200;
    int valCnt1 = 2;

    int keyCnt2 = 200;
    int valCnt2 = 4;

    super.initEnvironment(1024 * 1024);
    super.addInput(new UniformPactRecordGenerator(keyCnt1, valCnt1, true), 1);
    super.addInput(new UniformPactRecordGenerator(keyCnt2, valCnt2, true), 2);
    super.addOutput(this.outList);

    CoGroupTask<PactRecord, PactRecord, PactRecord> testTask = new CoGroupTask<PactRecord, PactRecord, PactRecord>();
    super.getTaskConfig().setLocalStrategy(LocalStrategy.MERGE);
    super.getTaskConfig().setMemorySize(0);
    super.getTaskConfig().setNumFilehandles(4);

    final int[] keyPos1 = new int[] { 0 };
    final int[] keyPos2 = new int[] { 0 };
    @SuppressWarnings("unchecked")
    final Class<? extends Key>[] keyClasses = (Class<? extends Key>[]) new Class[] { PactInteger.class };

    PactRecordComparatorFactory.writeComparatorSetupToConfig(super.getTaskConfig().getConfiguration(),
            super.getTaskConfig().getPrefixForInputParameters(0), keyPos1, keyClasses);
    PactRecordComparatorFactory.writeComparatorSetupToConfig(super.getTaskConfig().getConfiguration(),
            super.getTaskConfig().getPrefixForInputParameters(1), keyPos2, keyClasses);

    super.registerTask(testTask, MockCoGroupStub.class);

    try {//from  w ww  . j  av  a2s . c o  m
        testTask.invoke();
    } catch (Exception e) {
        LOG.debug(e);
        Assert.fail("Invoke method caused exception.");
    }

    int expCnt = valCnt1 * valCnt2 * Math.min(keyCnt1, keyCnt2) + Math.max(keyCnt1, keyCnt2)
            - Math.min(keyCnt1, keyCnt2);

    Assert.assertTrue("Resultset size was " + this.outList.size() + ". Expected was " + expCnt,
            this.outList.size() == expCnt);

    this.outList.clear();

}

From source file:org.jasig.schedassist.impl.SchedulingAssistantServiceImplTest.java

/**
 * Expect a SchedulingException/*from   w w  w  . ja  v a2 s  .com*/
 * @throws Exception
 */
@Test
public void testScheduleAppointmentVisitorLimitExceeded() throws Exception {
    // construct a schedule owner
    MockCalendarAccount ownerAccount = new MockCalendarAccount();
    ownerAccount.setUsername("user1");
    ownerAccount.setEmailAddress("owner@domain.com");
    ownerAccount.setDisplayName("OWNER OWNER");
    DefaultScheduleOwnerImpl owner = new DefaultScheduleOwnerImpl(ownerAccount, 1);

    // construct a schedule visitor
    MockCalendarAccount visitorAccount = new MockCalendarAccount();
    visitorAccount.setUsername("v1");
    visitorAccount.setEmailAddress("v1@doit.wisc.edu");
    visitorAccount.setDisplayName("VISITOR ONE");
    DefaultScheduleVisitorImpl visitor = new DefaultScheduleVisitorImpl(visitorAccount);
    // construct 2nd visitor
    MockCalendarAccount visitor2Account = new MockCalendarAccount();
    visitor2Account.setUsername("v2");
    visitor2Account.setEmailAddress("v2@doit.wisc.edu");
    visitor2Account.setDisplayName("VISITOR TWO");
    DefaultScheduleVisitorImpl visitor2 = new DefaultScheduleVisitorImpl(visitor2Account);

    // construct target availableblock for appointment
    AvailableBlock targetBlock = AvailableBlockBuilder.createBlock("20091111-1330", "20091111-1400", 2);

    DefaultEventUtilsImpl eventUtils = new DefaultEventUtilsImpl(new NullAffiliationSourceImpl());
    // construct expected VEvent
    VEvent expectedEvent = eventUtils.constructAvailableAppointment(targetBlock, owner, visitor, "description");
    expectedEvent.getProperties().add(eventUtils
            .constructSchedulingAssistantAttendee(visitor2.getCalendarAccount(), AppointmentRole.VISITOR));

    // create mock CalendarDao and AvailableScheduleDao
    ICalendarDataDao mockCalendarDao = EasyMock.createMock(ICalendarDataDao.class);
    EasyMock.expect(mockCalendarDao.getExistingAppointment(owner, targetBlock)).andReturn(expectedEvent);

    AvailableScheduleDao mockScheduleDao = EasyMock.createMock(AvailableScheduleDao.class);
    EasyMock.expect(mockScheduleDao.retrieveTargetBlock(owner,
            CommonDateOperations.parseDateTimePhrase("20091111-1330"))).andReturn(targetBlock);
    EasyMock.replay(mockCalendarDao, mockScheduleDao);

    SchedulingAssistantServiceImpl serviceImpl = new SchedulingAssistantServiceImpl();
    serviceImpl.setAvailableScheduleDao(mockScheduleDao);
    serviceImpl.setCalendarDataDao(mockCalendarDao);
    serviceImpl.setEventUtils(new DefaultEventUtilsImpl(new NullAffiliationSourceImpl()));

    // construct 3rd visitor
    MockCalendarAccount visitor3Account = new MockCalendarAccount();
    visitor3Account.setUsername("v3");
    visitor3Account.setEmailAddress("v3@doit.wisc.edu");
    visitor3Account.setDisplayName("VISITOR THREE");
    DefaultScheduleVisitorImpl visitor3 = new DefaultScheduleVisitorImpl(visitor3Account);

    try {
        serviceImpl.scheduleAppointment(visitor3, owner, targetBlock, "description");
        Assert.fail("expected SchedulingException not thrown");
    } catch (SchedulingException e) {
        // success
    }

    EasyMock.verify(mockCalendarDao, mockScheduleDao);
}

From source file:org.obiba.onyx.core.etl.participant.impl.XmlParticipantReaderTest.java

/**
 * Tests processing of an appointment list that contains a duplicate attribute column (Last Name).
 * /*from ww  w .  ja  v a  2  s  .c  o m*/
 * @throws IOException if the appointment list could not be read
 */
@Test
public void testProcessWithDuplicateAttributeTag() throws IOException {
    XmlParticipantReaderForTest reader = createXmlParticipantReaderForTest(false,
            TEST_RESOURCES_DIR + "/appointmentList_duplicateAttributeTag.xml");
    reader.setColumnNameToAttributeNameMap(columnNameToAttributeNameMap);
    reader.setParticipantMetadata(participantMetadata);

    reader.open(context);
    List<Participant> participants = new ArrayList<Participant>();

    try {
        while (reader.getIterator().hasNext()) {
            Participant participant = reader.read();
            if (participant != null)
                participants.add(participant);
        }
    } catch (Exception e) {
        String errorMessage = e.getMessage();
        Assert.assertEquals("Duplicate tag for field: NOM", errorMessage);
        return;
    }

    Assert.fail("Should have thrown an IllegalArgumentException");
}