This file contains hidden or 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.wixpress.report | |
| import com.fasterxml.jackson.databind.{DeserializationFeature, ObjectMapper} | |
| import com.fasterxml.jackson.datatype.guava.GuavaModule | |
| import com.fasterxml.jackson.module.scala.DefaultScalaModule | |
| import org.junit._ | |
| import Assert._ | |
| /** | |
| * @author: ittaiz |
This file contains hidden or 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 com.fasterxml.jackson.databind.{ObjectMapper, JsonNode} | |
| import scala.Some | |
| import org.specs2.mutable.SpecificationWithJUnit | |
| import com.fasterxml.jackson.module.scala.DefaultScalaModule | |
| class JsonNodeOptionDeserializerTest extends SpecificationWithJUnit { | |
| "Option[JsonNode] " should { | |
| "serialize its content when contained in an object" in { | |
| val mapper = new ObjectMapper().registerModule(DefaultScalaModule) | |
| val json: String = """{"prop":"value"}""" |
This file contains hidden or 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
| @Test | |
| public void cancellingAScheduledFutureWhileItIsRunningProhibitsItFromRunningJMock() throws InterruptedException { | |
| final CountDownLatch scheduledHasStarted = new CountDownLatch(1); | |
| final CountDownLatch scheduledHasBeenCancelled = new CountDownLatch(1); | |
| final AtomicInteger counter = new AtomicInteger(); | |
| DeterministicScheduler deterministicScheduler = new DeterministicScheduler(); | |
| final ScheduledFuture<?> scheduledFuture = deterministicScheduler.scheduleAtFixedRate(new Runnable() { | |
| @Override | |
| public void run() { | |
| scheduledHasStarted.countDown(); |
This file contains hidden or 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
| @Test | |
| public void cancellingAScheduledFutureWhileItIsRunningHasNoEffect() { | |
| DeterministicScheduler deterministicScheduler = new DeterministicScheduler(); | |
| SchedulerContainer schedulerContainer = new SchedulerContainer(deterministicScheduler); | |
| schedulerContainer.scheduleSelfCancellingTask(); | |
| deterministicScheduler.tick(2,TimeUnit.SECONDS); | |
| assertThat(schedulerContainer.runCount(), is(1)); | |
| } | |
| public static class SchedulerContainer { |
This file contains hidden or 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 com.fasterxml.jackson.databind.ObjectMapper; | |
| import com.fasterxml.jackson.module.scala.DefaultScalaModule; | |
| import org.junit.Test; | |
| import java.io.IOException; | |
| import static org.hamcrest.MatcherAssert.assertThat; | |
| import static org.hamcrest.core.Is.is; | |
| public class JacksonRegressionTest { | |
| @Test | |
| public void jacksonRegressionTest() throws IOException { | |
| SomeException ex = new SomeException("message"); |
This file contains hidden or 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
| Apache Maven 3.3.1 (cab6659f9874fa96462afef40fcf6bc033d58c1c; 2015-03-13T22:10:27+02:00) | |
| Maven home: /usr/local/Cellar/maven/3.3.1/libexec | |
| Java version: 1.7.0_71, vendor: Oracle Corporation | |
| Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre | |
| Default locale: en_US, platform encoding: UTF-8 | |
| [DEBUG] Reading global settings from /usr/local/Cellar/maven/3.3.1/libexec/conf/settings.xml | |
| [DEBUG] Reading user settings from /Users/ittaiz/.m2/settings.xml | |
| [DEBUG] Using manager EnhancedLocalRepositoryManager with priority 10.0 for /Users/ittaiz/.m2/repository | |
| [DEBUG] Dependency collection stats: {ConflictMarker.analyzeTime=1, ConflictMarker.markTime=0, ConflictMarker.nodeCount=20, ConflictIdSorter.graphTime=0, ConflictIdSorter.topsortTime=1, ConflictIdSorter.conflictIdCount=11, ConflictIdSorter.conflictIdCycleCount=0, ConflictResolver.totalTime=3, ConflictResolver.conflictItemCount=19, DefaultDependencyCollector.collectTime=125, DefaultDependencyCollector.transformTime=6} | |
| [DEBUG] io.takari.poly |
This file contains hidden or 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
| private class ShutdownAllowingDeterministicScheduler extends DeterministicScheduler { | |
| override def isShutdown: Boolean = shutdownRequested | |
| override def isTerminated: Boolean = shutdownRequested | |
| override def shutdown(): Unit = shutdownRequested = true | |
| override def shutdownNow: util.List[Runnable] = new util.ArrayList[Runnable] | |
| var shutdownRequested: Boolean = false |
This file contains hidden or 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
| <?xml version="1.0" encoding="UTF-8"?> | |
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
| <modelVersion>4.0.0</modelVersion> | |
| <groupId>org.specs2</groupId> | |
| <artifactId>specs2_2.11</artifactId> | |
| <version>3.5</version> | |
| <name>Specs2 includes</name> | |
| <packaging>pom</packaging> | |
| <dependencies> | |
| <dependency> |
This file contains hidden or 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
| class FruitTest extends SpecificationWithJUnit { | |
| trait Fruit | |
| case class Apple(color: String) extends Fruit | |
| case class Peach(ripeness: Double) extends Fruit | |
| def aColorfulApple(color: String): Matcher[Fruit] = { | |
| val appleMatcher: Matcher[Apple] = be_===(color) ^^ { a: Apple => | |
| a.color aka "apple color" |
This file contains hidden or 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 _scala_import_impl(ctx): | |
| code_jars = _filter_out_non_code_jars(ctx.attr.jar.files) | |
| code_jars_depset = depset(code_jars) | |
| return struct( | |
| scala = struct( | |
| outputs = struct( | |
| ijar = None, | |
| class_jar = code_jars[0], | |
| ), | |
| ), |