List of usage examples for junit.framework Assert fail
static public void fail(String message)
From source file:eu.cloud4soa.soa.git.GitProxyTest.java
@Test public void testRegisterGitRepository() { //Arguments String userInstanceUriId, String giturl, String reponame, String paasid String GITURL = "git@heroku.com"; String GITREPONAME = "c4sapp1.git"; String PAASID = "0"; String APPID = "0"; String APPURIID = "appUriId"; //Mocks//from w w w . ja v a2 s.c o m //Mock userdao.findBy User user = new User(); user.setId(new Long(0)); user.setFullname("Test"); user.setUriID(userInstanceUriId); user.setUsername("testUsername"); List<Object> userList = new ArrayList<Object>(); userList.add(user); when(userdao.findBy("uriID", userInstanceUriId)).thenReturn(userList); //Mock paasdao.findBy Paas paas = new Paas("Heroku", "heroku.com"); paas.setId(new Long(PAASID)); List<Object> paasList = new ArrayList<Object>(); paasList.add(paas); when(paasdao.findBy("id", new Long(PAASID))).thenReturn(paasList); ApplicationInstance app = new ApplicationInstance(); app.setId(new Long(APPID)); app.setUriID(APPID); List<ApplicationInstance> appList = new ArrayList<ApplicationInstance>(); appList.add(app); when(appdao.findByUriId(APPURIID)).thenReturn(appList); //Mock repodao.findByGitrepo(reponame); when(repodao.findByGitrepo(GITREPONAME)).thenReturn(new ArrayList<GitRepo>()); //Mock repodao.save(gitrepo); GitRepo repo = new GitRepo(); repo.setId(new Long(0)); repo.setGitrepo(GITREPONAME); repo.setGiturl(GITURL); repo.setUser(user); repo.setPaas(paas); when(repodao.save(repo)).thenReturn(repo); //Actual invocation String[] ret = gitservices.registerGitRepository("", userInstanceUriId, GITURL, GITREPONAME, PAASID); try { Assert.assertEquals("0", ret[0]); } catch (Exception ex) { logger.error("Error in testRegisterGitRepository: " + ex.getMessage()); Assert.fail("Error in testRegisterGitRepository: " + ex.getMessage()); } }
From source file:com.mnxfst.testing.server.cfg.TestPTestServerConfigurationParser.java
@Test public void testParserServeConfigurationWithNullArray() { try {//w w w . j a v a 2 s. c o m byte[] test = null; new PTestServerConfigurationParser().parseServerConfiguration(test); Assert.fail("Invalid file contents"); } catch (ServerConfigurationFailedException e) { // } }
From source file:eu.stratosphere.pact.runtime.task.MatchTaskTest.java
@Test public void testSortBoth5MatchTask() { int keyCnt1 = 20; int valCnt1 = 20; int keyCnt2 = 20; int valCnt2 = 20; 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); 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 {// w ww. j a va2 s . com 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:BQJDBC.QueryResultTest.BQScrollableResultSetFunctionTest.java
public void QueryLoad() { final String sql = "SELECT TOP(word,10) AS word, COUNT(*) as count FROM publicdata:samples.shakespeare"; final String description = "The top 10 word from shakespeare #TOP #COUNT"; String[][] expectation = new String[][] { { "you", "yet", "would", "world", "without", "with", "your", "young", "words", "word" }, { "42", "42", "42", "42", "42", "42", "41", "41", "41", "41" } }; /** somehow the result changed with time { "you", "yet", "would", "world", "without", "with", "will", "why", "whose", "whom" },// ww w . j a v a 2 s . c om { "42", "42", "42", "42", "42", "42", "42", "42", "42", "42" } }; */ this.logger.info("Test number: 01"); this.logger.info("Running query:" + sql); try { //Statement stmt = BQResultSetFunctionTest.con.createStatement(); Statement stmt = BQScrollableResultSetFunctionTest.con .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); stmt.setQueryTimeout(500); BQScrollableResultSetFunctionTest.Result = stmt.executeQuery(sql); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } Assert.assertNotNull(BQScrollableResultSetFunctionTest.Result); this.logger.debug(description); HelperFunctions.printer(expectation); try { Assert.assertTrue("Comparing failed in the String[][] array", this.comparer(expectation, BQSupportMethods.GetQueryResult(BQScrollableResultSetFunctionTest.Result))); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail(e.toString()); } }
From source file:com.imaginary.home.cloud.CloudTest.java
private void setupPairing() throws Exception { if (locationId == null) { setupLocation();// w w w.ja va2 s. co m } HashMap<String, Object> action = new HashMap<String, Object>(); action.put("action", "initializePairing"); HttpClient client = getClient(); HttpPut method = new HttpPut(cloudAPI + "/location/" + locationId); long timestamp = System.currentTimeMillis(); method.addHeader("Content-Type", "application/json"); method.addHeader("x-imaginary-version", VERSION); method.addHeader("x-imaginary-timestamp", String.valueOf(timestamp)); method.addHeader("x-imaginary-api-key", apiKeyId); method.addHeader("x-imaginary-signature", CloudService.sign(apiKeySecret.getBytes("utf-8"), "put:/location/" + locationId + ":" + apiKeyId + ":" + timestamp + ":" + VERSION)); //noinspection deprecation method.setEntity(new StringEntity((new JSONObject(action)).toString(), "application/json", "UTF-8")); HttpResponse response; StatusLine status; try { response = client.execute(method); status = response.getStatusLine(); } catch (IOException e) { e.printStackTrace(); throw new CommunicationException(e); } if (status.getStatusCode() == HttpServletResponse.SC_OK) { String json = EntityUtils.toString(response.getEntity()); JSONObject u = new JSONObject(json); pairingCode = (u.has("pairingCode") && !u.isNull("pairingCode")) ? u.getString("pairingCode") : null; } else { Assert.fail("Failed to initialize pairing (" + status.getStatusCode() + ": " + EntityUtils.toString(response.getEntity())); } }
From source file:BQJDBC.QueryResultTest.BQResultSetFunctionTest.java
public void QueryLoad() { final String sql = "SELECT TOP(word,10) AS word, COUNT(*) as count FROM publicdata:samples.shakespeare"; final String description = "The top 10 word from shakespeare #TOP #COUNT"; String[][] expectation = new String[][] { { "you", "yet", "would", "world", "without", "with", "your", "young", "words", "word" }, { "42", "42", "42", "42", "42", "42", "41", "41", "41", "41" } }; /** somehow the result changed with time { "you", "yet", "would", "world", "without", "with", "will", "why", "whose", "whom" },/*ww w .j av a 2s. c o m*/ { "42", "42", "42", "42", "42", "42", "42", "42", "42", "42" } }; */ this.logger.info("Test number: 01"); this.logger.info("Running query:" + sql); try { Statement stmt = BQResultSetFunctionTest.con.createStatement(); stmt.setQueryTimeout(500); BQResultSetFunctionTest.Result = stmt.executeQuery(sql); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } Assert.assertNotNull(BQResultSetFunctionTest.Result); this.logger.debug(description); this.printer(expectation); try { Assert.assertTrue("Comparing failed in the String[][] array", this.comparer(expectation, BQSupportMethods.GetQueryResult(BQResultSetFunctionTest.Result))); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail(e.toString()); } }
From source file:com.smartitengineering.dao.hbase.autoincrement.AutoIncrementRowIdForLongTest.java
@Test public void testMultithreadedKeysSelfProvided() throws Exception { ExecutorService service = Executors.newFixedThreadPool(THREAD_COUNT); final long start = 3102; final int bound = THREAD_COUNT; final int innerBound = 30; List<Future> futures = new ArrayList<Future>(); final long startTime = System.currentTimeMillis(); for (int i = 0; i < bound; ++i) { final int index = i; futures.add(service.submit(new Runnable() { @Override/* w ww . j av a 2s.c om*/ public void run() { for (int j = 0; j < innerBound; ++j) { final HTableInterface table = pool.getTable(TABLE_NAME); long id = index * bound + j + start; final long id1 = Long.MAX_VALUE - id; synchronized (ids) { final long mainId = Long.MAX_VALUE - id1; Assert.assertFalse(ids.contains(mainId)); ids.add(mainId); } final byte[] row = Bytes.toBytes(id1); Put put = new Put(row); final byte[] toBytes = Bytes.toBytes("value " + id); put.add(FAMILY_BYTES, CELL_BYTES, toBytes); Result get1; try { table.put(put); Get get = new Get(row); get1 = table.get(get); } catch (Exception ex) { LOGGER.error(ex.getMessage(), ex); get1 = null; Assert.fail(ex.getMessage()); } pool.putTable(table); Assert.assertNotNull(get1); Assert.assertFalse(get1.isEmpty()); Assert.assertTrue(Arrays.equals(row, get1.getRow())); Assert.assertTrue(Arrays.equals(toBytes, get1.getValue(FAMILY_BYTES, CELL_BYTES))); } } })); } for (Future future : futures) { future.get(); } final long endTime = System.currentTimeMillis(); LOGGER.info("Time for " + (bound * innerBound) + " rows ID retrieval, put and get is " + (endTime - startTime) + "ms"); Assert.assertEquals(bound * innerBound + start - 1, ids.size()); }
From source file:eu.stratosphere.pact.runtime.task.CrossTaskTest.java
@Test public void testBlockEmptyOuterCrossTask() { int keyCnt1 = 10; int valCnt1 = 1; int keyCnt2 = 0; int valCnt2 = 0; super.initEnvironment(1 * 1024 * 1024); super.addInput(new UniformPactRecordGenerator(keyCnt1, valCnt1, false), 0); super.addInput(new UniformPactRecordGenerator(keyCnt2, valCnt2, false), 1); super.addOutput(this.outList); CrossTask<PactRecord, PactRecord, PactRecord> testTask = new CrossTask<PactRecord, PactRecord, PactRecord>(); super.getTaskConfig().setLocalStrategy(LocalStrategy.NESTEDLOOP_BLOCKED_OUTER_SECOND); super.getTaskConfig().setMemorySize(1 * 1024 * 1024); super.registerTask(testTask, MockCrossStub.class); try {//from w ww. j a va 2 s . com 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:com.mnxfst.testing.server.cfg.TestPTestServerConfigurationParser.java
@Test public void testParserServeConfigurationWithEmptyArray() { try {/*ww w.java 2 s . co m*/ byte[] test = new byte[0]; new PTestServerConfigurationParser().parseServerConfiguration(test); Assert.fail("Invalid file contents"); } catch (ServerConfigurationFailedException e) { // } }
From source file:BQJDBC.QueryResultTest.Timeouttest.java
@Test public void QueryResultTest07() { final String sql = "SELECT corpus, SUM(word_count) as w_c FROM publicdata:samples.shakespeare GROUP BY corpus HAVING w_c > 20000 ORDER BY w_c ASC LIMIT 5;"; final String description = "A query which gets Shakespeare were there are more words then 20000 (only 5 is displayed ascending)"; String[][] expectation = new String[][] { { "juliuscaesar", "twelfthnight", "titusandronicus", "kingjohn", "tamingoftheshrew" }, { "21052", "21633", "21911", "21983", "22358" } }; this.logger.info("Test number: 07"); this.logger.info("Running query:" + sql); java.sql.ResultSet Result = null; try {//from w w w.ja v a 2 s. com 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()); } }