Roger's woze

August 31, 2009

easymock custom expectations example

Filed under: Uncategorized — rogerdpack @ 9:47 pm

Turns out to be a little tricky. Here’s one that asserts a list is passed in, but that the list isn’t empty



  public static ArrayList nonEmptyArrayList() {
    EasyMock.reportMatcher(new nonEmptyArrayList());
    return null;
  }

  public static class nonEmptyArrayList implements IArgumentMatcher {

    @Override
    public boolean matches(Object actual) {
      if (!(actual instanceof ArrayList)) {
        return false;
      }
      ArrayList actualList = (ArrayList) actual;
      if (actualList.size() < 0) {
        return false;
      }
      return true;
    }

    @Override
    public void appendTo(StringBuffer buffer) {
      buffer.append("got empty array list!");
    }
  }

use it like


expect(mockDB.changeTapeContent(eq("999998"), eq("preservation"), eq("2.1.0"),
                (ArrayList) nonEmptyArrayList())).andReturn(true);

maven woe

Filed under: Uncategorized — rogerdpack @ 4:37 pm

Exception in thread “main” java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory

means “run it with mvn exec:java -Dexec.mainClass=org.x.y.z” instead of home brew

August 29, 2009

ruby tk exec’ing a sub process without freezing the GUI

Filed under: Uncategorized — rogerdpack @ 10:41 pm

So turns out that currently, at least with 1.8.6, doing this in a ruby/tk application doesn’t actually help

Thread.new { run some process }

Tk somehow or other detects that you’re doing something else [maybe it can't select *at all* on other threads in windows 1.8.6?] and so it freezes.

The fix?
Start a process using win32-process gem.
Then every so often have a timer fire which checks if the process is still running or not.
a la


         require 'win32/process'
          require 'ruby-wmi'
          output_file_name = "out_#{@@next_number}.txt"
          @@next_number += 1
          # windows needs to run it through another cmd for some reason or it doesn't redirect right
          _cmd_ = "cmd /c \"#{_cmd_} > #{output_file_name}\""
          child = Process.create :command_line => _cmd_
          timer=nil
          procy = proc {
            still_alive = WMI::Win32_Process.find(:first, :conditions => {:ProcessId => child.process_id})
            if(!still_alive)
              timer.stop
              File.open(output_file_name, 'r') do |f|
                _readed = f.read
                _readed.strip!
                _readed += "\n" + "Done with #{_filename} in #{Time.now - start_time}s"
                Arcadia.console(self,'msg'=>_readed, 'level'=>'debug')
                _event.add_result(self, 'output'=>_readed)
              end
              File.delete output_file_name
            end
          }

          timer=TkAfter.new(1000,-1,procy) # repeating...
          timer.start
        else
          ... linux stuff
        end

how to run tk programs with ruby mingw

Filed under: Uncategorized — rogerdpack @ 5:08 pm

Currently the mingw builds given by the “rubyinstaller” project of ruby don’t have tk installed, because the installers haven’t gotten around to adding it, and hardly no on uses it.

That being said, here’s how to “install” the missing tk binaries for ruby 1.8.6 mingw
C:\> git clone git://github.com/rogerdpack/ruby_windows_tk.git
c:\> cd ruby_windows_tk
c:\> ruby install.rb # installs it into the guts of your ruby distro.
Not available for 1.9.x builds yet. Hopefully sometime, once it’s useful to someone.

August 27, 2009

glassfish woe

Filed under: Uncategorized — rogerdpack @ 7:37 pm

C:\downloads>cd glassfish

C:\downloads\glassfish>ant
‘ant’ is not recognized as an internal or external command,
operable program or batch file.

C:\downloads\glassfish>c:\installs\apache-ant-1.7.1-bin\apache-ant-1.7.1\bin\ant.cmd -f setup.xml

C:\downloads\glassfish>/*
‘/*’ is not recognized as an internal or external command,
operable program or batch file.

C:\downloads\glassfish>Licensed to the Apache Software Foundation (ASF) under one or more
‘Licensed’ is not recognized as an internal or external command,
operable program or batch file.

C:\downloads\glassfish>contributor license agreements. See the NOTICE file distributed with
‘contributor’ is not recognized as an internal or external command,
operable program or batch file.

C:\downloads\glassfish>this work for additional information regarding copyright
ownership.
‘this’ is not recognized as an internal or external command,
operable program or batch file.

C:\downloads\glassfish>The ASF licenses this file to You under the Apache License, Version 2.0
‘The’ is not recognized as an internal or external command,
operable program or batch file.
you was unexpected at this time.

C:\downloads\glassfish> (the “License”); you may not use this file except in compliance with

C:\downloads\glassfish>c:\installs\apache-ant-1.7.1-bin\apache-ant-1.7.1\bin\ant.cmd -f setup.xml

C:\downloads\glassfish>/*
‘/*’ is not recognized as an internal or external command,
operable program or batch file.

C:\downloads\glassfish>Licensed to the Apache Software Foundation (ASF) under one or more
‘Licensed’ is not recognized as an internal or external command,
operable program or batch file.

C:\downloads\glassfish>contributor license agreements. See the NOTICE file distributed with
‘contributor’ is not recognized as an internal or external command,
operable program or batch file.

C:\downloads\glassfish>this work for additional information regarding copyright
ownership.
‘this’ is not recognized as an internal or external command,
operable program or batch file.

C:\downloads\glassfish>The ASF licenses this file to You under the Apache License, Version 2.0
‘The’ is not recognized as an internal or external command,
operable program or batch file.
you was unexpected at this time.

C:\downloads\glassfish> (the “License”); you may not use this file except in compliance with

C:\downloads\glassfish>c:\installs\apache-ant-1.7.1-bin\apache-ant-1.7.1\bin\ant.cmd

C:\downloads\glassfish>/*
‘/*’ is not recognized as an internal or external command,
operable program or batch file.

C:\downloads\glassfish>Licensed to the Apache Software Foundation (ASF) under one or more
‘Licensed’ is not recognized as an internal or external command,
operable program or batch file.

C:\downloads\glassfish>contributor license agreements. See the NOTICE file distributed with
‘contributor’ is not recognized as an internal or external command,
operable program or batch file.

C:\downloads\glassfish>this work for additional information regarding copyright
ownership.
‘this’ is not recognized as an internal or external command,
operable program or batch file.

C:\downloads\glassfish>The ASF licenses this file to You under the Apache License, Version 2.0
‘The’ is not recognized as an internal or external command,
operable program or batch file.
you was unexpected at this time.

C:\downloads\glassfish> (the “License”); you may not use this file except in compliance with

meant “use the ant that they distribute *with* glassfish to install it, not your own installed version of ant”
glassfish\lib\something\ant -f setup.xml

August 26, 2009

java/maven woe

Filed under: Uncategorized — rogerdpack @ 10:06 pm

[INFO] ————————————————————————
[ERROR] BUILD ERROR
[INFO] ————————————————————————
[INFO] Failed to execute wsgen

Embedded error: com/sun/mirror/apt/AnnotationProcessorFactory
com.sun.mirror.apt.AnnotationProcessorFactory

meant “put the right java version in your path you’re using an old one or perhaps one without a compiler”

ruby debug debug19 woe

Filed under: Uncategorized — rogerdpack @ 7:17 pm

–without-ruby-include=${ruby-dir}/include
–with-ruby-lib
–without-ruby-lib=${ruby-dir}/lib
extconf.rb:20:in `

‘: undefined method `create_makefile_with_core’ for Ruby
_core_source:Module (NoMethodError)

meant “uninstall your old version of ruby_core_source or mark-moseley-ruby_core_source and run gem install again”

how to use jruby to develop rails apps on windows

Filed under: Uncategorized — rogerdpack @ 11:24 am

bookmark:

http://mastrodonato.info/index.php/2009/08/setting-up-an-environment-for-jruby-on-rails/?lang=en

seems like a pretty good how to on this subject. Not sure if I’d actually recommend it or not tho.

August 25, 2009

virtualbox linux additions gotcha

Filed under: Uncategorized — rogerdpack @ 4:49 pm

dp@rdp-vm:/cdrom$ sudo ./VBoxLinuxAdditions-amd64.run
[sudo] password for rdp:
Verifying archive integrity… All good.
Uncompressing VirtualBox 3.0.4 Guest Additions for Linux installation……………………………………………………………………………………………………………………………………………………………………………………………………
VirtualBox 3.0.4 Guest Additions installation
Detected unsupported x86 environment.

meant “though you’re using an amd64 cpu, your windows version is actually 32-bit windows, so just run the normal x86 version”

rdp@rdp-vm:/cdrom$ sudo ./VBoxLinuxAdditions-x86.run

how to use ruby2ruby with parse tree

Filed under: Uncategorized — rogerdpack @ 4:37 pm

So it turns out that you can’t actually *use* ruby2ruby with parse tree output. Since version > 1.1.9, it requires you to first parse the output THEN pass it to ruby2ruby. I guess to make things more explicit.

See comments

>> require ‘pathname’
>> require ‘parse_tree’
>> require ‘ruby2ruby’
>> Ruby2Ruby.new.process ParseTree.translate(Pathname, :children)
UnknownNodeError: Bug! Unknown node-type :zarray to Ruby2Ruby
from C:/ruby/lib/ruby/gems/1.8/gems/sexp_processor-3.0.2/lib/sexp_processor.rb:246:in `process’

http://rubyforge.org/tracker/index.php?func=detail&aid=26941&group_id=1513&atid=5921

Ruby2Ruby.new.process ParseTree.new.process(ParseTree.new.parse_tree_for_method(Pathname, :children))

GL.
-r

Older Posts »

Powered by WordPress