Skip to content

Instantly share code, notes, and snippets.

@russellkt
Created December 6, 2008 14:49
Show Gist options
  • Save russellkt/32884 to your computer and use it in GitHub Desktop.
Save russellkt/32884 to your computer and use it in GitHub Desktop.
1) Error:
test_ruby_jasper_can_compile_report(RubyJasperTest):
NameError: uninitialized constant RubyJasper::JRXmlLoader
/Users/ktrussell/jars/jruby-1.1.5/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:102:in `const_missing'
/Users/ktrussell/rails_projects/RailsApplication1/lib/ruby_jasper.rb:12:in `compile_report'
/Users/ktrussell/rails_projects/RailsApplication1/test/unit/ruby_jasper_test.rb:7:in `test_ruby_jasper_can_compile_report'
/Users/ktrussell/jars/jruby-1.1.5/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/testing/setup_and_teardown.rb:60:in `run_with_callbacks_and_testunit'
/Users/ktrussell/jars/jruby-1.1.5/lib/ruby/1.8/test/unit/testsuite.rb:34:in `run'
/Users/ktrussell/jars/jruby-1.1.5/lib/ruby/1.8/test/unit/testsuite.rb:33:in `each'
/Users/ktrussell/jars/jruby-1.1.5/lib/ruby/1.8/test/unit/testsuite.rb:33:in `run'
/Users/ktrussell/jars/jruby-1.1.5/lib/ruby/1.8/test/unit/ui/testrunnermediator.rb:46:in `run_suite'
Finished in 0.449 seconds.
1 tests, 0 failures, 1 errors
class RubyJasper
include RubyJasperLib
def compile_report
input = java.io.FileInputStream.new('ruby_report.jrxml')
design = RubyJasperLib::JRXmlLoader.load(input)
@report = RubyJasperLib::JasperCompileManager.compileReport(design)
end
def print_report
compile_report unless @report
data_file = java.io.FileInputStream.new('sampleData.csv')
data_source = RubyJasperLib::JRCsvDataSource.new(data_file)
data_source.setColumnNames(['id','name'].to_java(:string))
print = RubyJasperLib::JasperFillManager.fill_report(@report,{},data_source)
RubyJasperLib::JasperExportManager.export_report_to_pdf_file( print, 'sample_file.pdf' )
end
end
require 'java'
module RubyJasperLib
include_package 'net.sf.jasperreports.engine'
include_package 'net.sf.jasperreports.engine.xml'
include_package 'net.sf.jasperreports.engine.data'
end
require 'test_helper'
class RubyJasperTest < ActiveSupport::TestCase
test "ruby_jasper can compile report" do
assert rjasper = RubyJasper.new
assert rjasper.compile_report
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment