samples/exceptions/test/org/apidesign/exceptions/trycatchredo/api/IOManagerTest.java
1.1 --- a/samples/exceptions/test/org/apidesign/exceptions/trycatchredo/api/IOManagerTest.java Sun Feb 01 16:27:41 2009 +0100
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,64 +0,0 @@
1.4 -package org.apidesign.exceptions.trycatchredo.api;
1.5 -
1.6 -
1.7 -import org.apidesign.exceptions.trycatchredo.usage.MemoryURL;
1.8 -import java.awt.EventQueue;
1.9 -import java.awt.event.ActionEvent;
1.10 -import java.net.URL;
1.11 -import javax.swing.Action;
1.12 -import javax.swing.JOptionPane;
1.13 -import org.apidesign.exceptions.trycatchredo.usage.QueryStream;
1.14 -import org.junit.After;
1.15 -import org.junit.Before;
1.16 -import org.junit.Test;
1.17 -import static org.junit.Assert.*;
1.18 -
1.19 -/**
1.20 - *
1.21 - * @author Jaroslav Tulach <jtulach@netbeans.org>
1.22 - */
1.23 -public class IOManagerTest {
1.24 -
1.25 - public IOManagerTest() {
1.26 - }
1.27 -
1.28 - @Before
1.29 - public void setUp() {
1.30 - MemoryURL.initialize();
1.31 - }
1.32 -
1.33 - @After
1.34 - public void tearDown() {
1.35 - }
1.36 -
1.37 - @Test
1.38 - public void simpleWrite() throws Exception {
1.39 - URL u = new URL("memory://simpleWrite.txt");
1.40 - MemoryURL.registerURL(u.toExternalForm(), "", null);
1.41 - final Action a = IOManager.createSaveAction(u, "Hello World!");
1.42 - EventQueue.invokeAndWait(new Runnable() {
1.43 - public void run() {
1.44 - a.actionPerformed(new ActionEvent(this, 0, ""));
1.45 - }
1.46 - });
1.47 - String out = MemoryURL.getOutputForURL(u.toExternalForm());
1.48 - assertEquals("Hello World!", out);
1.49 - }
1.50 -
1.51 - @Test
1.52 - public void writeWithAQuestion() throws Exception {
1.53 - URL u = new URL("memory://queryEncoding.txt");
1.54 -
1.55 - MemoryURL.registerURL(u.toExternalForm(), "", new QueryStream());
1.56 - final Action a = IOManager.createSaveAction(u, "Ask a Question");
1.57 - // simulate that the user clicks Yes to the reverse question in the dialog
1.58 - IOManager.setVisibleOption = JOptionPane.YES_OPTION;
1.59 - EventQueue.invokeAndWait(new Runnable() {
1.60 - public void run() {
1.61 - a.actionPerformed(new ActionEvent(this, 0, ""));
1.62 - }
1.63 - });
1.64 - String out = MemoryURL.getOutputForURL(u.toExternalForm());
1.65 - assertEquals("Text is reversed", "noitseuQ a ksA", out);
1.66 - }
1.67 -}
1.68 \ No newline at end of file