Java Code Examples for org.testng.Assert.fail()

The following are Jave code examples for showing how to use fail() of the org.testng.Assert class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: openjdk-jdk10   File: TCKChronoZonedDateTime.java   View Source Code Vote up 7 votes
@Test(dataProvider="calendars")
public void test_badTemporalFieldChrono(Chronology chrono) {
    LocalDate refDate = LocalDate.of(2013, 1, 1);
    ChronoZonedDateTime<?> czdt = chrono.date(refDate).atTime(LocalTime.NOON).atZone(ZoneOffset.UTC);
    for (Chronology[] clist : data_of_calendars()) {
        Chronology chrono2 = clist[0];
        ChronoZonedDateTime<?> czdt2 = chrono2.date(refDate).atTime(LocalTime.NOON).atZone(ZoneOffset.UTC);
        TemporalField adjuster = new FixedTemporalField(czdt2);
        if (chrono != chrono2) {
            try {
                czdt.with(adjuster, 1);
                Assert.fail("TemporalField doWith() should have thrown a ClassCastException, " + czdt.getClass()
                        + " can not be cast to " + czdt2.getClass());
            } catch (ClassCastException cce) {
                // Expected exception; not an error
            }
        } else {
            // Same chronology,
            ChronoZonedDateTime<?> result = czdt.with(adjuster, 1);
            assertEquals(result, czdt2, "TemporalField doWith() failed to replace date");
        }
    }
}
 
Example 2
Project: openjdk-jdk10   File: CR6905829Test.java   View Source Code Vote up 6 votes
@Test
public final void testTransform() {
    try {
        String file = getClass().getResource("CR6905829.xsl").getFile();
        Transformer t = TransformerFactory.newInstance().newTransformer(new StreamSource(new File(file)));

        System.out.printf("transformer: %s%n", t.getClass().getName());

        StringWriter streamResult = new StringWriter();
        t.transform(new StreamSource(getClass().getResourceAsStream("CR6905829.xml")), new StreamResult(streamResult));

        // expected success
    } catch (Exception e) {
        // unexpected failure
        e.printStackTrace();
        Assert.fail(e.toString());
    }
}
 
Example 3
Project: openjdk-jdk10   File: Bug4996446.java   View Source Code Vote up 6 votes
@Test
public void testOne() {

    ErrorHandler errorHandler = new ErrorHandler();
    schemaFactory.setErrorHandler(errorHandler);
    URL fileName = Bug4996446.class.getResource("Bug4996446.xsd");
    try {
        schemaFactory.newSchema(fileName);
    } catch (SAXException e) {
    }

    if (errorHandler.errorCounter == 0) {
        Assert.fail(" No Errors reported: " + errorHandler.errorCounter);
    }
    return;
}
 
Example 4
Project: openjdk-jdk10   File: LSParserTCKTest.java   View Source Code Vote up 5 votes
/**
 * Equivalence class partitioning with state, input and output values
 * orientation for public Document parse(LSInput is), <br>
 * <b>pre-conditions</b>: set filter that accepts all, <br>
 * <b>is</b>: xml1 <br>
 * <b>output</b>: full XML document.
 */
@Test
public void testFilter0004() {
    LSParser parser = createLSParser();
    if (parser == null) {
        Assert.fail("Unable to create LSParser!");
    }
    // set filter
    parser.setFilter(new LSParserFilter() {
        public short startElement(Element elt) {
            return FILTER_ACCEPT;
        }

        public short acceptNode(Node enode) {
            return FILTER_ACCEPT;
        }

        public int getWhatToShow() {
            return NodeFilter.SHOW_ALL;
        }
    });
    String expected = "<ROOT><ELEMENT1><CHILD1/><CHILD1><COC1/></CHILD1></ELEMENT1><ELEMENT2>test1<CHILD2/></ELEMENT2></ROOT>";
    Document doc = parser.parse(getXmlSource(xml1));
    if (!match(expected, doc)) {
        Assert.fail("DOM structure after parsing is not equal to a structure of XML document, that being parsed");
    }
    System.out.println("OKAY");
}
 
Example 5
Project: openjdk-jdk10   File: Bug4992805.java   View Source Code Vote up 5 votes
@Test
public void testXPath30() throws Exception {
    try {
        createXPath().evaluate(expression, new InputSource(new StringReader("<root/>")), null);
        Assert.fail();
    } catch (NullPointerException e) {
        ; // as expected
    }
}
 
Example 6
Project: openjdk-jdk10   File: Bug4969110.java   View Source Code Vote up 5 votes
@Test
public void test1() throws SAXException {
    try {
        ValidatorHandler validatorHandler = schemaFactory.newSchema().newValidatorHandler();
        validatorHandler.getProperty("unknown1234");
        Assert.fail("SAXNotRecognizedException was not thrown.");
    } catch (SAXNotRecognizedException e) {
    }
}
 
Example 7
Project: openjdk-jdk10   File: XMLGregorianCalendarTest.java   View Source Code Vote up 5 votes
@Test
public void testToString() {
    try {
        String inputDateTime = "2006-10-23T22:15:01.000000135+08:00";
        DatatypeFactory factory = DatatypeFactory.newInstance();
        XMLGregorianCalendar calendar = factory.newXMLGregorianCalendar(inputDateTime);
        String toStr = calendar.toString();
        Assert.assertTrue(toStr.indexOf("E") == -1, "String value cannot contain exponent");
    } catch (DatatypeConfigurationException dce) {
        dce.printStackTrace();
        Assert.fail("Failed to create instance of DatatypeFactory " + dce.getMessage());
    }
}
 
Example 8
Project: openjdk-jdk10   File: MultiOccursUnboundedTest.java   View Source Code Vote up 5 votes
@Test
public void testMultiOccursMaxMinOk() throws Exception {
    printMethodName();

    File xmlFile = new File(getClass().getResource("multi-occurs-unbounded-ok.xml").getFile());
    try {
        errorFound = false;
        documentBuilder.parse(xmlFile);
    } catch (SAXException ex) {
        Assert.fail(ex.getMessage());
    }
    if (errorFound) {
        Assert.fail("Unexpected validation error reported");
    }
}
 
Example 9
Project: openjdk-jdk10   File: DOMConfigurationTest.java   View Source Code Vote up 5 votes
/**
 * Equivalence class partitioning with state and input values orientation
 * for public void setParameter(String name, Object value) throws
 * DOMException, <br>
 * <b>pre-conditions</b>: The root contains a CDATASection with the
 * termination marker ']]&gt;', <br>
 * <b>name</b>: split-cdata-sections <br>
 * <b>value</b>: true. <br>
 * <b>Expected results</b>: A warning is reported when the section is
 * splitted
 */
@Test
public void testSplitCDATA001() {
    DOMImplementation domImpl = null;
    try {
        domImpl = DocumentBuilderFactory.newInstance().newDocumentBuilder().getDOMImplementation();
    } catch (ParserConfigurationException pce) {
        Assert.fail(pce.toString());
    } catch (FactoryConfigurationError fce) {
        Assert.fail(fce.toString());
    }

    Document doc = domImpl.createDocument("namespaceURI", "ns:root", null);

    DOMConfiguration config = doc.getDomConfig();
    CDATASection cdata = doc.createCDATASection("text]" + "]>text");
    doc.getDocumentElement().appendChild(cdata);

    TestHandler testHandler = new TestHandler();
    config.setParameter("error-handler", testHandler);

    if (!config.canSetParameter("split-cdata-sections", Boolean.TRUE)) {
        Assert.fail("cannot set the parameters 'split-cdata-sections' to true");
    }
    config.setParameter("split-cdata-sections", Boolean.TRUE);

    doc.normalizeDocument();
    if (null == testHandler.getWarning()) {
        Assert.fail("no warning is reported");
    }

    return; // Status.passed("OK");

}
 
Example 10
Project: openjdk-jdk10   File: WriterTest.java   View Source Code Vote up 4 votes
@Test
public void testFive() {

    System.out.println("Test StreamWriter's Namespace Context.");

    try {

        String outputFile = USER_DIR + files[4] + ".out";
        System.out.println("Writing output to " + outputFile);

        xtw = outputFactory.createXMLStreamWriter(System.out);
        xtw.writeStartDocument();
        xtw.writeStartElement("elemTwo");
        xtw.setPrefix("html", "http://www.w3.org/TR/REC-html40");
        xtw.writeNamespace("html", "http://www.w3.org/TR/REC-html40");
        // xtw.writeEndDocument();
        NamespaceContext nc = xtw.getNamespaceContext();
        // Got a Namespace Context.class

        xtw = outputFactory.createXMLStreamWriter(new FileOutputStream(outputFile), ENCODING);

        xtw.writeComment("all elements here are explicitly in the HTML namespace");
        xtw.setNamespaceContext(nc);
        xtw.writeStartDocument("utf-8", "1.0");
        // xtw.setPrefix("html", "http://www.w3.org/TR/REC-html40");
        xtw.writeStartElement("http://www.w3.org/TR/REC-html40", "html");
        // xtw.writeNamespace("html", "http://www.w3.org/TR/REC-html40");

        xtw.writeStartElement("http://www.w3.org/TR/REC-html40", "head");
        xtw.writeStartElement("http://www.w3.org/TR/REC-html40", "title");

        xtw.writeCharacters("Frobnostication");
        xtw.writeEndElement();
        xtw.writeEndElement();

        xtw.writeStartElement("http://www.w3.org/TR/REC-html40", "body");
        xtw.writeStartElement("http://www.w3.org/TR/REC-html40", "p");
        xtw.writeCharacters("Moved to");
        xtw.writeStartElement("http://www.w3.org/TR/REC-html40", "a");
        xtw.writeAttribute("href", "http://frob.com");

        xtw.writeCharacters("here");
        xtw.writeEndElement();
        xtw.writeEndElement();
        xtw.writeEndElement();

        xtw.writeEndElement();

        xtw.writeEndDocument();
        xtw.flush();
        xtw.close();
        Assert.assertTrue(checkResults(outputFile, files[4] + ".org"));
        System.out.println("Done");
    } catch (Exception ex) {
        Assert.fail("testFive Failed " + ex);
        ex.printStackTrace();
    }

}
 
Example 11
Project: ctsms   File: SelectionSetService_getStaffStatusTypeTest.java   View Source Code Vote up 2 votes
/**
 * Test succes path for service method <code>getStaffStatusType</code>
 *
 * Tests expected behaviour of service method.
 */
@Test
public void testSuccessPath() {
  Assert.fail( "Test 'SelectionSetService_getStaffStatusTypeTest.testSuccessPath()}' not implemented." );
}
 
Example 12
Project: ctsms   File: CourseService_renderCourseCertificatesTest.java   View Source Code Vote up 2 votes
/**
 * Test succes path for service method <code>renderCourseCertificates</code>
 *
 * Tests expected behaviour of service method.
 */
@Test
public void testSuccessPath() {
  Assert.fail( "Test 'CourseService_renderCourseCertificatesTest.testSuccessPath()}' not implemented." );
}
 
Example 13
Project: ctsms   File: ProbandService_setInquiryValuesTest.java   View Source Code Vote up 2 votes
/**
 * Test succes path for service method <code>setInquiryValues</code>
 *
 * Tests expected behaviour of service method.
 */
@Test
public void testSuccessPath() {
  Assert.fail( "Test 'ProbandService_setInquiryValuesTest.testSuccessPath()}' not implemented." );
}
 
Example 14
Project: ctsms   File: CourseService_getCourseInventoryBookingCountTest.java   View Source Code Vote up 2 votes
/**
 * Test succes path for service method <code>getCourseInventoryBookingCount</code>
 *
 * Tests expected behaviour of service method.
 */
@Test
public void testSuccessPath() {
  Assert.fail( "Test 'CourseService_getCourseInventoryBookingCountTest.testSuccessPath()}' not implemented." );
}
 
Example 15
Project: ctsms   File: IcdSystDaoTransformTest.java   View Source Code Vote up 2 votes
/**
 * Test for method icdSystVOToEntity
 *
 * @see org.phoenixctms.ctsms.domain.IcdSystDao#icdSystVOToEntity(org.phoenixctms.ctsms.vo.IcdSystVO source, org.phoenixctms.ctsms.domain.IcdSyst target, boolean copyIfNull)
 */
@Test
public void testIcdSystVOToEntity() {
  Assert.fail("Test 'IcdSystDaoTransformTest.testIcdSystVOToEntity' not implemented!");
}
 
Example 16
Project: ctsms   File: ProbandService_getProbandTest.java   View Source Code Vote up 2 votes
/**
 * Test succes path for service method <code>getProband</code>
 *
 * Tests expected behaviour of service method.
 */
@Test
public void testSuccessPath() {
  Assert.fail( "Test 'ProbandService_getProbandTest.testSuccessPath()}' not implemented." );
}
 
Example 17
Project: ctsms   File: TrialService_getVisitCountTest.java   View Source Code Vote up 2 votes
/**
 * Test succes path for service method <code>getVisitCount</code>
 *
 * Tests expected behaviour of service method.
 */
@Test
public void testSuccessPath() {
  Assert.fail( "Test 'TrialService_getVisitCountTest.testSuccessPath()}' not implemented." );
}
 
Example 18
Project: ctsms   File: SelectionSetService_getAvailableInventoryTagsTest.java   View Source Code Vote up 2 votes
/**
 * Test succes path for service method <code>getAvailableInventoryTags</code>
 *
 * Tests expected behaviour of service method.
 */
@Test
public void testSuccessPath() {
  Assert.fail( "Test 'SelectionSetService_getAvailableInventoryTagsTest.testSuccessPath()}' not implemented." );
}
 
Example 19
Project: ctsms   File: ZipDaoTransformTest.java   View Source Code Vote up 2 votes
/**
 * Test for method zipVOToEntity
 *
 * @see org.phoenixctms.ctsms.domain.ZipDao#zipVOToEntity(org.phoenixctms.ctsms.vo.ZipVO source, org.phoenixctms.ctsms.domain.Zip target, boolean copyIfNull)
 */
@Test
public void testZipVOToEntity() {
  Assert.fail("Test 'ZipDaoTransformTest.testZipVOToEntity' not implemented!");
}
 
Example 20
Project: ctsms   File: SelectionSetService_getHyperlinkCategoriesTest.java   View Source Code Vote up 2 votes
/**
 * Test succes path for service method <code>getHyperlinkCategories</code>
 *
 * Tests expected behaviour of service method.
 */
@Test
public void testSuccessPath() {
  Assert.fail( "Test 'SelectionSetService_getHyperlinkCategoriesTest.testSuccessPath()}' not implemented." );
}