Advertisement
Guest User

Untitled

a guest
Apr 15th, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. package org.openchs
  2.  
  3. import java.util.concurrent.{ExecutorService, Executors}
  4.  
  5. import faker._
  6. import org.scalatest.{FlatSpec, Matchers}
  7. import scalikejdbc._
  8.  
  9. class PostgreSQLTest extends FlatSpec with Matchers {
  10. GlobalSettings.loggingSQLAndTime = LoggingSQLAndTimeSettings(
  11. enabled = false,
  12. singleLineMode = false,
  13. printUnprocessedStackTrace = false,
  14. stackTraceDepth = 15,
  15. logLevel = 'error,
  16. warningEnabled = false,
  17. warningThresholdMillis = 3000L,
  18. warningLogLevel = 'error
  19. )
  20. val pool: ExecutorService = Executors.newFixedThreadPool(3)
  21.  
  22. Class.forName("org.postgresql.Driver")
  23. ConnectionPool.singleton("jdbc:postgresql:dbtest", "mihir", "")
  24.  
  25. "Insert all Data" should "Should populate database" in {
  26. (1 to 33000000).par.map(id => {
  27. implicit val session = AutoSession
  28. sql"INSERT INTO patient VALUES(${id},${id.toString}, ${Name.first_name}, ${Name.first_name}, ${Name.last_name}, '2015-01-01')".update.apply()
  29. session.close()
  30. })
  31. (1 to 10000).par.map(id => {
  32. implicit val session = AutoSession
  33. sql"INSERT INTO provider VALUES(${id}, ${id.toString}, ${Name.first_name}, ${Name.first_name}, ${Name.last_name}, '2015-01-01')"
  34. .update.apply()
  35. sql"INSERT INTO facility VALUES(${id}, ${Name.first_name})".update.apply()
  36. session.close()
  37. })
  38. (1 to 1000000).par.map(id => {
  39. implicit val session = AutoSession
  40. (1 to 1000).par.map(sid => sql"INSERT INTO bulk_data VALUES(${id * sid}, ${id}, ${sid}, ${Name.first_name})".update.apply())
  41. session.close()
  42. })
  43. }
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement