junit suite wide setup (not @BeforeClass)

Problem

How do I run setup/teardown for my whole suite, not just one class/test?

Impact of Problem

JUnit offers @Before to run a method before each test and @BeforeClass to run a method once before a class.  For a small suite, @BeforeClass may be enough.  For a large integration test suite, setting up the database is a common task that should be done once for scores of tests.  Having everything in one class is not optimal.  Nor is manually listing all the tests.

Requirements

  1. Continue being able to use ClasspathSuite to gather tests in a subdirectory at runtime.
  2. Run a method before the first of these tests is run
  3. Run a method after the last of these tests is run
  4. Take advantage of JUnit’s runner for running all the tests

Solution

package com.javaranch.test.functional;

import static org.junit.extensions.cpsuite.SuiteType.*;

import org.junit.extensions.cpsuite.*;
import org.junit.extensions.cpsuite.ClasspathSuite.*;
import org.junit.runner.*;

// use cpsuite to dynamically list out tests
@RunWith(ClasspathSuite.class)
@ClassnameFilters( { "com.javaranch.*test.*Test", "net.jforum.*test.*Test" })
// include in case have a parameterized test case
@SuiteTypes( { RUN_WITH_CLASSES, TEST_CLASSES, JUNIT38_TEST_CLASSES })
public class All_JForum_Functional_Tests {
public static void main(String[] args) throws Exception {
setUp();
JUnitCore.main("com.javaranch.test.functional.All_JForum_Functional_Tests");
tearDown();
}

private static void setUp() {
// create the database
}

private static void tearDown() {
// destroy the database
}
}

If you’ve been reading my blog, you’ll know I am doing this to integration test the back end of JavaRanch’s JForum install.  I started by cloning a database and have now moved on to the integration test framework.  Next I will describe the actual database setup.

Apple blocks Adobe Flash CS5 iPhone Exporter

No Flash for Apple iPhone Fresh off the heels of the release of Flash Builder 4, Apple has announced it will be blocking any attempts by Adobe to create iPhone applications via a Flash CS5 iPhone compiler. Apple made this change following its iPhone 4 preview media event.

The new language in the iPhone SDK:

Applications must be originally written in Objective-C, C, C++, or JavaScript as executed by the iPhone OS WebKit engine, and only code written in C, C++, and Objective-C may compile and directly link against the Documented APIs (e.g., Applications that link to Documented APIs through an intermediary translation or compatibility layer or tool are prohibited).

In other words, one the shiniest, most powerful, most interesting new features of Flash CS5, namely the Packager for iPhone is dead exactly 4 days before the release of Adobe CS5. Adobe has acknowledged the issue.

Despite my previous article critical of Flash Builder 4, I am quite disappointed by this news. Since Flash has been banned from Apple portable devices since their inception, this could have been an excellent way to bring tens of thousands of applications to these devices without any of the risks Steve Jobs (pictured here) has publically chastised Flash for. It seems a like win-win compromise for everyone; Adobe gets Flash applications on the iPhone, and iPhone keeps free of any Adobe-made plug-ins since technically Apple is providing the run-time environment.

I would like to say the two companies will work it out, but the timing of the SDK change seems pointedly directed at Adobe. I guess it is safe to say Apple still holds a grudge.

Update Over the last few days there’s been numerous public fighting between the two companies. Now, sources close to the issue claim Adobe will file a suit against Apple. While I disagree with what Apple is doing, I agree with their ability to block Flash from their devices.

What a lot of Adobe fanatics tend to forget is that Flash is a proprietary platform, not an open web standard. It would be like a developer creating a specialized web plug-in and then demanding it be supported on a cell phone without the ability to modify/change the plug-in. In short, I’d only be on Adobe’s side if they made Flash an open standard that anyone can develop on. It’s ironic that Adobe is claiming foul on Apple’s proprietary platform when they make the only Flash/Flex compilers in the world (the only one anyone uses, to be precise).

cropping video fast for dummies

I wanted to edit a three minute video down to less than 15 seconds.  I’ve never done this before and don’t have any special software.  And I needed to do it in an hour.  What to do?  What to do?

Why the urgency?

I was giving an Ignite style presentation on Stuy Pulse’s journey this season (FIRST Robotics team #694).  Since Ignite slides are 15 seconds in length, I originally decided to go with a static picture.  The night before my presentation, an alum of the team sent out a really good 3 minute video.  I thought it would make my presentation much better to include one 15 second “slide” of video.

Where I started

The original video is 3 minutes and 36 seconds.  I decided it would be nice to show kicking a goal in autonomous (no humans involved), driving over the bump/ramp and hanging.

How I did it

  1. Note that I have Windows Movie Maker on my machine which I can use for basic editing.  The shortcut disappeared, but I can create a new one pointing to C:\Program Files\Movie Maker\moviemk.exe.
  2. Download the video using ClipNabber so I would have a copy of it locally.  This downloaded the clip as an .mp4 file.
  3. Since Windows media player doesn’t support .mp4 files, I needed to convert it to another format.  I downloaded the free QuickMedia converter which was a 45 MB file.  Thanks to the Microsoft forum for the idea.  Converting the file from .mp4 to .wmv took 2 minutes.
  4. In Windows Movie Maker, import the .wmv file.
  5. Play the video using the navigation icons to split the video into pieces.  The relevant buttons were:
    1. Play – to start it
    2. Split – to create a clip boundary (start of end the clip)
    3. Previous/Next frame for precision
  6. Drag the three completed clips to the storyboard
  7. File > Save movie file

How did it work?

This process was good for some rough editing.  I met my goal of having a clip under 15 seconds showing these three things.  For “real” editing, you’d want a better product of course.

The final product

The completed video does show what I wanted.  I didn’t edit out the sound because I knew the speakers would be off during my presentation.  The words that went with that slide were:

red al-liance! ,<clap><clap>, <clap><clap><clap>

blue al-liance! ,<clap><clap>, <clap><clap><clap>

hang! hang! hang!

if 694 wins this, we go to nationals!

<pause>

Then the next slide is a screenshot of the congratulations message; the one at the beginning of this post.

And yes, I got permission from the video creator to do this and blog about it.