Example usage for junit.framework Assert assertTrue

List of usage examples for junit.framework Assert assertTrue

Introduction

In this page you can find the example usage for junit.framework Assert assertTrue.

Prototype

static public void assertTrue(boolean condition) 

Source Link

Document

Asserts that a condition is true.

Usage

From source file:de.itsvs.cwtrpc.controller.config.RemoteServiceControllerConfigBeanDefinitionParserTest.java

@Test
public void test2() {
    RemoteServiceControllerConfig config;

    config = appContext.getBean("serviceController101", RemoteServiceControllerConfig.class);
    Assert.assertEquals(1, config.getServiceModuleConfigs().size());
    Assert.assertEquals("myModule701", config.getServiceModuleConfigs().iterator().next().getName());
    Assert.assertTrue(config.getResponseCompressionEnabled());
    Assert.assertFalse(config.getRpcTokenProtectionEnabled());
    Assert.assertEquals("rpcTokenService", config.getRpcTokenValidatorName());
    Assert.assertSame(appContext.getBean("serializationPolicyProvider"),
            config.getSerializationPolicyProvider());
}

From source file:com.sinosoft.one.showcase.rule.test.RuleServiceTest.java

@Test
public void testQuickPriceService() {
    CarInfoInputBOM qpib = new CarInfoInputBOM();
    qpib.setAreaCode("370000");
    qpib.setVehicleAge(1);/*from   ww w.j av  a2 s  .  c  o  m*/
    qpib.setReplacementValue(20000.00);
    QuickPriceInputGlobal global = new QuickPriceInputGlobal();
    double totalPremium = 0.00;
    try {
        System.out.println("=========begin QuickPriceRule");
        quickPriceRuleService.executeRuleWithGlobal("quickPriceRuleFlow", global, qpib);
        // quickPriceRuleService.executeRule( qpib);
        System.out.println("=========end QuickPriceRule");

        Iterator iter = global.getKinds().entrySet().iterator();
        while (iter.hasNext()) {
            Map.Entry entry = (Map.Entry) iter.next();
            String kindcode = (String) entry.getKey();
            KindBOM kind = (KindBOM) entry.getValue();
            System.out.println(kindcode + " name=" + kind.getKindName());
            System.out.print(kindcode + "amount=" + kind.getAmount());
            System.out.print(kindcode + "premium=" + kind.getPremium());
            double premium = new BigDecimal(kind.getPremium() * global.getDiscount())
                    .setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
            System.out.println(kindcode + "discount premium=" + premium);
            totalPremium += premium;
        }
        System.out.println(" totalPremium  " + totalPremium);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    Assert.assertTrue(totalPremium > 0.0);
}

From source file:org.ocpsoft.rewrite.prettyfaces.encoding.URLEncodingTest.java

@Test
public void testPrettyFacesFormActionURLEncodesProperly() throws Exception {
    String expected = "/custom/form";

    HttpAction<HttpGet> action = get(expected);

    Assert.assertTrue(action.getCurrentURL().endsWith(expected));
    Assert.assertTrue(action.getResponseContent().contains(expected));
}

From source file:com.cloudant.sync.datastore.BasicDBBodyTest.java

@Test
public void asMap_differentNumberTypes_jacksonPicksNaturalMapping() throws IOException {
    byte[] d = FileUtils.readFileToByteArray(new File("fixture/basic_bdbody_test_as_map.json"));
    DocumentBody body = new BasicDocumentBody(d);
    Assert.assertEquals("-101", body.asMap().get("StringValue"));

    Map<String, Object> m = body.asMap();

    Assert.assertTrue(m.get("LongValue") instanceof Long);
    Assert.assertTrue(m.get("LongValue").equals(2147483648l)); // Integer.MAX_VALUE + 1

    Assert.assertTrue(m.get("IntegerValue") instanceof Integer);
    Assert.assertTrue(m.get("IntegerValue").equals(2147483647)); // Integer.MAX_VALUE
}

From source file:com.couchbase.lite.DocumentTest.java

/**
 * https://github.com/couchbase/couchbase-lite-android/issues/301
 *//*from ww w  .  j a v  a2s . c  o  m*/
public void testPutDeletedDocument() throws CouchbaseLiteException {

    Document document = database.createDocument();
    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put("foo", "foo");
    properties.put("bar", Boolean.FALSE);
    document.putProperties(properties);
    Assert.assertNotNull(document.getCurrentRevision());
    String docId = document.getId();

    properties.put("_rev", document.getCurrentRevisionId());
    properties.put("_deleted", true);
    properties.put("mykey", "myval");
    SavedRevision newRev = document.putProperties(properties);
    newRev.loadProperties();
    assertTrue(newRev.getProperties().containsKey("mykey"));

    Assert.assertTrue(document.isDeleted());
    Document fetchedDoc = database.getExistingDocument(docId);
    Assert.assertNull(fetchedDoc);

    // query all docs and make sure we don't see that document
    database.getAllDocs(new QueryOptions());
    Query queryAllDocs = database.createAllDocumentsQuery();
    QueryEnumerator queryEnumerator = queryAllDocs.run();
    for (Iterator<QueryRow> it = queryEnumerator; it.hasNext();) {
        QueryRow row = it.next();
        Assert.assertFalse(row.getDocument().getId().equals(docId));
    }
}

From source file:com.nominanuda.springsoy.SoySourceTest.java

@Test
public void testJs() throws Exception {
    SoyJsTemplateServer soyJsTemplateServer = new SoyJsTemplateServer();
    soyJsTemplateServer.setSoySource(soySource);
    HttpRequest req = new HttpGet("/somepath/foo.soy.js?lang=en");
    DataObjectURISpec spec = new DataObjectURISpec("/somepath/{tpl **.soy.js}?{lang en|it}");
    DataObject cmd = spec.match(req.getRequestLine().getUri());
    CommandRequestHandlerAdapter adapter = new CommandRequestHandlerAdapter();
    StringEntity se = (StringEntity) adapter.invoke(soyJsTemplateServer, req, cmd);
    String jsFile = new IOHelper().readAndClose(se.getContent(), HttpProtocol.CS_UTF_8);
    Assert.assertTrue(jsFile.contains("examples.simple.helloWorld2 = function"));
    Assert.assertEquals(HttpProtocol.CT_TEXT_JAVASCRIPT_CS_UTF8, se.getContentType().getValue());
}

From source file:at.tfr.securefs.process.ProcessFilesTest.java

@Test
public void testCopyFile() throws Exception {

    // Given: the target directory, the source file
    toFilesPath = Files.createDirectories(toRoot.resolve(DATA_FILES));
    final String data = "Hallo Echo";
    try (OutputStream os = cp.getEncrypter(fromFile)) {
        IOUtils.write(data, os);//from w  ww.  ja v a2s.  c o m
    }

    ProcessFilesData cfd = new ProcessFilesData().setFromRootPath(fromRoot.toString())
            .setToRootPath(toRoot.toString()).setUpdate(false).setProcessActive(true);

    // When: copy of source file to toRoot
    ProcessFilesBean pf = new ProcessFilesBean(new MockSecureFsCache());
    pf.copy(fromFile, fromRoot.getNameCount(), toRoot, cp, newSecret, cfd);

    // Then: a target file is created in same subpath like sourceFile:
    Assert.assertTrue(Files.exists(targetToFile));

    // Then: the content of target file is decryptable with newSecret 
    //    and equals content of source file
    byte[] buf = new byte[data.getBytes().length];
    try (InputStream is = cp.getDecrypter(targetToFile, newSecret)) {
        IOUtils.read(is, buf);
    }
    Assert.assertEquals("failed to decrypt data", data, String.valueOf(data));
}

From source file:com.jgoetsch.eventtrader.test.ProfidingMsgParserTest.java

@SuppressWarnings("rawtypes")
public void testCommentary() throws Exception {
    msgParser.parseData("commentary", (Map) JSONValue.parse(
            "{\"newsletter\":3,\"date\":1344264740426,\"username\":\"timothysykes\",\"image\":\"http://a1.twimg.com/profile_images/1166026278/TimCover1_normal.jpg\",\"msg\":\"Message boards were speculating early in the year about their ability to manufacture iPad tablet screens, I'm gonna listen to conference call now and see if they confirmed it, then this could REALLY run, otherwise probly just gonna sell for a small gain \",\"msgId\":27889}"),
            new MsgHandler() {
                public boolean newMsg(Msg msg) {
                    Assert.assertEquals(Msg.class, msg.getClass());
                    Assert.assertEquals("timothysykes", msg.getSourceName());
                    Assert.assertEquals("http://a1.twimg.com/profile_images/1166026278/TimCover1_normal.jpg",
                            msg.getImageUrl());
                    Assert.assertEquals(1344264740426L, msg.getDate().toDate().getTime());
                    return false;
                }/*from w w  w  .  jav a 2s  .c  om*/
            });

    // a classic one for sure
    msgParser.parseData("commentary", (Map) JSONValue.parse(
            "{\"newsletter\":3,\"date\":1344347965675,\"username\":\"timothysykes\",\"image\":\"http://a1.twimg.com/profile_images/1166026278/TimCover1_normal.jpg\",\"msg\":\"I'm pissed at your laziness and pissed at myself for not following through on my CRMB buy idea int he 2.80s, now 3.50+, what a waste we all are\",\"msgId\":28006}"),
            new MsgHandler() {
                public boolean newMsg(Msg msg) {
                    Assert.assertEquals(Msg.class, msg.getClass());
                    Assert.assertEquals("timothysykes", msg.getSourceName());
                    Assert.assertEquals(1344347965675L, msg.getDate().toDate().getTime());
                    Assert.assertTrue(
                            msg.getMessage().startsWith("I'm pissed at your laziness and pissed at myself"));
                    return false;
                }
            });
}

From source file:de.hybris.platform.b2b.services.impl.B2BCostCenterServiceTest.java

@Test
public void testFindCostCentersAndBudgets() throws Exception {
    final String userId = "GC CEO";
    final B2BCustomerModel customer = login(userId);
    LOG.debug("Customer : " + customer.getUid());
    final B2BCostCenterModel costCenter = (B2BCostCenterModel) b2bCostCenterService
            .getCostCenterForCode("GC 2.4");

    Assert.assertNotNull(costCenter);/*from w  ww. j a  va2 s .  c  o  m*/
    final Set<B2BBudgetModel> budgetSet = costCenter.getBudgets();
    Assert.assertTrue(CollectionUtils.isNotEmpty(budgetSet));
}