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:eu.stratosphere.pact.runtime.task.CrossTaskTest.java

@Test
public void testStreamEmptyOuterCrossTask() {

    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_STREAMED_OUTER_SECOND);
    super.getTaskConfig().setMemorySize(1 * 1024 * 1024);

    super.registerTask(testTask, MockCrossStub.class);

    try {//from  ww w  .ja v a  2  s . co 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:eu.stratosphere.pact.runtime.task.ReduceTaskTest.java

@Test
public void testCancelReduceTaskWhileReducing() {

    final int keyCnt = 1000;
    final int valCnt = 2;

    addInput(new UniformRecordGenerator(keyCnt, valCnt, true));
    addInputComparator(this.comparator);
    setOutput(new NirvanaOutputList());
    getTaskConfig().setDriverStrategy(DriverStrategy.SORTED_GROUP_REDUCE);

    final GroupReduceDriver<Record, Record> testTask = new GroupReduceDriver<Record, Record>();

    final AtomicBoolean success = new AtomicBoolean(false);

    Thread taskRunner = new Thread() {
        @Override/*ww w.  j ava 2  s.  co m*/
        public void run() {
            try {
                testDriver(testTask, MockDelayingReduceStub.class);
                success.set(true);
            } catch (Exception ie) {
                ie.printStackTrace();
            }
        }
    };
    taskRunner.start();

    TaskCancelThread tct = new TaskCancelThread(2, taskRunner, this);
    tct.start();

    try {
        tct.join();
        taskRunner.join();
    } catch (InterruptedException ie) {
        Assert.fail("Joining threads failed");
    }

}

From source file:BQJDBC.QueryResultTest.BQForwardOnlyResultSetFunctionTest.java

@Test
public void TestResultSetgetBoolean() {
    try {/*  w w w  .j  a  v  a 2 s  .com*/
        Assert.assertTrue(Result.next());
        Assert.assertEquals(Boolean.parseBoolean("42"),
                BQForwardOnlyResultSetFunctionTest.Result.getBoolean(2));
    } catch (SQLException e) {
        this.logger.error("SQLexception" + e.toString());
        Assert.fail("SQLException" + e.toString());
    }
}

From source file:cz.PA165.vozovyPark.dao.ServiceIntervalDAOTest.java

/**
 *
 *///from w  ww  . j  a  v  a 2s  .com
@Test
public void testValidFindByVehicle() {
    try {
        Vehicle mercedes = ServiceIntervalDAOTest.getVehicle("Mercedes", 14000, "R4 Diesel", "A",
                UserClassEnum.PRESIDENT, "2f-4xxi-121245", 2009);
        vehicleDao.createVehicle(mercedes);
        ServiceInterval interval1 = ServiceIntervalDAOTest.getServiceInterval(new ArrayList<Date>(),
                "Prehodeni koles", 7, mercedes);
        serviceIntervalDAO.createSI(interval1);

        em.getTransaction().begin();
        List<ServiceInterval> intervalsOfVehicle = serviceIntervalDAO.findAllByVehicle(mercedes);
        em.getTransaction().commit();
        if (intervalsOfVehicle.isEmpty()) {
            Assert.fail("Any intervals of given vehicle were loaded from databse!");
        }
    } catch (Exception ex) {
        Assert.fail("Unexpected exception was throwed: " + ex + " " + ex.getMessage());
    }
}

From source file:com.verisign.epp.interfaces.EPPLaunchTst.java

/**
 * Unit test of using using the <code>EPPLaunchCheck</code> Extension with
 * <code>EPPDomain</code> info command with the following tests:<br>
 * <br>/* w  ww  .j av  a 2 s .  c  o m*/
 * <ol>
 * <li>Claims check with one domain name and implicitly setting the type.
 * <li>Claims check with two domain names and explicitly setting the type.
 * <li>Available check with two domain names for the custom "idn-release"
 * launch phase.
 * </ol>
 */
public void launchCheck() {
    printStart("launchCheck");

    EPPResponse claimsCheckResp;

    try {
        // Claims check with one domain name and implicitly setting the
        // type.
        System.out.println("\n----------------------------------------------------------------");

        System.out.println("launchCheck: Claims Check for example1.tld with implicit type");

        launch.setTransId("ABC-12345");

        launch.addDomainName("example1.tld");
        launch.setPhase(EPPLaunch.PHASE_CLAIMS);
        claimsCheckResp = launch.sendCheck();

        System.out.println("Response Type = " + claimsCheckResp.getType());

        System.out
                .println("Response.TransId.ServerTransId = " + claimsCheckResp.getTransId().getServerTransId());

        System.out
                .println("Response.TransId.ServerTransId = " + claimsCheckResp.getTransId().getClientTransId());

        // Output all of the response attributes
        System.out.println("\nlaunchCheck: Response = [" + claimsCheckResp + "]");

        // No EPPLaunchChkData extension in response?
        if (!claimsCheckResp.hasExtension(EPPLaunchChkData.class)) {
            Assert.fail("launchCheck: No EPPLaunchChkData extension found in claims check response");
        }

        EPPLaunchChkData theExt = (EPPLaunchChkData) claimsCheckResp.getExtension(EPPLaunchChkData.class);
        List<EPPLaunchCheckResult> results = theExt.getCheckResults();

        for (EPPLaunchCheckResult result : results) {

            if (result.isExists()) {
                System.out.println("launchCheck: Domain + " + result.getName() + ", mark exists, claimKey = ["
                        + result.getClaimKey() + "]");
            } else {
                System.out.println("launchCheck: Domain + " + result.getName() + ", mark DOES NOT exist");
            }

        }

        // Claims check with two domain names and explicitly setting the
        // type.
        System.out.println("\n----------------------------------------------------------------");

        System.out.println("launchCheck: Claims Check for example1.tld and example2.tld with explicit type");

        launch.setTransId("ABC-12345");

        launch.addDomainName("example1.tld");
        launch.addDomainName("example2.tld");
        launch.setPhase(EPPLaunch.PHASE_CLAIMS);
        launch.setType(EPPLaunch.TYPE_CLAIMS);
        claimsCheckResp = launch.sendCheck();

        System.out.println("Response Type = " + claimsCheckResp.getType());

        System.out
                .println("Response.TransId.ServerTransId = " + claimsCheckResp.getTransId().getServerTransId());

        System.out
                .println("Response.TransId.ServerTransId = " + claimsCheckResp.getTransId().getClientTransId());

        // Output all of the response attributes
        System.out.println("\nlaunchCheck: Response = [" + claimsCheckResp + "]");

        // No EPPLaunchChkData extension in response?
        if (!claimsCheckResp.hasExtension(EPPLaunchChkData.class)) {
            Assert.fail("launchCheck: No EPPLaunchChkData extension found in claims check response");
        }

        theExt = (EPPLaunchChkData) claimsCheckResp.getExtension(EPPLaunchChkData.class);

        results = theExt.getCheckResults();

        for (EPPLaunchCheckResult result : results) {

            if (result.isExists()) {
                System.out.println("launchCheck: Domain + " + result.getName() + ", mark exists, claimKey = ["
                        + result.getClaimKey() + "]");
            } else {
                System.out.println("launchCheck: Domain + " + result.getName() + ", mark DOES NOT exist");
            }

        }

        // Available check with two domain names for the custom
        // "idn-release" launch phase.
        System.out.println("\n----------------------------------------------------------------");

        System.out.println(
                "launchCheck: Availability Check for example1.tld and example2.tld with idn-release custom phase");

        launch.setTransId("ABC-12345");

        launch.addDomainName("example1.tld");
        launch.addDomainName("example2.tld");
        launch.setPhase(EPPLaunch.PHASE_CUSTOM);
        launch.setPhaseName("idn-release");
        launch.setType(EPPLaunch.TYPE_AVAILABILITY);

        EPPDomainCheckResp availCheckResp = (EPPDomainCheckResp) launch.sendCheck();

        // Output all of the response attributes
        System.out.println("\nlaunchCheck: Response = [" + availCheckResp + "]");
    } catch (Exception e) {
        handleException(e);
    }

    printEnd("launchCheck");
}

From source file:BQJDBC.QueryResultTest.BQResultSetFunctionTest.java

/**
 * Makes a new Bigquery Connection to URL in file and gives back the
 * Connection to static con member.//  w ww. j  ava  2  s.  co  m
 */
@Before
public void NewConnection() {

    try {
        if (BQResultSetFunctionTest.con == null || !BQResultSetFunctionTest.con.isValid(0)) {
            this.logger.info("Testing the JDBC driver");
            try {
                Class.forName("net.starschema.clouddb.jdbc.BQDriver");
                BQResultSetFunctionTest.con = DriverManager.getConnection(
                        BQSupportFuncts.constructUrlFromPropertiesFile(
                                BQSupportFuncts.readFromPropFile("installedaccount1.properties")),
                        BQSupportFuncts.readFromPropFile("installedaccount1.properties"));
            } catch (Exception e) {
                e.printStackTrace();
                this.logger.error("Error in connection" + e.toString());
                Assert.fail("General Exception:" + e.toString());
            }
            this.logger.info(((BQConnection) BQResultSetFunctionTest.con).getURLPART());
        }
    } catch (SQLException e) {
        logger.debug("Oops something went wrong", e);
    }
    this.QueryLoad();
}

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

@Test
public void testSortBoth4MatchTask() {

    int keyCnt1 = 20;
    int valCnt1 = 20;

    int keyCnt2 = 20;
    int valCnt2 = 1;

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

    MatchTask<PactRecord, PactRecord, PactRecord> testTask = new MatchTask<PactRecord, PactRecord, PactRecord>();
    super.getTaskConfig().setLocalStrategy(LocalStrategy.SORT_BOTH_MERGE);
    super.getTaskConfig().setMemorySize(6 * 1024 * 1024);
    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, MockMatchStub.class);

    try {//  ww  w .  j  a v a2  s.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);

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

    this.outList.clear();

}

From source file:example.crm.CrmIT.java

/**
 * HTTP PUT http://localhost:9003/customers is used to upload the contents of
 * the update_customer.xml file to update the customer information for customer 123.
 * <p/>/*from www  . j  a  v a2 s  .  c  o  m*/
 * On the server side, it matches the CustomerService's updateCustomer() method
 *
 * @throws Exception
 */
@Test
public void putCustomerTest() throws IOException {

    LOG.info("Sent HTTP PUT request to update customer info");

    String inputFile = this.getClass().getResource("/update_customer.xml").getFile();
    File input = new File(inputFile);
    PutMethod put = new PutMethod(CUSTOMER_SERVICE_URL);
    RequestEntity entity = new FileRequestEntity(input, "application/xml; charset=ISO-8859-1");
    put.setRequestEntity(entity);
    HttpClient httpclient = new HttpClient();
    int result = 0;
    try {
        result = httpclient.executeMethod(put);
        LOG.info("Response status code: " + result);
        LOG.info("Response body: ");
        LOG.info(put.getResponseBodyAsString());
    } catch (IOException e) {
        LOG.error("Error connecting to {}", CUSTOMER_SERVICE_URL);
        LOG.error(
                "You should build the 'camel-netty4-http' quick start and deploy it to a local Fabric8 before running this test");
        LOG.error("Please read the README.md file in 'camel-netty4-http' quick start root");
        Assert.fail("Connection error");
    } finally {
        // Release current connection to the connection pool once you are
        // done
        put.releaseConnection();
    }

    Assert.assertEquals(result, 200);
}

From source file:$.CrmTest.java

/**
     * HTTP PUT http://localhost:8181/cxf/crm/customerservice/customers is used to upload the contents of
     * the update_customer.xml file to update the customer information for customer 123.
     * <p/>//from  w  w  w. j  av a 2s  .c  o m
     * On the server side, it matches the CustomerService's updateCustomer() method
     *
     * @throws Exception
     */
    @Test
    public void putCustomerTest() throws IOException {

        LOG.info("Sent HTTP PUT request to update customer info");

        String inputFile = this.getClass().getResource("/update_customer.xml").getFile();
        File input = new File(inputFile);
        PutMethod put = new PutMethod(CUSTOMER_SERVICE_URL);
        RequestEntity entity = new FileRequestEntity(input, "application/xml; charset=ISO-8859-1");
        put.setRequestEntity(entity);
        HttpClient httpclient = new HttpClient();
        int result = 0;
        try {
            result = httpclient.executeMethod(put);
            LOG.info("Response status code: " + result);
            LOG.info("Response body: ");
            LOG.info(put.getResponseBodyAsString());
        } catch (IOException e) {
            LOG.error("Error connecting to {}", CUSTOMER_SERVICE_URL);
            LOG.error(
                    "You should build the 'cxf-cdi' quick start and deploy it to a local Fabric8 before running this test");
            LOG.error("Please read the README.md file in 'cxf-cdi' quick start root");
            Assert.fail("Connection error");
        } finally {
            // Release current connection to the connection pool once you are
            // done
            put.releaseConnection();
        }

        Assert.assertEquals(result, 200);
    }

From source file:hk.hku.cecid.corvus.ws.EBMSMessageHistoryQuerySenderTest.java

private EBMSMessageHistoryRequestData getHttpRequestData() throws Exception {
    // Check content Type
    String contentType = monitor.getContentType();

    if (contentType == null) {
        System.out.println((monitor == null ? "Null Monitor" : "Monitor not null"));
        System.out.println("Lengeth " + monitor.getContentLength());
        Assert.fail("Null Content");
    }/*from w  w w . jav  a2s.co  m*/

    String mediaType = contentType.split(";")[0];
    assertEquals("Invalid content type", "text/xml", mediaType);

    // Check the multi-part content.
    // Make a request context that bridge the content from our monitor to FileUpload library.    
    RequestContext rc = new RequestContext() {
        public String getCharacterEncoding() {
            return "charset=utf-8";
        }

        public int getContentLength() {
            return monitor.getContentLength();
        }

        public String getContentType() {
            return monitor.getContentType();
        }

        public InputStream getInputStream() {
            return monitor.getInputStream();
        }
    };

    BufferedReader bReader = new BufferedReader(new InputStreamReader(monitor.getInputStream()));

    String strLine = "";
    do {
        strLine = bReader.readLine();
    } while (!strLine.contains("SOAP-ENV"));

    MimeHeaders header = new MimeHeaders();
    header.addHeader("Content-Type", "text/xml");

    SOAPMessage msg = MessageFactory.newInstance().createMessage(header,
            new ByteArrayInputStream(strLine.getBytes()));

    EBMSMessageHistoryRequestData data = new EBMSMessageHistoryRequestData();
    data.setMessageId(getElementValue(msg.getSOAPBody(), "tns:messageId"));
    data.setMessageBox(getElementValue(msg.getSOAPBody(), "tns:messageBox"));
    data.setStatus(getElementValue(msg.getSOAPBody(), "tns:status"));
    data.setService(getElementValue(msg.getSOAPBody(), "tns:service"));
    data.setAction(getElementValue(msg.getSOAPBody(), "tns:action"));
    data.setConversationId(getElementValue(msg.getSOAPBody(), "tns:conversationId"));
    data.setCpaId(getElementValue(msg.getSOAPBody(), "tns:cpaId"));
    return data;
}