Your SlideShare is downloading. ×
Java весна 2013 лекция 5
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

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

256
views

Published on

Published in: Technology, Education

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
256
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. public class simpleTest { @Before public void setUp() throws Exception { } @After public void tearDown() throws Exception { } @Test public void test() { fail("Not yet implemented"); } }
  • 2. 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()); }
  • 3. 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();
  • 4. public void testLogin(…) public void moveRandom(…) public void stop(…) public void shoot(…) public void wait(…) public void suicide(…)
  • 5. private Map<Integer, Avatar> avatars = new HashMap<>(); public final int getTotalAvatars() { return avatars.size(); }
  • 6. 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 ); } }
  • 7. long free = Runtime.getRuntime().freeMemory(); long max = Runtime.getRuntime().maxMemory();
  • 8. jvisualvm входит в JDK

×