List of usage examples for junit.framework Assert fail
static public void fail(String message)
From source file:eu.stratosphere.pact.runtime.task.MatchTaskExternalITCase.java
@Test public void testExternalSort1MatchTask() { int keyCnt1 = 16384 * 2; int valCnt1 = 2; int keyCnt2 = 8192; int valCnt2 = 4 * 2; super.initEnvironment(6 * 1024 * 1024); super.addInput(new UniformPactRecordGenerator(keyCnt1, valCnt1, false), 1); super.addInput(new UniformPactRecordGenerator(keyCnt2, valCnt2, false), 2); super.addOutput(this.outList); final MatchTask<PactRecord, PactRecord, PactRecord> testTask = new MatchTask<PactRecord, PactRecord, PactRecord>(); super.getTaskConfig().setLocalStrategy(LocalStrategy.SORT_BOTH_MERGE); super.getTaskConfig().setMemorySize(6 * 1024 * 1024); super.getTaskConfig().setNumFilehandles(4); final int[] keyPos1 = new int[] { 0 }; final int[] keyPos2 = new int[] { 0 }; @SuppressWarnings("unchecked") final Class<? extends Key>[] keyClasses = (Class<? extends Key>[]) new Class[] { PactInteger.class }; PactRecordComparatorFactory.writeComparatorSetupToConfig(super.getTaskConfig().getConfiguration(), super.getTaskConfig().getPrefixForInputParameters(0), keyPos1, keyClasses); PactRecordComparatorFactory.writeComparatorSetupToConfig(super.getTaskConfig().getConfiguration(), super.getTaskConfig().getPrefixForInputParameters(1), keyPos2, keyClasses); super.registerTask(testTask, MockMatchStub.class); try {/*from ww w . ja v a 2 s . c o m*/ testTask.invoke(); } catch (Exception e) { LOG.debug(e); Assert.fail("Invoke method caused exception."); } int expCnt = valCnt1 * valCnt2 * Math.min(keyCnt1, keyCnt2); Assert.assertTrue("Resultset size was " + this.outList.size() + ". Expected was " + expCnt, this.outList.size() == expCnt); this.outList.clear(); }
From source file:com.atlassian.jira.rest.client.TestUtil.java
public static void assertErrorCode(int errorCode, String message, Runnable runnable) { try {/*w w w . jav a2s . c om*/ runnable.run(); Assert.fail(RestClientException.class + " exception expected"); } catch (com.atlassian.jira.rest.client.api.RestClientException e) { Assert.assertTrue(e.getStatusCode().isPresent()); Assert.assertEquals(errorCode, e.getStatusCode().get().intValue()); if (!StringUtils.isEmpty(message)) { // We expect a single error message. Either error or error message. Assert.assertEquals(1, e.getErrorCollections().size()); if (Iterators.getOnlyElement(e.getErrorCollections().iterator()).getErrorMessages().size() > 0) { Assert.assertEquals(getOnlyElement( getOnlyElement(e.getErrorCollections().iterator()).getErrorMessages().iterator()), message); } else if (Iterators.getOnlyElement(e.getErrorCollections().iterator()).getErrors().size() > 0) { Assert.assertEquals(getOnlyElement( getOnlyElement(e.getErrorCollections().iterator()).getErrors().values().iterator()), message); } else { Assert.fail("Expected an error message."); } } } }
From source file:org.apache.gobblin.writer.AsyncHttpWriterTest.java
/** * Test successful writes of 4 records//from w w w . j a v a 2s.c om */ @Test public void testSuccessfulWrites() { MockHttpClient client = new MockHttpClient(); MockRequestBuilder requestBuilder = new MockRequestBuilder(); MockResponseHandler responseHandler = new MockResponseHandler(); MockAsyncHttpWriterBuilder builder = new MockAsyncHttpWriterBuilder(client, requestBuilder, responseHandler); TestAsyncHttpWriter asyncHttpWriter = new TestAsyncHttpWriter(builder); List<MockWriteCallback> callbacks = new ArrayList<>(); for (int i = 0; i < 4; i++) { callbacks.add(new MockWriteCallback()); } asyncHttpWriter.write(new Object(), callbacks.get(0)); asyncHttpWriter.write(new Object(), callbacks.get(1)); asyncHttpWriter.write(new Object(), callbacks.get(2)); try { asyncHttpWriter.flush(); } catch (IOException e) { Assert.fail("Flush failed"); } asyncHttpWriter.write(new Object(), callbacks.get(3)); try { asyncHttpWriter.close(); } catch (IOException e) { Assert.fail("Close failed"); } // Assert all successful callbacks are invoked for (MockWriteCallback callback : callbacks) { Assert.assertTrue(callback.isSuccess); } Assert.assertTrue(client.isCloseCalled); }
From source file:net.sf.dynamicreports.test.jasper.chart.ThermometerChartTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);// ww w .jav a2 s . c o m JFreeChart chart = getChart("summary.chart1", 0); Plot plot = chart.getPlot(); Assert.assertEquals("renderer", ThermometerPlot.class, plot.getClass()); ThermometerPlot thermometerPlot = (ThermometerPlot) plot; Assert.assertEquals("value", 15, thermometerPlot.getDataset().getValue()); Assert.assertEquals("data range low", 3d, thermometerPlot.getLowerBound()); Assert.assertEquals("data range high", 30d, thermometerPlot.getUpperBound()); Assert.assertEquals("value color", Color.BLUE, thermometerPlot.getValuePaint()); try { Field field = thermometerPlot.getClass().getDeclaredField("valueFormat"); field.setAccessible(true); Assert.assertEquals("value mask", "15.0", ((NumberFormat) field.get(thermometerPlot)).format(15)); } catch (Exception e) { e.printStackTrace(); Assert.fail(e.getMessage()); } Assert.assertEquals("value font", new Font("Arial", Font.PLAIN, 10), thermometerPlot.getValueFont()); Assert.assertEquals("value location", ThermometerPlot.BULB, thermometerPlot.getValueLocation()); Assert.assertEquals("mercury color", Color.LIGHT_GRAY, thermometerPlot.getMercuryPaint()); try { Field field = thermometerPlot.getClass().getDeclaredField("subrangeInfo"); field.setAccessible(true); double[][] subrangeInfo = (double[][]) field.get(thermometerPlot); Assert.assertEquals("low data range low", 8d, subrangeInfo[2][0]); Assert.assertEquals("low data range high", 10d, subrangeInfo[2][1]); Assert.assertEquals("medium data range low", 18d, subrangeInfo[1][0]); Assert.assertEquals("medium data range high", 20d, subrangeInfo[1][1]); Assert.assertEquals("high data range low", 28d, subrangeInfo[0][0]); Assert.assertEquals("high data range high", 30d, subrangeInfo[0][1]); } catch (Exception e) { e.printStackTrace(); Assert.fail(e.getMessage()); } }
From source file:$.CrmTest.java
/** * HTTP GET http://localhost:8181/cxf/crm/customerservice/customers/123 * returns the XML document representing customer 123 * <p/>/*ww w . ja v a 2 s. c o m*/ * On the server side, it matches the CustomerService's getCustomer() method * * @throws Exception */ @Test public void getCustomerTest() throws Exception { LOG.info("Sent HTTP GET request to query customer info"); url = new URL(CUSTOMER_TEST_URL); InputStream in = null; try { in = url.openStream(); } catch (IOException e) { LOG.error("Error connecting to {}", CUSTOMER_TEST_URL); LOG.error( "You should build the 'cxf-cdi' quick start and deploy it to a local Fabric8 before running this test"); LOG.error("Please read the README.md file in 'cxf-cdi' quick start root"); Assert.fail("Connection error"); } String res = getStringFromInputStream(in); LOG.info(res); Assert.assertTrue(res.contains("123")); }
From source file:eu.stratosphere.pact.runtime.task.ReduceTaskTest.java
@Test public void testReduceTaskWithSortingInput() { final int keyCnt = 100; final int valCnt = 20; addInputComparator(this.comparator); setOutput(this.outList); getTaskConfig().setDriverStrategy(DriverStrategy.SORTED_GROUP_REDUCE); try {// w w w . j a va2s . co m addInputSorted(new UniformRecordGenerator(keyCnt, valCnt, false), this.comparator.duplicate()); GroupReduceDriver<Record, Record> testTask = new GroupReduceDriver<Record, Record>(); testDriver(testTask, MockReduceStub.class); } catch (Exception e) { LOG.debug(e); Assert.fail("Exception in Test."); } Assert.assertTrue("Resultset size was " + this.outList.size() + ". Expected was " + keyCnt, this.outList.size() == keyCnt); for (Record record : this.outList) { Assert.assertTrue("Incorrect result", record.getField(1, IntValue.class).getValue() == valCnt - record.getField(0, IntValue.class).getValue()); } this.outList.clear(); }
From source file:at.tugraz.ist.akm.test.webservice.server.SimpleWebServerTest.java
License:asdf
public void testStartStopServer() { try {/*www . j a v a2 s .c om*/ synchronized (this) { mWebserver = new SimpleWebServer(mContext, mServerConfig, null); mWebserver.startServer(); waitForServiceBeingStarted(20, 200); assertTrue(mWebserver.isRunning()); } } catch (Exception ex) { ex.printStackTrace(); Assert.fail("failed to start server"); } try { mWebserver.stopServer(); waitForServiceBeingStopped(20, 200); assertFalse(mWebserver.isRunning()); mWebserver.close(); } catch (Exception ex) { ex.printStackTrace(); Assert.fail("failed to stop server"); } }
From source file:org.slc.sli.dashboard.unit.controller.LayoutControllerTest.java
@SuppressWarnings("unchecked") @Test/*from www . j a v a 2 s. c om*/ public void testHandleLos() throws Exception { try { ModelAndView mv = layoutController.handleLos(request); Assert.assertEquals(2, ((Map<String, Config>) mv.getModel().get(Constants.MM_KEY_VIEW_CONFIGS)).size()); } catch (Exception e) { Assert.fail("Should pass but getting " + e.getMessage()); } }
From source file:com.aliyun.oss.integrationtests.ImageTest.java
@Test public void testCropImage() { String style = "image/crop,w_100,h_100,x_100,y_100,r_1"; // ? try {/*from w ww . j a v a 2 s . co m*/ 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(), 100); Assert.assertEquals(imageInfo.getWidth(), 100); Assert.assertEquals(imageInfo.getSize(), 2281); Assert.assertEquals(imageInfo.getFormat(), "jpg"); } catch (Exception e) { e.printStackTrace(); Assert.fail(e.getMessage()); } }
From source file:eu.stratosphere.pact.runtime.sort.AsynchonousPartialSorterITCase.java
@After public void afterTest() { this.ioManager.shutdown(); if (!this.ioManager.isProperlyShutDown()) { Assert.fail("I/O Manager was not properly shut down."); }/*from ww w. jav a2 s . c o m*/ if (this.memoryManager != null) { Assert.assertTrue("Memory leak: not all segments have been returned to the memory manager.", this.memoryManager.verifyEmpty()); this.memoryManager.shutdown(); this.memoryManager = null; } }