homebrew-core/Formula/mockserver.rb

41 lines
1.1 KiB
Ruby

class Mockserver < Formula
desc "Mock HTTP server and proxy"
homepage "https://www.mock-server.com/"
url "https://oss.sonatype.org/content/repositories/releases/org/mock-server/mockserver-netty/5.9.0/mockserver-netty-5.9.0-brew-tar.tar"
sha256 "ecf19a5be2f7f960cd050df06b780d41c9186d155559d2d6de0c256ea7bca722"
revision 1
bottle :unneeded
depends_on "openjdk"
def install
libexec.install Dir["*"]
(bin/"mockserver").write_env_script libexec/"bin/run_mockserver.sh", :JAVA_HOME => Formula["openjdk"].opt_prefix
lib.install_symlink "#{libexec}/lib" => "mockserver"
mockserver_log = var/"log/mockserver"
mockserver_log.mkpath
libexec.install_symlink mockserver_log => "log"
end
test do
port = free_port
mockserver = fork do
exec "#{bin}/mockserver", "-serverPort", port.to_s
end
loop do
Utils.popen_read("curl", "-s", "http://localhost:#{port}/status", "-X", "PUT")
break if $CHILD_STATUS.exitstatus.zero?
end
system "curl", "-s", "http://localhost:#{port}/stop", "-X", "PUT"
Process.wait(mockserver)
end
end