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 testRegisterGitProxy() { //Arguments String userInstanceUriId, String proxyname String PROXYNAME = "proxy1.git"; //Mocks/*from w w w . j a v a2 s . com*/ //Mock userdao.findBy("uriID", userInstanceUriId); 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 proxydao.findByProxyname(proxyname) when(proxydao.findByProxyname(PROXYNAME)).thenReturn(new ArrayList<GitProxy>()); //Mock proxydao.save(gitproxy); GitProxy proxy = new GitProxy(); proxy.setId(new Long(0)); proxy.setProxyname(PROXYNAME); proxy.setUser(user); //Invocation String[] ret = gitservices.registerGitProxy(userInstanceUriId, PROXYNAME); try { Assert.assertEquals("0", ret[0]); } catch (Exception ex) { logger.error("Error in testRegisterGitProxy: " + ex.getMessage()); Assert.fail("Error in testRegisterGitProxy: " + ex.getMessage()); } }
From source file:org.cloudifysource.azure.AbstractCliAzureDeploymentTest.java
public static String runCliCommands(File cliExecutablePath, List<List<String>> commands, boolean isDebug) throws IOException, InterruptedException { if (!cliExecutablePath.isFile()) { throw new IllegalArgumentException(cliExecutablePath + " is not a file"); }//w w w. j av a2 s . c o m File workingDirectory = cliExecutablePath.getAbsoluteFile().getParentFile(); if (!workingDirectory.isDirectory()) { throw new IllegalArgumentException(workingDirectory + " is not a directory"); } int argsCount = 0; for (List<String> command : commands) { argsCount += command.size(); } // needed to properly intercept error return code String[] cmd = new String[(argsCount == 0 ? 0 : 1) + 4 /* cmd /c call cloudify.bat ["args"] */]; int i = 0; cmd[i] = "cmd"; i++; cmd[i] = "/c"; i++; cmd[i] = "call"; i++; cmd[i] = cliExecutablePath.getAbsolutePath(); i++; if (argsCount > 0) { cmd[i] = "\""; //TODO: Use StringBuilder for (List<String> command : commands) { if (command.size() > 0) { for (String arg : command) { if (cmd[i].length() > 0) { cmd[i] += " "; } cmd[i] += arg; } cmd[i] += ";"; } } cmd[i] += "\""; } final ProcessBuilder pb = new ProcessBuilder(cmd); pb.directory(workingDirectory); pb.redirectErrorStream(true); String extCloudifyJavaOptions = ""; if (isDebug) { extCloudifyJavaOptions += "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=9000 -Xnoagent -Djava.compiler=NONE"; } pb.environment().put("EXT_CLOUDIFY_JAVA_OPTIONS", extCloudifyJavaOptions); final StringBuilder sb = new StringBuilder(); logger.info("running: " + cliExecutablePath + " " + Arrays.toString(cmd)); // log std output and redirected std error Process p = pb.start(); BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream())); String line = reader.readLine(); while (line != null) { sb.append(line).append('\n'); line = reader.readLine(); logger.info(line); } final String readResult = sb.toString(); final int exitValue = p.waitFor(); logger.info("Exit value = " + exitValue); if (exitValue != 0) { Assert.fail("Cli ended with error code: " + exitValue); } return readResult; }
From source file:com.mnxfst.testing.server.cfg.TestPTestServerConfigurationParser.java
@Test public void testParserServeConfigurationWithArrayHavingAnEmptyXMLDoc() { try {//from w w w. j a va 2 s . co m byte[] test = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><test/>".getBytes(); new PTestServerConfigurationParser().parseServerConfiguration(test); Assert.fail("Invalid file contents"); } catch (ServerConfigurationFailedException e) { // } }
From source file:BQJDBC.QueryResultTest.BQForwardOnlyResultSetFunctionTest.java
@Test public void TestResultSetNext() { try {//from w w w .ja va 2 s . com // Assert.assertTrue(BQForwardOnlyResultSetFunctionTest.Result.first()); Assert.assertTrue(BQForwardOnlyResultSetFunctionTest.Result.next()); Assert.assertTrue(BQForwardOnlyResultSetFunctionTest.Result.next()); Assert.assertEquals("yet", BQForwardOnlyResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQForwardOnlyResultSetFunctionTest.Result.next()); Assert.assertEquals("would", BQForwardOnlyResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQForwardOnlyResultSetFunctionTest.Result.next()); Assert.assertEquals("world", BQForwardOnlyResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQForwardOnlyResultSetFunctionTest.Result.next()); Assert.assertEquals("without", BQForwardOnlyResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQForwardOnlyResultSetFunctionTest.Result.next()); Assert.assertEquals("with", BQForwardOnlyResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQForwardOnlyResultSetFunctionTest.Result.next()); Assert.assertEquals("your", BQForwardOnlyResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQForwardOnlyResultSetFunctionTest.Result.next()); Assert.assertEquals("young", BQForwardOnlyResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQForwardOnlyResultSetFunctionTest.Result.next()); Assert.assertEquals("words", BQForwardOnlyResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQForwardOnlyResultSetFunctionTest.Result.next()); Assert.assertEquals("word", BQForwardOnlyResultSetFunctionTest.Result.getString(1)); Assert.assertFalse(BQForwardOnlyResultSetFunctionTest.Result.next()); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } try { Assert.assertEquals("", BQForwardOnlyResultSetFunctionTest.Result.getString(1)); } catch (SQLException e) { Assert.assertTrue(true); } }
From source file:BQJDBC.QueryResultTest.Timeouttest.java
@Test public void QueryResultTest08() { final String sql = "SELECT corpus, MAX(word_count) as m, word FROM publicdata:samples.shakespeare GROUP BY corpus,word ORDER BY m DESC LIMIT 5;"; final String description = "A query which gets those Shakespeare with the most common word ordered by count descending (only 5 is displayed)"; String[][] expectation = new String[][] { { "hamlet", "coriolanus", "kinghenryv", "2kinghenryiv", "kingrichardiii" }, { "995", "942", "937", "894", "848" }, { "the", "the", "the", "the", "the" } }; this.logger.info("Test number: 08"); this.logger.info("Running query:" + sql); java.sql.ResultSet Result = null; try {/* w w w. j ava 2 s .c o m*/ 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()); } }
From source file:org.deviceconnect.android.profile.restful.test.RESTfulDConnectTestCase.java
/** * RESTful?dConnectManager??./*from w ww. java 2s. com*/ * @param request Http * @param requiredAuth OAuth???????????????.true????? * @return ??intent */ protected final JSONObject sendRequestInternal(final HttpUriRequest request, final boolean requiredAuth) { try { HttpResponse response = requestHttpResponse(request); if (response == null) { return null; } switch (response.getStatusLine().getStatusCode()) { case HttpStatus.SC_OK: String msg = EntityUtils.toString(response.getEntity(), "UTF-8"); try { return new JSONObject(msg); } catch (JSONException e) { Assert.fail("JSON Format error: " + msg); } break; case HttpStatus.SC_NOT_FOUND: Assert.fail("Not found page. 404 "); break; default: Assert.fail("Connection Error. " + response.getStatusLine().getStatusCode() + " : " + response.getStatusLine().getReasonPhrase()); break; } } catch (IOException e) { Assert.fail("IOException: " + e.getMessage()); } return null; }
From source file:BQJDBC.QueryResultTest.QueryResultTest.java
@Test public void QueryResultTest08() { final String sql = "SELECT corpus, MAX(word_count) as m, word FROM publicdata:samples.shakespeare GROUP BY corpus,word ORDER BY m DESC LIMIT 5;"; final String description = "A query which gets those Shakespeare with the most common word ordered by count descending (only 5 is displayed)"; String[][] expectation = new String[][] { { "hamlet", "coriolanus", "kinghenryv", "2kinghenryiv", "kingrichardiii" }, { "995", "942", "937", "894", "848" }, { "the", "the", "the", "the", "the" } }; this.logger.info("Test number: 08"); this.logger.info("Running query:" + sql); java.sql.ResultSet Result = null; try {//ww w.j a va2s . c o m Result = QueryResultTest.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()); } }
From source file:eu.stratosphere.pact.runtime.task.MatchTaskTest.java
@Test public void testSortFirstMatchTask() { int keyCnt1 = 20; int valCnt1 = 20; int keyCnt2 = 20; int valCnt2 = 20; super.initEnvironment(5 * 1024 * 1024); super.addInput(new UniformPactRecordGenerator(keyCnt1, valCnt1, false), 1); super.addInput(new UniformPactRecordGenerator(keyCnt2, valCnt2, true), 2); super.addOutput(this.outList); MatchTask<PactRecord, PactRecord, PactRecord> testTask = new MatchTask<PactRecord, PactRecord, PactRecord>(); super.getTaskConfig().setLocalStrategy(LocalStrategy.SORT_FIRST_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, MockMatchStub.class); try {/*from w w w . ja va 2 s . c o m*/ testTask.invoke(); } catch (Exception e) { LOG.debug(e); e.printStackTrace(); 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.mnxfst.testing.server.cfg.TestPTestServerConfigurationParser.java
@Test public void testParserServeConfigurationWithArrayHavingAnXMLDocMissingHostname() { try {//from ww w . j a v a2 s.c o m byte[] test = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ptest-server/>".getBytes(); new PTestServerConfigurationParser().parseServerConfiguration(test); Assert.fail("Invalid file contents"); } catch (ServerConfigurationFailedException e) { // } }
From source file:org.jasig.schedassist.model.VisibleScheduleBuilderTest.java
/** * Create an advising schedule for Aug 4 2008. * Create a calendar with an appointment on Aug 4 2008. * Send the two into FreeBusyBuilder, and assert correct conflicts found. * /*from w w w.j ava 2 s .c o m*/ * @throws Exception */ @Test public void testOneAppointmentConflictsTwoBlocks() throws Exception { MockCalendarAccount person = new MockCalendarAccount(); person.setEmailAddress("someowner@wisc.edu"); person.setDisplayName("Some Owner"); MockScheduleOwner owner = new MockScheduleOwner(person, 1); AvailableBlock block = AvailableBlockBuilder.createBlock(makeDateTime("20091109-0930"), makeDateTime("20091109-1230")); Set<AvailableBlock> blocks = AvailableBlockBuilder.expand(block, 30); AvailableSchedule schedule = new AvailableSchedule(blocks); DateTime eventStart = new net.fortuna.ical4j.model.DateTime(makeDateTime("20091109-1030")); eventStart.setTimeZone(americaChicago); DateTime eventEnd = new net.fortuna.ical4j.model.DateTime(makeDateTime("20091109-1130")); eventEnd.setTimeZone(americaChicago); VEvent someEvent = new VEvent(eventStart, eventEnd, "some event"); ParameterList parameterList = new ParameterList(); parameterList.add(PartStat.ACCEPTED); parameterList.add(CuType.INDIVIDUAL); parameterList.add(Rsvp.FALSE); parameterList.add(new Cn(person.getDisplayName())); Attendee attendee = new Attendee(parameterList, "mailto:" + person.getEmailAddress()); someEvent.getProperties().add(attendee); ComponentList components = new ComponentList(); components.add(someEvent); VisibleSchedule calendar = builder.calculateVisibleSchedule(makeDateTime("20091109-0000"), makeDateTime("20091110-0000"), new Calendar(components), schedule, owner); Assert.assertEquals(6, calendar.getSize()); Assert.assertEquals(4, calendar.getFreeCount()); Assert.assertEquals(2, calendar.getBusyCount()); for (AvailableBlock busy : calendar.getBusyList()) { if (!busy.getStartTime().equals(makeDateTime("20091109-1030")) && !busy.getStartTime().equals(makeDateTime("20091109-1100"))) { Assert.fail("busyEvents contains unexpected block " + busy); } } }