List of usage examples for junit.framework Assert assertTrue
static public void assertTrue(boolean condition)
From source file:com.nomsic.randb.RandbTest.java
@Test public void testCreateBlockGroup() throws RandbException, FileNotFoundException, IOException { String name = "TEST"; manager.createBlockGroup(name, 2, Arrays.asList(new Integer[] { 2, 4 }), Arrays.asList(new String[] { "A", "B" })); String filename = provider.getIndexMap().get(name); File file = new File(TEST_DATA_FOLDER + File.separator + filename); Assert.assertTrue(file.exists()); String fileString = TestUtils.getFileAsString(file); Assert.assertTrue(fileString.contains(name)); }
From source file:org.atemsource.atem.impl.common.attribute.SingleAssociationAttributeTest.java
@Test public void testGetter() { EntityA entity = new EntityA(); final EntityB entityB = createEntity("Hallo", 2); entity.setEntityB(entityB);//from w ww. j a v a2 s . co m Attribute attribute = getAttribute(PROPERTY); Object value = attribute.getValue(entity); assertEquals(entity.getEntityB(), value); Assert.assertTrue(entity.getEntityB() == value); }
From source file:org.esigate.DriverCookieTest.java
/** * Ensure Secure attribute is kept is connection uses https. * // w w w. ja va2 s . c o m * @throws Exception */ public void testSecure() throws Exception { // Conf Properties properties = new Properties(); properties.put(Parameters.REMOTE_URL_BASE.getName(), "http://provider/"); // Setup remote server (provider) response. Driver driver = TestUtils.createMockDriver(properties, new IResponseHandler() { @Override public HttpResponse execute(HttpRequest request) throws IOException { return TestUtils.createHttpResponse().status(HttpStatus.SC_OK).reason("OK") .header("Set-Cookie", "testcookie=testvalue; Secure").entity("test").build(); } }); // Https request : Cookie is forwarded as Secure IncomingRequest request = TestUtils.createRequest("https://test.mydomain.fr/foobar/").build(); TestUtils.driverProxy(driver, request); Assert.assertTrue(((ClientCookie) request.getNewCookies()[0]).isSecure()); // Http request : Cookie is forwarded as NOT secure request = TestUtils.createRequest("http://test.mydomain.fr/foobar/").build(); TestUtils.driverProxy(driver, request); Assert.assertFalse(((ClientCookie) request.getNewCookies()[0]).isSecure()); }
From source file:es.tekniker.framework.ktek.questionnaire.mng.test.TestQuestionnaireMngServer.java
@org.junit.Test public void testGetKtekQuestionnaireModelByToken() { log.info("*************************************************************"); log.info("testGetKtekQuestionnaireModelByToken: START "); QuestionnaireMngServer manager = new QuestionnaireMngServer(); String result = TestDefines.RESULT_OK; Assert.assertTrue(true); int idquestionnaire = 1; int idlang = 1; String token = null;//w ww . j av a 2s. c o m KtekQuestionnaireModelEntity instance = null; String codtelecareprogram = "TBP1"; try { token = TestData.getLoginToken(); instance = manager.getQuestionnaireModelByToken(token, idlang, codtelecareprogram, idquestionnaire); if (instance != null) { log.info("testGetKtekQuestionnaireModelByToken: instance is not null"); Assert.assertTrue(true); } else { log.error("testGetKtekQuestionnaireModelByToken: instance is NULL "); result = TestDefines.RESULT_ERROR; Assert.assertTrue(false); } } catch (KtekExceptionEntity e) { log.error("testGetKtekQuestionnaireModelByToken: Exception " + e.getMessage()); e.printStackTrace(); result = TestDefines.RESULT_EXCEPTION; Assert.assertTrue(false); } log.info("testGetKtekQuestionnaireModelByToken: RESULT " + result); log.info("testGetKtekQuestionnaireModelByToken: END "); log.info("*************************************************************"); log.info(""); }
From source file:org.openmrs.module.sdmxhdintegration.SDMXHDMessageValidatorTest.java
@Test @Verifies(value = "should reject if name is empty", method = "validate(Object, Errors)") public void validate_shouldRejectIfNameEmpty() { SDMXHDMessage message = new SDMXHDMessage(); message.setName(null);/* w ww . java 2 s.c o m*/ message.setDescription("Description"); message.setZipFilename("dummy.zip"); Errors errors = new BindException(message, "message"); validator.validate(message, errors); Assert.assertTrue(errors.hasErrors()); }
From source file:com.github.neoio.net.message.staging.file.TestFileMessageStaging.java
@Test public void test_tempWrite() { ByteBuffer buffer = ByteBuffer.allocate(1024); buffer.put("Hello World".getBytes()); buffer.flip();//from w ww . j a v a 2 s.com staging.writeTempWriteBytes(buffer); Assert.assertTrue(staging.hasTempWriteBytes()); buffer.clear(); staging.readTempWriteBytes(buffer); Assert.assertEquals("Hello World", new String(ArrayUtils.subarray(buffer.array(), 0, "Hello World".getBytes().length))); staging.resetTempWriteBytes(); Assert.assertFalse(staging.hasTempWriteBytes()); }
From source file:com.nomsic.randb.persistence.xml.RandbXMLPersistenceProviderTest.java
@Test public void testInitExisting() throws RandbException, FileNotFoundException, IOException { String name = "testName"; provider.save(BlockGroup.generate(name, 2, Arrays.asList(new Integer[] { 2 }), Arrays.asList(new String[] { "A", "B" }))); File file = new File(TEST_DATA_FOLDER + File.separator + "index.xml"); Assert.assertTrue(file.exists()); String indexString = TestUtils.getFileAsString(file); Assert.assertTrue(indexString.contains(name)); provider = new RandbXMLPersistenceProvider(TEST_DATA_FOLDER); Index index = provider.getIndex();// w w w.j ava 2s. c om Assert.assertTrue(index.blockGroups.containsKey(name)); }
From source file:hu.ppke.itk.nlpg.purepos.model.internal.NGramModelTest.java
@Test public void testAgainstHunPos() { NGramModel<String> mymodel = new NGramModel<String>(3); // BOS[1] alma[4] krte[3] 1[2] EOS[0] // mymodel.addWord(Arrays.asList(2, 1), "EOS"); mymodel.addWord(Arrays.asList(3, 2), "1"); mymodel.addWord(Arrays.asList(4, 3), "krte"); mymodel.addWord(Arrays.asList(1, 4), "alma"); // System.out.println(mymodel.root.getReprString()); Assert.assertTrue(mymodel.root.hasChild(2)); Assert.assertTrue(mymodel.root.hasChild(4)); Assert.assertTrue(mymodel.root.hasChild(3)); Assert.assertTrue(mymodel.root.getChild(2).hasChild(3)); Assert.assertTrue(mymodel.root.getChild(4).hasChild(1)); Assert.assertTrue(mymodel.root.getChild(3).hasChild(4)); mymodel.calculateNGramLamdas();//from w ww .j a v a 2s . com Assert.assertEquals(Arrays.asList(0.0, 0.0, 0.0, 0.0), mymodel.lambdas); // + BOS[1], a[3], 1[2], EOS[1] mymodel.addWord(Arrays.asList(3, 2), "1"); mymodel.addWord(Arrays.asList(1, 3), "a"); mymodel.calculateNGramLamdas(); Assert.assertTrue(mymodel.root.hasChild(2)); Assert.assertTrue(mymodel.root.hasChild(4)); Assert.assertTrue(mymodel.root.hasChild(3)); Assert.assertTrue(mymodel.root.getChild(2).hasChild(3)); Assert.assertTrue(mymodel.root.getChild(4).hasChild(1)); Assert.assertTrue(mymodel.root.getChild(3).hasChild(4)); Assert.assertTrue(mymodel.root.getChild(3).hasChild(1)); Assert.assertEquals(Arrays.asList(0.0, 0.0, 0.0, 1.0), mymodel.lambdas); // logger.debug("\n" + mymodel.root.getReprString()); // logger.debug(mymodel.lambdas.toString()); }
From source file:org.ocpsoft.rewrite.servlet.config.EncodeQueryConfigurationTest.java
@Test public void testQueryEncodingExclusions() throws Exception { HttpAction<HttpGet> action = get("/encodequeryexcluding?foo=bar&keep=this"); Assert.assertEquals(210, action.getResponse().getStatusLine().getStatusCode()); Assert.assertTrue(action.getCurrentContextRelativeURL().contains("c=")); Assert.assertTrue(action.getCurrentContextRelativeURL().contains("keep=this")); }
From source file:ml.shifu.shifu.core.binning.EqualPopulationBinningTest.java
@Test public void testBinning() { Random rd = new Random(System.currentTimeMillis()); EqualPopulationBinning binning = new EqualPopulationBinning(10); long start = System.currentTimeMillis(); for (int i = 0; i < 100000; i++) { binning.addData(Integer.toString(rd.nextInt() % 1000)); }/*from w w w. j a v a 2s . c o m*/ long end = System.currentTimeMillis(); System.out.println("Spend " + (end - start) + " milli-seconds to create data."); System.out.println(binning.getDataBin()); String binStr = binning.objToString(); String[] fieldArr = binStr.split(Character.toString(AbstractBinning.FIELD_SEPARATOR)); Assert.assertTrue(fieldArr.length == 6); }