Created
February 18, 2013 08:26
-
-
Save stden/4975884 to your computer and use it in GitHub Desktop.
Пример чтения параметров из файла (тест)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package converttodb; | |
import org.junit.Test; | |
import java.io.FileNotFoundException; | |
import java.io.UnsupportedEncodingException; | |
import static junit.framework.Assert.assertEquals; | |
/** | |
* Разбор файла с параметрами конкретного мобильного телефона | |
*/ | |
public class DeviceParamsParseTest { | |
/** | |
* Пример, как читать параметры устройства из файла | |
*/ | |
@Test | |
public void parseAppleIPad() throws FileNotFoundException, UnsupportedEncodingException { | |
// Вызываем класс DeviceParams и передаём в как параметр конструктора имя файла входного файла | |
DeviceParams device = new DeviceParams("mobile\\info\\Apple\\Apple iPad 2 Wi-Fi.txt"); | |
// Когда конструктор отработал, поля в объекте заполнены значениями из файла | |
assertEquals("Apple iPad 2 Wi-Fi", device.name); | |
assertEquals("Tablet", device.deviceType); | |
assertEquals("iOS (6, 5.1, 5, 4.x)", device.OS); | |
assertEquals("9.50 x 7.31 x 0.34 inches (241.2 x 185.7 x 8.8 mm)", device.Dimensions); | |
assertEquals("21.20 oz (601 g)", device.Weight); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment