List of usage examples for junit.framework Assert fail
static public void fail(String message)
From source file:eu.stratosphere.pact.runtime.task.ReduceTaskExternalITCase.java
@Test public void testMultiLevelMergeCombiningReduceTask() { int keyCnt = 32768; int valCnt = 8; addInputComparator(this.comparator); setOutput(this.outList); getTaskConfig().setDriverStrategy(DriverStrategy.SORTED_GROUP_REDUCE); CombiningUnilateralSortMerger<Record> sorter = null; try {/*from w w w. j a v a 2s . c o m*/ sorter = new CombiningUnilateralSortMerger<Record>(new MockCombiningReduceStub(), getMemoryManager(), getIOManager(), new UniformRecordGenerator(keyCnt, valCnt, false), getOwningNepheleTask(), RecordSerializerFactory.get(), this.comparator.duplicate(), this.perSortMem, 2, 0.8f); addInput(sorter.getIterator()); GroupReduceDriver<Record, Record> testTask = new GroupReduceDriver<Record, Record>(); testDriver(testTask, MockCombiningReduceStub.class); } catch (Exception e) { LOG.debug(e); Assert.fail("Invoke method caused exception."); } finally { if (sorter != null) { sorter.close(); } } int expSum = 0; for (int i = 1; i < valCnt; i++) { expSum += i; } 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() == expSum - record.getField(0, IntValue.class).getValue()); } this.outList.clear(); }
From source file:BQJDBC.QueryResultTest.BQForwardOnlyResultSetFunctionTest.java
/** * Makes a new Bigquery Connection to URL in file and gives back the * Connection to static con member.//from ww w . j a v a 2 s. c o m */ @Before public void NewConnection() { try { if (BQForwardOnlyResultSetFunctionTest.con == null || !BQForwardOnlyResultSetFunctionTest.con.isValid(0)) { this.logger.info("Testing the JDBC driver"); try { Class.forName("net.starschema.clouddb.jdbc.BQDriver"); BQForwardOnlyResultSetFunctionTest.con = DriverManager.getConnection( BQSupportFuncts.constructUrlFromPropertiesFile( BQSupportFuncts.readFromPropFile("installedaccount1.properties")), BQSupportFuncts.readFromPropFile("installedaccount1.properties")); } catch (Exception e) { e.printStackTrace(); this.logger.error("Error in connection" + e.toString()); Assert.fail("General Exception:" + e.toString()); } this.logger.info(((BQConnection) BQForwardOnlyResultSetFunctionTest.con).getURLPART()); } } catch (SQLException e) { logger.debug("Oops something went wrong", e); } this.QueryLoad(); }
From source file:com.hoccer.tools.TestHelper.java
public static void assertSmaller(String message, int maximum, int measured) { if (maximum < measured) { Assert.fail(message + " but " + maximum + " is smaller than " + measured); }/*from w w w .j a v a 2s .co m*/ }
From source file:com.aliyun.oss.integrationtests.ImageProcessTest.java
@Test public void testFormatImage() { String style = "image/format,png"; // ? try {/*from ww w .j a v a 2 s .co m*/ 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(), 160733); Assert.assertEquals(imageInfo.getFormat(), "png"); } catch (Exception e) { e.printStackTrace(); Assert.fail(e.getMessage()); } }
From source file:my.adam.smo.ServerCorrectnessTest.java
@Test public void ultraHighPayloadTest() { // given/*from www .j a va 2s . co m*/ TestServices.NewUsefullTestService.BlockingInterface httpBlockingService = TestServices.NewUsefullTestService .newBlockingStub(httpBlockingChannel); TestServices.NewUsefullTestService.BlockingInterface socketBlockingService = TestServices.NewUsefullTestService .newBlockingStub(socketBlockingChannel); int dataAmount = 500; TestServices.HighWeightRequest in = TestServices.HighWeightRequest.newBuilder() .setRequest(ByteString.copyFrom(getMegaBytes(dataAmount))).setLoad(dataAmount).build(); int httpResponseSize = 0; int socketResponseSize = 0; // when try { httpResponseSize = httpBlockingService.doHighWeightGoodJob(new DummyRpcController(), in).getResponse() .size(); socketResponseSize = socketBlockingService.doHighWeightGoodJob(new DummyRpcController(), in) .getResponse().size(); } catch (ServiceException e) { logger.error("err", e); Assert.fail("call failed"); } // then Assert.assertEquals(1024 * dataAmount, httpResponseSize); Assert.assertEquals(1024 * dataAmount, socketResponseSize); }
From source file:org.jboss.shrinkwrap.tomcat_6.test.TomcatDeploymentIntegrationUnitTestCase.java
/** * Tests that we can execute an HTTP request and it's fulfilled as expected, * proving our deployment succeeded/*from www.java 2s .co m*/ */ @Test public void requestWebapp() throws Exception { // Get an HTTP Client final HttpClient client = new DefaultHttpClient(); // Make an HTTP Request, adding in a custom parameter which should be echoed back to us final String echoValue = "ShrinkWrap>Tomcat Integration"; final List<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("to", PATH_ECHO_SERVLET)); params.add(new BasicNameValuePair("echo", echoValue)); final URI uri = URIUtils.createURI("http", HTTP_BIND_HOST, HTTP_BIND_PORT, NAME_WEBAPP + SEPARATOR + servletClass.getSimpleName(), URLEncodedUtils.format(params, "UTF-8"), null); final HttpGet request = new HttpGet(uri); // Execute the request log.info("Executing request to: " + request.getURI()); final HttpResponse response = client.execute(request); System.out.println(response.getStatusLine()); final HttpEntity entity = response.getEntity(); if (entity == null) { Assert.fail("Request returned no entity"); } // Read the result, ensure it's what we're expecting (should be the value of request param "echo") final BufferedReader reader = new BufferedReader(new InputStreamReader(entity.getContent())); final String line = reader.readLine(); Assert.assertEquals("Unexpected response from Servlet", echoValue, line); }
From source file:eu.stratosphere.pact.runtime.task.CrossTaskTest.java
@Test public void testStream2CrossTask() { int keyCnt1 = 10; int valCnt1 = 1; int keyCnt2 = 100; int valCnt2 = 4; super.initEnvironment(1 * 1024 * 1024); super.addInput(new UniformPactRecordGenerator(keyCnt1, valCnt1, false), 1); super.addInput(new UniformPactRecordGenerator(keyCnt2, valCnt2, false), 2); super.addOutput(this.outList); CrossTask<PactRecord, PactRecord, PactRecord> testTask = new CrossTask<PactRecord, PactRecord, PactRecord>(); super.getTaskConfig().setLocalStrategy(LocalStrategy.NESTEDLOOP_STREAMED_OUTER_SECOND); super.getTaskConfig().setMemorySize(1 * 1024 * 1024); super.registerTask(testTask, MockCrossStub.class); try {/* www . ja v a 2s . co m*/ testTask.invoke(); } catch (Exception e) { LOG.debug(e); Assert.fail("Invoke method caused exception."); } int expCnt = keyCnt1 * valCnt1 * keyCnt2 * valCnt2; Assert.assertTrue("Resultset size was " + this.outList.size() + ". Expected was " + expCnt, this.outList.size() == expCnt); this.outList.clear(); }
From source file:eu.stratosphere.pact.runtime.sort.AsynchonousPartialSorterITCase.java
@Test public void testExceptionForwarding() throws IOException { try {/* w w w . j av a2s . c o m*/ Sorter<Record> sorter = null; try { final int NUM_RECORDS = 100; // 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 = new ExceptionThrowingAsynchronousPartialSorter<Record>(this.memoryManager, source, this.parentTask, this.serializer, this.comparator, 32 * 1024 * 1024); runPartialSorter(sorter, NUM_RECORDS, 0); Assert.fail("Expected Test Exception not thrown."); } catch (Exception e) { if (!containsTriggerException(e)) { throw e; } } finally { if (sorter != null) { sorter.close(); } } } catch (Exception t) { t.printStackTrace(); Assert.fail("Test failed due to an uncaught exception: " + t.getMessage()); } }
From source file:de.fhg.iais.cortex.search.SolrSearchServerTest.java
@Test public void testStop() 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();//from www .j av a 2 s.c om Jetty9SolrRunner runnerMock = Mockito.mock(Jetty9SolrRunner.class); Mockito.when(this.factoryMock.createJetty9SolrRunner(new File(this.baseDir, "solr").getAbsolutePath(), "", 8183, false, 5000)).thenReturn(runnerMock); try { solrSearchServer.doStart(); } catch (DbcException e) { Assert.fail("Should not throw a DbcException."); } try { solrSearchServer.doStop(); } catch (DbcException e) { Assert.fail("Should throw a DbcException."); } Mockito.verify(runnerMock, Mockito.times(1)).stop(); }
From source file:com.hoccer.tools.TestHelper.java
public static void assertIncludes(String message, String substring, String measured) { if (!measured.contains(substring)) { Assert.fail(message + " but '" + measured + "' does not contain '" + substring + "'"); }/* w w w.j ava2 s . c o m*/ }