Example usage for java.io BufferedReader ready

List of usage examples for java.io BufferedReader ready

Introduction

In this page you can find the example usage for java.io BufferedReader ready.

Prototype

public boolean ready() throws IOException 

Source Link

Document

Tells whether this stream is ready to be read.

Usage

From source file:com.google.gmail.test.GMailMessageSerDeTest.java

@Ignore
@Test//from w  w w. ja  v  a2 s . com
public void Tests() {
    mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, Boolean.TRUE);
    mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, Boolean.TRUE);
    mapper.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, Boolean.TRUE);

    InputStream is = GMailMessageSerDeTest.class.getResourceAsStream("/datasift_jsons.txt");
    InputStreamReader isr = new InputStreamReader(is);
    BufferedReader br = new BufferedReader(isr);

    try {
        while (br.ready()) {
            String line = br.readLine();
            LOGGER.debug(line);

            // implement
        }
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail();
    }
}

From source file:com.sysomos.test.SysomosJsonSerDeTest.java

@Test
public void Test() {
    mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, Boolean.FALSE);
    mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, Boolean.TRUE);
    mapper.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, Boolean.TRUE);

    InputStream is = SysomosJsonSerDeTest.class.getResourceAsStream("/sysomos_jsons.txt");
    InputStreamReader isr = new InputStreamReader(is);
    BufferedReader br = new BufferedReader(isr);

    try {//from  ww w.  j a v  a  2 s . c  om
        while (br.ready()) {
            String line = br.readLine();
            LOGGER.debug(line);

            Sysomos ser = mapper.readValue(line, Sysomos.class);

            String des = mapper.writeValueAsString(ser);
            LOGGER.debug(des);
        }
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail();
    }
}

From source file:capstone.yelpmodel.JSONWrapper.java

public JSONWrapper(File f) {

    try {// ww  w .j av a  2s .  c o m

        String src = "[";

        FileInputStream fis = new FileInputStream(f);
        InputStreamReader isr = new InputStreamReader(fis);
        BufferedReader br = new BufferedReader(isr);

        int count = 0;
        while (br.ready() && count < MAX_RECORDS) {
            String line = br.readLine();
            src += line + ",\n";
            count++;
        }

        src += "]";

        json = (JSONArray) JSONValue.parse(src);
    }

    catch (Exception e) {
        System.out.println(e);
    }
}

From source file:com.netscape.cms.servlet.test.ConfigurationTest.java

private static ConfigurationRequest constructExternalCADataPart2(String host, String port, String pin,
        String db_dir, String token_pwd, CryptoToken token, String extCertFile)
        throws NoSuchAlgorithmException, TokenException, IOException, InvalidBERException {
    ConfigurationRequest data = new ConfigurationRequest();
    data.setPin(pin);/*from www.ja v a2 s. c om*/

    data.setSecurityDomainType(ConfigurationRequest.NEW_DOMAIN);
    data.setSecurityDomainName("External CA security domain");

    data.setClone("false");
    data.setHierarchy("join");
    data.setToken(CryptoUtil.INTERNAL_TOKEN_FULL_NAME);
    data.setSubsystemName("test external ca subsystem");

    data.setDsHost(host);
    data.setDsPort("7389");
    data.setBaseDN("o=testexternalca");
    data.setBindDN("cn=Directory Manager");
    data.setDatabase("o=testexternalca");
    data.setBindpwd("redhat123");
    data.setRemoveData("true");
    data.setSecureConn("false");

    data.setBackupKeys("true");
    data.setBackupFile("/tmp/testexternalca.p12");
    data.setBackupPassword("redhat123");

    data.setAdminEmail("alee@redhat.com");
    data.setAdminName("admin");
    data.setAdminPassword("redhat123");
    data.setAdminProfileID("caAdminCert");
    data.setAdminUID("admin");
    String subjectdn = "CN=CA Administrator of Instance testexternalca, UID=admin, E=alee@redhat.com, o=testexternalca";
    data.setAdminSubjectDN(subjectdn);

    String crmf_request = generateCRMFRequest(token, "2048", subjectdn, false);
    data.setAdminCertRequest(crmf_request);
    data.setAdminCertRequestType("crmf");

    data.setIssuingCA("External CA");

    // create system certs
    List<SystemCertData> systemCerts = new ArrayList<SystemCertData>();
    SystemCertData cert1 = new SystemCertData();
    cert1.setTag("signing");
    cert1.setKeyAlgorithm("SHA256withRSA");
    cert1.setKeySize("2048");
    cert1.setKeyType("rsa");
    cert1.setNickname("signingCert testexternalca");
    cert1.setSigningAlgorithm("SHA256withRSA");
    cert1.setSubjectDN("CN=External CA Signing Certificate");
    cert1.setToken(CryptoUtil.INTERNAL_TOKEN_FULL_NAME);

    String extCert = "";
    BufferedReader in = new BufferedReader(new FileReader(extCertFile));
    while (in.ready()) {
        extCert += in.readLine();
    }
    in.close();
    cert1.setCert(extCert);

    systemCerts.add(cert1);

    SystemCertData cert2 = new SystemCertData();
    cert2.setTag("ocsp_signing");
    cert2.setKeyAlgorithm("SHA256withRSA");
    cert2.setKeySize("2048");
    cert2.setKeyType("rsa");
    cert2.setNickname("ocspSigningCert testexternalca");
    cert2.setSigningAlgorithm("SHA256withRSA");
    cert2.setSubjectDN("CN= External CA OCSP Signing Certificate");
    cert2.setToken(CryptoUtil.INTERNAL_TOKEN_FULL_NAME);
    systemCerts.add(cert2);

    SystemCertData cert3 = new SystemCertData();
    cert3.setTag("sslserver");
    cert3.setKeyAlgorithm("SHA256withRSA");
    cert3.setKeySize("2048");
    cert3.setKeyType("rsa");
    cert3.setNickname("sslServerCert testexternalca");
    cert3.setSubjectDN("CN=" + host);
    cert3.setToken(CryptoUtil.INTERNAL_TOKEN_FULL_NAME);
    systemCerts.add(cert3);

    SystemCertData cert4 = new SystemCertData();
    cert4.setTag("subsystem");
    cert4.setKeyAlgorithm("SHA256withRSA");
    cert4.setKeySize("2048");
    cert4.setKeyType("rsa");
    cert4.setNickname("subsystemCert testexternalca");
    cert4.setSubjectDN("CN=External CA Subsystem Certificate");
    cert4.setToken(CryptoUtil.INTERNAL_TOKEN_FULL_NAME);
    systemCerts.add(cert4);

    SystemCertData cert5 = new SystemCertData();
    cert5.setTag("audit_signing");
    cert5.setKeyAlgorithm("SHA256withRSA");
    cert5.setKeySize("2048");
    cert5.setKeyType("rsa");
    cert5.setNickname("auditSigningCert testexternalca");
    cert5.setSigningAlgorithm("SHA256withRSA");
    cert5.setSubjectDN("CN=SubCA Audit Signing Certificate");
    cert5.setToken(CryptoUtil.INTERNAL_TOKEN_FULL_NAME);
    systemCerts.add(cert5);

    data.setSystemCerts(systemCerts);

    return data;
}

From source file:br.com.ceosites.cachedproperties.cache.test.util.ScriptRunner.java

public void execute(BufferedReader bufferedReader) throws IOException, SQLException {
    StringBuilder scriptBuilder = new StringBuilder();
    while (bufferedReader.ready()) {
        scriptBuilder.append(bufferedReader.readLine());
    }//from  ww  w.  j  ava  2 s . c  o  m
    Connection con = this.dataSource.getConnection();
    con.prepareStatement(scriptBuilder.toString()).executeUpdate();
    con.close();
}

From source file:com.datasift.test.DatasiftSerDeTest.java

@Test
public void Tests() {
    InputStream is = DatasiftSerDeTest.class.getResourceAsStream("/part-r-00000.json");
    InputStreamReader isr = new InputStreamReader(is);
    BufferedReader br = new BufferedReader(isr);

    try {//from   w w  w.j  a  v  a 2  s . c  o m
        while (br.ready()) {
            String line = br.readLine();
            LOGGER.debug(line);
            System.out.println(line);

            Datasift ser = mapper.readValue(line, Datasift.class);

            String de = mapper.writeValueAsString(ser);

            LOGGER.debug(de);

            Datasift serde = mapper.readValue(de, Datasift.class);

            Assert.assertEquals(ser, serde);

            LOGGER.debug(mapper.writeValueAsString(serde));
        }
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail();
    }
}

From source file:br.edu.claudivan.controledegastos.dao.test.utils.ScriptRunner.java

public void execute(BufferedReader bufferedReader) throws IOException, SQLException {
    StringBuilder scriptBuilder = new StringBuilder();
    while (bufferedReader.ready()) {
        scriptBuilder.append(bufferedReader.readLine());
    }//from   w ww .j  av a2s .  com
    Connection con = this.dataSource.getConnection();
    Statement st = con.createStatement();
    st.execute(scriptBuilder.toString());
    con.close();
}

From source file:org.apache.streams.jackson.MemoryUsageDeserializerTest.java

@Test
public void serDeTest() {
    InputStream is = MemoryUsageDeserializerTest.class.getResourceAsStream("/MemoryUsageObjects.json");
    InputStreamReader isr = new InputStreamReader(is);
    BufferedReader br = new BufferedReader(isr);

    try {// www  .ja v  a  2 s  . com
        while (br.ready()) {
            String line = br.readLine();
            if (!StringUtils.isEmpty(line)) {
                LOGGER.info("raw: {}", line);
                MemoryUsageBroadcast broadcast = objectMapper.readValue(line, MemoryUsageBroadcast.class);

                LOGGER.info("activity: {}", broadcast);

                assertNotNull(broadcast);
                assertNotNull(broadcast.getVerbose());
                assertNotNull(broadcast.getObjectPendingFinalizationCount());
                assertNotNull(broadcast.getHeapMemoryUsage());
                assertNotNull(broadcast.getNonHeapMemoryUsage());
                assertNotNull(broadcast.getName());
            }
        }
    } catch (Exception ex) {
        LOGGER.error("Exception while testing serializability: {}", ex);
    }
}

From source file:org.kuali.ole.sys.service.impl.ReportAggregatorServiceTextImpl.java

protected int dumpFileContents(Writer outputWriter, File file, int currentPageNumber) {
    try {/* ww  w . jav  a2s  .co m*/
        BufferedReader reader = new BufferedReader(new FileReader(file));
        while (reader.ready()) {
            String line = reader.readLine();
            while (line.contains(OLEConstants.REPORT_WRITER_SERVICE_PAGE_NUMBER_PLACEHOLDER)) {
                line = StringUtils.replaceOnce(line, OLEConstants.REPORT_WRITER_SERVICE_PAGE_NUMBER_PLACEHOLDER,
                        String.valueOf(currentPageNumber));
                currentPageNumber++;
            }
            outputWriter.write(line);
            outputWriter.write(newLineCharacter);
        }
        reader.close();
        return currentPageNumber;
    } catch (IOException e) {
        throw new RuntimeException("Error reading or writing file", e);
    }
}

From source file:com.sysomos.test.SysomosXmlSerDeTest.java

@Test
public void Test() {
    InputStream is = SysomosXmlSerDeTest.class.getResourceAsStream("/sysomos_xmls.txt");
    InputStreamReader isr = new InputStreamReader(is);
    BufferedReader br = new BufferedReader(isr);

    try {//w w w. j  a  v  a2  s .  c o  m
        while (br.ready()) {
            String line = br.readLine();
            LOGGER.debug(line);

            BeatApi ser = xmlMapper.readValue(line, BeatApi.class);

            String des = xmlMapper.writeValueAsString(ser);
            LOGGER.debug(des);
        }
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail();
    }
}