Package org.archive.bdb

Examples of org.archive.bdb.AutoKryo


        TestCase.assertEquals(crawlHost.getClass(), o.getClass());
        TestCase.assertEquals(crawlHost, o);
    }
   
    public void testKryoSerialization() throws Exception {
        AutoKryo kryo = new AutoKryo();
        kryo.autoregister(CrawlHost.class);

        InetAddress localhost = InetAddress.getLocalHost();
        CrawlHost crawlHost0 = new CrawlHost(localhost.getHostName());
        crawlHost0.setIP(localhost, 431243);

        ByteBuffer buffer = ByteBuffer.allocateDirect(1024);
        kryo.writeObject(buffer, crawlHost0);
        buffer.flip();
       
        CrawlHost crawlHost1 = kryo.readObject(buffer, CrawlHost.class);

        TestCase.assertEquals(crawlHost0.getClass(), crawlHost1.getClass());
        TestCase.assertEquals(crawlHost0, crawlHost1);
        TestCase.assertEquals(localhost, crawlHost1.getIP());
    }
View Full Code Here


     * can lead to excess memory usage and CPU cycles. In one case, 450KB robots.txt
     * exploded into 450MB. See [HER-1912].
     * @throws IOException
     */
    public void testCompactSerialization() throws IOException {
        AutoKryo kryo = new AutoKryo();
        kryo.autoregister(Robotstxt.class);
       
        final String TEST_ROBOTS_TXT = "User-Agent:a\n" +
        "User-Agent:b\n" +
        "User-Agent:c\n" +
        "User-Agent:d\n" +
        "Disallow:/service\n";

        StringReader sr = new StringReader(TEST_ROBOTS_TXT);
        Robotstxt rt = new Robotstxt(new BufferedReader(sr));
        {
            RobotsDirectives da = rt.getDirectivesFor("a", false);
            RobotsDirectives db = rt.getDirectivesFor("b", false);
            assertTrue("user-agent a and b shares the same RobotsDirectives before serialization", da == db);
        }
        ByteBuffer buffer = ByteBuffer.allocateDirect(1024);
        kryo.writeObject(buffer, rt);
        buffer.flip();
        Robotstxt rt2 = kryo.readObject(buffer, Robotstxt.class);
        assertNotNull(rt2);
        {
            RobotsDirectives da = rt2.getDirectivesFor("a", false);
            RobotsDirectives db = rt2.getDirectivesFor("b", false);
            assertTrue("user-agent a and b shares the same RobotsDirectives after deserialization", da == db);
View Full Code Here

TOP

Related Classes of org.archive.bdb.AutoKryo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.