Subversion Repository Public Repository

litesoft

Diff Revisions 950 vs 961 for /trunk/DeviceDesktopTest/src/org/litesoft/useragent/UserAgentFormFactorDeterminerImplTest.java

Diff revisions: vs.
  @@ -7,20 +7,16 @@
7 7 import java.io.*;
8 8 import java.util.*;
9 9
10 - public class UserAgentFormFactorDeterminerImplTest
11 - {
10 + public class UserAgentFormFactorDeterminerImplTest {
12 11 public static final String USER_AGENT_FILES_SUB_DIR = "UserAgentFiles";
13 12
14 13 private static final UserAgentFormFactorDeterminer FFD = new UserAgentFormFactorDeterminerImpl();
15 14
16 15 private static String[] readTextFile( File pTextFile )
17 - throws IOException
18 - {
16 + throws IOException {
19 17 List<String> zLines = new ArrayList<>();
20 - try (Scanner scanner = new Scanner( pTextFile, "UTF-8" ))
21 - {
22 - while ( scanner.hasNextLine() )
23 - {
18 + try (Scanner scanner = new Scanner( pTextFile, "UTF-8" )) {
19 + while ( scanner.hasNextLine() ) {
24 20 zLines.add( scanner.nextLine() );
25 21 }
26 22 }
  @@ -28,17 +24,13 @@
28 24 }
29 25
30 26 private static void checkFileEntries( UserAgentFormFactor pExpected, String pFileNameWithUserAgentPerLine )
31 - throws IOException
32 - {
27 + throws IOException {
33 28 String[] zLines = readTextFile( new File( USER_AGENT_FILES_SUB_DIR, pFileNameWithUserAgentPerLine + ".txt" ) );
34 - for ( int i = 0; i < zLines.length; i++ )
35 - {
29 + for ( int i = 0; i < zLines.length; i++ ) {
36 30 String zLine = zLines[i].trim();
37 - if ( (zLine.length() != 0) && !zLine.startsWith( "!" ) )
38 - {
31 + if ( (zLine.length() != 0) && !zLine.startsWith( "!" ) ) {
39 32 UserAgentFormFactor zActual = FFD.determine( zLine );
40 - if ( zActual != pExpected )
41 - {
33 + if ( zActual != pExpected ) {
42 34 Assert.assertEquals( "From '" + pFileNameWithUserAgentPerLine + "[" + i + "]" + "': " + zLine, pExpected, zActual );
43 35 }
44 36 }
  @@ -46,18 +38,15 @@
46 38 }
47 39
48 40 private static void checkEntriesFromFiles( UserAgentFormFactor pExpected, String... pFileNamesWithUserAgentPerLine )
49 - throws IOException
50 - {
51 - for ( String zFileName : pFileNamesWithUserAgentPerLine )
52 - {
41 + throws IOException {
42 + for ( String zFileName : pFileNamesWithUserAgentPerLine ) {
53 43 checkFileEntries( pExpected, zFileName );
54 44 }
55 45 }
56 46
57 47 @Test
58 48 public void testDetermine()
59 - throws Exception
60 - {
49 + throws Exception {
61 50 checkEntriesFromFiles( UserAgentFormFactor.SingleViewOnly,
62 51 "iPhone",
63 52 "iPod",