当前位置: 首页>>代码示例>>Java>>正文


Java Assert.fail方法代码示例

本文整理汇总了Java中org.testng.Assert.fail方法的典型用法代码示例。如果您正苦于以下问题:Java Assert.fail方法的具体用法?Java Assert.fail怎么用?Java Assert.fail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.testng.Assert的用法示例。


在下文中一共展示了Assert.fail方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testTransform

import org.testng.Assert; //导入方法依赖的package包/类
@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());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:CR6905829Test.java

示例2: test_badTemporalFieldChrono

import org.testng.Assert; //导入方法依赖的package包/类
@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");
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:TCKChronoZonedDateTime.java

示例3: testOne

import org.testng.Assert; //导入方法依赖的package包/类
@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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:Bug4996446.java

示例4: testFilter0004

import org.testng.Assert; //导入方法依赖的package包/类
/**
 * 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");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:35,代码来源:LSParserTCKTest.java

示例5: testXPath30

import org.testng.Assert; //导入方法依赖的package包/类
@Test
public void testXPath30() throws Exception {
    try {
        createXPath().evaluate(expression, new InputSource(new StringReader("<root/>")), null);
        Assert.fail();
    } catch (NullPointerException e) {
        ; // as expected
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:Bug4992805.java

示例6: test1

import org.testng.Assert; //导入方法依赖的package包/类
@Test
public void test1() throws SAXException {
    try {
        ValidatorHandler validatorHandler = schemaFactory.newSchema().newValidatorHandler();
        validatorHandler.getProperty("unknown1234");
        Assert.fail("SAXNotRecognizedException was not thrown.");
    } catch (SAXNotRecognizedException e) {
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:Bug4969110.java

示例7: testToString

import org.testng.Assert; //导入方法依赖的package包/类
@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());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:XMLGregorianCalendarTest.java

示例8: testMultiOccursMaxMinOk

import org.testng.Assert; //导入方法依赖的package包/类
@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");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:MultiOccursUnboundedTest.java

示例9: testSplitCDATA001

import org.testng.Assert; //导入方法依赖的package包/类
/**
 * 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");

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:45,代码来源:DOMConfigurationTest.java

示例10: testFive

import org.testng.Assert; //导入方法依赖的package包/类
@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();
    }

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:60,代码来源:WriterTest.java

示例11: testSuccessPath

import org.testng.Assert; //导入方法依赖的package包/类
/**
 * 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." );
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:10,代码来源:SelectionSetService_getStaffStatusTypeTest.java

示例12: testSuccessPath

import org.testng.Assert; //导入方法依赖的package包/类
/**
 * 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." );
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:10,代码来源:CourseService_renderCourseCertificatesTest.java

示例13: testSuccessPath

import org.testng.Assert; //导入方法依赖的package包/类
/**
 * 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." );
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:10,代码来源:ProbandService_setInquiryValuesTest.java

示例14: testSuccessPath

import org.testng.Assert; //导入方法依赖的package包/类
/**
 * 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." );
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:10,代码来源:CourseService_getCourseInventoryBookingCountTest.java

示例15: testIcdSystVOToEntity

import org.testng.Assert; //导入方法依赖的package包/类
/**
 * 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!");
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:10,代码来源:IcdSystDaoTransformTest.java


注:本文中的org.testng.Assert.fail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。