12. July 2010 13:57

Using utPLSQL with multiple schemas

I really like unit testing, and nowadays there is an helping framework for almost every environment and/or programming language. For PL/SQL this is utPLSQL, which consists of a bunch of packages that you need to put on your database and then you should be good to test your could. You should.

I just spent some hours debugging my test code, so I want to share this with you, maybe I can save someone out there some time.

My setting

  • Schema A: utPLSQL package
  • Schema B: package XY (code to test), package UT_XY (test code)

I have two schemas A and B. In schema A utPLSQL is installed, and in B is the code to test. It is recommended to have your code to test and your test code in the same schema.

The following script is used to run the tests:

 begin
   for c in (select object_name,owner
               from all_objects
              where object_name like 'UT\_%' escape '\'
                and object_type ='PACKAGE')
   loop
     begin
     utPLSQL.test(
       package_in => substr(c.object_name,4),
       prefix_in => 'UT_',
       owner_in => c.owner
     );
   exception
     -- in case of a faulty unittest continue with the others.
     when others then
       null;
   end;
   end loop;
 end;
 /

But I kept getting the error:

 Program named "XY" does not exist.

So I thought that somehow the schema A does not “see” the packages in the schema B and created public synonyms. Unfortunately this didn’t help. Then I tried to move the “UT_” package to schema A, which worked, but now I got an error that the code to test and the test code are in different schemas.

There must be something obvious I’m missing!

And there it was: A had not “execute” grant on the packages in B.

  grant execute on b.xy to A;

Now everything just worked fine.


Tags:  unit testing  utplsql  oracle 
Comments
30. May 2010 18:04

Erroneous copyFrom() method in JCIFS/VFS

At the HSR (University of Applied Science Rapperswil) we are currently developing a software to synchronize files from the central fileserver to the students computers. This should help the students to get the latest slides for their lectures.

The software is based on VFS (Virtual Filesystem) from the Apache Commons project. The file server is a classic Samba server that uses the CIFS protocol, and with the use of VFS we ensured a common access the the filesystem, no matter if it’s the remote filesystem of the file server or the local filesystem on the student’s computers.

At a point we got a very strange error: we could copy files from the remote system, but when we delete the files while the application is running, and try to copy the files again, the copy fails:

FileSystemException "could not copy [source-path] to [target-path]".

We figured out, that the problem were the folders that don’t exist yet. But according the the documentation of the the copyFrom method the parent folder should be created if it does not exist. This is also the case when we do the first-time-copy, which works like a charm.

After serveral tries with refresh() etc. to bring the FileObjects and the actual filesystem to sync, we finally implemented this workaround, maybe somebody else can use it:

protected void copyFile(FileObject targetFile, FileObject sourceFile) {
    try {
        FileObject parentFile = targetFile.getParent();
        parentFile.refresh();
        log.debug("Parent exists?: " + parentFile.exists());

        if (!parentFile.exists()) {
            parentFile.createFolder();
            log.debug(" => Folder created");
        }
        targetFile.copyFrom(sourceFile),new AllFileSelector());
    } catch (FileSystemException e) {
        log.warn("Could not copy file, FileSystemException: "
                + e.getMessage());
    }
}

(the above code is a little bit simplified, and the use of an extra FileObject for the parent is not absolutely necessary, but it clarifies the code)

In my opinion the copyFrom implementation of JCFIS (which is the Samba part of VFS) does not work, i.e. this is a bug. But I’m not sure, maybe we overlook an obvious thing on our side. Fact is, the above solution works for us. The JCIFS is part of the VFS sandbox, this means the library is still in development. Maybe I’ll file a bug, if I can clearly reproduce this behavior.


Tags:  java  vfs  jcifs 
Comments
23. December 2009 15:32
Comments
22. December 2009 10:38
Comments
3. December 2009 19:06
mnmal:

I think this summarizes everything.

mnmal:

I think this summarizes everything.


Comments
3. December 2009 15:38
Comments
2. December 2009 10:56

Mein erstes Geschenk von meinem Twichtel, Danke!


Tags:  twichtelnCH 
Comments
17. November 2009 22:32

WWFM VI in Zürich, das Video zum Event


Comments
11. November 2009 11:06

The Go Programming Language

Today I came across a new programming language called Go, developed by Google

It is meant to be fast, but still garbage collected and type safe. They use pointers, but no pointer arithmetic.
The questions remains: Do we really need another C++-like language?

See Yourself:


Tags:  Programming 
Comments
11. November 2009 09:48

5. Trivadis Java Lounge

Endlich schaffte ich es auch mal an die Trivadis Java Lounge, welche nun bereits zum fünften Mal stattfand. Diesmal wurde das Hallenstadion als Location ausgewählt, eingeladen waren Kunden und Partner von Trivadis.

Es wurden folgende Präsentationen gezeigt:

  • Spring Dynamic Modules - OSGi mit dem Spring Framework (Slides bei Slideshare)
  • Google App Engine - Java in der Cloud

Mehr Infos bald im Trivadis Blog.


Tags:  Trivadis  Java 
Comments
10. November 2009 23:11

30 Google Wave Invites

Ich habe noch Google Wave Einladungen, falls jemand eine will kann er sich bei mir via Mail, Twitter, Kommentar oder persönlich melden.

I got some Google Wave invites left, if you like one, get in contact with me via mail, twitter, comments or personally.


Tags:  Google Wave 
Comments
9. November 2009 15:22

Extract .tar.gz to specific directory

I want to extract all files form a “.tar.gz” file to a specific directory (not the current).

When you ask Google you quickly come up with the elegant solution:

$ gzip -cd /some/dir/something.tar.gz | tar -xvf - -C /specific/directory

Somehow my development machine doesn’t accept this, as I keep getting the error:

File -C not present in the archive.
File /specific/directory not present in the archive.

I couldn’t find the answer, but as usual many ways lead to Rome. I’m able to extract the files to the current directory using

$ gzip -cd /some/dir/something.tar.gz | tar -xvf -

Therefore I can simply change the current directory to my specific directory and after the extraction return to the prior directory (I need to unzip the file in a script, therefore I need a generic approach). When we put all that together the following finally works:

$ cd /specific/directory && gzip -cd /some/dir/something.tar.gz | tar -xvf - && cd -

Tags:  Linux 
Comments
9. November 2009 13:34

WWFM IV in Zürich

Am nächsten Wochenende (14. November 2009) ist wieder mal ein World-Wide-Flash-Mob (WWFM) der Geocache-Anhänger. WWFM Geocaching

Dieser Event steht ganz im Zeichen der kalten Jahreszeit und wird mit Wunderkerzen und Räbeliechtli bestritten. Der Clou ist etwas Verwirrung und Verwunderung zu stiften und natürlich sich mal wieder zu treffen.

Solche Event-Caches sind immer eine wunderbare Gelegenheit sich über Caches zu unterhalten, mal Leute zu sehen die man sonst nur liest oder einfach in der Gruppe eine lustige Aktion durchzuführen.

Also alle Cacher da draussen: Kommt auch nach Zürich, oder besucht einen der 150 anderen WWFM Event Caches in eurer Nähe!


Tags:  Geocaching 
Comments
6. November 2009 20:09

Kino: Der Fürsorger

Ich habe diese Woche wieder das Überraschungskino der Kitag besucht, wo jeweils Vorpremieren von Filmen gezeigt werden. Der Clou: vorher ist nicht bekannt, welcher Film das läuft.

Das Prozedere ist ganz einfach: Zuerst werden 4-5 Trailer gezeigt, einer der Filme läuft danach in voller Länge.

Diesmal wurde eine Schweizer Produktion gezeigt: Der Fürsorger.

Der Film erzählt die Geschichte einen Hochstaplers, welche viele Leute um ihr Vermögen gebracht hat mit einem plumpen “Anlage-Trick”. Die Hauptperson wird gespielt von Roeland Wiesnekker, der diese Rolle wie ich finde sehr gut interpretiert.

Alles in allen ist der Film aber zu lang und zu holprig. Die Erzählung wird immer weiter verschachtelt, da der Herr Betrüger immer wieder seine Geschichte zu erzählen beginnt. Der Film bietet gute Unterhaltung und kann man sich getrost ansehen. Vielleicht aber eher an einem gemütlichen Sonntagabend zu Hause, denn im Kino.

Ahja, der Film basiert auf einer wahren Geschichte.

Trailer:


Tags:  Kino 
Comments
25. October 2009 15:32

BarCamp Rapperswil

Das gestrige BarCamp in Rapperswil hat riesigen Spass gemacht.

BarCamp Rapperswil

Als erstes will ich mich gleich bei Corsin als Organisator bedanken, war echt super. Das BarCamp fand in der Hochschule für Technik Rapperswil (HSR) statt, von dem her ein für mich vertrautes Terrain. Es war ein Treffen technisch interessierter Leute über die unterschiedlichsten Facetten der IT. Da gab es einen Speech von Urs (ComMetrics) über Blogs, Social Media und deren Messbarkeit. Dann war Yvonne-Anne von Fybit vor Ort um ihr Produkt RIATrax vorzustellen (Rich Internet Applications in Pure Java), oder Frank, welcher eine Diskussion leitete über die Zukunft des Web 2.0, welche Konzepte überleben, welche nicht und warum.

Ein weiteres Highlight war die Präsentation von Markus Stolze (Professor an der HSR) über den Multi-Touch Table, welcher an der HSR mitentwickelt wurde. Multi-Touch Table

Alles in allem war es ein Event unter Gleichgesinnten um sich auszutauschen. Wir haben viel gelacht (z.B. über das Hashtag #bcrappi) und nachgedacht, kritisch betrachtet und kommentiert.

Ich ging mit vielen neuen Ideen und Eindrücken nach Hause, genau so sollte das sein. Ich freue mich bereits auf nachfolgende BarCamps, ist sicher nicht das letzte Mal, dass ich da war.

Die Bilder zum Event gibts auf Flickr.

PS: I don’t want to miss to mention Joel our Swedish guy, who made this BarCamp truly international ;-)


Tags:  Barcamp  HSR  bcrappi 
Comments