author | Jaroslav Tulach <jtulach@netbeans.org> |
Sun, 01 Feb 2009 13:27:04 +0100 | |
changeset 308 | 7f38f014244c |
child 310 | fba31e9504a1 |
permissions | -rw-r--r-- |
jtulach@308 | 1 |
package org.apidesign.exceptions.trycatchredo; |
jtulach@308 | 2 |
|
jtulach@308 | 3 |
|
jtulach@308 | 4 |
import java.awt.EventQueue; |
jtulach@308 | 5 |
import java.awt.event.ActionEvent; |
jtulach@308 | 6 |
import java.net.URL; |
jtulach@308 | 7 |
import javax.swing.Action; |
jtulach@308 | 8 |
import org.junit.After; |
jtulach@308 | 9 |
import org.junit.Before; |
jtulach@308 | 10 |
import org.junit.Test; |
jtulach@308 | 11 |
import static org.junit.Assert.*; |
jtulach@308 | 12 |
|
jtulach@308 | 13 |
/** |
jtulach@308 | 14 |
* |
jtulach@308 | 15 |
* @author Jaroslav Tulach <jtulach@netbeans.org> |
jtulach@308 | 16 |
*/ |
jtulach@308 | 17 |
public class IOManagerTest { |
jtulach@308 | 18 |
|
jtulach@308 | 19 |
public IOManagerTest() { |
jtulach@308 | 20 |
} |
jtulach@308 | 21 |
|
jtulach@308 | 22 |
@Before |
jtulach@308 | 23 |
public void setUp() { |
jtulach@308 | 24 |
MemoryURL.initialize(); |
jtulach@308 | 25 |
} |
jtulach@308 | 26 |
|
jtulach@308 | 27 |
@After |
jtulach@308 | 28 |
public void tearDown() { |
jtulach@308 | 29 |
} |
jtulach@308 | 30 |
|
jtulach@308 | 31 |
@Test |
jtulach@308 | 32 |
public void simpleWrite() throws Exception { |
jtulach@308 | 33 |
URL u = new URL("memory://simpleWrite.txt"); |
jtulach@308 | 34 |
MemoryURL.registerURL(u.toExternalForm(), "", null); |
jtulach@308 | 35 |
final Action a = IOManager.createSaveAction(u, "Ahoj"); |
jtulach@308 | 36 |
EventQueue.invokeAndWait(new Runnable() { |
jtulach@308 | 37 |
public void run() { |
jtulach@308 | 38 |
a.actionPerformed(new ActionEvent(this, 0, "")); |
jtulach@308 | 39 |
} |
jtulach@308 | 40 |
}); |
jtulach@308 | 41 |
byte[] out = MemoryURL.getOutputForURL(u.toExternalForm()); |
jtulach@308 | 42 |
assertEquals("Four bytes", 4, out.length); |
jtulach@308 | 43 |
} |
jtulach@308 | 44 |
} |