Package net.sf.uadetector

Examples of net.sf.uadetector.UserAgent


  }

  @Test
  public void parse_browser_mobile_SAFARI_IPAD() throws Exception {
    final String userAgent = "Mozilla/5.0 (iPad; U; CPU OS 4_2_1 like Mac OS X; ja-jp) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148 Safari/6533.18.5";
    final UserAgent agent = PARSER.parse(userAgent);
    assertThat(agent).isNotNull();

    // check user agent informations
    assertThat(agent.getFamily()).isEqualTo(UserAgentFamily.MOBILE_SAFARI);
    assertThat(agent.getIcon()).isEqualTo("safari.png");
    assertThat(agent.getName()).isEqualTo("Mobile Safari");
    assertThat(agent.getProducer()).isEqualTo("Apple Inc.");
    assertThat(agent.getProducerUrl()).isEqualTo("http://www.apple.com/");
    assertThat(agent.getType()).isEqualTo(UserAgentType.MOBILE_BROWSER);
    assertThat(agent.getTypeName()).isEqualTo("Mobile Browser");
    assertThat(agent.getUrl()).isEqualTo("http://en.wikipedia.org/wiki/Safari_%28web_browser%29");
    assertThat(agent.getVersionNumber().toVersionString()).isEqualTo("5.0.2");

    // check operating system informations
    final OperatingSystem os = agent.getOperatingSystem();
    assertThat(os.getFamily()).isEqualTo(OperatingSystemFamily.IOS);
    assertThat(os.getFamilyName()).isEqualTo("iOS");
    assertThat(os.getIcon()).isEqualTo("iphone.png");
    assertThat(os.getName()).isEqualTo("iOS");
    assertThat(os.getProducer()).isEqualTo("Apple Inc.");
    assertThat(os.getProducerUrl()).isEqualTo("http://www.apple.com/");
    assertThat(os.getUrl()).isEqualTo("http://en.wikipedia.org/wiki/IOS");
    assertThat(os.getVersionNumber().toVersionString()).isEqualTo("4.2.1");

    // check device category informations
    final DeviceCategory category = agent.getDeviceCategory();
    assertThat(category.getCategory()).isEqualTo(Category.TABLET);
    assertThat(category.getName()).isEqualTo(Category.TABLET.getName());
    assertThat(category.getIcon()).isEqualTo("tablet.png");
    assertThat(category.getInfoUrl()).isEqualTo("/list-of-ua/device-detail?device=Tablet");
  }
View Full Code Here


  }

  @Test
  public void parse_browser_mobile_SAFARI_IPAD_IOS5() throws Exception {
    final String userAgent = "Mozilla/5.0 (iPad; CPU OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3";
    final UserAgent agent = PARSER.parse(userAgent);
    assertThat(agent).isNotNull();

    // check user agent informations
    assertThat(agent.getFamily()).isEqualTo(UserAgentFamily.MOBILE_SAFARI);
    assertThat(agent.getIcon()).isEqualTo("safari.png");
    assertThat(agent.getName()).isEqualTo("Mobile Safari");
    assertThat(agent.getProducer()).isEqualTo("Apple Inc.");
    assertThat(agent.getProducerUrl()).isEqualTo("http://www.apple.com/");
    assertThat(agent.getType()).isEqualTo(UserAgentType.MOBILE_BROWSER);
    assertThat(agent.getTypeName()).isEqualTo("Mobile Browser");
    assertThat(agent.getUrl()).isEqualTo("http://en.wikipedia.org/wiki/Safari_%28web_browser%29");
    assertThat(agent.getVersionNumber().toVersionString()).isEqualTo("5.1");

    // check operating system informations
    final OperatingSystem os = agent.getOperatingSystem();
    assertThat(os.getFamily()).isEqualTo(OperatingSystemFamily.IOS);
    assertThat(os.getFamilyName()).isEqualTo("iOS");
    assertThat(os.getIcon()).isEqualTo("iphone.png");
    assertThat(os.getName()).isEqualTo("iOS 5");
    assertThat(os.getProducer()).isEqualTo("Apple Inc.");
    assertThat(os.getProducerUrl()).isEqualTo("http://www.apple.com/");
    assertThat(os.getUrl()).isEqualTo("http://en.wikipedia.org/wiki/IOS_5");
    assertThat(os.getVersionNumber().toVersionString()).isEqualTo("5.0");

    // check device category informations
    final DeviceCategory category = agent.getDeviceCategory();
    assertThat(category.getCategory()).isEqualTo(Category.TABLET);
    assertThat(category.getName()).isEqualTo(Category.TABLET.getName());
    assertThat(category.getIcon()).isEqualTo("tablet.png");
    assertThat(category.getInfoUrl()).isEqualTo("/list-of-ua/device-detail?device=Tablet");
  }
View Full Code Here

  }

  @Test
  public void parse_browser_mobile_SAFARI_IPHONE() throws Exception {
    final String userAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B206 Safari/7534.48.3";
    final UserAgent agent = PARSER.parse(userAgent);
    assertThat(agent).isNotNull();

    // check user agent informations
    assertThat(agent.getFamily()).isEqualTo(UserAgentFamily.MOBILE_SAFARI);
    assertThat(agent.getIcon()).isEqualTo("safari.png");
    assertThat(agent.getName()).isEqualTo("Mobile Safari");
    assertThat(agent.getProducer()).isEqualTo("Apple Inc.");
    assertThat(agent.getProducerUrl()).isEqualTo("http://www.apple.com/");
    assertThat(agent.getType()).isEqualTo(UserAgentType.MOBILE_BROWSER);
    assertThat(agent.getTypeName()).isEqualTo("Mobile Browser");
    assertThat(agent.getUrl()).isEqualTo("http://en.wikipedia.org/wiki/Safari_%28web_browser%29");
    assertThat(agent.getVersionNumber().toVersionString()).isEqualTo("5.1");

    // check operating system informations
    final OperatingSystem os = agent.getOperatingSystem();
    assertThat(os.getFamily()).isEqualTo(OperatingSystemFamily.IOS);
    assertThat(os.getFamilyName()).isEqualTo("iOS");
    assertThat(os.getIcon()).isEqualTo("iphone.png");
    assertThat(os.getName()).isEqualTo("iOS 5");
    assertThat(os.getProducer()).isEqualTo("Apple Inc.");
    assertThat(os.getProducerUrl()).isEqualTo("http://www.apple.com/");
    assertThat(os.getUrl()).isEqualTo("http://en.wikipedia.org/wiki/IOS_5");
    assertThat(os.getVersionNumber().toVersionString()).isEqualTo("5.1.1");

    // check device category informations
    final DeviceCategory category = agent.getDeviceCategory();
    assertThat(category.getCategory()).isEqualTo(Category.SMARTPHONE);
    assertThat(category.getName()).isEqualTo(Category.SMARTPHONE.getName());
    assertThat(category.getIcon()).isEqualTo("phone.png");
    assertThat(category.getInfoUrl()).isEqualTo("/list-of-ua/device-detail?device=Smartphone");
  }
View Full Code Here

  }

  @Test
  public void parse_browser_OPERA() throws Exception {
    final String userAgent = "Opera/9.80 (Windows NT 5.1; U; cs) Presto/2.2.15 Version/10.00";
    final UserAgent agent = PARSER.parse(userAgent);
    assertThat(agent).isNotNull();

    // check user agent informations
    assertThat(agent.getFamily()).isEqualTo(UserAgentFamily.OPERA);
    assertThat(agent.getIcon()).isEqualTo("opera.png");
    assertThat(agent.getName()).isEqualTo("Opera");
    assertThat(agent.getProducer()).isEqualTo("Opera Software ASA.");
    assertThat(agent.getProducerUrl()).isEqualTo("http://www.opera.com/");
    assertThat(agent.getType()).isEqualTo(UserAgentType.BROWSER);
    assertThat(agent.getTypeName()).isEqualTo("Browser");
    assertThat(agent.getUrl()).isEqualTo("http://www.opera.com/");
    assertThat(agent.getVersionNumber().toVersionString()).isEqualTo("10.00");

    // check operating system informations
    final OperatingSystem os = agent.getOperatingSystem();
    assertThat(os.getFamily()).isEqualTo(OperatingSystemFamily.WINDOWS);
    assertThat(os.getFamilyName()).isEqualTo("Windows");
    assertThat(os.getIcon()).isEqualTo("windowsxp.png");
    assertThat(os.getName()).isEqualTo("Windows XP");
    assertThat(os.getProducer()).isEqualTo("Microsoft Corporation.");
    assertThat(os.getProducerUrl()).isEqualTo("http://www.microsoft.com/");
    assertThat(os.getUrl()).isEqualTo("http://en.wikipedia.org/wiki/Windows_XP");
    assertThat(os.getVersionNumber().toVersionString()).isEqualTo("5.1");

    // check device category informations
    final DeviceCategory category = agent.getDeviceCategory();
    assertThat(category.getCategory()).isEqualTo(Category.PERSONAL_COMPUTER);
    assertThat(category.getName()).isEqualTo(Category.PERSONAL_COMPUTER.getName());
    assertThat(category.getIcon()).isEqualTo("desktop.png");
    assertThat(category.getInfoUrl()).isEqualTo("/list-of-ua/device-detail?device=Personal computer");
  }
View Full Code Here

  }

  @Test
  public void parse_browser_SAFARI() throws Exception {
    final String userAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/534.55.3 (KHTML, like Gecko) Version/5.1.5 Safari/534.55.3";
    final UserAgent agent = PARSER.parse(userAgent);
    assertThat(agent).isNotNull();

    // check user agent informations
    assertThat(agent.getFamily()).isEqualTo(UserAgentFamily.SAFARI);
    assertThat(agent.getIcon()).isEqualTo("safari.png");
    assertThat(agent.getName()).isEqualTo("Safari");
    assertThat(agent.getProducer()).isEqualTo("Apple Inc.");
    assertThat(agent.getProducerUrl()).isEqualTo("http://www.apple.com/");
    assertThat(agent.getType()).isEqualTo(UserAgentType.BROWSER);
    assertThat(agent.getTypeName()).isEqualTo("Browser");
    assertThat(agent.getUrl()).isEqualTo("http://en.wikipedia.org/wiki/Safari_%28web_browser%29");
    assertThat(agent.getVersionNumber().toVersionString()).isEqualTo("5.1.5");

    // check operating system informations
    final OperatingSystem os = agent.getOperatingSystem();
    assertThat(os.getFamily()).isEqualTo(OperatingSystemFamily.OS_X);
    assertThat(os.getFamilyName()).isEqualTo("OS X");
    assertThat(os.getIcon()).isEqualTo("macosx.png");
    assertThat(os.getName()).isEqualTo("OS X 10.7 Lion");
    assertThat(os.getProducer()).isEqualTo("Apple Computer, Inc.");
    assertThat(os.getProducerUrl()).isEqualTo("http://www.apple.com/");
    assertThat(os.getUrl()).isEqualTo("http://www.apple.com/osx/");
    assertThat(os.getVersionNumber().toVersionString()).isEqualTo("10.7.3");

    // check device category informations
    final DeviceCategory category = agent.getDeviceCategory();
    assertThat(category.getCategory()).isEqualTo(Category.PERSONAL_COMPUTER);
    assertThat(category.getName()).isEqualTo(Category.PERSONAL_COMPUTER.getName());
    assertThat(category.getIcon()).isEqualTo("desktop.png");
    assertThat(category.getInfoUrl()).isEqualTo("/list-of-ua/device-detail?device=Personal computer");
  }
View Full Code Here

  }

  @Test
  public void parse_browser_SILK() throws Exception {
    final String userAgent = "Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; Silk/1.1.0-80) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1 Silk-Accelerated=true";
    final UserAgent agent = PARSER.parse(userAgent);
    assertThat(agent).isNotNull();
    assertThat(agent).isNotEqualTo(UserAgent.EMPTY);

    // check user agent informations
    assertThat(agent.getFamily()).isEqualTo(UserAgentFamily.SILK);
    assertThat(agent.getName()).isEqualTo("Silk");
    assertThat(agent.getProducer()).isEqualTo("Amazon.com, Inc.");
    assertThat(agent.getProducerUrl()).isEqualTo("http://www.amazon.com/");
    assertThat(agent.getTypeName()).isEqualTo("Mobile Browser");
    assertThat(agent.getUrl()).isEqualTo("http://amazonsilk.wordpress.com/");
    assertThat(agent.getVersionNumber().toVersionString()).isEqualTo("1.1.0-80");

    // check operating system informations
    final OperatingSystem os = agent.getOperatingSystem();
    assertThat(os.getFamily()).isEqualTo(OperatingSystemFamily.ANDROID);
    assertThat(os.getFamilyName()).isEqualTo("Android");
    assertThat(os.getName()).isEqualTo("Android 2.3.x Gingerbread");
    assertThat(os.getProducer()).isEqualTo("Google, Inc.");
    assertThat(os.getProducerUrl()).isEqualTo("http://www.google.com/");
    assertThat(os.getUrl()).isEqualTo("http://en.wikipedia.org/wiki/Android_%28operating_system%29");

    // check device category informations
    final DeviceCategory category = agent.getDeviceCategory();
    assertThat(category.getCategory()).isEqualTo(Category.TABLET);
    assertThat(category.getName()).isEqualTo(Category.TABLET.getName());
    assertThat(category.getIcon()).isEqualTo("tablet.png");
    assertThat(category.getInfoUrl()).isEqualTo("/list-of-ua/device-detail?device=Tablet");
  }
View Full Code Here

  }

  @Test
  public void parse_browser_SITESUCKER() throws Exception {
    final String userAgent = "SiteSucker/1.6.9";
    final UserAgent agent = PARSER.parse(userAgent);
    assertThat(agent).isNotNull();

    // check user agent informations
    assertThat(agent.getFamily()).isEqualTo(UserAgentFamily.SITESUCKER);
    assertThat(agent.getName()).isEqualTo("SiteSucker");
    assertThat(agent.getProducer()).isEqualTo("Rick Cranisky");
    assertThat(agent.getProducerUrl()).isEqualTo("");
    assertThat(agent.getTypeName()).isEqualTo("Offline Browser");
    assertThat(agent.getUrl()).isEqualTo("http://www.sitesucker.us/");
    assertThat(agent.getVersionNumber().toVersionString()).isEqualTo("1.6.9");

    // check operating system informations
    final OperatingSystem os = agent.getOperatingSystem();
    assertThat(os.getFamily()).isEqualTo(OperatingSystemFamily.MAC_OS);
    assertThat(os.getFamilyName()).isEqualTo("Mac OS");
    assertThat(os.getName()).isEqualTo("Mac OS");
    assertThat(os.getProducer()).isEqualTo("Apple Computer, Inc.");
    assertThat(os.getProducerUrl()).isEqualTo("http://www.apple.com/");
    assertThat(os.getUrl()).isEqualTo("http://en.wikipedia.org/wiki/Mac_OS");

    // check device category informations
    final DeviceCategory category = agent.getDeviceCategory();
    assertThat(category.getCategory()).isEqualTo(Category.PERSONAL_COMPUTER);
    assertThat(category.getName()).isEqualTo(Category.PERSONAL_COMPUTER.getName());
    assertThat(category.getIcon()).isEqualTo("desktop.png");
    assertThat(category.getInfoUrl()).isEqualTo("/list-of-ua/device-detail?device=Personal computer");
  }
View Full Code Here

  }

  @Test
  public void parse_browser_SKYFIRE() throws Exception {
    final String userAgent = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_7; en-us) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Safari/530.17 Skyfire/2.0";
    final UserAgent agent = PARSER.parse(userAgent);
    assertThat(agent).isNotNull();

    // check user agent informations
    assertThat(agent.getFamily()).isEqualTo(UserAgentFamily.SKYFIRE);
    assertThat(agent.getName()).isEqualTo("Skyfire");
    assertThat(agent.getProducer()).isEqualTo("Skyfire Labs, Inc.");
    assertThat(agent.getProducerUrl()).isEqualTo("http://www.skyfire.com/about");
    assertThat(agent.getTypeName()).isEqualTo("Mobile Browser");
    assertThat(agent.getUrl()).isEqualTo("http://www.skyfire.com/");
    assertThat(agent.getVersionNumber().toVersionString()).isEqualTo("2.0");

    // check operating system informations
    final OperatingSystem os = agent.getOperatingSystem();
    assertThat(os.getFamily()).isEqualTo(OperatingSystemFamily.OS_X);
    assertThat(os.getFamilyName()).isEqualTo("OS X");
    assertThat(os.getName()).isEqualTo("OS X 10.5 Leopard");
    assertThat(os.getProducer()).isEqualTo("Apple Computer, Inc.");
    assertThat(os.getProducerUrl()).isEqualTo("http://www.apple.com/");
    assertThat(os.getUrl()).isEqualTo("http://www.apple.com/osx/");

    // check device category informations
    final DeviceCategory category = agent.getDeviceCategory();
    assertThat(category.getCategory()).isEqualTo(Category.SMARTPHONE);
    assertThat(category.getName()).isEqualTo(Category.SMARTPHONE.getName());
    assertThat(category.getIcon()).isEqualTo("phone.png");
    assertThat(category.getInfoUrl()).isEqualTo("/list-of-ua/device-detail?device=Smartphone");
  }
View Full Code Here

  }

  @Test
  public void parse_browser_SKYFIRE_withoutOperatingSystemInfo() throws Exception {
    final String userAgent = "Mozilla/5.0 AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Safari/530.17 Skyfire/2.0";
    final UserAgent agent = PARSER.parse(userAgent);
    assertThat(agent).isNotNull();

    // check user agent informations
    assertThat(agent.getFamily()).isEqualTo(UserAgentFamily.SKYFIRE);
    assertThat(agent.getName()).isEqualTo("Skyfire");
    assertThat(agent.getProducer()).isEqualTo("Skyfire Labs, Inc.");
    assertThat(agent.getProducerUrl()).isEqualTo("http://www.skyfire.com/about");
    assertThat(agent.getTypeName()).isEqualTo("Mobile Browser");
    assertThat(agent.getUrl()).isEqualTo("http://www.skyfire.com/");
    assertThat(agent.getVersionNumber().toVersionString()).isEqualTo("2.0");

    // check operating system informations
    assertThat(agent.getOperatingSystem()).isEqualTo(OperatingSystem.EMPTY);

    // check device category informations
    final DeviceCategory category = agent.getDeviceCategory();
    assertThat(category.getCategory()).isEqualTo(Category.SMARTPHONE);
    assertThat(category.getName()).isEqualTo(Category.SMARTPHONE.getName());
    assertThat(category.getIcon()).isEqualTo("phone.png");
    assertThat(category.getInfoUrl()).isEqualTo("/list-of-ua/device-detail?device=Smartphone");
  }
View Full Code Here

  }

  @Test
  public void parse_browser_BB10() throws Exception {
    final String userAgent = "Mozilla/5.0 (BB10; Touch) AppleWebKit/537.10+ (KHTML, like Gecko) Version/10.1.0.4633 Mobile Safari/537.10+";
    final UserAgent agent = PARSER.parse(userAgent);
    assertThat(agent).isNotNull();

    // check user agent informations
    assertThat(agent.getFamily()).isEqualTo(UserAgentFamily.BLACKBERRY_BROWSER);
    assertThat(agent.getName()).isEqualTo("BlackBerry Browser");
    assertThat(agent.getProducer()).isEqualTo("Research In Motion Limited");
    assertThat(agent.getProducerUrl()).isEqualTo("http://www.rim.com/");
    assertThat(agent.getTypeName()).isEqualTo("Mobile Browser");
    assertThat(agent.getUrl()).isEqualTo("http://www.blackberry.com/");
    assertThat(agent.getVersionNumber().toVersionString()).isEqualTo("");

    // check operating system informations
    final OperatingSystem os = agent.getOperatingSystem();
    assertThat(os.getFamily()).isEqualTo(OperatingSystemFamily.BLACKBERRY_OS);
    assertThat(os.getFamilyName()).isEqualTo("BlackBerry OS");
    assertThat(os.getName()).isEqualTo("BlackBerry OS");
    assertThat(os.getProducer()).isEqualTo("BlackBerry Ltd");
    assertThat(os.getProducerUrl()).isEqualTo("http://www.blackberry.com/");
    assertThat(os.getUrl()).isEqualTo("http://en.wikipedia.org/wiki/BlackBerry_OS");

    // check device category informations
    final DeviceCategory category = agent.getDeviceCategory();
    assertThat(category.getCategory()).isEqualTo(Category.SMARTPHONE);
    assertThat(category.getName()).isEqualTo(Category.SMARTPHONE.getName());
    assertThat(category.getIcon()).isEqualTo("phone.png");
    assertThat(category.getInfoUrl()).isEqualTo("/list-of-ua/device-detail?device=Smartphone");
  }
View Full Code Here

TOP

Related Classes of net.sf.uadetector.UserAgent

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.