sapnwrfc 0.23-i686-linux → 0.24-i686-linux

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/ruby
2
+ $:.unshift(File.dirname(__FILE__) + '/lib')
3
+ $:.unshift(File.dirname(__FILE__) + '/ext/nwsaprfc')
4
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
5
+ $:.unshift(File.dirname(__FILE__) + '/../ext/nwsaprfc')
6
+
7
+ require 'sapnwrfc'
8
+
9
+ $ITER = 50
10
+ $TEST_FILE = ENV.has_key?('SAP_YML') ? ENV['SAP_YML'] : 'sap.yml'
11
+
12
+ require 'test/unit'
13
+ require 'test/unit/assertions'
14
+
15
+ class SAPFunctionsTest < Test::Unit::TestCase
16
+ def setup
17
+ #SAP_LOGGER.warn "Current DIR: #{Dir.pwd}\n"
18
+ if FileTest.exists?($TEST_FILE)
19
+ SAPNW::Base.config_location = $TEST_FILE
20
+ else
21
+ SAPNW::Base.config_location = 'test/' + $TEST_FILE
22
+ end
23
+ SAPNW::Base.load_config
24
+ #SAP_LOGGER.warn "program: #{$0}\n"
25
+ end
26
+
27
+ def test_BASIC_00010_Function_LookUp
28
+ $ITER.to_i.times do
29
+ begin
30
+ assert(conn = SAPNW::Base.rfc_connect)
31
+ attrib = conn.connection_attributes
32
+ #SAP_LOGGER.warn "Connection Attributes: #{attrib.inspect}\n"
33
+ fd = conn.discover("RFC_READ_TABLE")
34
+ assert(fd.name == "RFC_READ_TABLE")
35
+ f = fd.new_function_call
36
+ #SAP_LOGGER.warn "FunctionDescriptor: #{fd.inspect}\n"
37
+ #SAP_LOGGER.warn "FunctionDescriptor parameters: #{fd.parameters.inspect}\n"
38
+ assert(fd.parameters.has_key?("QUERY_TABLE"))
39
+ assert(f.name == "RFC_READ_TABLE")
40
+ #SAP_LOGGER.warn "FunctionCall: #{f.inspect}\n"
41
+ assert(conn.close)
42
+ rescue SAPNW::RFC::ConnectionException => e
43
+ SAP_LOGGER.warn "ConnectionException ERROR: #{e.inspect} - #{e.error.inspect}\n"
44
+ end
45
+ end
46
+ GC.start
47
+ end
48
+
49
+ def test_BASIC_00020_Function_LookUp_Volume
50
+ $ITER.to_i.times do
51
+ assert(conn = SAPNW::Base.rfc_connect)
52
+ ["STFC_CHANGING", "STFC_XSTRING", "RFC_READ_TABLE", "RFC_READ_REPORT", "RPY_PROGRAM_READ", "RFC_PING", "RFC_SYSTEM_INFO"].each do |f|
53
+ fd = conn.discover(f)
54
+ assert(fd.name == f)
55
+ #SAP_LOGGER.warn "FunctionDescriptor: #{fd.inspect}\n"
56
+ #SAP_LOGGER.warn "FunctionDescriptor parameters: #{fd.parameters.inspect}\n"
57
+ c = fd.new_function_call
58
+ #SAP_LOGGER.warn "Function Name: #{c.name}\n"
59
+ assert(c.name == f)
60
+ end
61
+ GC.start
62
+ end
63
+ end
64
+
65
+ def teardown
66
+ end
67
+ end
@@ -0,0 +1,65 @@
1
+ $:.unshift(File.dirname(__FILE__) + '/lib')
2
+ $:.unshift(File.dirname(__FILE__) + '/ext/nwsaprfc')
3
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
4
+ $:.unshift(File.dirname(__FILE__) + '/../ext/nwsaprfc')
5
+
6
+ require 'sapnwrfc'
7
+
8
+ $TEST_FILE = 'test_sap_logger.log'
9
+ require 'fileutils'
10
+
11
+ require 'test/unit'
12
+ require 'test/unit/assertions'
13
+
14
+ class SAPLoggerTest < Test::Unit::TestCase
15
+
16
+
17
+ def setup
18
+ SAP_LOGGER.set_logdev($TEST_FILE)
19
+ #SAP_LOGGER.warn "program: #{$0}\n"
20
+ end
21
+
22
+ # The different ways of connecting to SAP
23
+ def get_log
24
+ log = File.open($TEST_FILE) { |f| f.gets(nil) }
25
+ #SAP_LOGGER.warn log
26
+ return log
27
+ end
28
+
29
+ def log_lines
30
+ lines = get_log.split(/\n/)
31
+ #SAP_LOGGER.warn lines.inspect
32
+ return lines
33
+ end
34
+
35
+ def test_BASIC_00010_All_Messages
36
+ assert( SAP_LOGGER.info("an info") )
37
+ assert( SAP_LOGGER.warn("a warning") )
38
+ assert( SAP_LOGGER.error("an error") )
39
+ assert( SAP_LOGGER.fatal("a fatal") )
40
+ assert( SAP_LOGGER.unknown("an unknown") )
41
+ assert( FileTest.exists?($TEST_FILE) )
42
+ #$stderr.print "lines: #{log_lines.length}\n"
43
+ assert( log_lines.length >= 5 ) # one for each log entry and a header
44
+ end
45
+
46
+ def test_BASIC_00020_Above_Warn
47
+ SAP_LOGGER.level = Logger::WARN
48
+ assert( SAP_LOGGER.info("an info") )
49
+ assert( SAP_LOGGER.warn("a warning") )
50
+ assert( SAP_LOGGER.error("an error") )
51
+ assert( SAP_LOGGER.fatal("a fatal") )
52
+ assert( SAP_LOGGER.unknown("an unknown") )
53
+ assert( FileTest.exists?($TEST_FILE) )
54
+ #$stderr.print "lines: #{log_lines.length}\n"
55
+ assert( log_lines.length >= 5 ) # one for each log entry >= WARN and a header
56
+ end
57
+
58
+ def teardown
59
+ if FileTest.exists?($TEST_FILE)
60
+ SAP_LOGGER.set_logdev(STDERR) # Unlock the log file before deletion
61
+ GC.start # Ensure garbage colletion is run (unlock)
62
+ File.delete($TEST_FILE)
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/ruby
2
+ $KCODE = 'u'
3
+ $:.unshift(File.dirname(__FILE__) + '/lib')
4
+ $:.unshift(File.dirname(__FILE__) + '/ext/nwsaprfc')
5
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
6
+ $:.unshift(File.dirname(__FILE__) + '/../ext/nwsaprfc')
7
+
8
+ require 'sapnwrfc'
9
+
10
+ $TEST_FILE = ENV.has_key?('SAP_YML') ? ENV['SAP_YML'] : 'sap.yml'
11
+
12
+ require 'test/unit'
13
+ require 'test/unit/assertions'
14
+
15
+ class SAPSFlightTest < Test::Unit::TestCase
16
+ def setup
17
+ #SAP_LOGGER.warn "Current DIR: #{Dir.pwd}\n"
18
+ if FileTest.exists?($TEST_FILE)
19
+ SAPNW::Base.config_location = $TEST_FILE
20
+ else
21
+ SAPNW::Base.config_location = 'test/' + $TEST_FILE
22
+ end
23
+ SAPNW::Base.load_config
24
+ #SAP_LOGGER.warn "program: #{$0}\n"
25
+ end
26
+
27
+ def test_BASIC_00010_Test_Data
28
+ assert(conn = SAPNW::Base.rfc_connect)
29
+ attrib = conn.connection_attributes
30
+ #SAP_LOGGER.warn "Connection Attributes: #{attrib.inspect}\n"
31
+ fld = conn.discover("BAPI_FLIGHT_GETLIST")
32
+ flgd = conn.discover("BAPI_FLIGHT_GETDETAIL")
33
+ fl = fld.new_function_call
34
+ fl.AIRLINE = "AA "
35
+ fl.invoke
36
+ fl.FLIGHT_LIST.each do |row|
37
+ SAP_LOGGER.debug "row: #{row.inspect}\n"
38
+ flg = flgd.new_function_call
39
+ flg.AIRLINEID = row['AIRLINEID']
40
+ flg.CONNECTIONID = row['CONNECTID']
41
+ flg.FLIGHTDATE = row['FLIGHTDATE']
42
+ flg.invoke
43
+ SAP_LOGGER.debug "\tflight data: #{flg.FLIGHT_DATA.inspect}\n"
44
+ SAP_LOGGER.debug "\tadditional info: #{flg.ADDITIONAL_INFO.inspect}\n"
45
+ SAP_LOGGER.debug "\tavailability: #{flg.AVAILIBILITY.inspect}\n"
46
+ end
47
+ fd = conn.discover("BAPI_FLBOOKING_CREATEFROMDATA")
48
+ assert(fd.name == "BAPI_FLBOOKING_CREATEFROMDATA")
49
+ f = fd.new_function_call
50
+ assert(f.name == "BAPI_FLBOOKING_CREATEFROMDATA")
51
+ f.BOOKING_DATA = { 'AIRLINEID' => "AA ", 'CONNECTID' => "0001", 'FLIGHTDATE' => "20070130", 'CLASS' => "F", 'CUSTOMERID' => "00000001", 'AGENCYNUM' => '00000093' }
52
+ begin
53
+ f.invoke
54
+ rescue SAPNW::RFC::FunctionCallException => e
55
+ SAP_LOGGER.warn "FunctionCallException: #{e.error.inspect}\n"
56
+ raise "gone"
57
+ end
58
+ f.RETURN.each do |row|
59
+ SAP_LOGGER.debug "row: #{row.inspect}\n"
60
+ end
61
+ SAP_LOGGER.debug "PRICE: #{f.TICKET_PRICE.inspect}\n"
62
+ cd = conn.discover("BAPI_TRANSACTION_COMMIT")
63
+ c = cd.new_function_call
64
+ c.WAIT = "X"
65
+ c.invoke
66
+ assert(conn.close)
67
+ end
68
+
69
+ def teardown
70
+ end
71
+ end
@@ -0,0 +1,87 @@
1
+ #!/usr/bin/ruby
2
+ $KCODE = 'u'
3
+ $:.unshift(File.dirname(__FILE__) + '/lib')
4
+ $:.unshift(File.dirname(__FILE__) + '/ext/nwsaprfc')
5
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
6
+ $:.unshift(File.dirname(__FILE__) + '/../ext/nwsaprfc')
7
+
8
+ require 'sapnwrfc'
9
+
10
+ $TEST_FILE = ENV.has_key?('SAP_YML') ? ENV['SAP_YML'] : 'sap.yml'
11
+ $WAIT = 10
12
+
13
+ require 'test/unit'
14
+ require 'test/unit/assertions'
15
+
16
+ class SAPRegisterTest < Test::Unit::TestCase
17
+ def setup
18
+ #SAP_LOGGER.warn "Current DIR: #{Dir.pwd}\n"
19
+ if FileTest.exists?($TEST_FILE)
20
+ SAPNW::Base.config_location = $TEST_FILE
21
+ else
22
+ SAPNW::Base.config_location = 'test/' + $TEST_FILE
23
+ end
24
+ SAPNW::Base.load_config
25
+ #SAP_LOGGER.warn "program: #{$0}\n"
26
+ end
27
+
28
+ def test_BASIC_00010_Test_Register
29
+ begin
30
+ func = SAPNW::RFC::FunctionDescriptor.new("RFC_REMOTE_PIPE")
31
+ pipedata = SAPNW::RFC::Type.new({:name => 'DATA',
32
+ :type => SAPNW::RFC::TABLE,
33
+ :fields => [{:name => 'LINE',
34
+ :type => SAPNW::RFC::CHAR,
35
+ :len => 80}
36
+ ]
37
+ })
38
+ func.addParameter(SAPNW::RFC::Export.new(:name => "COMMAND", :len => 80, :type => SAPNW::RFC::CHAR))
39
+ func.addParameter(SAPNW::RFC::Table.new(:name => "PIPEDATA", :len => 80, :type => pipedata))
40
+ $stderr.print "Built up FunctionDescriptor: #{func.inspect}/#{func.parameters.inspect}\n"
41
+ pass = 0
42
+ func.callback = Proc.new do |fc|
43
+ $stderr.print "#{fc.name} got called with #{fc.COMMAND}\n"
44
+ if /^blah/.match(fc.COMMAND)
45
+ raise SAPNW::RFC::ServerException.new({'error' => "Got Blah", 'code' => 111, 'key' => "RUBY_RUNTIME", 'message' => "Got a blah message" })
46
+ end
47
+ call = `#{fc.COMMAND}`
48
+ fc.PIPEDATA = []
49
+ call.split(/\n/).each do |val|
50
+ fc.PIPEDATA.push({'LINE' => val})
51
+ end
52
+ pass += 1
53
+ $stderr.print "pass: #{pass}\n"
54
+ # dont ever "return" inside a callback - or it just exits
55
+ # make the last value true or nil depending on whether
56
+ # you successfully handled callback or not
57
+ true
58
+ end
59
+ $stderr.print "Register...\n"
60
+ assert(server = SAPNW::Base.rfc_register)
61
+ attrib = server.connection_attributes
62
+ SAP_LOGGER.warn "Connection Attributes: #{attrib.inspect}\n"
63
+ $stderr.print "Install...\n"
64
+ assert(server.installFunction(func))
65
+ globalCallBack = Proc.new do |attrib|
66
+ $stderr.print "global got called: #{attrib.inspect}\n"
67
+ if pass < 150
68
+ true
69
+ else
70
+ # will tell the accept() loop to exit
71
+ false
72
+ end
73
+ end
74
+ $stderr.print "Accept...\n"
75
+ server.accept($WAIT, globalCallBack)
76
+ rescue SAPNW::RFC::ServerException => e
77
+ SAP_LOGGER.warn "ServerException ERROR: #{e.inspect} - #{e.error.inspect}\n"
78
+ rescue SAPNW::RFC::FunctionCallException => e
79
+ SAP_LOGGER.warn "FunctionCallException ERROR: #{e.inspect} - #{e.error.inspect}\n"
80
+ rescue SAPNW::RFC::ConnectionException => e
81
+ SAP_LOGGER.warn "ConnectionException ERROR: #{e.inspect} - #{e.error.inspect}\n"
82
+ end
83
+ end
84
+
85
+ def teardown
86
+ end
87
+ end
@@ -0,0 +1,88 @@
1
+ #!/usr/bin/ruby
2
+ $KCODE = 'u'
3
+ $:.unshift(File.dirname(__FILE__) + '/lib')
4
+ $:.unshift(File.dirname(__FILE__) + '/ext/nwsaprfc')
5
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
6
+ $:.unshift(File.dirname(__FILE__) + '/../ext/nwsaprfc')
7
+
8
+ require 'sapnwrfc'
9
+
10
+ $TEST_FILE = ENV.has_key?('SAP_YML') ? ENV['SAP_YML'] : 'sap.yml'
11
+ $WAIT = 10
12
+
13
+ require 'test/unit'
14
+ require 'test/unit/assertions'
15
+
16
+ class SAPRegisterTest < Test::Unit::TestCase
17
+ def setup
18
+ #SAP_LOGGER.warn "Current DIR: #{Dir.pwd}\n"
19
+ if FileTest.exists?($TEST_FILE)
20
+ SAPNW::Base.config_location = $TEST_FILE
21
+ else
22
+ SAPNW::Base.config_location = 'test/' + $TEST_FILE
23
+ end
24
+ SAPNW::Base.load_config
25
+ #SAP_LOGGER.warn "program: #{$0}\n"
26
+ end
27
+
28
+ def test_BASIC_00010_Test_Register
29
+ begin
30
+ func = SAPNW::RFC::FunctionDescriptor.new("RFC_REMOTE_PIPE")
31
+ pipedata = SAPNW::RFC::Type.new({:name => 'DATA',
32
+ :type => SAPNW::RFC::TABLE,
33
+ :fields => [{:name => 'LINE',
34
+ :type => SAPNW::RFC::CHAR,
35
+ :len => 80}
36
+ ]
37
+ })
38
+ func.addParameter(SAPNW::RFC::Export.new(:name => "COMMAND", :len => 80, :type => SAPNW::RFC::CHAR))
39
+ func.addParameter(SAPNW::RFC::Table.new(:name => "PIPEDATA", :len => 80, :type => pipedata))
40
+ $stderr.print "Built up FunctionDescriptor: #{func.inspect}/#{func.parameters.inspect}\n"
41
+ pass = 0
42
+ func.callback = Proc.new do |fc|
43
+ $stderr.print "#{fc.name} got called with #{fc.COMMAND}\n"
44
+ if /^blah/.match(fc.COMMAND)
45
+ raise SAPNW::RFC::ServerException.new({'error' => "Got Blah", 'code' => 111, 'key' => "RUBY_RUNTIME", 'message' => "Got a blah message" })
46
+ end
47
+ call = `#{fc.COMMAND}`
48
+ fc.PIPEDATA = []
49
+ call.split(/\n/).each do |val|
50
+ fc.PIPEDATA.push({'LINE' => val})
51
+ end
52
+ pass += 1
53
+ $stderr.print "pass: #{pass}\n"
54
+ # dont ever "return" inside a callback - or it just exits
55
+ # make the last value true or nil depending on whether
56
+ # you successfully handled callback or not
57
+ true
58
+ end
59
+ $stderr.print "Register...\n"
60
+ assert(server = SAPNW::Base.rfc_register)
61
+ attrib = server.connection_attributes
62
+ SAP_LOGGER.warn "Connection Attributes: #{attrib.inspect}\n"
63
+ $stderr.print "Install...\n"
64
+ assert(server.installFunction(func))
65
+ globalCallBack = Proc.new do |attrib|
66
+ end
67
+ $stderr.print "Process loop...\n"
68
+ while rc = server.process($WAIT)
69
+ $stderr.print "in process loop: #{rc}\n"
70
+ case rc
71
+ when SAPNW::RFC::RFC_OK, SAPNW::RFC::RFC_RETRY
72
+ else
73
+ break
74
+ end
75
+ break unless pass < 10
76
+ end
77
+ rescue SAPNW::RFC::ServerException => e
78
+ SAP_LOGGER.warn "ServerException ERROR: #{e.inspect} - #{e.error.inspect}\n"
79
+ rescue SAPNW::RFC::FunctionCallException => e
80
+ SAP_LOGGER.warn "FunctionCallException ERROR: #{e.inspect} - #{e.error.inspect}\n"
81
+ rescue SAPNW::RFC::ConnectionException => e
82
+ SAP_LOGGER.warn "ConnectionException ERROR: #{e.inspect} - #{e.error.inspect}\n"
83
+ end
84
+ end
85
+
86
+ def teardown
87
+ end
88
+ end
data/test/testsuite.rb ADDED
@@ -0,0 +1,33 @@
1
+ $:.unshift('./test')
2
+
3
+ require 'test/unit/testsuite'
4
+ require 'test/unit/ui/console/testrunner'
5
+
6
+ require 'test_logger'
7
+ require 'test_config'
8
+ require 'test_connect'
9
+ require 'test_attributes'
10
+ require 'test_functions'
11
+ require 'test_call'
12
+ require 'test_changing'
13
+ require 'test_data'
14
+ require 'test_deep'
15
+ require 'test_sflight'
16
+
17
+ class TS_MyTests
18
+ def self.suite
19
+ suite = Test::Unit::TestSuite.new
20
+ suite = SAPLoggerTest.suite
21
+ suite << SAPConfigTest.suite
22
+ suite << SAPConnectTest.suite
23
+ suite << SAPConnectionAttributeTest.suite
24
+ suite << SAPFunctionsTest.suite
25
+ suite << SAPCallTest.suite
26
+ suite << SAPChangingTest.suite
27
+ suite << SAPDataTest.suite
28
+ suite << SAPDeepTest.suite
29
+ suite << SAPSFlightTest.suite
30
+ return suite
31
+ end
32
+ end
33
+ Test::Unit::UI::Console::TestRunner.run(TS_MyTests)
metadata CHANGED
@@ -1,35 +1,51 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sapnwrfc
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.23'
4
+ version: '0.24'
5
5
  prerelease:
6
6
  platform: i686-linux
7
7
  authors:
8
8
  - Piers Harding
9
- autorequire:
10
- - sapnwrfc
9
+ - Michele Franzin
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-07-27 00:00:00.000000000 +02:00
14
- default_executable:
13
+ date: 2012-04-10 00:00:00.000000000Z
15
14
  dependencies: []
16
15
  description: ! " sapnwrfc is a ruby module for performing RFC functions and BAPI
17
16
  calls on\n an SAP Netweaver system NW2004+\n"
18
- email: piers@ompka.net
17
+ email:
18
+ - piers@ompka.netmichele@franzin.net
19
19
  executables: []
20
20
  extensions: []
21
21
  extra_rdoc_files: []
22
22
  files:
23
23
  - lib/sapnwrfc/config.rb
24
+ - lib/sapnwrfc/version.rb
24
25
  - lib/sapnwrfc/base.rb
25
26
  - lib/sapnwrfc/connection.rb
26
27
  - lib/sapnwrfc/functions.rb
27
28
  - lib/sapnwrfc/server.rb
28
29
  - lib/sapnwrfc/parameters.rb
29
30
  - lib/sapnwrfc.rb
31
+ - README.rdoc
32
+ - ChangeLog
30
33
  - ext/nwsaprfc/nwsaprfc.so
31
- has_rdoc: true
32
- homepage: http://www.piersharding.com
34
+ - test/test_changing.rb
35
+ - test/test_attributes.rb
36
+ - test/sap.yml
37
+ - test/testregister2.rb
38
+ - test/test_data.rb
39
+ - test/test_call.rb
40
+ - test/test_deep.rb
41
+ - test/testsuite.rb
42
+ - test/testregister.rb
43
+ - test/test_config.rb
44
+ - test/test_functions.rb
45
+ - test/test_connect.rb
46
+ - test/test_logger.rb
47
+ - test/test_sflight.rb
48
+ homepage: http://github.com/fuzziness/sapnwrfc
33
49
  licenses: []
34
50
  post_install_message:
35
51
  rdoc_options: []
@@ -50,8 +66,22 @@ required_rubygems_version: !ruby/object:Gem::Requirement
50
66
  version: '0'
51
67
  requirements: []
52
68
  rubyforge_project:
53
- rubygems_version: 1.6.2
69
+ rubygems_version: 1.8.10
54
70
  signing_key:
55
71
  specification_version: 3
56
72
  summary: SAP Netweaver RFC connector for Ruby
57
- test_files: []
73
+ test_files:
74
+ - test/test_changing.rb
75
+ - test/test_attributes.rb
76
+ - test/sap.yml
77
+ - test/testregister2.rb
78
+ - test/test_data.rb
79
+ - test/test_call.rb
80
+ - test/test_deep.rb
81
+ - test/testsuite.rb
82
+ - test/testregister.rb
83
+ - test/test_config.rb
84
+ - test/test_functions.rb
85
+ - test/test_connect.rb
86
+ - test/test_logger.rb
87
+ - test/test_sflight.rb