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
import java.io.{ByteArrayOutputStream, ByteArrayInputStream} | |
import java.util.zip.{GZIPOutputStream, GZIPInputStream} | |
import scala.util.Try | |
object Gzip { | |
def compress(input: Array[Byte]): Array[Byte] = { | |
val bos = new ByteArrayOutputStream(input.length) | |
val gzip = new GZIPOutputStream(bos) |
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
import unfiltered.request._ | |
import unfiltered.response._ | |
import java.lang.Thread.sleep | |
trait FakeHttpServer { | |
private val CONTEXT_OAUTH2 = "/oauth2" | |
private val CONTEXT_SERVICE1 = "/service1" | |
private val DELAY = 500 |
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
def withMetrics[R](f: => R): (Long, R) = { | |
val t0 = System.currentTimeMillis() | |
val result = f | |
(System.currentTimeMillis() - t0, result) | |
} |
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 com.acervera.osm4scala.spark | |
import org.scalatest.matchers.should.Matchers | |
import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach} | |
import org.scalatest.wordspec.AnyWordSpec | |
class ScalaTestExecutionOrderSpec extends AnyWordSpec with Matchers with BeforeAndAfterAll with BeforeAndAfterEach { | |
override protected def beforeAll(): Unit = { | |
println("BEFORE ALL ...........") | |
super.beforeAll() |
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
import org.scalatest.{Matchers, WordSpecLike} | |
import scala.util.{Failure, Success, Try} | |
object ExceptionHandlingExamples { | |
case class CaseClass(a: Int, b: Int) | |
def parseUsingMatchOnTry(str: String): Either[String, CaseClass] = | |
str.split("_") match { |
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
# Ubuntu 18.04 and various Docker images such as openjdk:9-jdk throw exceptions when | |
# Java applications use SSL and HTTPS, because Java 9 changed a file format, if you | |
# create that file from scratch, like Debian / Ubuntu do. | |
# | |
# Before applying, run your application with the Java command line parameter | |
# java -Djavax.net.ssl.trustStorePassword=changeit ... | |
# to verify that this workaround is relevant to your particular issue. | |
# | |
# The parameter by itself can be used as a workaround, as well. |
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
import org.apache.spark.{SparkConf, SparkContext} | |
import org.scalatest.{BeforeAndAfterAll, Suite} | |
trait SparkTestSetup extends BeforeAndAfterAll { this: Suite => | |
// Overwrite if it is neccesary | |
def master = "local[4]" | |
def appName: String | |
def defaultSparkConf = new SparkConf().setAppName(appName).setMaster(master) |