All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hyperscala.web.StressTester.scala Maven / Gradle / Ivy

There is a newer version: 0.9.0
Show newest version
package org.hyperscala.web

import java.net.URL
import org.powerscala.concurrent.{Time, AtomicInt, Executor}

/**
 * @author Matt Hicks 
 */
object StressTester {
  def connect() = {
    val url = new URL("http://localhost:8080/privacy.html")
    val connection = url.openConnection()
    if (connection.getContentType != "text/html") {
      println("Unexpected content type: %s".format(connection.getContentType))
    }
  }

  def main(args: Array[String]): Unit = {
    val increment = new AtomicInt(0)
    (0 until 500).foreach {
      case index => Executor.invoke {
        println("connecting %s".format(index))
        connect()
        increment.addAndGet(1)
      }
    }
    Time.waitFor(Double.MaxValue) {
      increment.get() == 500
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy