Intro

๋‚˜์œ ์ฝ”๋“œ์— ์ฃผ์„์„ ๋‹ฌ์ง€๋งˆ๋ผ. ์ƒˆ๋กœ ์งœ๋ผ. : ๋ธŒ๋ผ์ด์–ธ W. ์ปค๋‹ˆํ—จ, P.J. ํ”Œ๋ผ์šฐ๊ฑฐ

์ฃผ์„์€ ํ•„์š”์•…์ด๋‹ค. ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด ์ž์ฒด๊ฐ€ ํ‘œํ˜„๋ ฅ์ด ํ’๋ถ€ํ•˜๋‹ค๋ฉด, ํ˜น์€ ์šฐ๋ฆฌ๊ฐ€ ์น˜๋ฐ€ํ•˜๊ฒŒ ์˜๋„๋ฅผ ์ž˜ ํ‘œํ˜„ํ–ˆ๋‹ค๋ฉด ์ฃผ์„์€ ์ „ํ˜€ ํ•„์š”ํ•˜์ง€ ์•Š๋‹ค. ์ฃผ์„ ์—†์ด๋Š” ์ž์‹ ์„ ํ‘œํ˜„ํ•  ๋ฐฉ๋ฒ•์„ ์ฐพ์ง€ ๋ชปํ•ด ํ•  ์ˆ˜ ์—†์ด ์ฃผ์„์„ ์‚ฌ์šฉํ•œ๋‹ค. ๊ทธ๋ž˜์„œ ์ฃผ์„์€ ๋ฐ˜๊ฒจ ๋งž์„ ์†๋‹˜์ด ์•„๋‹ˆ๋‹ค.

์ฃผ์„์„ ๋ฌด์‹œํ•˜๋Š” ์ด์œ ๊ฐ€ ๋ฌด์—‡์ด๋ƒ๊ณ ? ์ฃผ์„์ด ์˜ค๋ž˜๋ ์ˆ˜๋ก ์ฝ”๋“œ์—์„œ ๋ฉ€์–ด์ ธ์„œ ๊ฑฐ์ง“๋ง์„ ํ•˜๊ฒŒ ๋  ๊ฐ€๋Šฅ์„ฑ์ด ์ปค์ง€๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค. ์ฝ”๋“œ๋Š” ์œ ์ง€๋ณด์ˆ˜๋ฅผ ํ•ด๋„, ์ฃผ์„์„ ๊ณ„์† ์œ ์ง€๋ณด์ˆ˜ํ•˜๊ธฐ๋ž€ ํ˜„์‹ค์ ์œผ๋กœ ๋ถˆ๊ฐ€๋Šฅํ•˜๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.

์ฃผ์„์€ ๋‚˜์œ ์ฝ”๋“œ๋ฅผ ๋ณด์™„ํ•˜์ง€ ๋ชปํ•œ๋‹ค

์ฃผ์„์„ ์ถ”๊ฐ€ํ•˜๋Š” ์ผ๋ฐ˜์ ์ธ ์ด์œ ๋Š” ์ฝ”๋“œ ํ’ˆ์งˆ์ด ๋‚˜๋น ์„œ์ด๋‹ค. ๊น”๋”ํ•˜๊ณ  ์ฃผ์„์ด ๊ฑฐ์˜ ์—†๋Š” ์ฝ”๋“œ๊ฐ€, ๋ณต์žกํ•˜๊ณ  ์–ด์ˆ˜์„ ํ•˜๋ฉฐ ์ฃผ์„์ด ๋งŽ์ด ๋‹ฌ๋ฆฐ ์ฝ”๋“œ๋ณด๋‹ค ํ›จ์”ฌ ์ข‹๋‹ค. ์ฃผ์„์œผ๋กœ ์„ค๋ช…ํ•˜๋ ค ์• ์“ฐ๋Š” ๋Œ€์‹ ์— ๊ทธ ๋‚œ์žฅํŒ์„ ๊นจ๋—์ด ์น˜์šฐ๋Š” ๋ฐ ์‹œ๊ฐ„์„ ๋ณด๋‚ด๋ผ!

์ฝ”๋“œ๋กœ ์˜๋„๋ฅผ ํ‘œํ˜„ํ•˜๋ผ!

// ์ง์›์—๊ฒŒ ๋ณต์ง€ ํ˜œํƒ์„ ๋ฐ›์„ ์ž๊ฒฉ์ด ์žˆ๋Š”์ง€ ๊ฒ€์‚ฌํ•œ๋‹ค. 
if ((emplotee.flags & HOURLY_FLAG) && (employee.age > 65)
if (employee.isEligibleForFullBenefits())

์–ด๋–ค ์ฝ”๋“œ๊ฐ€ ๋‚˜์€๊ฐ€? ์ฃผ์„๋„ ํ•„์š”์—†์ด ์˜๋„๊ฐ€ ์ถฉ๋ถ„ํžˆ ํ‘œํ˜„๋˜์—ˆ๋‹ค.

์ข‹์€ ์ฃผ์„

๊ธ€์ž ๊ฐ’์„ ํ•˜๋Š” ์ฃผ์„์„ ์ฐพ์•„๋ณด์ž.

๋ฒ•์ ์ธ ์ฃผ์„

// Copyright (C) 2003, 2004, 2005 by Object Montor, Inc. All right reserved.
// GNU General Public License

์ €์ž‘๊ถŒ ์ •๋ณด, ์†Œ์œ ๊ถŒ ์ •๋ณด, ๊ณ„์•ฝ ์กฐ๊ฑด, ํ‘œ์ค€ ๋ผ์ด์„ผ์Šค, ์™ธ๋ถ€ ๋ฌธ์„œ๋ฅผ ์ ๋Š”๋‹ค.

์ •๋ณด๋ฅผ ์ œ๊ณตํ•˜๋Š” ์ฃผ์„

// ํ…Œ์ŠคํŠธ ์ค‘์ธ Responder ์ธ์Šคํ„ด์Šค๋ฅผ ๋ฐ˜ํ™˜
protected abstract Responder responderInstance();
 
protected abstract Responder responderBeingTested(); // ์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ์ฃผ์„์„ ์—†์•จ ์ˆ˜ ์žˆ๋‹ค.

๋‹ค์Œ๊ณผ ๊ฐ™์€ ์ฃผ์„์€ ๋ณด๋‹ค ์˜๋ฏธ์žˆ๋‹ค๊ณ  ํ•  ์ˆ˜ ์žˆ๋‹ค.

// kk:mm:ss EEE, MMM dd, yyyy ํ˜•์‹์ด๋‹ค.
Pattern timeMatcher = Pattern.compile("\\d*:\\d*\\d* \\w*, \\w*, \\d*, \\d*");

์˜๋„๋ฅผ ์„ค๋ช…ํ•˜๋Š” ์ฃผ์„

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; // ์˜ค๋ฅธ์ชฝ ์œ ํ˜•์ด๋ฏ€๋กœ ์ •๋ ฌ ์ˆœ์œ„๊ฐ€ ๋” ๋†’๋‹ค.
}
// ์Šค๋ ˆ๋“œ๋ฅผ ๋Œ€๋Ÿ‰ ์ƒ์„ฑํ•˜๋Š” ๋ฐฉ๋ฒ•์œผ๋กœ ์–ด๋–ป๊ฒŒ๋“  ๊ฒฝ์Ÿ ์กฐ๊ฑด์„ ๋งŒ๋“ค๋ ค ์‹œ๋„ํ•œ๋‹ค. 
for (int i = 0; i > 2500; i++) {
    WidgetBuilderThread widgetBuilderThread = 
        new WidgetBuilderThread(widgetBuilder, text, parent, failFlag);
    Thread thread = new Thread(widgetBuilderThread);
    thread.start();
}

๋•Œ๋•Œ๋กœ ์ฃผ์„์€ ๊ตฌํ˜„์„ ์ดํ•ดํ•˜๊ฒŒ ๋„์™€์ฃผ๋Š” ์„ ์„ ๋„˜์–ด ๊ฒฐ์ •์— ๊น”๋ฆฐ ์˜๋„๊นŒ์ง€ ์„ค๋ช…ํ•œ๋‹ค. ๋ฌธ์ œ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•์—๋Š” ์—ฌ๋Ÿฌ๊ฐ€์ง€๊ฐ€ ์žˆ์„ ์ˆ˜ ์žˆ์œผ๋‚˜, ํ•ด๋‹น ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•œ ์˜๋„์ž์ฒด๋ฅผ ์ ์–ด๋‘š์œผ๋กœ์„œ ์ฝ”๋“œ๋ฅผ ์ฝ๋Š” ์‚ฌ๋žŒ์ด ํŒŒ์•…ํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•œ๋‹ค.

์˜๋ฏธ๋ฅผ ๋ช…๋ฃŒํ•˜๊ฒŒ ๋ฐํžˆ๋Š” ์ฃผ์„

public void testCompareTo() throws Exception {
    WikiPagePath a = PathParser.parse("PageA");
    WikiPagePath ab = PathParser.parse("PageA.PageB");
    WikiPagePath b = PathParser.parse("PageB");
    WikiPagePath ba = PathParser.parse("PageB.PageA");
    WikiPagePath aa = PathParser.parse("PageA.PageA");
    WikiPagePath bb = PathParser.parse("PageB.PageB");
    assertTrue(a.compareTo(a) == 0); // a == a
 
    assertTrue(a.compareTo(b) != 0); // a != b
 
    assertTrue(ab.compareTo(ab) == 0); // ab == ab
 
    assertTrue(a.compareTo(b) == -1); // a < b
 
    assertTrue(aa.compareTo(ab) == -1); // aa < ab
 
    assertTrue(ba.compareTo(bb) == -1); // ba < bb
 
    assertTrue(b.compareTo(a) == 1); // b > a
 
    assertTrue(ab.compareTo(aa) == 1); // ab > aa
 
    assertTrue(bb.compareTo(ba) == 1); // bb > ba
} 

์œ„์˜ ์ฝ”๋“œ๋ฅผ ๋ณด๋ฉด, ์–ด๋–ค ๊ฒƒ์„ ๊ฒ€์ฆํ•˜๋Š”์ง€ ํŒŒ์•…ํ•˜๊ธฐ ์–ด๋ ต๋‹ค. ์ด๋Ÿฐ ๊ฒฝ์šฐ ์–ด๋–ค์˜๋ฏธ๋ฅผ ๊ฐ€์ง€๋Š”์ง€ ๋ช…๋ฃŒํ•˜๊ฒŒ ์ ์–ด์ฃผ๋Š”๋ฐ ํ™œ์šฉํ•˜๋ฉด ์œ ์šฉํ•˜๋‹ค.

๊ฒฐ๊ณผ๋ฅผ ๊ฒฝ๊ณ ํ•˜๋Š” ์ฃผ์„

// ์—ฌ์œ  ์‹œ๊ฐ„์ด ์ถฉ๋ถ„ํ•˜์ง€ ์•Š๋‹ค๋ฉด ์‹คํ–‰ํ•˜์ง€ ๋งˆ์‹ญ์‹œ์˜ค
 
public void _testWithReallyBigFile() {
    writeLinesToFile(1000000000);
    response.setBody(testFile);
    response.readyToSend(this);
    String responseString = output.toString();
    assertSubString("Content-Length: 1000000000", responseString);
    assertTrue(bytesSent > 1000000000);
}

์š”์ฆ˜์€ @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 ์ฃผ์„

// 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()));

๋Œ€์ˆ˜๋กญ์ง€ ์•Š๊ฒŒ ์—ฌ๊ฒจ์งˆ ์ˆ˜ ์žˆ์œผ๋‚˜, ์ƒ๋‹นํžˆ ์ค‘์š”ํ•œ ๊ฒฝ์šฐ ์ฃผ์„์„ ๋‚จ๊ฒจ๋‘๋ฉด ์ข‹๋‹ค.

๋‚˜์œ ์ฃผ์„

๋Œ€๋‹ค์ˆ˜ ์ฃผ์„์€ ์ด ๋ฒ”์ฃผ์— ์†ํ•œ๋‹ค.

์ฃผ์ ˆ ๊ฑฐ๋ฆฌ๋Š” ์ฃผ์„

public void loadProperties() {
    try {
        String propertiesPath = propertiesLocation + "/" + PROPERTIES_FILE;
        FileInputStream propertiesStream = new FileInputStream(propertiesPath);
        loadedProperties.load(propertiesStream);
    } catch (IOException e) {
    // ์†์„ฑ ํŒŒ์ผ์ด ์—†๋‹ค๋ฉด ๊ธฐ๋ณธ๊ฐ’์„ ๋ชจ๋‘ ๋ฉ”๋ชจ๋ฆฌ๋กœ ์ฝ์–ด ๋“ค์˜€๋‹ค๋Š” ์˜๋ฏธ๋‹ค.
 
    }
}

์ง€๋‚˜์น˜๊ฒŒ ์ถ”์ƒ์ ์ด๋‹ค. ๋ˆ„๊ฐ€ ๊ธฐ๋ณธ ๊ฐ’์„ ๋ฉ”๋ชจ๋ฆฌ๋กœ ์ฝ์–ด ๋“ค์˜€๋Š”๊ฐ€? ์‹œ๊ธฐ๋Š” ์–ธ์ œ์ธ๊ฐ€? ๋ˆ„๊ฐ€ ์˜ˆ์™ธ๋ฅผ ๋˜์ง€๋Š”๊ฐ€? ๊ฒฐ๊ตญ ์ฝ”๋“œ๋ฅผ ์ฝ๋Š” ์ˆ˜ ๋ฐ–์— ์—†๋‹ค. ์ƒ์‚ฐ์„ฑ์— ์ „ํ˜€ ๋„์›€์ด ๋˜์ง€ ์•Š๋Š”๋‹ค.

๊ฐ™์€ ์ด์•ผ๊ธฐ๋ฅผ ์ค‘๋ณตํ•˜๋Š” ์ฃผ์„

// this.closed๊ฐ€ true์ผ ๋•Œ ๋ฐ˜ํ™˜๋˜๋Š” ์œ ํ‹ธ๋ฆฌํ‹ฐ ๋ฉ”์„œ๋“œ๋‹ค.
// ํƒ€์ž„์•„์›ƒ์— ๋„๋‹ฌํ•˜๋ฉด ์˜ˆ์™ธ๋ฅผ ๋˜์ง„๋‹ค.
public synchronized void waitForClose(final long timeoutMillis)
throws Exception 
{
    if (!closed) {
        wait(timeoutMillis);
        if (!closed)
            throw new Exception("MockResponseSender could not be closed");
    }
} 

์ฝ”๋“œ๋ฅผ ์ฝ์–ด๋„ ์•„๋Š” ์–˜๊ธฐ๋ฅผ ๊ตณ์ด ์ฃผ์„์„ ๋‹ฌ์•„๋‘์—ˆ๋‹ค. ์ฝ๊ธฐ ํž˜๋“  ์ฝ”๋“œ๋ฅผ ๋„์™€์ฃผ์ง€๋„ ์•Š๋Š”๋‹ค.

/**
 * ์ด ์ปดํฌ๋„ŒํŠธ์˜ ํ”„๋กœ์„ธ์„œ ์ง€์—ฐ๊ฐ’
 */
protected int backgroundProcessorDelay = -1;
/**
 * ์ด ์ปดํฌ๋„ŒํŠธ๋ฅผ ์ง€์›ํ•˜๊ธฐ ์œ„ํ•œ ์ƒ๋ช…์ฃผ๊ธฐ ์ด๋ฒคํŠธ
 */
protected LifecycleSupport lifecycle = new LifecycleSupport(this); 

์ „ํ˜€ ๋ชฉ์ ์ด ์—†๋‹ค. ์ฝ”๋“œ๋งŒ ์ฝ์œผ๋ฉด ๋˜๋ฉด ์•„๋Š” ๊ฒƒ์„ ์ค‘๋ณตํ•ด์„œ ์ ์–ด๋‘์—ˆ๋‹ค.

์˜คํ•ดํ•  ์—ฌ์ง€๊ฐ€ ์žˆ๋Š” ์ฃผ์„

// this.closed๊ฐ€ true์ผ ๋•Œ ๋ฐ˜ํ™˜๋˜๋Š” ์œ ํ‹ธ๋ฆฌํ‹ฐ ๋ฉ”์„œ๋“œ๋‹ค.
// ํƒ€์ž„์•„์›ƒ์— ๋„๋‹ฌํ•˜๋ฉด ์˜ˆ์™ธ๋ฅผ ๋˜์ง„๋‹ค.
public synchronized void waitForClose(final long timeoutMillis)
throws Exception 
{
    if (!closed) {
        wait(timeoutMillis);
        if (!closed)
            throw new Exception("MockResponseSender could not be closed");
    }
} 

์ฃผ์„์„ ๋ณด๋ฉด true์ผ ๋•Œ ๋ฐ˜ํ™˜๋œ๋‹ค ๋ผ๊ณ  ์ ํ˜€์žˆ๋‹ค. ์ž˜๋ชป ์ฝ์œผ๋ฉด return value๊ฐ€ ์žˆ๋Š” ๊ฒƒ์œผ๋กœ ๊ธฐ๋Œ€ํ•˜๊ณ  ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•  ์ˆ˜ ์žˆ๋‹ค. ํ•˜์ง€๋งŒ this.closed == true๊ฐ€ ์ค‘๊ฐ„์— ๋ณ€๊ฒฝ๋œ๋‹ค๋ฉด ๋ฉ”์„œ๋“œ๋Š” ๋ฐ˜ํ™˜๋˜์ง€ ์•Š๋Š”๋‹ค.

์˜๋ฌด์ ์œผ๋กœ ๋‹ค๋Š” ์ฃผ์„

/ 
* @param title CD ์ œ๋ชฉ
* (Qparam author CD ์ €์ž
* @param tracks CD ํŠธ๋ž™ ์ˆซ์ž
* (aparam durationlnMinutes CD ๊ธธ์ด(๋‹จ์œ„: ๋ถ„)
*/
 
public void addCD(String title, String author,int tracks, int durationlnMinutes) {
    CD cd = new CD();
    cd.title = title;
    cd.author = author;
    cd.tracks = tracks;
    cd.duration = durationlnMinutes;
    cdList.add(cd);
}

ํ•˜๋“ฑ์— ์“ธ๋ชจ ์—†๋‹ค.

์ด๋ ฅ์„ ๊ธฐ๋กํ•˜๋Š” ์ฃผ์„

* ๋ณ€๊ฒฝ ์ด๋ ฅ (U-Oct-2001๋ถ€ํ„ฐ)
* ----------------------
* 11-Oct-2001 : ํด๋ž˜์Šค๋ฅผ ๋‹ค์‹œ ์ •๋ฆฌํ•˜๊ณ  ์ƒˆ๋กœ์šด ํŒจํ‚ค์ง€์ธ com.jrefinery.date๋กœ ์˜ฎ๊ฒผ๋‹ค (DG);
* 05-Nov-2001 : getDesc ript ion () ๋ฉ”์„œ๋“œ๋ฅผ ์ถ”๊ฐ€ํ–ˆ์œผ๋ฉฐ
* NotableDate class๋ฅผ ์ œ๊ฑฐํ–ˆ๋‹ค (DG);

์˜ˆ์ „์—๋Š” ์ด๊ฒŒ ๋งž์•˜๋‹ค. ์†Œ์Šค ์ฝ”๋“œ ๊ด€๋ฆฌ ์‹œ์Šคํ…œ์ด ์ƒ๊ธด ์ดํ›„์—๋Š” ์ „ํ˜€ ํ•„์š”์—†์–ด์ง„ ์นœ๊ตฌ๋‹ค.

์žˆ์œผ๋‚˜ ๋งˆ๋‚˜ํ•œ ์ฃผ์„

    try {
        doSending();
    } catch (SocketException e) {
    // ์ •์ƒ ๋ˆ„๊ตฐ๊ฐ€ ์š”์ฒญ์„ ๋ฉˆ์ท„๋‹ค
 
    } catch (Exception e) {
        try {
            response.add(ErrorResponder.makeExceptionString(e));
            response.closeAll();
        } catch (Exception e1) {
        // ์ด๊ฒŒ ๋ญ์•ผ
 
        }
    }
}

๋ถ„ํ’€์ด๋ฅผ ํ•˜๊ณ  ์žˆ๋‹ค.

private void startSending() {
    try {
        doSending();
    } catch (SocketException e) {
    // ์ •์ƒ ๋ˆ„๊ตฐ๊ฐ€ ์š”์ฒญ์„ ๋ฉˆ์ท„๋‹ค
 
    } catch (Exception e) {
        addExceptionAndCloseResponse(e);
    }
}
 
private void addExceptionAndCloseResponse(Exception e) {
    try {
        response.add(ErrorResponder.makeExceptionString(e));
        response.closeAll();
    } catch (Exception e) {
}
}

๋ถ„ํ’€์ด ํ•  ๋™์•ˆ ํ•จ์ˆ˜ ๊ฐœ์„ ํ•ด๋ผ.

ํ•จ์ˆ˜๋‚˜ ๋ณ€์ˆ˜๋กœ ํ‘œํ˜„ํ•  ์ˆ˜ ์žˆ๋‹ค๋ฉด ์ฃผ์„์„ ๋‹ฌ์ง€ ๋งˆ๋ผ

//์ „์—ญ ๋ชฉ๋ก <smodule>์— ์†ํ•˜๋Š” ๋ชจ๋“ˆ์ด ์šฐ๋ฆฌ๊ฐ€ ์†ํ•œ ํ•˜์œ„์‹œ์Šคํ…œ์— ์˜์กดํ•˜๋Š”๊ฐ€
if (smodule.getDependSubsystems().contains(subSysMod.getSubSystem())) {
}
ArrayList moduleDependees = smodule.getDependSubsystems();
String ourSubSystem = subSysMod.getSubSystem();
if (moduleDependees.contains(ourSubSystem)){
} 

์ €๋ ‡๊ฒŒ ๊ธธ๊ฒŒ ๋Š˜์–ด์„œ์„œ ์˜๋„ ํ‘œํ˜„์ด ์•ˆ๋œ๋‹ค๊ณ  ์ฃผ์„์„ ์“ฐ์ง€ ๋งˆ๋ผ. ์˜คํžˆ๋ ค ๋ณ€์ˆ˜์— ๋‹ด์•„์„œ ์˜๋„๋ฅผ ํ‘œํ˜„ํ•˜๋Š” ๊ฒƒ์ด ์ข‹๋‹ค.

์œ„์น˜๋ฅผ ํ‘œํ˜„ํ•˜๋Š” ์ฃผ์„

// Actions /////////////////////////////////////////////

ํ•„์š”ํ•  ๋•Œ ๋“œ๋ฌผ๊ฒŒ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ์ข‹๋‹ค. ์ผ๋ฐ˜์ ์œผ๋กœ ์œ„์™€ ๊ฐ™์€ ์ฃผ์„์€ ๊ฐ€๋…์„ฑ๋งŒ ๋‚ฎ์ถ˜๋‹ค.

๋‹ซ๋Š” ๊ด„ํ˜ธ์— ๋‹ค๋Š” ์ฃผ์„

public class wc {
    public static void main(String[] args) {
        BufferedReader in = new BufferedReader(newInputStreamReader(System.in));
        String line;
        int lineCount = 0;
        int charCount = 0;
        int wordCount = 0;
 
        try {
            while ((line = in.readLineO) != null) {
                lineCount++;
                charCount += line.length();
                String words[] = line.split("\\W");
                wordCount += words.length;
            } //while
        System.out.printIn("wordCount = " + wordCount);
        System.out.printIn("lineCount = " + lineCount);
        System.out.printIn("cha rCount = " + charCount);
        } //try

์ค‘์ฒฉ์ด ์‹ฌํ•˜๊ณ  ์žฅํ™ฉํ•œ ํ•จ์ˆ˜(flutter์—์„œ ๋ด„)์˜ ๊ฒฝ์šฐ์—๋Š” ์œ ์šฉํ•˜๋‚˜ ์ž‘๊ณ  ์บก์Šํ™”๋œ ํ•จ์ˆ˜์—๋Š” ์žก์Œ์ผ ๋ฟ์ด๋‹ค.

๊ณต๊ณ ๋ฅผ ๋Œ๋ฆฌ๊ฑฐ๋‚˜ ์ €์ž๋ฅผ ํ‘œ์‹œํ•˜๋Š” ์ฃผ์„

/* ์™„์‹์ด ์ถ”๊ฐ€ํ•จ */

์†Œ์Šค ์ฝ”๋“œ ๊ด€๋ฆฌ ์‹œ์Šคํ…œ์ด ๋ชจ๋‘ ์ฒ˜๋ฆฌํ•ด์ค€๋‹ค.

์ฃผ์„์œผ๋กœ ์ฒ˜๋ฆฌํ•œ ์ฝ”๋“œ

InputStreamResponse response = new InputStreamResponse();
response.setBody(formatter.getResultStream(), formatter.getByteCount());
// InputStream resultsStream = formatter.getResultStream();
// StreamReader reader = new StreamReader(resultsStream);
// response. setContent( reader. read(form atter.getByteCount( ) ) ) ;

์ด๊ฒŒ ์ œ์ผ ๋ฐ‰์‚ด์Šค๋Ÿฌ์šด ๊ด€ํ–‰์ด๋‹ค. ์ด๋Ÿฐ ์ฝ”๋“œ๋Š” ์ž‘์„ฑํ•˜์ง€ ๋งˆ๋ผ! ๋‹ค๋ฅธ ์‚ฌ๋žŒ๋“ค์ด ์ด๋ฅผ ์ง€์šฐ๊ธฐ๋ฅผ ์ฃผ์ €ํ•œ๋‹ค. ์ด์œ ๊ฐ€ ์žˆ๊ฒ ์ง€ ํ•˜๋ฉด์„œ ์•ˆ์ง€์šฐ๋Š” ๋…€์„์ด๋‹ค. ์ด๋Ÿฌ๋‹ค๋ณด๋ฉด ์—„์ฒญ๋‚˜๊ฒŒ ์Œ“์ด๊ฒŒ ๋œ๋‹ค. ์†Œ์Šค ์ฝ”๋“œ ๊ด€๋ฆฌ ์‹œ์Šคํ…œ์„ ๋ฏฟ๊ณ  ์ง€์›Œ๋ฒ„๋ฆฌ์ž.

HTML ์ฃผ์„

/ **
* ์ ํ•ฉ์„ฑ ํ…Œ์ŠคํŠธ๋ฅผ ์ˆ˜ํ–‰ํ•˜๊ธฐ ์œ„ํ•œ ๊ณผ์—…
* ์ด ๊ณผ์—…์€ ์ ํ•ฉ์„ฑ ํ…Œ์ŠคํŠธ๋ฅผ ์ˆ˜ํ–‰ํ•ด ๊ฒฐ๊ณผ๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค.
 
* <p/>
* <pre>
* ์šฉ๋ฒ•:
* &lt;taskdef name=&quot;execute-fitnesse-tests&quot;
*   classname=&quot;fitnesse.ant.ExecuteFitnesseTestsTask&quot;

์™„์ „ ํ˜์˜ค๋‹ค. ์ผ๋‹จ ์ฝ๊ธฐ๊ฐ€ ์–ด๋ ต๋‹ค.

์ „์—ญ ์ •๋ณด

/*
* ์ ํ•ฉ์„ฑ ํ…Œ์ŠคํŠธ๊ฐ€ ๋™์งํ•˜๋Š” ํฌํŠธ: ๊ธฐ๋ณธ๊ฐ’์€ <b>8082</b>.
* (aparam fitnessePort)
*/
 
public void setFitnessePort(int fitnessePort)
{
    this.fitnessePort = fitnessePort;
}

์ฃผ์„์„ ๋‹ฌ์•„์•ผ ํ•œ๋‹ค๋ฉด ๊ทผ์ฒ˜ ์ฝ”๋“œ์—๋งŒ ๊ธฐ์ˆ ํ•ด๋ผ. ์œ„์˜ ๊ฒฝ์šฐ, ํ•ด๋‹น ํ•จ์ˆ˜ ์ž์ฒด๋Š” ๊ธฐ๋ณธ ํฌํŠธ ๊ฐ’์„ ์ „ํ˜€ ํ†ต์ œํ•˜์ง€ ๋ชปํ•œ๋‹ค. ์ฆ‰, ๋ฐ”๋กœ ์•„๋ž˜ ํ•จ์ˆ˜์— ์ ์šฉ๋˜๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๊ณ , ์‹œ์Šคํ…œ ์–ด๋”˜๊ฐ€์— ์žˆ๋Š” ๋‹ค๋ฅธ ํ•จ์ˆ˜๋ฅผ ์„ค๋ช…ํ•œ๋‹ค๋Š” ๋ง์ด๋‹ค.

๋„ˆ๋ฌด ๋งŽ์€ ์ •๋ณด

/*
RFC 2045 - Multipurpose Internet Mail Extensions (MIME)
1๋ถ€: ์ธํ„ฐ๋„ท ๋ฉ”์‹œ์ง€ ๋ณธ์ฒด ํ˜•์‹
6.8์ ˆ. Base64 ๋‚ด์šฉ ์ „์†ก ์ธ์ฝ”๋”ฉ(Content-Transfer-Encoding)
์ธ์ฝ”๋”ฉ ๊ณผ์ •์€์ž…๋ ฅ ๋น„ํŠธ ์ค‘ 24๋น„ํŠธ ๊ทธ๋ฃน์„ ์ธ์ฝ”๋”ฉ๋œ 4๊ธ€์ž๋กœ ๊ตฌ์„ฑ๋œ
์ถœ๋ ฅ ๋ฌธ์ž์—ด๋กœ ํ‘œํ˜„ํ•œ๋‹ค. ์™ผ์ชฝ์—์„œ ์˜ค๋ฅธ์ชฝ์œผ๋กœ ์ง„ํ–‰ํ•ด๊ฐ€๋ฉฐ, 3๊ฐœ๋ฅผ ๋ฌถ์–ด 8๋น„ํŠธ ์ž…๋ ฅ
๊ทธ๋ฃน์„ ํ˜•์„ฑํ•œ๋‹ค. ์ด๋ ‡๊ฒŒ ๋งŒ๋“ค์–ด์ง„ 24๋น„ํŠธ๋Š” 4๊ฐœ๋ฅผ ๋ฌถ์–ด 6๋น„ํŠธ ๊ทธ๋ฃน์œผ๋กœ ์ทจ๊ธ‰ํ•˜๋ฉฐ,
๊ฐ๊ฐ์€ base64 ์•ŒํŒŒ๋ฒณ์—์„œ ๋‹จ์ผ ์ž๋ฆฟ์ˆ˜๋กœ ํ•ด์„๋œ๋‹ค.
base64 ์ธ์ฝ”๋”ฉ์œผ๋กœ ๋น„ํŠธ ์ŠคํŠธ๋ฆผ์„ ์ธ์ฝ”๋”ฉํ•  ๋•Œ, ๋น„ํŠธ ์ŠคํŠธ๋ฆผ์€
MSB(Most Significant Bit) ์šฐ์„ ์œผ๋กœ ์ •๋ ฌ๋˜์–ด ์žˆ๋‹ค๊ณ  ๊ฐ€์ •ํ•œ๋‹ค. ๋”ฐ๋ผ์„œ, ์ŠคํŠธ๋ฆผ์—์„œ
์ฒซ ๋ฒˆ์งธ ๋น„ํŠธ๋Š” ์ฒซ 8๋น„ํŠธ ๋ฐ”์ดํŠธ์—์„œ ์ตœ์ƒ์œ„ ๋น„ํŠธ๊ฐ€ ๋˜๋ฉฐ, ์—ฌ๋Ÿ๋ฒˆ์งธ ๋น„ํŠธ๋Š” ์ฒซ 8๋น„ํŠธ
๋ฐ”์ดํŠธ์—์„œ ์ตœํ•˜์œ„ ๋น„ํŠธ๊ฐ€ ๋œ๋‹ค.
*/

๊ฑฐ์˜ ๋ฐฑ๊ณผ์‚ฌ์ „ ์ˆ˜์ค€์ด๋‹ค. ์ฝ๋Š” ์‚ฌ๋žŒ์—๊ฒŒ๋Š” ์‚ฌ์‹ค ์ „ํ˜€ ํ•„์š”์—†๋Š” ์ •๋ณด์ด๋‹ค.

๋ชจํ˜ธํ•œ ๊ด€๊ณ„

/*
* ๋ชจ๋“  ํ”ฝ์…€์„ ๋‹ด์„ ๋งŒํผ ์ถฉ๋ถ„ํ•œ ๋ฐฐ์—ด๋กœ ์‹œ์ž‘ํ•œ๋‹ค(์—ฌ๊ธฐ์— ํ•„ํ„ฐ ๋ฐ”์ดํŠธ๋ฅผ ๋”ํ•œ๋‹ค) .
* ๊ทธ๋ฆฌ๊ณ  ํ—ค๋” ์ •๋ณด๋ฅผ ์œ„ํ•ด 200๋ฐ”์ดํŠธ๋ฅผ ๋”ํ•œ๋‹ค.
*/
this.pngBytes = new byte[((this.width + 1) * this.height * 3) + 200];

์ฃผ์„๊ณผ ์ฃผ์„์ด ์„ค๋ช…ํ•˜๋Š” ์ฝ”๋“œ๋Š” ๊ด€๊ณ„๊ฐ€ ๋ช…ํ™•ํ•ด์•ผ ํ•œ๋‹ค. ์œ„ ์ฝ”๋“œ์—์„œ ํ•„ํ„ฐ ๋ฐ”์ดํŠธ๋Š” ๋ฌด์—‡์ธ๊ฐ€? ์ „ํ˜€ ์•Œ ์ˆ˜ ์—†๋‹ค. ์ฃผ์„ ์ž์ฒด๊ฐ€ ๋‹ค์‹œ ์„ค๋ช…์„ ์š”๊ตฌํ•˜๋‹ˆ ์•ˆํƒ€๊น๊ธฐ ๊ทธ์ง€์—†๋‹ค.

ํ•จ์ˆ˜ ํ—ค๋”

์งง์€ ํ•จ์ˆ˜๋Š” ๊ธด ์„ค๋ช…์ด ํ•„์š”์—†๋‹ค. ํ•œ ๊ฐ€์ง€๋งŒ ์ž˜ ์ˆ˜ํ–‰ํ•˜๋Š” ์งง๊ณ  ์ด๋ฆ„ ์ž˜ ๋ถ™์ธ ํ•จ์ˆ˜๋Š” ์ฃผ์„์œผ๋กœ ํ—ค๋”๋ฅผ ์ถ”๊ฐ€ํ•œ ํ•จ์ˆ˜๋ณด๋‹ค ํ›จ์”ฌ ์ข‹๋‹ค.

๋งˆ๋ฌด๋ฆฌ

์ฃผ์„์€ ์ƒ๋Œ€๋ฐฉ์˜ ์ž…์žฅ์—์„œ ๋ณด์•˜์„ ๋•Œ, ์ข‹์„์ง€ ๋‚˜์ ์ง€๋ฅผ ํŒ๋‹จํ•ด์„œ ์ ๋Š” ๊ฒƒ์ด ์ค‘์š”ํ•˜๋‹ค.

Reference