Java Code Examples for org.testng.Assert#fail()
The following examples show how to use
org.testng.Assert#fail() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CorePredicatesTest.java From template-compiler with Apache License 2.0 | 6 votes |
@Test public void testJsonPredicateVariable() throws CodeException { Context ctx = context("{\"number\": 1, \"foo\": {\"bar\": 1}}"); ctx.pushSection(new String[] { "foo", "bar" }); assertTrue(EQUAL, ctx, maker().args(" number")); String template = "{.repeated section nums}{.equal? @index 2}{@}{.end}{.end}"; JsonNode json = json("{\"nums\": [10, 20, 30]}"); ctx = execute(template, json); assertEquals(ctx.buffer().toString(), "20"); // Ensure that invalid arguments are caught and proper error raised. template = "{.equal? 1 -}#{.end}"; try { execute("{.equal? 1 .}#{.end}", json("{}")); Assert.fail("Expected CodeSyntaxException PREDICATE_ARGS_INVALID to be thrown"); } catch (CodeSyntaxException e) { assertEquals(e.getErrorInfo().getType(), SyntaxErrorType.PREDICATE_ARGS_INVALID); } }
Example 2
Source File: SchedulerServiceTest.java From sherlock with GNU General Public License v3.0 | 6 votes |
@Test public void testBulkStopJob() throws SchedulerException, IOException, JobNotFoundException { init(); doCallRealMethod().when(ss).stopJob(anySet()); Set<String> jobSet = new HashSet<String>() { { add("1"); add("2"); add("3"); } }; ss.stopJob(jobSet); Mockito.verify(js, Mockito.times(1)).removeQueue(jobSet); IOException ioex = new IOException("error"); Mockito.doThrow(ioex).when(js).removeQueue(anySet()); try { ss.stopJob(jobSet); } catch (SchedulerException e) { Assert.assertEquals(e.getMessage(), "error"); Assert.assertEquals(e.getCause(), ioex); return; } Assert.fail(); }
Example 3
Source File: InfoTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Test that cputime used shows up in ProcessHandle.info */ @Test public static void test1() { System.out.println("Note: when run in samevm mode the cputime of the " + "test runner is included."); ProcessHandle self = ProcessHandle.current(); Duration someCPU = Duration.ofMillis(200L); Instant end = Instant.now().plus(someCPU); while (Instant.now().isBefore(end)) { // waste the cpu } ProcessHandle.Info info = self.info(); System.out.printf(" info: %s%n", info); Optional<Duration> totalCpu = info.totalCpuDuration(); if (totalCpu.isPresent() && (totalCpu.get().compareTo(someCPU) < 0)) { Assert.fail("reported cputime less than expected: " + someCPU + ", " + "actual: " + info.totalCpuDuration()); } }
Example 4
Source File: NamespaceTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Test public void testDoubleXmlNs() { try { xmlStreamWriter.writeStartDocument(); xmlStreamWriter.writeStartElement("foo"); xmlStreamWriter.writeNamespace("xml", XMLConstants.XML_NS_URI); xmlStreamWriter.writeAttribute("xml", XMLConstants.XML_NS_URI, "lang", "ja_JP"); xmlStreamWriter.writeCharacters("Hello"); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeEndDocument(); xmlStreamWriter.flush(); String actualOutput = byteArrayOutputStream.toString(); if (DEBUG) { System.out.println("testDoubleXmlNs(): actualOutput: " + actualOutput); } // there should be no xmlns:xml Assert.assertTrue(actualOutput.split("xmlns:xml").length == 1, "Expected 0 xmlns:xml, actual output: " + actualOutput); } catch (Exception e) { e.printStackTrace(); Assert.fail(e.getMessage()); } }
Example 5
Source File: Bug6467808.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Test public void test() { try { SAXParserFactory fac = SAXParserFactory.newInstance(); fac.setNamespaceAware(true); SAXParser saxParser = fac.newSAXParser(); StreamSource src = new StreamSource(new StringReader(SIMPLE_TESTXML)); Transformer transformer = TransformerFactory.newInstance().newTransformer(); DOMResult result = new DOMResult(); transformer.transform(src, result); } catch (Throwable ex) { // unexpected failure ex.printStackTrace(); Assert.fail(ex.toString()); } }
Example 6
Source File: TCKChronoZonedDateTime.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider="calendars") public void test_badPlusAdjusterChrono(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); TemporalAmount adjuster = new FixedAdjuster(czdt2); if (chrono != chrono2) { try { czdt.plus(adjuster); Assert.fail("WithAdjuster should have thrown a ClassCastException, " + "required: " + czdt + ", supplied: " + czdt2); } catch (ClassCastException cce) { // Expected exception; not an error } } else { // Same chronology, ChronoZonedDateTime<?> result = czdt.plus(adjuster); assertEquals(result, czdt2, "WithAdjuster failed to replace date time"); } } }
Example 7
Source File: TCKChronoLocalDate.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider="calendars") public void test_badWithAdjusterChrono(Chronology chrono) { LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoLocalDate date = chrono.date(refDate); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; ChronoLocalDate date2 = chrono2.date(refDate); TemporalAdjuster adjuster = new FixedAdjuster(date2); if (chrono != chrono2) { try { date.with(adjuster); Assert.fail("WithAdjuster should have thrown a ClassCastException"); } catch (ClassCastException cce) { // Expected exception; not an error } } else { // Same chronology, ChronoLocalDate result = date.with(adjuster); assertEquals(result, date2, "WithAdjuster failed to replace date"); } } }
Example 8
Source File: TestFrameworkEdges.java From xian with Apache License 2.0 | 6 votes |
@Test public void testStopped() throws Exception { CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)); try { client.start(); client.getData(); } finally { CloseableUtils.closeQuietly(client); } try { client.getData(); Assert.fail(); } catch ( Exception e ) { // correct } }
Example 9
Source File: YamlsTest.java From brooklyn-server with Apache License 2.0 | 6 votes |
@Test public void testExtractNoOOBE() { // this might log a warning, as item not found, but won't throw YamlExtract r1 = Yamls.getTextOfYamlAtPath( "items:\n- id: sample2\n itemType: location\n item:\n type: jclouds:aws-ec2\n brooklyn.config:\n key2: value2\n\n", "item"); // won't throw r1.getMatchedYamlTextOrWarn(); // will throw try { r1.getMatchedYamlText(); Assert.fail(); } catch (UserFacingException e) { // expected, it should give a vaguely explanatory exception and no trace } }
Example 10
Source File: NamespaceTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Reset Writer for reuse. */ private void resetWriter() { // reset the Writer try { byteArrayOutputStream.reset(); xmlStreamWriter = xmlOutputFactory.createXMLStreamWriter(byteArrayOutputStream, "utf-8"); } catch (XMLStreamException xmlStreamException) { Assert.fail(xmlStreamException.toString()); } }
Example 11
Source File: JMSTransportProxyTestCase.java From micro-integrator with Apache License 2.0 | 5 votes |
@Test(groups = { "wso2.esb" }, description = "Test proxy service with jms transport") public void testJMSProxy() throws Exception { JMSQueueMessageProducer sender = new JMSQueueMessageProducer( JMSBrokerConfigurationProvider.getInstance().getBrokerConfiguration()); String queueName = "JmsTransportProxy"; try { sender.connect(queueName); for (int i = 0; i < 3; i++) { sender.pushMessage("<?xml version='1.0' encoding='UTF-8'?>" + "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"" + " xmlns:ser=\"http://services.samples\" xmlns:xsd=\"http://services.samples/xsd\">" + " <soapenv:Header/>" + " <soapenv:Body>" + " <ser:placeOrder>" + " <ser:order>" + " <xsd:price>100</xsd:price>" + " <xsd:quantity>2000</xsd:quantity>" + " <xsd:symbol>JMSTransport</xsd:symbol>" + " </ser:order>" + " </ser:placeOrder>" + " </soapenv:Body>" + "</soapenv:Envelope>"); } } finally { sender.disconnect(); } Thread.sleep(30000); JMSQueueMessageConsumer consumer = new JMSQueueMessageConsumer( JMSBrokerConfigurationProvider.getInstance().getBrokerConfiguration()); try { consumer.connect(queueName); for (int i = 0; i < 3; i++) { if (consumer.popMessage() != null) { Assert.fail("JMS Proxy service failed to pick the messages from Queue"); } } } finally { consumer.disconnect(); } }
Example 12
Source File: EntityJerseyResourceIT.java From atlas with Apache License 2.0 | 5 votes |
@Test public void testAddTrait() throws Exception { String dbName = "db" + randomString(); String tableName = "table" + randomString(); Referenceable hiveDBInstance = createHiveDBInstanceBuiltIn(dbName); Id dbId = createInstance(hiveDBInstance); Referenceable hiveTableInstance = createHiveTableInstanceBuiltIn(dbName, tableName, dbId); Id id = createInstance(hiveTableInstance); final String guid = id._getId(); try { Assert.assertNotNull(UUID.fromString(guid)); } catch (IllegalArgumentException e) { Assert.fail("Response is not a guid, " + guid); } String traitName = "PII_Trait" + randomString(); TraitTypeDefinition piiTrait = TypesUtil.createTraitTypeDef(traitName, null, Collections.<String>emptySet()); String traitDefinitionAsJSON = AtlasType.toV1Json(piiTrait); LOG.debug("traitDefinitionAsJSON = {}", traitDefinitionAsJSON); TypesDef typesDef = new TypesDef(Collections.emptyList(), Collections.emptyList(), Collections.singletonList(piiTrait), Collections.emptyList()); createType(typesDef); Struct traitInstance = new Struct(traitName); atlasClientV1.addTrait(guid, traitInstance); assertEntityAudit(guid, EntityAuditEvent.EntityAuditAction.TAG_ADD); }
Example 13
Source File: InvalidPrefixTestCase.java From micro-integrator with Apache License 2.0 | 5 votes |
@Test(groups = { "wso2.esb" }, description = "SwitchMediator:Negative Case 2: Invalid prefix") public void testSample2() throws Exception { try { axis2Client.sendSimpleStockQuoteRequest(getProxyServiceURLHttp("switchMediatorInvalidPrefixTestProxy"), getBackEndServiceUrl(ESBTestConstant.SIMPLE_STOCK_QUOTE_SERVICE), "IBM"); Assert.fail("This Request should throw AxisFault"); } catch (AxisFault e) { Assert.assertEquals(e.getReason(), ESBTestConstant.INCOMING_MESSAGE_IS_NULL, "Error Message mismatched"); } }
Example 14
Source File: TitanFileConverterUnitTest.java From gatk-protected with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void basicHetConverterTest() { final File tempOutput = createTempFile("titanHet", ".tsv"); TitanFileConverter.convertHetPulldownToTitanHetFile(TUMOR_ALLELIC_COUNTS_FILE, tempOutput); try { Assert.assertEquals(FileUtils.readLines(tempOutput).size(), FileUtils.readLines(TUMOR_ALLELIC_COUNTS_FILE).size()); final List<String> headers = Arrays.asList(FileUtils.readLines(tempOutput).get(0).split("\t")); Assert.assertEquals(headers, TitanAllelicCountTableColumn.COLUMNS.names()); } catch (final IOException ioe) { Assert.fail("Problem with unit test configuration.", ioe); } }
Example 15
Source File: DeviceManagementConfigTests.java From carbon-device-mgt with Apache License 2.0 | 5 votes |
@BeforeClass private void initSchema() { File deviceManagementSchemaConfig = new File(DeviceManagementConfigTests.TEST_CONFIG_SCHEMA_LOCATION); SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); try { schema = factory.newSchema(deviceManagementSchemaConfig); } catch (SAXException e) { Assert.fail("Invalid schema found", e); } }
Example 16
Source File: CalciteSqlCompilerTest.java From incubator-pinot with Apache License 2.0 | 4 votes |
@Test public void testAliasQuery() { String sql; PinotQuery pinotQuery; // Valid alias in query. sql = "select secondsSinceEpoch, sum(rsvp_count) as sum_rsvp_count, count(*) as cnt from meetupRsvp group by secondsSinceEpoch order by cnt, sum_rsvp_count DESC limit 50"; pinotQuery = CalciteSqlParser.compileToPinotQuery(sql); Assert.assertEquals(pinotQuery.getSelectListSize(), 3); Assert.assertEquals(pinotQuery.getGroupByListSize(), 1); Assert.assertEquals(pinotQuery.getOrderByListSize(), 2); Assert.assertEquals(pinotQuery.getOrderByList().get(0).getFunctionCall().getOperator(), "ASC"); Assert.assertEquals( pinotQuery.getOrderByList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(), "COUNT"); Assert.assertEquals( pinotQuery.getOrderByList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0) .getIdentifier().getName(), "*"); Assert.assertEquals(pinotQuery.getOrderByList().get(1).getFunctionCall().getOperator(), "DESC"); Assert.assertEquals( pinotQuery.getOrderByList().get(1).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(), "SUM"); Assert.assertEquals( pinotQuery.getOrderByList().get(1).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0) .getIdentifier().getName(), "rsvp_count"); // Valid mixed alias expressions in query. sql = "select secondsSinceEpoch, sum(rsvp_count), count(*) as cnt from meetupRsvp group by secondsSinceEpoch order by cnt, sum(rsvp_count) DESC limit 50"; pinotQuery = CalciteSqlParser.compileToPinotQuery(sql); Assert.assertEquals(pinotQuery.getSelectListSize(), 3); Assert.assertEquals(pinotQuery.getGroupByListSize(), 1); Assert.assertEquals(pinotQuery.getOrderByListSize(), 2); Assert.assertEquals(pinotQuery.getOrderByList().get(0).getFunctionCall().getOperator(), "ASC"); Assert.assertEquals( pinotQuery.getOrderByList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(), "COUNT"); Assert.assertEquals( pinotQuery.getOrderByList().get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0) .getIdentifier().getName(), "*"); Assert.assertEquals(pinotQuery.getOrderByList().get(1).getFunctionCall().getOperator(), "DESC"); Assert.assertEquals( pinotQuery.getOrderByList().get(1).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(), "SUM"); Assert.assertEquals( pinotQuery.getOrderByList().get(1).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0) .getIdentifier().getName(), "rsvp_count"); sql = "select secondsSinceEpoch/86400 AS daysSinceEpoch, sum(rsvp_count) as sum_rsvp_count, count(*) as cnt from meetupRsvp where daysSinceEpoch = 18523 group by daysSinceEpoch order by cnt, sum_rsvp_count DESC limit 50"; pinotQuery = CalciteSqlParser.compileToPinotQuery(sql); Assert.assertEquals(pinotQuery.getSelectListSize(), 3); Assert.assertEquals(pinotQuery.getFilterExpression().getFunctionCall().getOperator(), "EQUALS"); Assert.assertEquals( pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(), "DIVIDE"); Assert.assertEquals( pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0) .getIdentifier().getName(), "secondsSinceEpoch"); Assert.assertEquals( pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(1) .getLiteral().getLongValue(), 86400); Assert.assertEquals( pinotQuery.getFilterExpression().getFunctionCall().getOperands().get(1).getLiteral().getLongValue(), 18523); Assert.assertEquals(pinotQuery.getGroupByListSize(), 1); Assert.assertEquals(pinotQuery.getGroupByList().get(0).getFunctionCall().getOperator(), "DIVIDE"); Assert.assertEquals( pinotQuery.getGroupByList().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(), "secondsSinceEpoch"); Assert.assertEquals( pinotQuery.getGroupByList().get(0).getFunctionCall().getOperands().get(1).getLiteral().getLongValue(), 86400); Assert.assertEquals(pinotQuery.getOrderByListSize(), 2); // Invalid groupBy clause shouldn't contain aggregate expression, like sum(rsvp_count), count(*). try { sql = "select sum(rsvp_count), count(*) as cnt from meetupRsvp group by group_country, cnt limit 50"; CalciteSqlParser.compileToPinotQuery(sql); Assert.fail("Query should have failed compilation"); } catch (Exception e) { Assert.assertTrue(e instanceof SqlCompilationException); Assert.assertTrue(e.getMessage().contains("is not allowed in GROUP BY clause.")); } }
Example 17
Source File: ProbandService_getProbandGroupListTest.java From ctsms with GNU Lesser General Public License v2.1 | 2 votes |
/** * Test succes path for service method <code>getProbandGroupList</code> * * Tests expected behaviour of service method. */ @Test public void testSuccessPath() { Assert.fail( "Test 'ProbandService_getProbandGroupListTest.testSuccessPath()}' not implemented." ); }
Example 18
Source File: StaffService_deleteStaffTagValueTest.java From ctsms with GNU Lesser General Public License v2.1 | 2 votes |
/** * Test succes path for service method <code>deleteStaffTagValue</code> * * Tests expected behaviour of service method. */ @Test public void testSuccessPath() { Assert.fail( "Test 'StaffService_deleteStaffTagValueTest.testSuccessPath()}' not implemented." ); }
Example 19
Source File: TrialService_getTrialTagValueListTest.java From ctsms with GNU Lesser General Public License v2.1 | 2 votes |
/** * Test succes path for service method <code>getTrialTagValueList</code> * * Tests expected behaviour of service method. */ @Test public void testSuccessPath() { Assert.fail( "Test 'TrialService_getTrialTagValueListTest.testSuccessPath()}' not implemented." ); }
Example 20
Source File: SearchService_getCriteriaCategoriesTest.java From ctsms with GNU Lesser General Public License v2.1 | 2 votes |
/** * Test succes path for service method <code>getCriteriaCategories</code> * * Tests expected behaviour of service method. */ @Test public void testSuccessPath() { Assert.fail( "Test 'SearchService_getCriteriaCategoriesTest.testSuccessPath()}' not implemented." ); }