-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathassertj-swing-migrating.html
209 lines (166 loc) · 10.6 KB
/
assertj-swing-migrating.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="AssertJ site">
<meta name="author" content="Joel Costigliola">
<title>AssertJ / Fluent assertions for java</title>
<!-- CSS -->
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Inconsolata|Source+Code+Pro|Open+Sans|Ubuntu|Varela+Round|Karla">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="font-awesome/css/font-awesome.min.css" rel="stylesheet">
<script src="highlight/highlight.pack.js"></script>
<link rel="stylesheet" href="highlight/styles/railscasts.css">
<script>hljs.initHighlightingOnLoad();</script>
<link href="css/assertj.min.css" rel="stylesheet">
<link rel="shortcut icon" href="favicon.png" />
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<!-- You'll want to use a responsive image option so this logo looks good on devices - I recommend using something like retina.js (do a quick Google search for it and you'll find it) -->
<a class="navbar-brand" href="index.html">AssertJ</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav navbar-nav navbar-right">
<li><a href="assertj-core-quick-start.html">Quick start</a></li>
<li><a href="assertj-news.html">News</a></li>
<li><a href="assertj-core.html">Core</a></li>
<li><a href="assertj-assertions-generator.html">Assertions generator</a></li>
<li><a href="assertj-guava.html">Guava</a></li>
<li><a href="assertj-joda-time.html">Joda-Time</a></li>
<li><a href="assertj-db.html">DB</a></li>
<li><a href="assertj-neo4j.html">Neo4j</a></li>
<li><a href="assertj-swing.html">Swing</a></li>
<li><a href="assertj-help.html">Help</a></li>
</ul>
</div>
</div>
</nav>
<div class="container">
<div class="row" >
<div class="col-md-2 assertj-sidebar-menu">
<div class="bs-sidebar hidden-print affix-top" role="complementary">
<ul class="bs-sidenav nav ">
<li class="sidenav-header">About</li>
<li><a href="assertj-swing.html">Overview</a></li>
<li><a href="assertj-swing-quick-start.html">Quick start</a></li>
<li><a href="assertj-swing-news.html">News & releases</a></li>
<li><a href="swing/api/index.html">Javadoc</a></li>
<li><a href="assertj-swing.html#code">Code & issues <i class="fa fa-github"></i></a></li>
<li><a href="assertj-swing.html#contributing">Contributing</a></li>
<li class="sidenav-header">Working with it</li>
<li><a href="assertj-swing-getting-started.html">Getting started</a></li>
<li><a href="assertj-swing-basics.html">Basics</a></li>
<li><a href="assertj-swing-edt.html">EDT</a></li>
<li><a href="assertj-swing-lookup.html">Component lookup</a></li>
<li><a href="assertj-swing-launch.html">Launching</a></li>
<li><a href="assertj-swing-input.html">Input simulation</a></li>
<li><a href="assertj-swing-running.html">Running tests</a></li>
<li><a href="assertj-swing-troubleshooting.html">Troubleshooting</a></li>
<li><a href="assertj-swing-advanced.html">Advanced features</a></li>
<li class="sidenav-header">Migrating</li>
<li><a href="assertj-swing-migrating.html">From Fest</a></li>
</ul>
</div>
</div>
<div class="col-lg-10 col-md-10 col-sm-10 text-left" >
<h1 class="page-header">Migrating from Fest Swing</h1>
<p>Migrating from Fest is easy! Since AssertJ Swing is a fork of Fest, there are very few breaking
changes. But we forked a not-published version (1.4-SNAPSHOT). So you may have to migrate more than this few
easy changes from your Fest version to AssertJ Swing. Below are all steps regarding to your Fest
version.</p>
<h2 class="page-header">Scriptable (aka Migrating from Fest 1.4-SNAPSHOT)</h2>
<p>The easiest part of the migration might be the part we changed: the naming from Fest to
AssertJ Swing.</p>
<h4 class="page-header">Migrate to AssertJ Core</h4>
<p>First you should have a look at the <a href="assertj-core-migrating-from-fest.html">FEST to AssertJ
migration guide</a>! All steps of migrating the core assertions are not described here but
<a href="assertj-core-migrating-from-fest.html">there</a>.</p>
<h4 class="page-header">Imports</h4>
<p>You should change your imports. Both, normal and static imports.</p>
<pre><code class="java">import static org.fest.swing.*</code></pre>
<p>to</p>
<pre><code class="java">import static org.assertj.swing.*</code></pre>
<p>For linux users, a quick way to do that is to use this command (see also
<a href="#all-in-one-command">all-in-one command</a>)</p>
<pre><code class="bash">find . -name "*.java" -exec sed -i "s/import static org.fest.swing./import static org.assertj.swing./g;s/import org.fest.swing./import org.assertj.swing./g" '{}' \;</code></pre>
<h4 class="page-header">Base test classes</h4>
<p>Another simple (in terms of automatable) task is to rename the base test classes from</p>
<pre><code class="java">FestSwingTestCaseTemplate
FestSwingJUnitTestCase
FestSwingTestNGTestCase</code></pre>
<p>to</p>
<pre><code class="java">AssertJSwingTestCaseTemplate
AssertJSwingJUnitTestCase
AssertJSwingTestNGTestCase</code></pre>
<p>Linux users use this command (see also <a href="#all-in-one-command">all-in-one command</a>)</p>
<pre><code class="bash">find . -name "*.java" -exec sed -i "s/FestSwingTestCaseTemplate/AssertJSwingTestCaseTemplate/g;s/FestSwingJUnitTestCase/AssertJSwingJUnitTestCase/g;s/FestSwingTestNGTestCase/AssertJSwingTestNGTestCase/g" '{}' \;</code></pre>
<h4 class="page-header"><span id="all-in-one-command"></span>All-in-one command</h3>
<p>To perform all steps above at once use this script.</p>
<pre><code class="bash">find . -name "*.java" -exec sed -i "s/import static org.fest.swing./import static org.assertj.swing./g;s/import org.fest.swing./import org.assertj.swing./g;s/FestSwingTestCaseTemplate/AssertJSwingTestCaseTemplate/g;s/FestSwingJUnitTestCase/AssertJSwingJUnitTestCase/g;s/FestSwingTestNGTestCase/AssertJSwingTestNGTestCase/g" '{}' \;</code></pre>
<h2 class="page-header">Hardly scriptable (aka Migrating from Fest 1.2.x)</h2>
<p>Above we described the steps that should help you to migrate most parts of your code. Unfortunately there
are some things to do which we were not able to script so that it would be 100% fail-safe (<em>but of course
we would love to see your solution if you made it!</em>). So you have to do them manually. These migrations
are the result of the refactorings made after publishing Fest 1.2.x.</p>
<p>Surely we missed some migration steps since we don't make use of the full API in our sample projects. So
<strong>please don't hesitate to notify us about further migration steps you encounter!</strong></p>
<h4 class="page-header">Direct field access</h4>
<p>Fest 1.2.x allowed to access some fields directly, Fest 1.4-SNAPSHOT and therefore AssertJ Swing does
not. Basically this comes down to replacing</p>
<pre><code class="java"><AbstractComponentFixture>.robot
<AbstractComponentFixture>.target</code></pre>
<p>by</p>
<pre><code class="java"><AbstractComponentFixture>.robot()
<AbstractComponentFixture>.target()</code></pre>
<p>Although scriptable <strong>this is not fail-safe</strong>, use this command only if you have a sufficient
VCS or backups.</p>
<pre><code class="bash">find . -name "*.java" -exec sed -i "s/robot\([^(]\)/robot()\1/g;s/target\([^(]\)/target()\1/g" '{}' \;</code></pre>
<h4 class="page-header">component()</h4>
<p>Fest 1.2.x has the method <span class="small-code">component()</span>, Fest 1.4-SNAPSHOT not. Replace it by
<span class="small-code">target()</span>.</p>
<p>Although scriptable <strong>this is not fail-safe</strong>, use this command only if you have a sufficient
VCS or backups.</p>
<pre><code class="bash">find . -name "*.java" -exec sed -i "s/component()/target()/g" '{}' \;</code></pre>
<h4 class="page-header">Replacing a driver</h4>
<p>With Fest 1.2.x you could replace a driver of a fixture with
<span class="small-code">driver(ComponentDriver)</span>. This method has been renamed to
<span class="small-code">replaceDriverWith(ComponentDriver)</span>.</p>
<p>Although scriptable <strong>this is not fail-safe</strong>, use this command only if you have a sufficient
VCS or backups.</p>
<pre><code class="bash">find . -name "*.java" -exec sed -i "s/driver(\([^)]\)/replaceDriverWith(\1/g" '{}' \;</code></pre>
<h4 class="page-header">Fields of Pair</h4>
<p>The class <span class="small-code">Pair</span> had two fields: <span class="small-code">i</span> and
<span class="small-code">ii</span>. These are now called <span class="small-code">first</span> and
<span class="small-code">second</span>.</p>
</div>
</div>
</div>
<br>
<!--
<div class="container">
<footer>
<div class="row">
<div class="col-lg-12">
<p>AssertJ - Licensed under the Apache License, Version 2.0.</p>
</div>
</div>
</footer>
</div>
-->
<script src="js/jquery-1.10.2.js"></script>
<script src="js/bootstrap.js"></script>
<script src="js/modern-business.js"></script>
<script src="js/assertj.js"></script>
</body>
</html>