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