Skip to content

Commit c62079e

Browse files
craigtavernerSaschaPeukert
authored andcommitted
Use PortAuthority for LoadCSV tests
1 parent 12b7d45 commit c62079e

1 file changed

Lines changed: 5 additions & 14 deletions

File tree

community/cypher/cypher/src/test/scala/org/neo4j/cypher/HttpServerTestSupport.scala

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,24 @@ import com.sun.net.httpserver.{HttpExchange, HttpHandler, HttpServer}
2323
import java.net.{InetAddress, InetSocketAddress}
2424
import java.io.IOException
2525
import java.util.concurrent.Executors
26+
27+
import org.neo4j.ports.allocation.PortAuthority
28+
2629
import scala.collection.mutable
2730

2831
trait HttpServerTestSupport {
2932
def boundInfo: InetSocketAddress
3033
def start()
31-
def restart()
3234
def stop()
3335
}
3436

3537
class HttpServerTestSupportBuilder {
36-
val ASK_OS_TO_PROVIDE_A_PORT = 0
37-
private var port = ASK_OS_TO_PROVIDE_A_PORT
38+
private val port = PortAuthority.allocatePort
3839
private var allowedMethods: Set[String] = Set()
3940
private val mapping = new mutable.HashMap[String, (HttpExchange => Unit)]()
4041
private val filters = new mutable.HashMap[String, (HttpExchange => Boolean)]()
4142
private val transformations = new mutable.HashMap[String, (HttpExchange => HttpExchange)]()
4243

43-
def withPort(newPort: Int) {
44-
assert(newPort >= 0 && newPort < 65536)
45-
port = newPort
46-
}
47-
4844
def onPathReplyWithData(path: String, data: Array[Byte]) {
4945
assert(path != null && !path.isEmpty)
5046
assert(data != null)
@@ -108,7 +104,7 @@ class HttpServerTestSupportBuilder {
108104

109105
val path = exchange.getRequestURI.getPath
110106
if (mapping.contains(path)) {
111-
if (filters.getOrElse(path, {_: HttpExchange => true})(exchange)) {
107+
if (filters.getOrElse(path, { _: HttpExchange => true })(exchange)) {
112108
val reply = transformations.getOrElse(path, identity[HttpExchange](_))(exchange)
113109
mapping(path)(reply)
114110
}
@@ -122,11 +118,6 @@ class HttpServerTestSupportBuilder {
122118
server.start()
123119
}
124120

125-
def restart(): Unit = {
126-
stop()
127-
start()
128-
}
129-
130121
def stop() {
131122
optServer.foreach(server => server.stop(0))
132123
}

0 commit comments

Comments
 (0)