• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Java весна 2013 лекция 5
 

Java весна 2013 лекция 5

on

  • 324 views

 

Statistics

Views

Total Views
324
Views on SlideShare
287
Embed Views
37

Actions

Likes
0
Downloads
3
Comments
0

2 Embeds 37

https://tech-mail.ru 36
http://tp.mail.ru 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Java весна 2013 лекция 5 Java весна 2013 лекция 5 Presentation Transcript

    • public class simpleTest { @Before public void setUp() throws Exception { } @After public void tearDown() throws Exception { } @Test public void test() { fail("Not yet implemented"); } }
    • public class Math { private int a; private int b; public Math (int a, int b) { this.a = a; this.b = b; } public int getSum() { return this.a + this.b; } public int getDiv() { return this.a / this.b; } } public class simpleTest { private Math math; private int a = 3; private int b = 0; @Before public void setUp() throws Exception { math = new Math(a, b); } @Test public void testGood() { assertEqual(a+b, math.getSum()); } @Test public void testBad() { assertEqual(a/b, math.getDiv()); }
    • public void testLogin(@NotNull String url,@NotNull String username,@NotNull String password) { } WebDriver driver = new HtmlUnitDriver(true); driver.get(url); // Find the text input element by its name WebElement element = driver.findElement(By.name(“userName")); element.sendKeys(username); WebElement element = driver.findElement(By.name(“password")); element.sendKeys(password); // Now submit the form. WebDriver will find the form for us from the element element.submit(); // Wait for the page to load, timeout after 10 seconds (new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() { @Override @NotNull public Boolean apply(@NotNull WebDriver d) { final int id = d.findElement(By.name(“id”)); return id != 0; } }); driver.quit();
    • public void testLogin(…) public void moveRandom(…) public void stop(…) public void shoot(…) public void wait(…) public void suicide(…)
    • private Map<Integer, Avatar> avatars = new HashMap<>(); public final int getTotalAvatars() { return avatars.size(); }
    • public void run () { while(True) { msgSystem.execForAbonent(this); Thread.sleep(100); } } private static int TICK_TIME = 100; public void run () { while(True) { long startTime = System.currentTimeMillis(); msgSystem.execForAbonent(this); int deltaTime = System.currentTimeMillis() - startTime; float load = deltaTime / TICK_TIME; if (load < 1) Thread.sleep( TICK_TIME - deltaTime ); } }
    • long free = Runtime.getRuntime().freeMemory(); long max = Runtime.getRuntime().maxMemory();
    • jvisualvm входит в JDK