List of usage examples for junit.framework Assert fail
static public void fail(String message)
From source file:BQJDBC.QueryResultTest.BQScrollableResultSetFunctionTest.java
/** * For testing isValid() , Close() , isClosed() *//*w ww . java2 s.c o m*/ @Test public void isClosedValidtest() { try { Assert.assertEquals(true, BQScrollableResultSetFunctionTest.con.isValid(0)); } catch (SQLException e) { Assert.fail("Got an exception" + e.toString()); e.printStackTrace(); } try { Assert.assertEquals(true, BQScrollableResultSetFunctionTest.con.isValid(10)); } catch (SQLException e) { Assert.fail("Got an exception" + e.toString()); e.printStackTrace(); } try { BQScrollableResultSetFunctionTest.con.isValid(-10); } catch (SQLException e) { Assert.assertTrue(true); // e.printStackTrace(); } try { BQScrollableResultSetFunctionTest.con.close(); } catch (SQLException e) { e.printStackTrace(); } try { Assert.assertTrue(BQScrollableResultSetFunctionTest.con.isClosed()); } catch (SQLException e1) { e1.printStackTrace(); } try { BQScrollableResultSetFunctionTest.con.isValid(0); } catch (SQLException e) { Assert.assertTrue(true); e.printStackTrace(); } }
From source file:BQJDBC.QueryResultTest.BQForwardOnlyResultSetFunctionTest.java
public void QueryLoad() { final String sql = "SELECT TOP(word,10) AS word, COUNT(*) as count FROM publicdata:samples.shakespeare"; this.logger.info("Test number: 01"); this.logger.info("Running query:" + sql); try {/* w w w .j a v a2 s. com*/ //Statement stmt = BQResultSetFunctionTest.con.createStatement(); Statement stmt = BQForwardOnlyResultSetFunctionTest.con.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); stmt.setQueryTimeout(500); BQForwardOnlyResultSetFunctionTest.Result = stmt.executeQuery(sql); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } Assert.assertNotNull(BQForwardOnlyResultSetFunctionTest.Result); }
From source file:BQJDBC.QueryResultTest.Timeouttest.java
@Test public void QueryResultTest04() { final String sql = "SELECT corpus FROM publicdata:samples.shakespeare WHERE LOWER(word)=\"lord\" GROUP BY corpus ORDER BY corpus DESC LIMIT 5;"; final String description = "A query which gets 5 of Shakespeare were the word lord is present"; String[][] expectation = new String[][] { { "winterstale", "various", "twogentlemenofverona", "twelfthnight", "troilusandcressida" } }; this.logger.info("Test number: 04"); this.logger.info("Running query:" + sql); java.sql.ResultSet Result = null; try {/*from w ww. j a v a 2 s .co m*/ Result = Timeouttest.con.createStatement().executeQuery(sql); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } Assert.assertNotNull(Result); this.logger.debug(description); HelperFunctions.printer(expectation); try { Assert.assertTrue("Comparing failed in the String[][] array", this.comparer(expectation, BQSupportMethods.GetQueryResult(Result))); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail(e.toString()); } }
From source file:org.deviceconnect.android.profile.restful.test.RESTfulDConnectTestCase.java
/** * HTTP???.//from www . ja v a 2 s .c o m * @param uri ??URI * @return */ protected final byte[] getBytesFromHttp(final String uri) { HttpUriRequest request = new HttpGet(uri); HttpClient client = new DefaultHttpClient(); try { HttpResponse response = client.execute(request); switch (response.getStatusLine().getStatusCode()) { case HttpStatus.SC_OK: InputStream in = response.getEntity().getContent(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] buf = new byte[BUF_SIZE]; int len; while ((len = in.read(buf)) > 0) { baos.write(buf, 0, len); } return baos.toByteArray(); case HttpStatus.SC_NOT_FOUND: Assert.fail("Not found page. 404: " + uri); break; default: Assert.fail("Connection Error. " + response.getStatusLine().getStatusCode()); break; } } catch (ClientProtocolException e) { Assert.fail("ClientProtocolException: " + e.getMessage()); } catch (IOException e) { Assert.fail("IOException: " + e.getMessage()); } return null; }
From source file:org.jasig.schedassist.impl.SchedulingAssistantServiceImplTest.java
/** * Expect a SchedulingException//from w w w . j a va2 s . c o m * @throws Exception */ @Test public void testScheduleAppointmentNotInSchedule() throws Exception { // construct a schedule owner MockCalendarAccount ownerAccount = new MockCalendarAccount(); ownerAccount.setUsername("user1"); DefaultScheduleOwnerImpl owner = new DefaultScheduleOwnerImpl(ownerAccount, 1); // construct a schedule visitor MockCalendarAccount visitorAccount = new MockCalendarAccount(); visitorAccount.setUsername("user2"); DefaultScheduleVisitorImpl visitor = new DefaultScheduleVisitorImpl(visitorAccount); // construct target availableblock for appointment AvailableBlock targetBlock = AvailableBlockBuilder.createBlock("20091111-1330", "20091111-1400", 1); AvailableScheduleDao mockScheduleDao = EasyMock.createMock(AvailableScheduleDao.class); EasyMock.expect(mockScheduleDao.retrieveTargetBlock(owner, targetBlock.getStartTime())).andReturn(null); EasyMock.replay(mockScheduleDao); SchedulingAssistantServiceImpl serviceImpl = new SchedulingAssistantServiceImpl(); serviceImpl.setAvailableScheduleDao(mockScheduleDao); try { serviceImpl.scheduleAppointment(visitor, owner, targetBlock, "description"); Assert.fail("expected SchedulingException not thrown"); } catch (SchedulingException e) { // success } EasyMock.verify(mockScheduleDao); }
From source file:example.crm.CrmIT.java
/** * HTTP POST http://localhost:9003/customers is used to upload the contents of * the add_customer.xml file to add a new customer to the system. * <p/>/* w w w . j a v a2s .c om*/ * On the server side, it matches the CustomerService's addCustomer() method * * @throws Exception */ @Test public void postCustomerTest() throws IOException { LOG.info("Sent HTTP POST request to add customer"); String inputFile = this.getClass().getResource("/add_customer.xml").getFile(); File input = new File(inputFile); PostMethod post = new PostMethod(CUSTOMER_SERVICE_URL); post.addRequestHeader("Accept", "application/xml"); RequestEntity entity = new FileRequestEntity(input, "application/xml; charset=ISO-8859-1"); post.setRequestEntity(entity); HttpClient httpclient = new HttpClient(); String res = ""; try { int result = httpclient.executeMethod(post); LOG.info("Response status code: " + result); LOG.info("Response body: "); res = post.getResponseBodyAsString(); LOG.info(res); } 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 post.releaseConnection(); } Assert.assertTrue(res.contains("Jack")); }
From source file:BQJDBC.QueryResultTest.QueryResultTest.java
@Test public void QueryResultTest04() { final String sql = "SELECT corpus FROM publicdata:samples.shakespeare WHERE LOWER(word)=\"lord\" GROUP BY corpus ORDER BY corpus DESC LIMIT 5;"; final String description = "A query which gets 5 of Shakespeare were the word lord is present"; String[][] expectation = new String[][] { { "winterstale", "various", "twogentlemenofverona", "twelfthnight", "troilusandcressida" } }; this.logger.info("Test number: 04"); this.logger.info("Running query:" + sql); java.sql.ResultSet Result = null; try {//www. jav a 2s.c o m Result = QueryResultTest.con.createStatement().executeQuery(sql); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } Assert.assertNotNull(Result); this.logger.debug(description); HelperFunctions.printer(expectation); try { Assert.assertTrue("Comparing failed in the String[][] array", this.comparer(expectation, BQSupportMethods.GetQueryResult(Result))); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail(e.toString()); } }
From source file:com.aliyun.oss.integrationtests.ImageProcessTest.java
@Test public void testGeneratePresignedUrlWithProcess() { String style = "image/resize,m_fixed,w_100,h_100"; // try {// w w w . j a v a 2 s . co m Date expiration = DateUtil.parseRfc822Date("Wed, 21 Dec 2022 14:20:00 GMT"); GeneratePresignedUrlRequest req = new GeneratePresignedUrlRequest(bucketName, originalImage, HttpMethod.GET); req.setExpiration(expiration); req.setProcess(style); URL signedUrl = ossClient.generatePresignedUrl(req); System.out.println(signedUrl); OSSObject ossObject = ossClient.getObject(signedUrl, null); ossClient.putObject(bucketName, newImage, ossObject.getObjectContent()); ImageInfo imageInfo = getImageInfo(bucketName, newImage); Assert.assertEquals(imageInfo.getHeight(), 100); Assert.assertEquals(imageInfo.getWidth(), 100); Assert.assertEquals(imageInfo.getFormat(), "jpg"); } catch (Exception e) { e.printStackTrace(); Assert.fail(e.getMessage()); } }
From source file:hk.hku.cecid.corvus.ws.EBMSMessageHistoryQuerySenderTest.java
@Test public void testSpecialCharacterCriteriaData() throws Exception { EBMSMessageHistoryRequestData expectData = new EBMSMessageHistoryRequestData(); expectData.setEndPoint(TEST_ENDPOINT); expectData.setMessageBox("INbox"); expectData.setStatus("dL"); expectData.setMessageId("*msg#Id"); expectData.setService("cecid:cecid"); expectData.setAction("<>"); expectData.setConversationId("?ID%"); expectData.setCpaId("#^&--"); this.target = new EBMSMessageHistoryQuerySender(this.testClassLogger, expectData); try {/*from w ww . j a va2s. c o m*/ this.target.run(); } catch (Error err) { Assert.fail("Error should Not be thrown here."); } EBMSMessageHistoryRequestData actualData = getHttpRequestData(); Assert.assertEquals(expectData.getMessageId(), actualData.getMessageId()); Assert.assertEquals(expectData.getService(), actualData.getService()); Assert.assertEquals(expectData.getAction(), actualData.getAction()); Assert.assertEquals(expectData.getCpaId(), actualData.getCpaId()); Assert.assertEquals(expectData.getConversationId(), actualData.getConversationId()); Assert.assertTrue("INbox".equals(actualData.getMessageBox())); Assert.assertTrue("dL".equals(actualData.getStatus())); }
From source file:es.tid.fiware.rss.expenditureLimit.processing.test.ProcessingLimitUtilTest.java
/** * Test the createControl function with no endUserId *///from w w w. ja va 2s. c om @Test public void createControlNoEndUser() { DbeExpendLimit limit = new DbeExpendLimit(); DbeExpendLimitPK id = new DbeExpendLimitPK(); id.setTxElType(ProcessingLimitService.DAY_PERIOD_TYPE); limit.setId(id); DbeTransaction tx = ProcessingLimitServiceTest.generateTransaction(); tx.setTxEndUserId(null); DbeExpendControl control; try { control = utils.createControl(tx, limit); Assert.assertEquals(tx.getTxGlobalUserId(), control.getId().getTxEndUserId()); } catch (RSSException e) { Assert.fail("Exception received: " + e.getMessage()); } }