Examples of UpdatingUserAgentStringParserImpl


Examples of net.sf.uadetector.parser.UpdatingUserAgentStringParserImpl

    final CachingXmlDataStore store = CachingXmlDataStore.createCachingXmlDataStore(cache, DATA_URL, VERSION_URL, CHARSET, fallback);
    assertThat(store.getData().getVersion()).isEqualTo(fallback.getData().getVersion());
    final long duration = System.currentTimeMillis() - startTime;
    assertThat(duration < 1000).as("loading unreachable remote data takes too long").isTrue();

    final UpdatingUserAgentStringParserImpl parser = new UpdatingUserAgentStringParserImpl(store);
    parser.parse("test");

    final long lookupStartTime = System.currentTimeMillis();
    do {
      Thread.sleep(1000);
    } while (!readFile(cache).contains(DATA_VERSION) && !(System.currentTimeMillis() - lookupStartTime > WAIT_UNTIL_ABORT));
View Full Code Here

Examples of net.sf.uadetector.parser.UpdatingUserAgentStringParserImpl

    // create caching data store without a cache file
    final CachingXmlDataStore store = CachingXmlDataStore.createCachingXmlDataStore(cache, UNREACHABLE_URL, UNREACHABLE_URL, CHARSET,
        fallback);
    assertThat(store.getData().getVersion()).isEqualTo(fallback.getData().getVersion());

    final UpdatingUserAgentStringParserImpl parser = new UpdatingUserAgentStringParserImpl(store);
    parser.parse("test");

    final String newerVersionOfFallback = UrlUtil.read(TestXmlDataStore.VERSION_URL_NEWER, DataStore.DEFAULT_CHARSET);
    final long lookupStartTime = System.currentTimeMillis();
    do {
      Thread.sleep(1000l);
View Full Code Here

Examples of net.sf.uadetector.parser.UpdatingUserAgentStringParserImpl

    final File cache = folder.newFile("uas_temp.xml");
    assertThat(readFile(cache)).isEqualTo("");

    // create caching data store
    final CachingXmlDataStore store = CachingXmlDataStore.createCachingXmlDataStore(cache, DATA_URL, VERSION_URL, CHARSET, fallback);
    final UpdatingUserAgentStringParserImpl parser = new UpdatingUserAgentStringParserImpl(store);

    Thread.sleep(1000l);
    assertThat(readFile(cache).length() >= 721915).isTrue();

    final long firstLastUpdateCheck = store.getUpdateOperation().getLastUpdateCheck();
    LOG.debug("LastUpdateCheck at: " + firstLastUpdateCheck);
    final long originalInterval = parser.getUpdateInterval();

    // reduce the interval since testing
    LOG.debug("Reducing the update interval during the test.");
    parser.setUpdateInterval(1000l);
    // we have to read to activate the update mechanism
    parser.parse("check for updates");

    Thread.sleep(3000l);
    final long currentLastUpdateCheck = store.getUpdateOperation().getLastUpdateCheck();
    LOG.debug("LastUpdateCheck at: " + currentLastUpdateCheck);
    assertThat(firstLastUpdateCheck < currentLastUpdateCheck).isTrue();

    parser.setUpdateInterval(originalInterval);
  }
View Full Code Here

Examples of net.sf.uadetector.parser.UpdatingUserAgentStringParserImpl

    final TestXmlDataStore fallbackDataStore = new TestXmlDataStore();

    // create caching data store without a cache file
    final CachingXmlDataStore store1 = CachingXmlDataStore.createCachingXmlDataStore(cache, DATA_URL_OLDER, VERSION_URL_OLDER, CHARSET,
        fallbackDataStore);
    final UpdatingUserAgentStringParserImpl parser1 = new UpdatingUserAgentStringParserImpl(store1);
    parser1.parse("test");

    Thread.sleep(1000l);
    final String readIn1 = readFile(cache);
    assertThat(readIn1.contains(DATA_VERSION_OLDER)).isTrue();
    assertThat(readIn1.length() >= 721915).isTrue();

    // create caching data store with filled cache and available update
    final CachingXmlDataStore store2 = CachingXmlDataStore.createCachingXmlDataStore(cache, DATA_URL_NEWER, VERSION_URL_NEWER, CHARSET,
        fallbackDataStore);
    final UpdatingUserAgentStringParserImpl parser2 = new UpdatingUserAgentStringParserImpl(store2);
    parser2.parse("test");

    Thread.sleep(1000l);
    final String readIn2 = readFile(cache);
    assertThat(readIn2.contains(DATA_VERSION_NEWER)).isTrue();
    assertThat(readIn2.length() >= 721915).isTrue();

    // create caching data store with filled cache and without an available update
    final CachingXmlDataStore store = CachingXmlDataStore.createCachingXmlDataStore(cache, DATA_URL_NEWER, VERSION_URL_NEWER, CHARSET,
        fallbackDataStore);
    final UpdatingUserAgentStringParserImpl parser = new UpdatingUserAgentStringParserImpl(store);
    parser.parse("test");

    Thread.sleep(1000l);
    final String readIn = readFile(cache);
    assertThat(readIn.contains(DATA_VERSION_NEWER)).isTrue();
    assertThat(readIn.length() >= 721915).isTrue();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.