• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package org.robolectric;
2 
3 import static com.google.common.truth.Truth.assertThat;
4 
5 import org.junit.Test;
6 import org.junit.runner.RunWith;
7 import org.junit.runners.JUnit4;
8 import org.robolectric.util.JavaVersion;
9 
10 @RunWith(JUnit4.class)
11 public class JavaVersionTest {
12   @Test
jdk8()13   public void jdk8() {
14     check("1.8.1u40", "1.8.5u60");
15     check("1.8.0u40", "1.8.0u60");
16     check("1.8.0u40", "1.8.0u100");
17   }
18 
19   @Test
jdk9()20   public void jdk9() {
21     check("9.0.1+12", "9.0.2+12");
22     check("9.0.2+60", "9.0.2+100");
23   }
24 
25   @Test
differentJdk()26   public void differentJdk() {
27     check("1.7.0", "1.8.0u60");
28     check("1.8.1u40", "9.0.2+12");
29   }
30 
31   @Test
longer()32   public void longer() {
33     check("1.8.0", "1.8.0.1");
34   }
35 
36   @Test
longerEquality()37   public void longerEquality() {
38     checkEqual("1.8.0", "1.8.0");
39     checkEqual("1.8.0u33", "1.8.0u33");
40     checkEqual("5", "5");
41   }
42 
check(String v1, String v2)43   private static void check(String v1, String v2) {
44     assertThat(new JavaVersion(v1).compareTo(new JavaVersion(v2))).isLessThan(0);
45   }
46 
checkEqual(String v1, String v2)47   private static void checkEqual(String v1, String v2) {
48     assertThat(new JavaVersion(v1).compareTo(new JavaVersion(v2))).isEqualTo(0);
49   }
50 
51 }