List of usage examples for junit.framework Assert assertTrue
static public void assertTrue(boolean condition)
From source file:com.github.brandtg.switchboard.TestMysqlReplicationApplier.java
@Test public void testRestoreFromBinlog() throws Exception { MysqlReplicationApplier applier = null; try (Connection conn = DriverManager.getConnection(jdbc, "root", "")) { // Write some rows, so we have binlog entries PreparedStatement pstmt = conn.prepareStatement("INSERT INTO simple VALUES(?, ?)"); for (int i = 0; i < 10; i++) { pstmt.setInt(1, i);//from ww w.ja v a2s . co m pstmt.setInt(2, i); pstmt.execute(); } // Copy the binlog somewhere Statement stmt = conn.createStatement(); ResultSet rset = stmt.executeQuery("SHOW BINARY LOGS"); rset.next(); String binlogName = rset.getString("Log_name"); rset = stmt.executeQuery("SELECT @@datadir"); rset.next(); String dataDir = rset.getString("@@datadir"); File copyFile = new File(System.getProperty("java.io.tmpdir"), TestMysqlReplicationApplier.class.getName()); FileUtils.copyFile(new File(dataDir + binlogName), copyFile); // Clear everything in MySQL resetMysql(); // Get input stream, skipping and checking binlog magic number InputStream inputStream = new FileInputStream(copyFile); byte[] magic = new byte[MySQLConstants.BINLOG_MAGIC.length]; int bytesRead = inputStream.read(magic); Assert.assertEquals(bytesRead, MySQLConstants.BINLOG_MAGIC.length); Assert.assertTrue(CodecUtils.equals(magic, MySQLConstants.BINLOG_MAGIC)); // Restore from binlog PoolingDataSource<PoolableConnection> dataSource = getDataSource(); applier = new MysqlReplicationApplier(inputStream, dataSource); ExecutorService executorService = Executors.newSingleThreadExecutor(new ThreadFactory() { @Override public Thread newThread(Runnable r) { Thread t = new Thread(r); t.setDaemon(true); return t; } }); executorService.submit(applier); // Poll until we have restored long startTime = System.currentTimeMillis(); long currentTime = startTime; do { stmt = conn.createStatement(); rset = stmt.executeQuery("SELECT COUNT(*) FROM test.simple"); rset.next(); long count = rset.getLong(1); if (count == 10) { return; } Thread.sleep(1000); currentTime = System.currentTimeMillis(); } while (currentTime - startTime < 10000); } finally { if (applier != null) { applier.shutdown(); } } Assert.fail("Timed out when polling"); }
From source file:ejportal.webapp.action.SignupActionTest.java
/** * Test execute./*from w w w .j a v a2 s. c o m*/ * * @throws Exception * the exception */ public void testExecute() throws Exception { final User user = new User(); user.setUsername("self-registered"); user.setPassword("Password1"); user.setConfirmPassword("Password1"); user.setFirstName("First"); user.setLastName("Last"); final Address address = new Address(); address.setCity("Denver"); address.setProvince("CO"); address.setCountry("USA"); address.setPostalCode("80210"); user.setAddress(address); user.setEmail("self-registered@raibledesigns.com"); user.setWebsite("http://raibledesigns.com"); user.setPasswordHint("Password is one with you."); this.action.setUser(user); // set mock response so setting cookies doesn't fail ServletActionContext.setResponse(new MockHttpServletResponse()); // start SMTP Server final Wiser wiser = new Wiser(); wiser.setPort(this.getSmtpPort()); wiser.start(); Assert.assertEquals("success", this.action.save()); Assert.assertFalse(this.action.hasActionErrors()); // verify an account information e-mail was sent wiser.stop(); Assert.assertTrue(wiser.getMessages().size() == 1); // verify that success messages are in the session Assert.assertNotNull(this.action.getSession().getAttribute(Constants.REGISTERED)); SecurityContextHolder.getContext().setAuthentication(null); }
From source file:com.buddycloud.mediaserver.download.DownloadAvatarTest.java
@Test public void anonymousSuccessfulDownload() throws Exception { ClientResource client = new ClientResource(URL); client.setChallengeResponse(ChallengeScheme.HTTP_BASIC, BASE_USER, BASE_TOKEN); File file = new File(TEST_OUTPUT_DIR + File.separator + "downloadedAvatar.jpg"); FileOutputStream outputStream = FileUtils.openOutputStream(file); client.get().write(outputStream);/* w w w . j av a 2 s . c o m*/ Assert.assertTrue(file.exists()); // Delete downloaded file FileUtils.deleteDirectory(new File(TEST_OUTPUT_DIR)); outputStream.close(); }
From source file:org.ocpsoft.redoculous.tests.asciidoc.AsciidocIncludeTest.java
License:asdf
@Test public void testServeAsciidocWithInclude() throws Exception { WebTest test = new WebTest(baseUrl); String repositoryURL = "file://" + repository.getAbsolutePath(); HttpAction<HttpPost> action = test.post("/api/v1/manage?repo=" + repositoryURL); Assert.assertEquals(201, action.getResponse().getStatusLine().getStatusCode()); String location = URLDecoder.decode(action.getResponseHeaderValue("location"), "UTF8"); Assert.assertEquals(test.getBaseURL() + test.getContextPath() + "/api/v1/serve?repo=" + repositoryURL, location);//from w ww . j a va 2 s .c o m HttpAction<HttpGet> document = test.get("/api/v1/serve?repo=" + repositoryURL + "&ref=master&path=master"); Assert.assertTrue(document.getResponseContent().contains("PrettyFaces")); Assert.assertTrue(document.getResponseContent().contains(ASDF123)); }
From source file:org.geomajas.gwt2.client.map.layer.VectorLayerTest.java
@Test public void testMarkedAsVisible() { VectorServerLayerImpl layer = new VectorServerLayerImpl(mapConfig, layerInfo, viewPort, eventBus); Assert.assertTrue(layer.isMarkedAsVisible()); layer.setMarkedAsVisible(false);//from w w w .j a va 2 s . c o m Assert.assertFalse(layer.isMarkedAsVisible()); layer.setMarkedAsVisible(true); Assert.assertTrue(layer.isMarkedAsVisible()); }
From source file:com.cloudant.sync.datastore.BasicDBBodyTest.java
private void assertMapIsCorrect(Map<String, Object> actualMap) { Assert.assertEquals(5, actualMap.size()); Assert.assertTrue((Boolean) actualMap.get("Sunrise")); Assert.assertEquals("A run to the head of the blood", (String) actualMap.get("Data")); Assert.assertEquals(2, ((List) actualMap.get("Activities")).size()); }
From source file:com.sap.prd.mobile.ios.mios.FatBinaryTest.java
@Test public void testUsePreferredFatLib() throws Exception { final File testSourceDirApp = new File(getTestRootDirectory(), "straight-forward/MyApp"); final File alternateTestSourceDirApp = new File(getTestRootDirectory(), "straight-forward-fat-libs/MyApp"); final String testName = getTestName(); Map<String, String> additionalSystemProperties = new HashMap<String, String>(); additionalSystemProperties.put("xcode.preferFatLibs", Boolean.TRUE.toString()); Properties pomReplacements = new Properties(); pomReplacements.setProperty(PROP_NAME_DEPLOY_REPO_DIR, remoteRepoDir.getAbsolutePath()); pomReplacements.setProperty(PROP_NAME_DYNAMIC_VERSION, dynamicVersion); test(testName, testSourceDirApp, "install", THE_EMPTY_LIST, additionalSystemProperties, pomReplacements, new FileCopyProjectModifier(alternateTestSourceDirApp)); final File testRootDir = getTestExecutionDirectory(testName, "MyApp"); Assert.assertTrue(new File(testRootDir, "target/xcode-deps/libs/Release/com.sap.ondevice.production.ios.tests/MyLibrary/libMyLibrary.a") .exists());//from w w w . j a v a2s . c om Assert.assertFalse(new File(testRootDir, "target/libs/Release-iphoneos/com.sap.ondevice.production.ios.tests/MyLibrary/libMyLibrary.a") .exists()); Assert.assertFalse(new File(testRootDir, "target/libs/Release-iphonesimulator/com.sap.ondevice.production.ios.tests/MyLibrary/libMyLibrary.a") .exists()); }
From source file:org.jasig.ssp.util.importer.job.BatchPartialUploadTest.java
@SuppressWarnings("unchecked") @Test/*from w ww . j a v a 2 s . c om*/ public void testPartialUploadGuard() throws Exception { deleteDirectory(inputDirectoryPath); createFiles(inputDirectoryPath); Assert.assertTrue(directoryContainsFiles(inputDirectoryPath, 3, csvFilter)); JobExecution jobExecution = jobLauncherTestUtils.launchJob(); BatchStatus exitStatus = jobExecution.getStatus(); Map<String, ReportEntry> report = (Map<String, ReportEntry>) jobExecution.getExecutionContext() .get("report"); Assert.assertNull(report); Assert.assertEquals(BatchStatus.STOPPED, exitStatus); Assert.assertTrue(directoryExists(inputDirectoryPath)); Assert.assertTrue(directoryContainsFiles(inputDirectoryPath, 3, csvFilter)); }
From source file:org.ocpsoft.rewrite.prettyfaces.encoding.URLEncodingTest.java
@Test // http://code.google.com/p/prettyfaces/issues/detail?id=64 public void testPrettyFacesFormActionURLEncodesProperlyWithCustomRegexAndMultiplePathSegments() throws Exception { String expected = "/foo/bar/baz/car/"; HttpAction<HttpGet> action = get(expected); Assert.assertTrue(action.getCurrentURL().endsWith(expected)); Assert.assertTrue(action.getResponseContent().contains(expected)); Assert.assertTrue(action.getResponseContent().contains("beanPathText=foo/bar/baz/car")); }
From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.ConceptNameControllerTest.java
@Test public void shouldListNamesForAConcept() throws Exception { SimpleObject results = controller.getAll(conceptUuid2, request, response); List<Object> resultsList = (List<Object>) PropertyUtils.getProperty(results, "results"); Assert.assertNotNull(results);//from ww w. j a v a 2 s .co m Assert.assertEquals(3, resultsList.size()); List<Object> names = Arrays.asList(PropertyUtils.getProperty(resultsList.get(0), "name"), PropertyUtils.getProperty(resultsList.get(1), "name"), PropertyUtils.getProperty(resultsList.get(2), "name")); Assert.assertTrue(names.contains("CD4 COUNT")); Assert.assertTrue(names.contains("CD4")); Assert.assertTrue(names.contains("CD3+CD4+ABS CNT")); }