Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adding routing changes for 1.6 and trying to get http proxying transp…

…arently
  • Loading branch information...
commit 54336fee601e27c7026dae8c320c563bbcb1e7cf 1 parent 1eec721
@hyperthunk authored
View
20 axiom-integration-test/src/test/resources/ruby/integration/http_routes.rb
@@ -26,10 +26,13 @@
#
require 'java'
+require 'uri'
require 'axiom'
require 'axiom/plugins'
require 'axiom/core/processor'
+import org.apache.camel.component.http.HttpProducer
+
route do
# the global request log
@@ -50,10 +53,21 @@
intercept(is_not(valid_schema?(xsd_file))).
to("file://#{invalid_schema_log}")
- from("jetty:http://#{config >> 'http.test.inbound.uri'}").
+ in_uri = URI.parse("jetty:http://#{config >> 'http.test.inbound.uri'}")
+ in_context_path = in_uri.path
+
+ out_uri = URI.parse("http://#{config >> 'http.test.outbound.uri'}")
+ out_context_path = out_uri.path
+
+ from(in_uri.to_s).
process(Axiom::Core::Processor.new do |ex|
- ex.out.headers['foobar'] = ex.request.getRequestURI
- end).to("http://#{config >> 'http.test.outbound.uri'}")
+ logger.warn("EXCHANGE INFO: " + ex.inspect)
+ logger.warn("CHANNEL INFO: " + ex.in.inspect)
+ logger.warn("HTTP INFO: " + ex.in.getExchange())
+ url = "foobar"
+ context_path = url.sub(/#{in_context_path}/, out_context_path)
+ ex.out.headers[HttpProducer.HTTP_URI] = 'nil'
+ end).to(out_uri.to_s)
# outbound_route = "http://#{config >> 'http.test.outbound.uri'}"
View
73 axiom-integration-test/src/test/resources/ruby/integration/http_routing_spec.rb
@@ -101,47 +101,48 @@ def invalid_request_log
rm config >> 'http.test.data.schema.file', :force => true, :verbose => true
end
- it "should spool up an http endpoint listening on the given port" do
- http_interaction inbound_uri, '<request />' do |response|
- response.code.to_i.should eql(200)
- end
- end
+# it "should spool up an http endpoint listening on the given port" do
+# http_interaction inbound_uri, '<request />' do |response|
+# response.code.to_i.should eql(200)
+# end
+# end
it "should transparently pass on any additional uri path components" do
- http_interaction inbound_uri + "/foo/bar", '<request />' do |response|
+ extended_uri = URI.parse("http://#{config >> 'http.test.inbound.uri'}/foo/bar")
+ http_interaction extended_uri, '<request />' do |response|
response.code.to_i.should eql(200)
end
end
- it "should forward incoming requests to the specified outbound http endpoint" do
- timeout = 25 # seconds
- # Ping.pingecho(@listener.host, timeout, @listener.port).should be_true
- post_data=<<-EOF
- <request>
- <data />
- </request>
- EOF
- post_data.strip!
- http_interaction inbound_uri, post_data
- request = @requests.pop
- request.body.should =~ /#{post_data}/ # the final newline is stripped by the server
- end
-
- it "should route schema compliant messages to the outbound channel directly" do
- data=<<-EOF
- <request id='foo' />
- EOF
- data.lstrip!
- http_interaction inbound_uri, data
- fail_entries = File.readlines invalid_request_log
- fail_entries.find { |e| e =~ /#{data}/ }.should be_nil
- end
-
- it "should fail and stop routing non-compliant messages" do
- invalid_payload = "<foo><bar /></foo>\n";
- http_interaction inbound_uri, invalid_payload
- fail_entries = File.readlines invalid_request_log
- fail_entries.should include(invalid_payload)
- end
+# it "should forward incoming requests to the specified outbound http endpoint" do
+# timeout = 25 # seconds
+# # Ping.pingecho(@listener.host, timeout, @listener.port).should be_true
+# post_data=<<-EOF
+# <request>
+# <data />
+# </request>
+# EOF
+# post_data.strip!
+# http_interaction inbound_uri, post_data
+# request = @requests.pop
+# request.body.should =~ /#{post_data}/ # the final newline is stripped by the server
+# end
+#
+# it "should route schema compliant messages to the outbound channel directly" do
+# data=<<-EOF
+# <request id='foo' />
+# EOF
+# data.lstrip!
+# http_interaction inbound_uri, data
+# fail_entries = File.readlines invalid_request_log
+# fail_entries.find { |e| e =~ /#{data}/ }.should be_nil
+# end
+#
+# it "should fail and stop routing non-compliant messages" do
+# invalid_payload = "<foo><bar /></foo>\n";
+# http_interaction inbound_uri, invalid_payload
+# fail_entries = File.readlines invalid_request_log
+# fail_entries.should include(invalid_payload)
+# end
end
View
8 axiom-integration-test/src/test/resources/ruby/integration/spec_helper.rb
@@ -28,6 +28,9 @@
require 'axiom'
require 'webrick'
+require "uri"
+uri = URI.parse "http://0.0.0.0:10001/test/inbound"
+
module HTTPTestListener
def start_http! uri, &block
@@ -54,9 +57,12 @@ module HTTPSpecSupport
include HTTPTestListener
def http_interaction uri, post_data, headers={'Content-Type' => 'text/xml'}
+ logger.debug("host=#{uri.host}")
+ logger.debug("port=#{uri.port}")
+ logger.debug("path=#{uri.path}")
Net::HTTP.start(uri.host, uri.port) do |http|
response = http.post(uri.path, post_data, headers)
- logger.debug("response = " + response)
+ logger.debug("response = " + response.to_s)
yield response if block_given?
end
end

0 comments on commit 54336fe

Please sign in to comment.
Something went wrong with that request. Please try again.