Example usage for junit.framework Assert assertFalse

List of usage examples for junit.framework Assert assertFalse

Introduction

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

Prototype

static public void assertFalse(boolean condition) 

Source Link

Document

Asserts that a condition is false.

Usage

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

@Test
public void testValidateFilesByWalkFileHierarchy() throws Exception {

    // Given: NO target directory yet!!, the source file
    generateFileHierarchy(fromRoot, 0, MAX_DIR_DEPTH, cp, secret);
    Assert.assertFalse(Files.exists(toRoot.resolve(DATA_FILES)));
    Assert.assertFalse(Files.exists(targetToFile));
    ProcessFiles pf = new ProcessFilesBean(new MockSecureFsCache());
    ProcessFilesData cfd = new ProcessFilesData();

    // Then we can generate a full hierarchy copy
    generateHierachyCopy(pf, cfd);/*  w  w w .j  a  va2 s  . c o m*/

    // Then both hierarchies may be validated:
    pf.verify(fromRoot, cp, secret, cfd);
    Assert.assertTrue("verification failed", cfd.getErrors().isEmpty());
    pf.verify(toRoot, cp, newSecret, cfd);
    Assert.assertTrue("verification failed", cfd.getErrors().isEmpty());
}

From source file:org.wso2.carbon.apimgt.handlers.AuthenticationHandlerTest.java

@Test(description = "Handle request with device type URI with Encoded Pem with invalid response", dependsOnMethods = "testHandleSuccessRequestEncodedPem")
public void testHandleSuccessRequestEncodedPemInvalidResponse() throws Exception {
    HashMap<String, String> transportHeaders = new HashMap<>();
    transportHeaders.put(AuthConstants.ENCODED_PEM, "encoded pem");
    setMockClient();/*from w  ww .  jav  a  2s  .  c o  m*/
    this.mockClient.setResponse(getAccessTokenReponse());
    this.mockClient.setResponse(getInvalidResponse());
    MessageContext messageContext = createSynapseMessageContext("<empty/>", this.synapseConfiguration,
            transportHeaders, "https://test.com/testservice/api/testdevice");
    boolean response = this.handler.handleRequest(messageContext);
    Assert.assertFalse(response);
    this.mockClient.reset();
}

From source file:com.impetus.kundera.rest.resources.MongoQueryTest.java

@Test
public void testCompositeUserCRUD() throws JsonParseException, JsonMappingException, IOException {
    WebResource webResource = resource();
    restClient = new RESTClientImpl();
    restClient.initialize(webResource, mediaType);

    // Get Application Token
    applicationToken = restClient.getApplicationToken(_PU, null);
    Assert.assertNotNull(applicationToken);
    applicationToken = applicationToken.replaceAll("^\"|\"$", "");
    Assert.assertTrue(applicationToken.startsWith("AT_"));

    // Get Session Token
    sessionToken = restClient.getSessionToken(applicationToken);
    Assert.assertNotNull(sessionToken);//ww w .  jav a2 s . c o  m
    sessionToken = sessionToken.replaceAll("^\"|\"$", "");
    Assert.assertTrue(sessionToken.startsWith("ST_"));

    UUID timeLineId = UUID.randomUUID();
    Date currentDate = new Date();
    MongoCompoundKey key = new MongoCompoundKey("mevivs", 1, timeLineId);

    MongoPrimeUser timeLine = new MongoPrimeUser(key);
    timeLine.setKey(key);
    timeLine.setTweetBody("my first tweet");
    timeLine.setTweetDate(currentDate);

    MongoCompoundKey key1 = new MongoCompoundKey("john", 2, timeLineId);

    MongoPrimeUser timeLine2 = new MongoPrimeUser(key1);
    timeLine2.setKey(key1);
    timeLine2.setTweetBody("my second tweet");
    timeLine2.setTweetDate(currentDate);

    String mongoUser = JAXBUtils.toString(timeLine, MediaType.APPLICATION_JSON);
    Assert.assertNotNull(mongoUser);

    String mongoUser1 = JAXBUtils.toString(timeLine2, MediaType.APPLICATION_JSON);
    Assert.assertNotNull(mongoUser1);

    // Insert Record
    String insertResponse1 = restClient.insertEntity(sessionToken, mongoUser, "MongoPrimeUser");
    String insertResponse2 = restClient.insertEntity(sessionToken, mongoUser1, "MongoPrimeUser");

    Assert.assertNotNull(insertResponse1);
    Assert.assertNotNull(insertResponse2);

    Assert.assertTrue(insertResponse1.indexOf("200") > 0);
    Assert.assertTrue(insertResponse2.indexOf("200") > 0);
    String encodepk1 = null;
    pk1 = JAXBUtils.toString(key, MediaType.APPLICATION_JSON);
    pk2 = JAXBUtils.toString(key1, MediaType.APPLICATION_JSON);
    try {
        encodepk1 = java.net.URLEncoder.encode(pk1, "UTF-8");
    } catch (UnsupportedEncodingException e) {
        log.error(e.getMessage());
    }
    // Find Record
    String foundUser = restClient.findEntity(sessionToken, encodepk1, "MongoPrimeUser");
    Assert.assertNotNull(foundUser);

    Assert.assertNotNull(foundUser);
    Assert.assertTrue(foundUser.indexOf("mevivs") > 0);

    foundUser = foundUser.substring(1, foundUser.length() - 1);
    Map<String, Object> userDetails = new HashMap<String, Object>();
    ObjectMapper mapper = new ObjectMapper();
    userDetails = mapper.readValue(foundUser, userDetails.getClass());
    foundUser = mapper.writeValueAsString(userDetails.get("mongoprimeuser"));

    // Update Record
    foundUser = foundUser.replaceAll("first", "hundreth");

    String updatedUser = restClient.updateEntity(sessionToken, foundUser, MongoPrimeUser.class.getSimpleName());

    Assert.assertNotNull(updatedUser);
    Assert.assertTrue(updatedUser.indexOf("hundreth") > 0);

    /** JPA Query - Select */
    // Get All users
    String jpaQuery = "select p from " + MongoPrimeUser.class.getSimpleName() + " p";
    String queryResult = restClient.runJPAQuery(sessionToken, jpaQuery, new HashMap<String, Object>());
    log.debug("Query Result:" + queryResult);

    Assert.assertNotNull(queryResult);
    Assert.assertFalse(StringUtils.isEmpty(queryResult));

    Assert.assertTrue(queryResult.indexOf("mongoprimeuser") > 0);
    Assert.assertTrue(queryResult.indexOf(pk1) > 0);
    Assert.assertTrue(queryResult.indexOf(pk2) > 0);

    Assert.assertTrue(queryResult.indexOf("Motif") < 0);

    jpaQuery = "select p from " + MongoPrimeUser.class.getSimpleName() + " p WHERE p.key = :key";
    Map<String, Object> params = new HashMap<String, Object>();

    params.put("key", pk1);

    queryResult = restClient.runObjectJPAQuery(sessionToken, jpaQuery, params);
    log.debug("Query Result:" + queryResult);

    Assert.assertNotNull(queryResult);
    Assert.assertFalse(StringUtils.isEmpty(queryResult));
    Assert.assertTrue(queryResult.indexOf("mongoprimeuser") > 0);
    Assert.assertTrue(queryResult.indexOf(timeLineId.toString()) > 0);
    Assert.assertTrue(queryResult.indexOf(pk2) < 0);

    Assert.assertTrue(queryResult.indexOf("Motif") < 0);

    jpaQuery = "select p from " + MongoPrimeUser.class.getSimpleName() + " p";
    params = new HashMap<String, Object>();
    params.put("firstResult", 0);
    params.put("maxResult", 1);

    queryResult = restClient.runObjectJPAQuery(sessionToken, jpaQuery, params);

    log.debug("Query Result:" + queryResult);

    String userList = queryResult.substring(1, queryResult.length() - 1);

    mapper = new ObjectMapper();
    userDetails = new HashMap<String, Object>();
    userDetails = mapper.readValue(userList, userDetails.getClass());
    userList = mapper.writeValueAsString(userDetails.get("mongoprimeuser"));

    List<MongoPrimeUser> navigation = mapper.readValue(userList,
            mapper.getTypeFactory().constructCollectionType(List.class, MongoPrimeUser.class));

    Assert.assertNotNull(queryResult);
    Assert.assertFalse(StringUtils.isEmpty(queryResult));
    Assert.assertTrue(queryResult.indexOf("mongoprimeuser") > 0);
    Assert.assertTrue(queryResult.indexOf(timeLineId.toString()) > 0);
    Assert.assertEquals(1, navigation.size());

    /** JPA Query - Select All */
    // Get All Users
    String allUsers = restClient.getAllEntities(sessionToken, MongoPrimeUser.class.getSimpleName());
    log.debug(allUsers);
    Assert.assertNotNull(allUsers);

    // Close Session
    restClient.closeSession(sessionToken);

    // Close Application
    restClient.closeApplication(applicationToken);
}

From source file:com.gisgraphy.helper.StringHelperTest.java

@Test
public void isEmptyString() {
    Assert.assertTrue(StringHelper.isEmptyString(null));
    Assert.assertTrue(StringHelper.isEmptyString(" "));
    Assert.assertTrue(StringHelper.isEmptyString(""));
    Assert.assertFalse(StringHelper.isEmptyString("f"));
}

From source file:com.smartitengineering.dao.hbase.autoincrement.AutoIncrementRowIdForLongTest.java

@Test
public void testMultithreadedKeys() throws Exception {
    ExecutorService service = Executors.newFixedThreadPool(THREAD_COUNT);
    final long start = 102;
    final int bound = THREAD_COUNT;
    final int innerBound = 30;
    List<Future> futures = new ArrayList<Future>();
    final long startTime = System.currentTimeMillis();
    for (int i = 0; i < bound; ++i) {
        final int index = i;
        futures.add(service.submit(new Runnable() {

            @Override//from  ww  w  . j  av a  2 s  .  c  o m
            public void run() {
                for (int j = 0; j < innerBound; ++j) {
                    final HTableInterface table = pool.getTable(TABLE_NAME);
                    long id = index * bound + j + start;
                    final long id1 = getId();
                    synchronized (ids) {
                        final long mainId = Long.MAX_VALUE - id1;
                        Assert.assertFalse(ids.contains(mainId));
                        ids.add(mainId);
                    }
                    final byte[] row = Bytes.toBytes(id1);
                    Put put = new Put(row);
                    final byte[] toBytes = Bytes.toBytes("value " + id);
                    put.add(FAMILY_BYTES, CELL_BYTES, toBytes);
                    Result get1;
                    try {
                        table.put(put);
                        Get get = new Get(row);
                        get1 = table.get(get);
                    } catch (Exception ex) {
                        LOGGER.error(ex.getMessage(), ex);
                        get1 = null;
                        Assert.fail(ex.getMessage());
                    }
                    pool.putTable(table);
                    Assert.assertNotNull(get1);
                    Assert.assertFalse(get1.isEmpty());
                    Assert.assertTrue(Arrays.equals(row, get1.getRow()));
                    Assert.assertTrue(Arrays.equals(toBytes, get1.getValue(FAMILY_BYTES, CELL_BYTES)));
                }
            }
        }));
    }
    for (Future future : futures) {
        future.get();
    }
    final long endTime = System.currentTimeMillis();
    LOGGER.info("Time for " + (bound * innerBound) + " rows ID retrieval, put and get is "
            + (endTime - startTime) + "ms");
    Assert.assertEquals(bound * innerBound + start - 1, ids.size());
}

From source file:com.idtmatter.insta4j.client.FullInstaClientTest.java

@Test(expected = IllegalArgumentException.class)
public void shouldDeleteFolderThatDoesNotExist() throws Exception {
    final FullInstaClient client = FullInstaClient.create("jinstapaper@gmail.com", "open");
    Assert.assertFalse(client.deleteFolder("000"));
}

From source file:com.ebay.cloud.cms.query.service.QueryPaginationTest.java

@Test
public void testService03() {
    QueryContext tempContext = newQueryContext(RAPTOR_REPO, RAPTOR_MAIN_BRANCH_ID);
    tempContext.setAllowFullTableScan(true);
    tempContext.setRegistration(TestUtils.getDefaultDalImplementation(dataSource));
    IQueryResult result = queryService.query("ApplicationService.services{@name}.runsOn{@name}", tempContext);
    List<IEntity> services = (List<IEntity>) result.getEntities();

    Assert.assertEquals(10, services.size());
    Assert.assertEquals("srp-app:Raptor-00002", services.get(0).getFieldValues("name").get(0));
    Assert.assertEquals("srp-app:Raptor-00003", services.get(1).getFieldValues("name").get(0));
    Assert.assertFalse(result.hasMoreResults());
}

From source file:com.gisgraphy.helper.StringHelperTest.java

@Test
public void isNotEmptyString() {
    Assert.assertFalse(StringHelper.isNotEmptyString(null));
    Assert.assertFalse(StringHelper.isNotEmptyString(" "));
    Assert.assertFalse(StringHelper.isNotEmptyString(""));
    Assert.assertTrue(StringHelper.isNotEmptyString("f"));
}

From source file:com.sludev.commons.vfs2.provider.s3.SS3FileProviderTest.java

@Test
public void A003_exist() throws Exception {
    String currAccountStr = testProperties.getProperty("s3.access.id");
    String currKey = testProperties.getProperty("s3.access.secret");
    String currContainerStr = testProperties.getProperty("s3.test0001.bucket.name");
    String currHost = testProperties.getProperty("s3.host");
    String currRegion = testProperties.getProperty("s3.region");
    String currFileNameStr;/* w w w.  j av  a  2 s.  c om*/

    SS3FileProvider currSS3 = new SS3FileProvider();

    DefaultFileSystemManager currMan = new DefaultFileSystemManager();
    currMan.addProvider(SS3Constants.S3SCHEME, currSS3);
    currMan.init();

    StaticUserAuthenticator auth = new StaticUserAuthenticator("", currAccountStr, currKey);
    FileSystemOptions opts = new FileSystemOptions();
    DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth);

    currFileNameStr = "test01.tmp";
    String currUriStr = String.format("%s://%s/%s/%s", SS3Constants.S3SCHEME, currHost, currContainerStr,
            currFileNameStr);
    FileObject currFile = currMan.resolveFile(currUriStr, opts);

    log.info(String.format("exist() file '%s'", currUriStr));

    Boolean existRes = currFile.exists();
    Assert.assertTrue(existRes);

    currFileNameStr = "non-existant-file-8632857264.tmp";
    currUriStr = String.format("%s://%s/%s/%s", SS3Constants.S3SCHEME, currHost, currContainerStr,
            currFileNameStr);
    currFile = currMan.resolveFile(currUriStr, opts);

    log.info(String.format("exist() file '%s'", currUriStr));

    existRes = currFile.exists();
    Assert.assertFalse(existRes);
}

From source file:org.opencastproject.episode.filesystem.FileSystemElementStoreTest.java

@Test
public void testDeleteNoneVersion() throws Exception {
    DeletionSelector noneVersionSelector = new DeletionSelector(ORG_ID, MP_ID, Option.<Version>none());
    Assert.assertTrue(repo.delete(noneVersionSelector));
    Assert.assertFalse(sampleElemDir.exists());

    File file = new File(PathSupport.concat(new String[] { tmpRoot.toString(), ORG_ID, MP_ID }));
    Assert.assertFalse(file.exists());/*  ww w . j av  a 2  s  .  com*/
}