๐ย ์ค๋ ์ฝ์ ๋ฒ์ : 4.์ฃผ์(68~75p)
MockRequest request;
private final String HTTP_DATE_REGEXP =
"[SMTWF][a-z]{2}\\,\\s[0-9]{2}\\s[JFMASOND][a-z]{2}\\s"+
"[0-9]{4}\\s[0-9]{2}\\:[0-9]{2}\\:[0-9]{2}\\sGMT"; private Response response;
private FitNesseContext context;
private FileResponder responder;
private Locale saveLocale;
// Example: "Tue, 02 Apr 2003 22:18:49 GMT"
๋์ค์ ์ถ๊ฐ๋ ์ธ์คํด์ค ๋ณ์๋ค์ด ์ฃผ์์ ์๋ณธ ์ฝ๋์์ ๋ฉ์ด์ง๊ฒ ํ์๋ฏํ๋ค// ์ง์์๊ฒ ๋ณต์ง ํํ์ ๋ฐ์ ์๊ฒฉ์ด ์๋์ง ๊ฒ์ฌํ๋ค.
if ((employee.flags & HOURLY_FLAG) &&
(employee.age > 65))
๋ณด๋ค๋.. ์ฃผ์๋ ํจ์๋ช ์ผ๋ก ํํํ๋ค
if (employee.isEligibleForFullBenefits())
// Copyright (C) 2003,2004,2005 by Object Mentor, Inc. All rights reserved.
// GNU General Public License ๋ฒ์ 2 ์ด์์ ๋ฐ๋ฅด๋ ์กฐ๊ฑด์ผ๋ก ๋ฐฐํฌํ๋ค.
// ํ
์คํธ ์ค์ธ Responder ์ธ์คํด์ค๋ฅผ ๋ฐํํ๋ค.
protected abstract Responder responderInstance();
๊ทธ๋๋ ์ ๋งํ๋ฉด responderBeingTested
์ ๊ฐ์ ์ด๋ฆ์ผ๋ก ์ค๋ช
ํ์public int compareTo(Object o) {
if(o instanceof WikiPagePath) {
WikiPagePath p = (WikiPagePath) o;
String compressedName = StringUtil.join(names, "");
String compressedArgumentName = StringUtil.join(p.names, "");
return compressedName.compareTo(compressedArgumentName);
}
return 1; // ์ค๋ฅธ์ชฝ ์ ํ์ด๋ฏ๋ก ์ ๋ ฌ ์์๊ฐ ๋ ๋๋ค.
}
public void testConcurrentAddWidgets() throws Exception {
WidgetBuilder widgetBuilder =
new WidgetBuilder(new Class[] {
BoldWidget.class
});
String text = "'''bold text'''";
ParentWidget parent =
new BoldWidget(new MockWidgetRoot(), "'''bold text'''");
AtomicBoolean failFlag = new AtomicBoolean();
failFlag.set(false);
// ์ค๋ ๋๋ฅผ ๋๋ ์์ฑํ๋ ๋ฐฉ๋ฒ์ผ๋ก ์ด๋ป๊ฒ๋ ๊ฒฝ์ ์กฐ๊ฑด์ ๋ง๋ค๋ ค ์๋ํ๋ค.
for (int i = 0; i < 25000; i++) {
WidgetBuilderThread widgetBuilderThread =
new WidgetBuilderThread(widgetBuilder, text, parent, failFlag);
Thread thread = new Thread(widgetBuilderThread);
thread.start();
}
assertEquals(false, failFlag.get());
}
public void testCompareTo() throws Exception {
WikiPagePath a = PathParser.parse("PageA");
WikiPagePath ab = PathParser.parse("PageA.PageB");
WikiPagePath b = PathParser.parse("PageB");
WikiPagePath aa = PathParser.parse("PageA.PageA");
WikiPagePath bb = PathParser.parse("PageB.PageB");
WikiPagePath ba = PathParser.parse("PageB.PageA");
assertTrue(a.compareTo(a) == 0);
assertTrue(a.compareTo(b) != 0);
assertTrue(ab.compareTo(ab) == 0);
assertTrue(a.compareTo(b) == -1);
assertTrue(aa.compareTo(ab) == -1);
assertTrue(ba.compareTo(bb) == -1);
assertTrue(b.compareTo(a) == 1);
assertTrue(ab.compareTo(aa) == 1);
assertTrue(bb.compareTo(ba) == 1);
// a == a // a != b // ab == ab // a < b
// aa < ab // ba < bb // b > a // ab > aa // bb > ba
}
// ์ฌ์ ์๊ฐ์ด ์ถฉ๋ถํ์ง ์๋ค๋ฉด ์คํํ์ง ๋ง์ญ์์ค.
public void _testWithReallyBigFile() {
writeLinesToFile(10000000);
response.setBody(testFile);
response.readyToSend(this);
String responseString = output.toString();
assertSubString("Content-Length: 1000000000", responseString);
assertTrue(bytesSent > 1000000000);
}
JUnit4 ์ดํ๋ก๋@Ignore
์์ฑ์ ์ด์ฉํด ํ
์คํธ๋ฅผ ๋์๋ ์์
@Ignore("์คํ์ด ๋๋ฌด ์ค๋ ๊ฑธ๋ฆฐ๋ค.")
...
ํ๋ก๊ทธ๋จ ํจ์จ ๋์ธ๋ค๊ณ ์ ์ ์ด๊ธฐํ ํจ์๋ฅผ ์ฌ์ฉํ ๋ป ํ๋ค๊ฐ ์ฃผ์์ ํตํด ์ค์๋ฅผ ๋ฉดํจ
public static SimpleDateFormat makeStandardHttpDateFormat() {
// SimpleDateFormat์ ์ค๋ ๋์ ์์ ํ์ง ๋ชปํ๋ค.
// ๋ฐ๋ผ์ ๊ฐ ์ธ์คํด์ค๋ฅผ ๋
๋ฆฝ์ ์ผ๋ก ์์ฑํด์ผ ํ๋ค.
SimpleDateFormat df = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z");
df.setTimeZone(TimeZone.getTimeZone("GMT"));
return df;
}
// TODO-MdM ํ์ฌ ํ์ํ์ง ์๋ค.
// ์ฒดํฌ์์ ๋ชจ๋ธ์ ๋์
ํ๋ฉด ํจ์๊ฐ ํ์ ์๋ค.
protected VersionInfo makeVersion() throws Exception {
return null;
}
String listItemContent = match.group(3).trim();
// ์ฌ๊ธฐ์ trim์ ์ ๋ง ์ค์ํ๋ค. trim ํจ์๋ ๋ฌธ์์ด์์ ์์ ๊ณต๋ฐฑ์ ์ ๊ฑฐํ๋ค.
// ๋ฌธ์์ด์ ์์ ๊ณต๋ฐฑ์ด ์์ผ๋ฉด ๋ค๋ฅธ ๋ฌธ์์ด๋ก ์ธ์๋๊ธฐ ๋๋ฌธ์ด๋ค.
new ListItemWidget(this, listItemContent, this.level + 1);
return buildList(text.substring(match.end()));