1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/samples/exceptions/test/org/apidesign/exceptions/trycatchredo/IOManagerTest.java Sun Feb 01 13:27:04 2009 +0100
1.3 @@ -0,0 +1,44 @@
1.4 +package org.apidesign.exceptions.trycatchredo;
1.5 +
1.6 +
1.7 +import java.awt.EventQueue;
1.8 +import java.awt.event.ActionEvent;
1.9 +import java.net.URL;
1.10 +import javax.swing.Action;
1.11 +import org.junit.After;
1.12 +import org.junit.Before;
1.13 +import org.junit.Test;
1.14 +import static org.junit.Assert.*;
1.15 +
1.16 +/**
1.17 + *
1.18 + * @author Jaroslav Tulach <jtulach@netbeans.org>
1.19 + */
1.20 +public class IOManagerTest {
1.21 +
1.22 + public IOManagerTest() {
1.23 + }
1.24 +
1.25 + @Before
1.26 + public void setUp() {
1.27 + MemoryURL.initialize();
1.28 + }
1.29 +
1.30 + @After
1.31 + public void tearDown() {
1.32 + }
1.33 +
1.34 + @Test
1.35 + public void simpleWrite() throws Exception {
1.36 + URL u = new URL("memory://simpleWrite.txt");
1.37 + MemoryURL.registerURL(u.toExternalForm(), "", null);
1.38 + final Action a = IOManager.createSaveAction(u, "Ahoj");
1.39 + EventQueue.invokeAndWait(new Runnable() {
1.40 + public void run() {
1.41 + a.actionPerformed(new ActionEvent(this, 0, ""));
1.42 + }
1.43 + });
1.44 + byte[] out = MemoryURL.getOutputForURL(u.toExternalForm());
1.45 + assertEquals("Four bytes", 4, out.length);
1.46 + }
1.47 +}
1.48 \ No newline at end of file