List of usage examples for junit.framework Assert assertNotSame
static public void assertNotSame(String message, Object expected, Object actual)
From source file:org.dataconservancy.dcs.util.ChecksumGeneratorVerifierTest.java
/** * Verify that we can generate a correct SHA1 checksum hex string for a file, and that if the file is modified the checksum changes *//*from w ww . j av a2 s.c o m*/ @Test public void testGenerateSHA1checksum() { String checksum = ChecksumGeneratorVerifier.generateSHA1checksum(file1); Assert.assertEquals(file1SHA1checksum, checksum); String modifiedChecksum = ChecksumGeneratorVerifier.generateSHA1checksum(modifiedFile1); Assert.assertNotSame("The modified file should not have the same checksum.", file1SHA1checksum, modifiedChecksum); }
From source file:org.outermedia.solrfusion.SolrFusionServletTest.java
@Test public void testConfigReload() throws ServletException, IOException, InterruptedException { TestSolrFusionServlet servlet = new TestSolrFusionServlet(); GregorianCalendar currentCal = new GregorianCalendar(2014, 6, 3, 12, 0, 0); long startTime = currentCal.getTimeInMillis(); servlet.currentTime = startTime;//w ww. j a v a2 s .c o m File tmpSchema = File.createTempFile("test-schema-", ".xml", new File("target/test-classes")); FileUtils.copyFile(new File("target/test-classes/test-fusion-schema.xml"), tmpSchema); FileUtils.touch(tmpSchema); servlet.loadSolrFusionConfig(tmpSchema.getName(), false); Configuration oldCfg = servlet.getCfg(); Assert.assertNotNull("Solr Fusion schema not loaded", oldCfg); // try to re-load immediately, which should be done after 5 minutes only log.info("----1"); servlet.loadSolrFusionConfig(tmpSchema.getName(), false); Assert.assertEquals("Solr Fusion schema re-loaded", oldCfg, servlet.getCfg()); // 6 minutes in the future, without schema modifications, nothing should happen currentCal.add(Calendar.MINUTE, 6); servlet.currentTime = currentCal.getTimeInMillis(); log.info("----2"); servlet.loadSolrFusionConfig(tmpSchema.getName(), false); Assert.assertEquals("Solr Fusion schema re-loaded", oldCfg, servlet.getCfg()); // 6 minutes in the future with schema modifications servlet.setSolrFusionSchemaLoadTime(startTime); // modified after loadSolrFusionConfig() call Thread.sleep(1001); // await new time FileUtils.touch(tmpSchema); log.info("----3"); servlet.loadSolrFusionConfig(tmpSchema.getName(), false); Assert.assertNotSame("Solr Fusion schema not re-loaded", oldCfg, servlet.getCfg()); oldCfg = servlet.getCfg(); // force re-load currentCal.add(Calendar.MINUTE, 1); servlet.currentTime = currentCal.getTimeInMillis(); log.info("----4"); servlet.loadSolrFusionConfig(tmpSchema.getName(), false); Assert.assertEquals("Solr Fusion schema re-loaded", oldCfg, servlet.getCfg()); log.info("----5"); servlet.loadSolrFusionConfig(tmpSchema.getName(), true); Assert.assertNotSame("Solr Fusion schema not re-loaded", oldCfg, servlet.getCfg()); }