1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package net.sf.sail.common.apps;
24
25 import java.util.logging.Logger;
26
27 import java.awt.BorderLayout;
28 import java.awt.Container;
29 import java.io.File;
30 import java.io.IOException;
31 import java.net.MalformedURLException;
32 import java.net.URL;
33
34 import javax.swing.ImageIcon;
35 import javax.swing.JFrame;
36 import javax.swing.JLabel;
37 import javax.swing.JTextArea;
38
39 import net.sf.sail.core.util.BinaryUtils;
40
41
42
43
44 public class TestJWS extends JFrame {
45
46
47
48 private static final Logger logger = Logger.getLogger(TestJWS.class
49 .getName());
50
51 private static final long serialVersionUID = 5826896226244741246L;
52
53 URL checkboxSource;
54
55 URL badxSource;
56
57 URL dlSource;
58 {
59 try {
60 checkboxSource = new URL(
61 "http://www2.sls.lib.il.us/CTS/checkmark.gif");
62 badxSource = new URL(
63 "http://audilab.bmed.mcgill.ca/~funnell/quiz/gif/red_x.GIF");
64 dlSource = new URL(
65 "http://turadg.wisetest.org/tmp/jnlp/curnit16146.zip");
66 } catch (MalformedURLException e) {
67 e.printStackTrace();
68 }
69 }
70
71 StringBuffer messageBuffer = new StringBuffer("Messages:\n");
72
73 boolean success = true;
74
75
76
77
78 public void buildContent() {
79 Container contentPane = getContentPane();
80 contentPane.setLayout(new BorderLayout());
81 ImageIcon imageIcon;
82 if (success)
83 imageIcon = new ImageIcon(checkboxSource);
84 else
85 imageIcon = new ImageIcon(badxSource);
86 contentPane.add(new JLabel(imageIcon), BorderLayout.NORTH);
87 JTextArea messageArea = new JTextArea(messageBuffer.toString());
88 messageArea.setLineWrap(true);
89 contentPane.add(messageArea, BorderLayout.CENTER);
90 setSize(400, 600);
91 }
92
93 public static void main(String[] args) {
94 TestJWS tester = new TestJWS();
95 tester.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
96 tester.check();
97 tester.buildContent();
98 tester.setVisible(true);
99 }
100
101
102
103
104 private void check() {
105 try {
106 File downloaded = BinaryUtils.tempFileForUrl(dlSource);
107 if (!downloaded.exists())
108 throw new IOException("failed to download");
109 messageBuffer.append("download success");
110 } catch (IOException e) {
111 logger.severe("exception: " + e);
112 success = false;
113 messageBuffer.append("while downloading:\n " + e);
114 }
115 }
116
117 }