List of usage examples for junit.framework Assert fail
static public void fail(String message)
From source file:com.aliyun.oss.integrationtests.ImageTest.java
@Test public void testWatermarkImage() { String style = "image/watermark,text_SGVsbG8g5Zu-54mH5pyN5YqhIQ"; // ? try {/*from w w w . j a va 2s .c om*/ GetObjectRequest request = new GetObjectRequest(bucketName, originalImage); request.addParameter("x-oss-process", style); OSSObject ossObject = ossClient.getObject(request); ossClient.putObject(bucketName, newImage, ossObject.getObjectContent()); ImageInfo imageInfo = getImageInfo(bucketName, newImage); Assert.assertEquals(imageInfo.getHeight(), 267); Assert.assertEquals(imageInfo.getWidth(), 400); Assert.assertEquals(imageInfo.getSize(), 26953); Assert.assertEquals(imageInfo.getFormat(), "jpg"); } catch (Exception e) { e.printStackTrace(); Assert.fail(e.getMessage()); } }
From source file:com.aliyun.oss.perftests.PerftestRunner.java
public void prepareEnv() { String endpoint = scenario.getHost(); String accessId = scenario.getAccessId(); String accessKey = scenario.getAccessKey(); ossClient = new OSSClient(endpoint, accessId, accessKey); try {// w w w .j ava 2 s . c om byteArray1KB = createFixedLengthBytes(1024); byteArray100KB = createFixedLengthBytes(102400); byteArray1MB = createFixedLengthBytes(1 * 1024 * 1024); byteArray4MB = createFixedLengthBytes(4 * 1024 * 1024); } catch (Exception e) { log.error(e.getMessage()); Assert.fail(e.getMessage()); } }
From source file:net.sf.dynamicreports.test.jasper.AbstractJasperChartTest.java
protected JFreeChart getChart(JRPrintImage image) { DrawChartRenderer renderer = (DrawChartRenderer) image.getRenderable(); try {//from w w w.ja v a 2 s . c om Field field = renderer.getClass().getDeclaredField("chart"); field.setAccessible(true); return (JFreeChart) field.get(renderer); } catch (Exception e) { e.printStackTrace(); Assert.fail(e.getMessage()); } return null; }
From source file:com.hoccer.tools.TestHelper.java
/** * Assert two {@linkplain InputStream input streams} to deliver equal content. * /*from w w w . j a va 2 s .com*/ * @param message * the error message * @param expected * reference input * @param current * input to compare * @since 1.0 * @author Apache Project (package org.apache.commons.id.test) * @license Apache Lichense 2.0 */ public static void assertInputStreamEquals(final String message, final InputStream expected, final InputStream current) { long counter = 0; int eByte, cByte; try { for (; (eByte = expected.read()) != -1; ++counter) { cByte = current.read(); if (eByte != cByte) { Assert.assertEquals( (message != null ? message + ": " : "") + "Stream not equal at position " + counter, eByte, cByte); } } } catch (final IOException e) { Assert.fail((message != null ? message + ": " : "") + e.getMessage()); } }
From source file:com.aliyun.oss.integrationtests.ImageProcessTest.java
@Test public void testWatermarkImage() { String style = "image/watermark,text_SGVsbG8g5Zu-54mH5pyN5YqhIQ"; // ? try {/* www . j a v a 2 s . c om*/ GetObjectRequest request = new GetObjectRequest(bucketName, originalImage); request.setProcess(style); OSSObject ossObject = ossClient.getObject(request); ossClient.putObject(bucketName, newImage, ossObject.getObjectContent()); ImageInfo imageInfo = getImageInfo(bucketName, newImage); Assert.assertEquals(imageInfo.getHeight(), 267); Assert.assertEquals(imageInfo.getWidth(), 400); Assert.assertEquals(imageInfo.getSize(), 26953); Assert.assertEquals(imageInfo.getFormat(), "jpg"); } catch (Exception e) { e.printStackTrace(); Assert.fail(e.getMessage()); } }
From source file:eu.stratosphere.pact.runtime.sort.AsynchonousPartialSorterITCase.java
@Test public void testLargeSortAcrossMultipleWindows() throws Exception { try {//from w w w . j a v a 2 s . c o m final int NUM_RECORDS = 1000000; // reader final TestData.Generator generator = new TestData.Generator(SEED, KEY_MAX, VALUE_LENGTH, KeyMode.RANDOM, ValueMode.CONSTANT, VAL); final MutableObjectIterator<Record> source = new TestData.GeneratorIterator(generator, NUM_RECORDS); // merge iterator LOG.debug("Initializing sortmerger..."); Sorter<Record> sorter = new AsynchronousPartialSorter<Record>(this.memoryManager, source, this.parentTask, this.serializer, this.comparator, 32 * 1024 * 1024); runPartialSorter(sorter, NUM_RECORDS, 28); } catch (Exception t) { t.printStackTrace(); Assert.fail("Test failed due to an uncaught exception: " + t.getMessage()); } }
From source file:com.cubusmail.server.user.UserAccountDaoTest.java
@Test public void testInsertAddressFolder() { List<AddressFolder> folders = (List<AddressFolder>) this.applicationContext.getBean("testAddressFolders"); try {//w w w. j a v a 2 s . c o m for (AddressFolder folder : folders) { folder.setUserAccount(this.testUserAccount); this.userAccountDao.saveAddressFolder(folder); } List<AddressFolder> savedAdressFolders = this.userAccountDao .retrieveAddressFolders(this.testUserAccount); Assert.assertNotNull(savedAdressFolders); Assert.assertEquals(folders.size(), savedAdressFolders.size()); Assert.assertEquals(folders.get(0).getName(), savedAdressFolders.get(0).getName()); } catch (Exception e) { log.error(e.getMessage(), e); Assert.fail(e.getMessage()); } }
From source file:com.hoccer.tools.TestHelper.java
public static void assertGreater(String message, double minimum, double measured) { if (minimum > measured) { Assert.fail(message + " but " + minimum + " is greater than " + measured); }/* w w w . j a v a 2s . co m*/ }
From source file:example.crm.CrmIT.java
/** * HTTP POST http://localhost:9003/customers is used to upload the contents of * the add_customer.json file to add a new customer to the system. * <p/>//from w w w . j a va2 s. co m * On the server side, it matches the CustomerService's addCustomer() method * * @throws Exception */ @Test public void postCustomerTestJson() throws IOException { LOG.info("Sent HTTP POST request to add customer"); String inputFile = this.getClass().getResource("/add_customer.json").getFile(); File input = new File(inputFile); PostMethod post = new PostMethod(CUSTOMER_SERVICE_URL); post.addRequestHeader("Accept", "application/json"); RequestEntity entity = new FileRequestEntity(input, "application/json; 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:de.fhg.iais.cortex.search.SolrSearchServerTest.java
@Test public void testStopException() throws Exception { SolrSearchServer solrSearchServer = new SolrSearchServer(this.homeMock, this.factoryMock, this.CONTEXT_URI, this.SOLR_SEARCH_DIR, this.SOLR_NODESTORE_DIR, this.SOLR_ENTITY_DIR); solrSearchServer.doStop();// www. j av a 2 s .c o m Jetty9SolrRunner runnerMock = Mockito.mock(Jetty9SolrRunner.class); Mockito.when(this.factoryMock.createJetty9SolrRunner(new File(this.baseDir, "solr").getAbsolutePath(), "", 8183, false, 5000)).thenReturn(runnerMock); Mockito.doThrow(new Exception("Some exception.")).when(runnerMock).stop(); try { solrSearchServer.doStart(); } catch (DbcException e) { Assert.fail("Should not throw a DbcException."); } try { solrSearchServer.doStop(); Assert.fail("Should throw a DbcException."); } catch (DbcException e) { ; } }