Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Styx tests should pass in windows #101

Merged
merged 10 commits into from
Mar 15, 2018
Prev Previous commit
Next Next commit
DISP-1419: fixing failing tests in Windows. "e2e" tests fixed. We sti…
…ll need to fix the issue with FileBackedRegistry.readFile() not closing the inputstream.
  • Loading branch information
a-dlatorre committed Mar 14, 2018
commit 5591c196165510adba45b4cc5eef89a6694a57a8
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
*/
package com.hotels.styx

import com.hotels.styx.infrastructure.{RegistryServiceAdapter, MemoryBackedRegistry}
import java.nio.file.Paths

import com.hotels.styx.infrastructure.{MemoryBackedRegistry, RegistryServiceAdapter}
import com.hotels.styx.plugins.PluginPipelineSpec
import com.hotels.styx.support.{ImplicitStyxConversions, configuration}
import com.hotels.styx.support.configuration.{ImplicitOriginConversions, StyxBackend, StyxBaseConfig}
import com.hotels.styx.support.{ImplicitStyxConversions, configuration}
import org.scalatest._


Expand All @@ -42,7 +44,7 @@ trait StyxProxySpec extends StyxClientSupplier

def resourcesPluginsPath: String = {
val url = classOf[PluginPipelineSpec].getClassLoader.getResource("plugins")
url.getPath
Paths.get(url.toURI).toString
}

override protected def beforeAll() = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class FormUrlEncodedDataSpec extends FunSpec with StyxProxySpec with Eventually
.build()
val resp = decodedRequest(request)
assert(resp.status() == OK)
assert(resp.bodyAs(UTF_8) == "app: bar\nversion: 54.0")
assert(resp.bodyAs(UTF_8) == s"app: bar${System.lineSeparator()}version: 54.0")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class PluginToggleSpec extends FunSpec with StyxProxySpec with StyxClientSupplie
resp2.status() should be (OK)
resp2.bodyAs(UTF_8) should include("response-from-plugin")

checkPluginEnabled() should be("enabled\n")
checkPluginEnabled() should be("enabled${System.lineSeparator}")
}

override protected def afterAll(): Unit = {
Expand Down Expand Up @@ -79,17 +79,17 @@ class PluginToggleSpec extends FunSpec with StyxProxySpec with StyxClientSupplie
disablePlugin()

val outcome = setPluginEnabled("true")
outcome should be("{\"message\":\"State of 'pluginUnderTest' changed to 'enabled'\",\"plugin\":{\"name\":\"pluginUnderTest\",\"state\":\"enabled\"}}\n")
checkPluginEnabled() should be("enabled\n")
outcome should be("{\"message\":\"State of 'pluginUnderTest' changed to 'enabled'\",\"plugin\":{\"name\":\"pluginUnderTest\",\"state\":\"enabled\"}}${System.lineSeparator}")
checkPluginEnabled() should be("enabled${System.lineSeparator}")
}
}

private def disablePlugin() = {
val outcome = setPluginEnabled("false")

outcome should be("{\"message\":\"State of 'pluginUnderTest' changed to 'disabled'\",\"plugin\":{\"name\":\"pluginUnderTest\",\"state\":\"disabled\"}}\n")
outcome should be("{\"message\":\"State of 'pluginUnderTest' changed to 'disabled'\",\"plugin\":{\"name\":\"pluginUnderTest\",\"state\":\"disabled\"}}${System.lineSeparator}")

checkPluginEnabled() should be("disabled\n")
checkPluginEnabled() should be("disabled${System.lineSeparator}")
}

private def setPluginEnabled(enabled : String): String = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (C) 2013-2017 Expedia Inc.
* Copyright (C) 2013-2018 Expedia Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -22,14 +22,14 @@ import com.google.common.base.Charsets.{US_ASCII, UTF_8}
import com.google.common.net.HostAndPort
import com.hotels.styx.StyxProxySpec
import com.hotels.styx.api.HttpHeaderNames.{CONTENT_TYPE, HOST}
import com.hotels.styx.client.StyxHeaderConfig.STYX_INFO_DEFAULT
import com.hotels.styx.support.matchers.LoggingEventMatcher.loggingEvent
import com.hotels.styx.support.matchers.RegExMatcher.matchesRegex
import com.hotels.styx.support.matchers.{LoggingTestSupport, RegExMatcher}
import com.hotels.styx.api.metrics.HttpErrorStatusCauseLogger
import com.hotels.styx.client.StyxHeaderConfig.STYX_INFO_DEFAULT
import com.hotels.styx.support.TestClientSupport
import com.hotels.styx.support.configuration.{HttpBackend, Origins, ProxyConfig, StyxConfig}
import com.hotels.styx.support.backends.FakeHttpServer
import com.hotels.styx.support.configuration.{HttpBackend, Origins, ProxyConfig, StyxConfig}
import com.hotels.styx.support.matchers.LoggingEventMatcher.loggingEvent
import com.hotels.styx.support.matchers.LoggingTestSupport
import com.hotels.styx.support.matchers.RegExMatcher.matchesRegex
import com.hotels.styx.utils.HttpTestClient
import io.netty.buffer.Unpooled
import io.netty.channel.{Channel, ChannelInitializer}
Expand Down Expand Up @@ -133,7 +133,7 @@ class BadRequestsSpec extends FunSpec
assert(response.status == BAD_REQUEST, s"\nExpecting 400 Bad Request in message: \n$response \n\n$content\n\n")
assertThat(response.headers().get(STYX_INFO_DEFAULT), matchesRegex("noJvmRouteSet;"))

assertThat(loggingSupport.log(), hasItem(loggingEvent(ERROR, "Failure status=\"400 Bad Request\"", "io.netty.handler.codec.DecoderException", "com.hotels.styx.server.BadRequestException: Bad Host header. .*")))
assertThat(loggingSupport.log(), hasItem(loggingEvent(ERROR, "Failure status=\"400 Bad Request\"", "io.netty.handler.codec.DecoderException", "com.hotels.styx.server.BadRequestException: Bad Host header.*")))
}
}

Expand Down Expand Up @@ -173,7 +173,7 @@ class BadRequestsSpec extends FunSpec
val content = response.content().toString(UTF_8)
assert(response.status == REQUEST_TIMEOUT, s"\nExpecting 408 Request Timeout in message: \n$response \n\n$content\n\n")
assertThat(response.headers().get(STYX_INFO_DEFAULT), matchesRegex("noJvmRouteSet;[0-9a-f-]+"))
assertThat(loggingSupport.log(), hasItem(loggingEvent(ERROR, "Failure status=\"408 Request Timeout\"", "com.hotels.styx.server.RequestTimeoutException", "message=DefaultHttpRequest.decodeResult: success..*")))
assertThat(loggingSupport.log(), hasItem(loggingEvent(ERROR, "Failure status=\"408 Request Timeout\"", "com.hotels.styx.server.RequestTimeoutException", "message=DefaultHttpRequest.decodeResult: success.*")))
}
}
}
Expand Down