Skip to content

Instantly share code, notes, and snippets.

@MarkMenard
MarkMenard / gist:340526
Created March 22, 2010 21:05
Example Groovy JPA
package models
import javax.persistence.*
@Entity (name="Agreement")
@Table (name="agreement")
@EntityListeners ([QIdSetter.class])
class AgreementJpaImpl extends QIdEntityImpl implements Agreement {
@ManyToOne (targetEntity=PartyJpaImpl.class)
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
describe Scm::OnHandReportsController do
#Delete these examples and add some real ones
it "should use Scm::OnHandReportsController" do
controller.should be_an_instance_of(Scm::OnHandReportsController)
end
Caused by: org.jruby.rack.RackInitializationException: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getContextPath()Ljava/lang/String;
from file:/Users/mark/opt/JBoss-4.0.2/server/default/tmp/deploy/tmp4851618238755102823mori.ear-contents/mori.war/WEB-INF/lib/jruby-rack-0.9.7.jar!/jruby/rack/rails.rb:113:in `setup_relative_url_root'
from file:/Users/mark/opt/JBoss-4.0.2/server/default/tmp/deploy/tmp4851618238755102823mori.ear-contents/mori.war/WEB-INF/lib/jruby-rack-0.9.7.jar!/jruby/rack/rails.rb:48:in `load_environment'
from file:/Users/mark/opt/JBoss-4.0.2/server/default/tmp/deploy/tmp4851618238755102823mori.ear-contents/mori.war/WEB-INF/lib/jruby-rack-0.9.7.jar!/jruby/rack/rails.rb:38:in `to_app'
from file:/Users/mark/opt/JBoss-4.0.2/server/default/tmp/deploy/tmp4851618238755102823mori.ear-contents/mori.war/WEB-INF/lib/jruby-rack-0.9.7.jar!/jruby/rack/rails.rb:186:in `new'
from <script>:2
from file:/Users/mark/opt/JBoss-4.0.2/server/default/tmp/deploy/tmp485161823875510
class HapagLloydMoveDocWrapper < DocWrapperBase
property :carrier_description, :string, './td[1]'
property :location, :string, './td[2]'
multi_property :time_of_move, ['./td[3]','./td[4]'] do |x|
Time.parse("#{x[0]} #{x[1]}".strip)
end
property :status, :raw, './td[1]' do |node_list|
node = node_list.first
if node.attribute("class") && node.attribute("class").content =~ /strong/
'ACTUAL'
class A {
def foo = "A"
def printFoo () {
println foo
}
}
class B extends A {
def foo = "B"
def printFoo () {
public class A {
private String foo = "A";
public void printFoo () {
System.out.println(foo);
}
}
public class B extends A {
// With the Category annotation this throws a ValidationError
// Without the annotation everything runs as exepected
@Category(Object)
class Base {
def errors = []
def foo () {
errors = []
}
import org.springframework.beans.BeanUtils
import java.lang.reflect.Field;
import java.lang.reflect.Method;
@Category(Object)
class PropertyUtils {
def getPropertyValue (Class clazz, String name, Object ob) {
Method getter = BeanUtils.findDeclaredMethod(clazz, getGetterName(name), null)
try {
org.jruby.rack.RackInitializationException: Valid types are [:development, :runtime], not nil
from /Users/enablelabs/opt/jboss/server/default/tmp/deploy/tmp2213791091804345453mori.ear-contents/mori.war/WEB-INF/gems/gems/bundler-1.0.7/lib/bundler/resolver.rb:359:in `new'
from /Users/enablelabs/opt/jboss/server/default/tmp/deploy/tmp2213791091804345453mori.ear-contents/mori.war/WEB-INF/gems/gems/bundler-1.0.7/lib/bundler/resolver.rb:359:in `search'
from /Users/enablelabs/opt/jboss/server/default/tmp/deploy/tmp2213791091804345453mori.ear-contents/mori.war/WEB-INF/gems/gems/bundler-1.0.7/lib/bundler/resolver.rb:354:in `gems_size'
from /Users/enablelabs/opt/jboss/server/default/tmp/deploy/tmp2213791091804345453mori.ear-contents/mori.war/WEB-INF/gems/gems/bundler-1.0.7/lib/bundler/resolver.rb:179:in `resolve'
from /Users/enablelabs/opt/jboss/server/default/tmp/deploy/tmp2213791091804345453mori.ear-contents/mori.war/WEB-INF/gems/gems/bundler-1.0.7/lib/bundler/resolver.rb:175:in `each'
from /Users/enablelabs/op
# My first attempt at using both Mocha and RSpec mocks in a project.
module Spec
module Adapters
module MockFramework
# Mocha::Standalone was deprecated as of Mocha 0.9.7.
begin
include Mocha::API
rescue NameError