List of usage examples for junit.framework Assert fail
static public void fail(String message)
From source file:com.amazonaws.http.AmazonHttpClientRequestTimeoutTest.java
@Test public void testResponseNotBufferedForStreamingOperation() throws IOException, InterruptedException { ClientConfiguration config = new ClientConfiguration().withRequestTimeout(5 * 1000); HttpClientFactory httpClientFactory = new HttpClientFactory(); HttpClient rawHttpClient = spy(httpClientFactory.createHttpClient(config)); HttpResponseProxy responseProxy = createHttpResponseProxySpy(); doReturn(responseProxy).when(rawHttpClient).execute(any(HttpRequestBase.class), any(HttpContext.class)); String localhostEndpoint = "http://localhost:0"; Request<?> request = new EmptyHttpRequest(localhostEndpoint, HttpMethodName.GET); AmazonHttpClient httpClient = new AmazonHttpClient(config, rawHttpClient, null); try {// w w w . j av a 2s. c om httpClient.execute(request, new NullResponseHandler() { @Override public boolean needsConnectionLeftOpen() { return true; } }, new NullErrorResponseHandler(), new ExecutionContext()); Assert.fail("Should have been unable to unmarshall the response!"); } catch (AmazonClientException e) { } /* Verify the response is not buffered when the response handler requires the connection to be left open. */ verify(responseProxy, never()).setEntity(any(BufferedHttpEntity.class)); httpClient.shutdown(); }
From source file:eu.cloud4soa.soa.git.GitProxyTest.java
@Test public void getPublicKeysForUser() { User user = new User(); user.setId(new Long(0)); user.setFullname("Test"); user.setUriID(userInstanceUriId);/* w ww.j av a2 s . co m*/ user.setUsername("testUsername"); List<Object> userList = new ArrayList<Object>(); userList.add(user); when(userdao.findBy("uriID", userInstanceUriId)).thenReturn(userList); PubKey pubkey1 = new PubKey(); pubkey1.setId(new Long(0)); pubkey1.setPubkey("pubkey1"); pubkey1.setUser(user); PubKey pubkey2 = new PubKey(); pubkey2.setId(new Long(0)); pubkey2.setPubkey("pubkey2"); pubkey2.setUser(user); List<PubKey> pubkeysList = new ArrayList<PubKey>(); pubkeysList.add(pubkey1); pubkeysList.add(pubkey2); when(pubkeydao.findByUser(user)).thenReturn(pubkeysList); try { List<PubKey> publicKeysForUser = gitservices.getPublicKeysForUser(userInstanceUriId); logger.info(publicKeysForUser.toString()); Assert.assertNotNull(publicKeysForUser); Assert.assertEquals(2, publicKeysForUser.size()); } catch (SOAException ex) { Assert.fail("SOA Error in getPublicKeysForUser: " + ex.getMessage()); } catch (Exception ex) { logger.error("Error in getPublicKeysForUser: " + ex.getMessage()); Assert.fail("Error in getPublicKeysForUser: " + ex.getMessage()); } }
From source file:BQJDBC.QueryResultTest.Timeouttest.java
@Test public void QueryResultTest05() { final String sql = "SELECT word FROM publicdata:samples.shakespeare WHERE word=\"huzzah\""; final String description = "The word \"huzzah\" NOTE: It doesn't appear in any any book, so it returns with a null #WHERE"; this.logger.info("Test number: 05"); this.logger.info("Running query:" + sql); java.sql.ResultSet Result = null; try {/*from w w w . ja v a2 s.co m*/ Result = Timeouttest.con.createStatement().executeQuery(sql); this.logger.debug(Result.getMetaData().getColumnCount()); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } Assert.assertNotNull(Result); this.logger.debug(description); try { if (Result.getType() != ResultSet.TYPE_FORWARD_ONLY) Assert.assertFalse(Result.first()); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail(e.toString()); } }
From source file:BQJDBC.QueryResultTest.BQForwardOnlyResultSetFunctionTest.java
@Test public void TestResultSetFirst() { try {//from w w w .j a va 2s . com // Assert.assertTrue(BQForwardOnlyResultSetFunctionTest.Result.first()); Result.next(); Assert.assertTrue(BQForwardOnlyResultSetFunctionTest.Result.isFirst()); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } }
From source file:hk.hku.cecid.corvus.ws.EBMSMessageHistoryQuerySenderTest.java
@Test public void testFail_NegativeQueryLimit() throws Exception { EBMSMessageHistoryRequestData expectData = new EBMSMessageHistoryRequestData(); expectData.setEndPoint(TEST_ENDPOINT); expectData.setMessageBox(""); expectData.setStatus(""); this.target = new EBMSMessageHistoryQuerySender(this.testClassLogger, expectData); try {// w w w .j a v a2 s . c o m this.target.run(); } catch (Error err) { Assert.fail("Query Limit should transformed to 100"); } EBMSMessageHistoryRequestData actualData = getHttpRequestData(); }
From source file:BQJDBC.QueryResultTest.QueryResultTest.java
@Test public void QueryResultTest05() { final String sql = "SELECT word FROM publicdata:samples.shakespeare WHERE word='huzzah' ;"; final String description = "The word \"huzzah\" NOTE: It doesn't appear in any any book, so it returns with a null #WHERE"; this.logger.info("Test number: 05"); this.logger.info("Running query:" + sql); java.sql.ResultSet Result = null; try {// w w w . j a va 2 s . c o m Result = QueryResultTest.con.createStatement().executeQuery(sql); this.logger.debug(Result.getMetaData().getColumnCount()); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } Assert.assertNotNull(Result); this.logger.debug(description); try { if (Result.getType() != ResultSet.TYPE_FORWARD_ONLY) Assert.assertFalse(Result.first()); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail(e.toString()); } }
From source file:at.tugraz.ist.akm.test.webservice.server.SimpleWebServerTest.java
License:asdf
public void testStartSecureServer() { logDebug("testStartSecureServer"); mServerConfig.isHttpsEnabled = true; mServerConfig.isUserAuthEnabled = false; mServerConfig.password = "asdf"; mServerConfig.port = 8888;//from w w w . j a va2 s. c o m mServerConfig.protocolName = "https"; mServerConfig.username = "huaba"; SharedPreferencesProvider serverConfig = new SharedPreferencesProvider(mContext); String keystorePassword = "foobar64"; serverConfig.setKeyStorePassword(keystorePassword); String keystoreFilePath = new String(mContext.getFilesDir().getPath().toString() + "/" + mContext.getResources().getString(R.string.preferences_keystore_store_filename)); try { serverConfig.close(); } catch (Throwable e) { logError("failed closing server config"); } ApplicationKeyStore appKeystore = new ApplicationKeyStore(); appKeystore.loadKeystore(keystorePassword, keystoreFilePath); try { appKeystore.close(); } catch (Throwable e) { logError("failed closing application keystore"); } try { startServer(true); Assert.assertTrue(mWebserver.isRunning()); } catch (Exception ex) { ex.printStackTrace(); Assert.fail(ex.getMessage()); } stopServer(); Assert.assertFalse(mWebserver.isRunning()); try { mWebserver.close(); } catch (Throwable e) { logError("failed closing webserver", e); } }
From source file:com.cubusmail.server.user.UserAccountDaoTest.java
@Test public void testInsertAddress() { try {/* w w w . j ava 2 s . c om*/ List<AddressFolder> folders = (List<AddressFolder>) this.applicationContext .getBean("testAddressFolders"); folders.get(0).setUserAccount(this.testUserAccount); this.userAccountDao.saveAddressFolder(folders.get(0)); List<Address> testAddressList = (List<Address>) this.applicationContext.getBean("testAddresses"); for (Address address : testAddressList) { address.setAddressFolder(folders.get(0)); this.userAccountDao.saveAddress(address); } List<Address> savedAddressList = this.userAccountDao.retrieveAddressList(folders.get(0)); Assert.assertEquals(testAddressList.get(0), savedAddressList.get(0)); } catch (Exception e) { log.error(e.getMessage(), e); Assert.fail(e.getMessage()); } }
From source file:eu.stratosphere.pact.runtime.task.CoGroupTaskTest.java
@Test public void testSortSecondCoGroupTask() { int keyCnt1 = 200; int valCnt1 = 2; int keyCnt2 = 200; int valCnt2 = 4; super.initEnvironment(5 * 1024 * 1024); super.addInput(new UniformPactRecordGenerator(keyCnt1, valCnt1, true), 1); super.addInput(new UniformPactRecordGenerator(keyCnt2, valCnt2, false), 2); super.addOutput(this.outList); CoGroupTask<PactRecord, PactRecord, PactRecord> testTask = new CoGroupTask<PactRecord, PactRecord, PactRecord>(); super.getTaskConfig().setLocalStrategy(LocalStrategy.SORT_SECOND_MERGE); super.getTaskConfig().setMemorySize(5 * 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, MockCoGroupStub.class); try {/* ww w. j ava 2 s . co m*/ testTask.invoke(); } catch (Exception e) { LOG.debug(e); Assert.fail("Invoke method caused exception."); } int expCnt = valCnt1 * valCnt2 * Math.min(keyCnt1, keyCnt2) + Math.max(keyCnt1, keyCnt2) - 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:org.opencastproject.remotetest.server.RetryStrategiesTest.java
@Test public void testRetry() throws Exception { // ------------------------------------------------- // FIRST WORKFLOW (RETRY) // ------------------------------------------------- // Start a workflow instance via the rest endpoint HttpPost postStart = new HttpPost(BASE_URL + "/workflow/start"); List<NameValuePair> formParams = new ArrayList<NameValuePair>(); formParams.add(new BasicNameValuePair("definition", getSampleWorkflowDefinition("workflow-retry.xml"))); formParams.add(new BasicNameValuePair("mediapackage", getSampleMediaPackage())); formParams.add(new BasicNameValuePair("properties", "this=that")); postStart.setEntity(new UrlEncodedFormEntity(formParams, "UTF-8")); // Grab the new workflow instance from the response String postResponse = EntityUtils.toString(client.execute(postStart).getEntity()); String id = getWorkflowInstanceId(postResponse); // Ensure that the workflow finishes successfully int attempts = 0; while (true) { if (++attempts == 20) Assert.fail("workflow rest endpoint test has hung"); HttpGet getWorkflowMethod = new HttpGet(BASE_URL + "/workflow/instance/" + id + ".xml"); String getResponse = EntityUtils.toString(client.execute(getWorkflowMethod).getEntity()); String state = getWorkflowInstanceStatus(getResponse); if ("FAILED".equals(state)) break; if ("SUCCEEDED".equals(state)) Assert.fail("workflow instance " + id + " succeeded"); if ("PAUSED".equals(state)) Assert.fail("workflow instance " + id + " paused"); System.out.println("workflow " + id + " is " + state); Thread.sleep(5000);//from w ww.j av a 2s .c o m } // Get Ingest service state // Should be WARNING HttpGet getWorkflowMethod = new HttpGet( BASE_URL + "/services/services.json?serviceType=org.opencastproject.inspection&host=" + BASE_URL); String jsonResponse = EntityUtils.toString(client.execute(getWorkflowMethod).getEntity()); String state = new JSONObject(jsonResponse).getJSONObject("services").getJSONObject("service") .getString("service_state"); Assert.assertEquals("WARNING", state); // Get the number of failed on Ingest service, // Should be 1 getWorkflowMethod = new HttpGet(BASE_URL + "/services/count?serviceType=org.opencastproject.inspection"); String getResponse = EntityUtils.toString(client.execute(getWorkflowMethod).getEntity()); logger.debug("Job count response: {}", getResponse); Assert.assertEquals(2, Integer.parseInt(getResponse) - initCount); // ------------------------------------------------- // SECOND WORKFLOW (NONE) // ------------------------------------------------- // Start a workflow instance via the rest endpoint postStart = new HttpPost(BASE_URL + "/workflow/start"); formParams = new ArrayList<NameValuePair>(); formParams.add(new BasicNameValuePair("definition", getSampleWorkflowDefinition("workflow-none.xml"))); formParams.add(new BasicNameValuePair("mediapackage", getSecondSampleMediaPackage())); formParams.add(new BasicNameValuePair("properties", "this=that")); postStart.setEntity(new UrlEncodedFormEntity(formParams, "UTF-8")); // Grab the new workflow instance from the response postResponse = EntityUtils.toString(client.execute(postStart).getEntity()); id = getWorkflowInstanceId(postResponse); // Ensure that the workflow finishes successfully attempts = 0; while (true) { if (++attempts == 20) Assert.fail("workflow rest endpoint test has hung"); getWorkflowMethod = new HttpGet(BASE_URL + "/workflow/instance/" + id + ".xml"); getResponse = EntityUtils.toString(client.execute(getWorkflowMethod).getEntity()); state = getWorkflowInstanceStatus(getResponse); if ("FAILED".equals(state)) break; if ("SUCCEEDED".equals(state)) Assert.fail("workflow instance " + id + " succeeded"); if ("PAUSED".equals(state)) Assert.fail("workflow instance " + id + " paused"); System.out.println("workflow " + id + " is " + state); Thread.sleep(5000); } // Get Ingest service state // Should be WARNING getWorkflowMethod = new HttpGet( BASE_URL + "/services/services.json?serviceType=org.opencastproject.inspection&host=" + BASE_URL); jsonResponse = EntityUtils.toString(client.execute(getWorkflowMethod).getEntity()); state = new JSONObject(jsonResponse).getJSONObject("services").getJSONObject("service") .getString("service_state"); Assert.assertEquals("ERROR", state); // Get available ingest service, because ingest service is in ERROR mode he is not returned getWorkflowMethod = new HttpGet( BASE_URL + "/services/available.json?serviceType=org.opencastproject.inspection"); jsonResponse = EntityUtils.toString(client.execute(getWorkflowMethod).getEntity()); Assert.assertNull(new JSONObject(jsonResponse).optJSONObject("services")); // Get the number of failed on Ingest service, // Should be 1 getWorkflowMethod = new HttpGet(BASE_URL + "/services/count?serviceType=org.opencastproject.inspection"); getResponse = EntityUtils.toString(client.execute(getWorkflowMethod).getEntity()); logger.debug("Job count response: {}", getResponse); Assert.assertEquals(3, Integer.parseInt(getResponse) - initCount); }