List of usage examples for junit.framework Assert assertTrue
static public void assertTrue(boolean condition)
From source file:com.nomsic.randb.persistence.xml.JaxbIndexTest.java
@Test public void testIndex() throws RandbException, FileNotFoundException, IOException { File file = new File(TARGET_TEST_DATA_INDEX_XML); Index index = new Index(); String key = "name"; String value = "filename"; index.addBlockGroup(key, value);/* w w w . j a v a 2s . c o m*/ jaxbUtil.write(index, file); Assert.assertTrue(file.exists()); String indexString = IOUtils.toString(new FileReader(file)); Assert.assertTrue(indexString.contains(key)); Assert.assertTrue(indexString.contains(value)); }
From source file:org.openmrs.web.controller.maintenance.SystemInformationControllerTest.java
/** * @see SystemInformationController#showPage(ModelMap) *//*from w w w .j a va2s.c o m*/ @Test @Verifies(value = "should add module information attribute to the model map", method = "showPage()") public void showPage_shouldReturnAllJavaRuntimeInformation() { Assert.assertTrue(((Map<String, Map<String, String>>) model.get("systemInfo")) .containsKey("SystemInfo.title.moduleInformation")); }
From source file:org.jasig.ssp.util.importer.job.BatchFinalizerTest.java
@SuppressWarnings("unchecked") @Test/*w w w . j a v a 2 s . c o m*/ public void testFinalizer() throws Exception { deleteDirectory(processDirectoryPath); deleteDirectory(upsertDirectoryPath); deleteDirectory(inputDirectoryPath); createFiles(inputDirectoryPath); createFiles(upsertDirectoryPath); createFiles(processDirectoryPath); Assert.assertTrue(directoryContainsFiles(inputDirectoryPath, 3, csvFilter)); Assert.assertTrue(directoryContainsFiles(upsertDirectoryPath, 3, csvFilter)); Assert.assertTrue(directoryContainsFiles(processDirectoryPath, 3, csvFilter)); BatchStatus exitStatus = jobLauncherTestUtils.launchJob().getStatus(); Assert.assertTrue(directoryExists(processDirectoryPath)); Assert.assertTrue(directoryExists(upsertDirectoryPath)); Assert.assertTrue(directoryExists(inputDirectoryPath)); Assert.assertTrue(directoryExists(archiveDirectoryPath)); Assert.assertTrue(directoryContainsFiles(processDirectoryPath, 0, csvFilter)); Assert.assertTrue(directoryContainsFiles(upsertDirectoryPath, 0, csvFilter)); Assert.assertTrue(directoryContainsFiles(inputDirectoryPath, 0, csvFilter)); Assert.assertTrue(directoryContainsFiles(archiveDirectoryPath, 1, zipFilter)); Assert.assertEquals(BatchStatus.COMPLETED, exitStatus); }
From source file:es.tekniker.framework.ktek.commons.mng.db.test.TestCommonsManagerDB.java
@org.junit.Test public void testGetLanguages() { log.info("*************************************************************"); log.info("testGetLanguages: START "); Ktek_language[] array = null;/* w w w . j av a 2 s . c o m*/ CommonsManagerDB db = new CommonsManagerDB(); String result = TestDefines.RESULT_OK; array = db.getLanguages(); if (array != null) { log.info("testGetLanguages: Languages " + array.length); Assert.assertTrue(true); } else { log.error("testGetLanguages: Array Languages is NULL "); Assert.assertTrue(false); result = TestDefines.RESULT_ERROR; } log.info("testGetLanguages: RESULT " + result); log.info("testGetLanguages: END "); log.info("*************************************************************"); log.info(""); }
From source file:de.hybris.platform.virtualjdbc.jalo.AbstractVjdbcSqlTest.java
protected void selectTest(final Connection vjdbcCon) throws Exception { final String tablePrefix = Registry.getCurrentTenant().equals(Registry.getMasterTenant()) ? "" : Registry.getCurrentTenant().getTenantID() + "_"; String realQuery = String.format(QUERY_FIND_PRODUCTS, StringUtils.isEmpty(tablePrefix) ? "" : tablePrefix); realQuery = realQuery + CONDITION;// w w w . j ava 2 s. co m Statement stmt = null; ResultSet res = null; try { verifyUnderlyingConnection(vjdbcCon); stmt = vjdbcCon.createStatement(); LOG.info("Underlying data base url:: " + vjdbcCon.getMetaData().getURL()); LOG.info("Executing query:: " + realQuery); res = stmt.executeQuery(realQuery);//stmt.getResultSet(); int idx = 0; if (res != null) { while (res.next()) { ++idx; if (LOG.isDebugEnabled()) { LOG.debug("result[" + (idx) + "]:" + res.getString(1)); } Assert.assertTrue(res.getString(1).startsWith(PRODUCT_PREFIX)); } } Assert.assertTrue("Should get " + PRODUCT_COUNT + " instead of " + idx, idx == PRODUCT_COUNT); } finally { Utilities.tryToCloseJDBC(vjdbcCon, stmt, res); } }
From source file:it.geosolutions.geobatch.testsuite.EventGeneratorTestCase.java
@Test public void testFileBasedEventGeneratorService() throws IOException, InterruptedException { // ////from w w w . j a va 2 s . c o m // // get the FileBasedEventGeneratorService bean service from the context // // // Object o = context.getBean("fsEventGeneratorService", FileBasedEventGeneratorService.class); Assert.assertNotNull(o); Assert.assertTrue(o instanceof FileBasedEventGeneratorService); final FileBasedEventGeneratorService service = (FileBasedEventGeneratorService) o; // // // // Create a fictitious configuration // // // // final FileBasedEventGeneratorConfiguration configuration = new FileBasedEventGeneratorConfiguration(); // configuration.setId("id"); // configuration.setName("name"); // configuration.setDescription("description"); // configuration.setOsType(OsType.OS_UNDEFINED); // configuration.setWorkingDirectory(TestData.file(this, ".").getAbsolutePath()); // // // // Check if we can create the needed EventGenerator and if so create it // // // // final boolean result = service.canCreateEventGenerator(configuration); // Assert.assertTrue(result); // // // create the event generator // final FileBasedEventGenerator eg = service.createEventGenerator(configuration); // start to listen on it and then create it // eg.addListener(this); // eg.start(); Thread.sleep(5000); // final File file = TestData.temp(this, "test"); if (file.exists()) { synchronized (this) { this.wait(5000); } Assert.assertTrue("unable to create test", this.caughtEvent); } else { Assert.assertTrue("unable to create test", false); } }
From source file:org.jasig.ssp.util.importer.job.BatchInitializerHeaderFailTest.java
@Test public void testHeaderFailTest() throws Exception { deleteDirectory(processDirectoryPath); deleteDirectory(upsertDirectoryPath); Assert.assertTrue(!directoryExists(processDirectoryPath)); Assert.assertTrue(!directoryExists(upsertDirectoryPath)); JobExecution jobExecution = jobLauncherTestUtils.launchJob(); Assert.assertEquals(BatchStatus.FAILED, jobExecution.getStatus()); @SuppressWarnings("unchecked") Map<String, ReportEntry> report = (Map<String, ReportEntry>) jobExecution.getExecutionContext() .get("report"); Assert.assertNull(report);//from ww w. ja v a 2 s. c om @SuppressWarnings("unchecked") List<ErrorEntry> errors = (List<ErrorEntry>) jobExecution.getExecutionContext().get("errors"); Assert.assertNull(errors); List<Throwable> failureExceptions = jobExecution.getAllFailureExceptions(); Assert.assertEquals(new Integer(1), new Integer(failureExceptions.size())); Assert.assertEquals(PartialUploadGuardException.class, failureExceptions.get(0).getClass()); }
From source file:com.googlecode.t7mp.steps.CopySetenvScripStepTest.java
@Test public void testCopySetenvScriptStep() { String setenvScriptPath = getClass().getResource("/com/googlecode/t7mp/bin/setenv.sh").getPath(); File t7mpDirectory = new File(setenvScriptPath).getParentFile().getParentFile(); File confDirectory = new File(t7mpDirectory, "/conf/"); Assert.assertNotNull(confDirectory); Assert.assertTrue(confDirectory.exists()); Mockito.when(configuration.getTomcatConfigDirectory()).thenReturn(new File(t7mpDirectory, "/conf/")); Context context = new DefaultContext(new ChainedArtifactResolver(), configuration); Step step = new CopySetenvScriptStep(); step.execute(context);/*from w w w. j av a2 s .co m*/ File binDirectory = new File(catalinaBaseDir, "/bin/"); Assert.assertNotNull(binDirectory); Assert.assertTrue(binDirectory.exists()); File copyiedSetenvScript = new File(binDirectory, "setenv.sh"); Assert.assertNotNull(copyiedSetenvScript); Assert.assertTrue(copyiedSetenvScript.exists()); }
From source file:com.hybris.datahub.service.impl.DefaultJsonServiceTest.java
/** * convertTmallAuthJson/*from w w w. j ava2 s.c o m*/ */ @Test public void convertTmallAuthJson() { final Class<? extends DefaultJsonServiceTest> instance = getClass(); if (instance != null) { final ClassLoader classLoader = instance.getClassLoader(); if (classLoader != null) { String json = ""; InputStream resourceAsStream = null; try { resourceAsStream = classLoader.getResourceAsStream(SAMPLE_TMALL_AUTH_JSON); json = IOUtils.toString(resourceAsStream); } catch (final IOException e) { LOG.error(e.getMessage(), e); } finally { if (resourceAsStream != null) { try { resourceAsStream.close(); } catch (final IOException e) { LOG.error(e.getMessage(), e); } } } final List<Map<String, String>> csv = service.parse(json); final Map<String, String> raw = csv.get(0); Assert.assertTrue(raw.containsKey("marketplaceStoreName")); Assert.assertTrue(raw.containsKey("integrationId")); Assert.assertTrue(raw.containsKey("authorized")); Assert.assertEquals("TmallStore", raw.get("marketplaceStoreName")); Assert.assertEquals("1234567890", raw.get("integrationId")); Assert.assertEquals("true", raw.get("authorized")); } } else { Assert.fail("Class not found."); } }
From source file:com.googlecode.t7mp.steps.resources.ConfigFilesSequenceTest.java
@Test public void testConfigFilesSequence() throws IOException { Mockito.when(mojo.getCatalinaBase()).thenReturn(catalinaBaseDir); Mockito.when(mojo.getLog()).thenReturn(log); Mockito.when(mojo.getTomcatShutdownCommand()).thenReturn("SHUTDOWN"); Context context = new DefaultContext(mojo); ConfigFilesSequence sequence = new ConfigFilesSequence(); sequence.execute(context);//from ww w .j a v a 2 s. co m File catalinaProperties = new File(confDirectory, "catalina.properties"); Assert.assertTrue(catalinaProperties.exists()); System.out.println(new String(getBytesFromFile(catalinaProperties))); }