<?xml version="1.0" encoding="gb2312"?>
<rss version="2.0">
<channel>
<title><![CDATA[乱七八糟]]></title>
        <image>
        <title>http://hi.baidu.com</title>
        <link>http://hi.baidu.com</link>
        <url>http://img.baidu.com/img/logo-hi.gif</url>
        </image>
<description><![CDATA[]]></description>
<link>http://hi.baidu.com/amess</link>
<language>zh-cn</language>
<generator>www.baidu.com</generator>
<ttl>5</ttl>


<item>
        <title><![CDATA[JUnit FAQ]]></title>
        <link><![CDATA[http://hi.baidu.com/amess/blog/item/02d60d3b85cdf7ed15cecba9.html]]></link>
        <description><![CDATA[
		
		<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt; text-indent: -21pt; mso-char-indent-count: 0; mso-list: l0 level1 lfo1"><span style=" mso-fareast- mso-bidi-"><span style="mso-list: Ignore">l<span style="font: 7pt  Times New Roman ">  </span></span></span><span><font face="Calibri">If you are running your JUnit 4 tests with a JUnit 3.x runner, write a suite() method that uses the JUnit4TestAdapter class to create a suite containing all of your test methods: </font></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt"><span><font face="Calibri"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;  </span>public static junit.framework.Test suite() {</font></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt"><span><font face="Calibri"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  </span>return new junit.framework.JUnit4TestAdapter(SimpleTest.class);</font></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-indent: 20.25pt"><span><font face="Calibri">}</font></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-indent: 20.25pt"><span><font face="Calibri"> </font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt; text-indent: -21pt; mso-char-indent-count: 0; mso-list: l0 level1 lfo1"><span style=" mso-fareast- mso-bidi-"><span style="mso-list: Ignore">l<span style="font: 7pt  Times New Roman ">  </span></span></span><span><font face="Calibri">Tests can use the objects (variables) in a test fixture, with each test invoking different methods on objects in the fixture and asserting different expected results. Each test runs in its own test fixture to isolate tests from the changes made by other tests. That is, tests don't share the state of objects in the test fixture. Because the tests are isolated, they can be run in any order. </font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt; text-indent: 0cm; mso-char-indent-count: 0"><span><font face="Calibri"> </font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt; text-indent: -21pt; mso-char-indent-count: 0; mso-list: l0 level1 lfo1"><span style=" mso-fareast- mso-bidi-"><span style="mso-list: Ignore">l<span style="font: 7pt  Times New Roman ">  </span></span></span><span><font face="Calibri">A related issue is to design for testing. For example, if you have a method that is meant to output to a file, don't pass in a filename, or even a FileWriter. Instead, pass in a Writer. That way you can pass in a StringWriter to capture the output for testing purposes. Then you can add a method (e.g. writeToFileNamed(String filename)) to encapsulate the FileWriter creation. </font></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri"> </font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt; text-indent: -21pt; mso-char-indent-count: 0; mso-list: l0 level1 lfo1"><span style=" mso-fareast- mso-bidi-"><span style="mso-list: Ignore">l<span style="font: 7pt  Times New Roman ">  </span></span></span><strong style="mso-bidi-font-weight: normal"><span><font face="Calibri">How do I test things that must be run in a J2EE container (e.g. servlets, EJBs)? </font></span></strong></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt; text-indent: 0cm; mso-char-indent-count: 0"><span><font face="Calibri">Refactoring J2EE components to delegate functionality to other objects that don't have to be run in a J2EE container will improve the design and testability of the software. </font></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt"><span><span style="mso-tab-count: 1"><font face="Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  </font></span></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt; text-indent: 0cm; mso-char-indent-count: 0"><font face="Calibri"><strong style="mso-bidi-font-weight: normal"><span>Cactus</span></strong><span> is an open source JUnit extension that can be used to test J2EE components in their natural environment.</span></font></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt; text-indent: -21pt; mso-char-indent-count: 0; mso-list: l0 level1 lfo1"><span style=" mso-fareast- mso-bidi-"><span style="mso-list: Ignore">l<span style="font: 7pt  Times New Roman ">  </span></span></span><strong style="mso-bidi-font-weight: normal"><span><font face="Calibri">How do I run JUnit using Ant? </font></span></strong></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 42pt; text-indent: -21pt; mso-char-indent-count: 0; mso-list: l3 level1 lfo2"><span style="mso-fareast- mso-bidi- mso-fareast-theme-font: minor-latin; mso-bidi-theme-font: minor-latin"><span style="mso-list: Ignore"><font face="Calibri">1.</font><span style="font: 7pt  Times New Roman ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  </span></span></span><span><font face="Calibri">Define any necessary Ant properties: </font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri">&lt;property name=&quot;src&quot; value=&quot;./src&quot; /&gt;</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri">&lt;property name=&quot;lib&quot; value=&quot;./lib&quot; /&gt;</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri">&lt;property name=&quot;classes&quot; value=&quot;./classes&quot; /&gt;</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri">&lt;property name=&quot;test.class.name&quot; value=&quot;com.xyz.MyTestSuite&quot; /&gt;</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 42pt; text-indent: -21pt; mso-char-indent-count: 0; mso-list: l3 level1 lfo2"><span style="mso-fareast- mso-bidi- mso-fareast-theme-font: minor-latin; mso-bidi-theme-font: minor-latin"><span style="mso-list: Ignore"><font face="Calibri">2.</font><span style="font: 7pt  Times New Roman ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  </span></span></span><span><font face="Calibri">Set up the CLASSPATH to be used by JUnit: </font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri">&lt;path id=&quot;test.classpath&quot;&gt;</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri"><span style="mso-spacerun: yes">  </span>&lt;pathelement location=&quot;${classes}&quot; /&gt;</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri"><span style="mso-spacerun: yes">  </span>&lt;pathelement location=&quot;/path/to/junit.jar&quot; /&gt;</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri"><span style="mso-spacerun: yes">  </span>&lt;fileset dir=&quot;${lib}&quot;&gt;</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;  </span>&lt;include name=&quot;**/*.jar&quot;/&gt;</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri"><span style="mso-spacerun: yes">  </span>&lt;/fileset&gt;</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri">&lt;/path&gt;</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 42pt; text-indent: -21pt; mso-char-indent-count: 0; mso-list: l3 level1 lfo2"><span style="mso-fareast- mso-bidi- mso-fareast-theme-font: minor-latin; mso-bidi-theme-font: minor-latin"><span style="mso-list: Ignore"><font face="Calibri">3.</font><span style="font: 7pt  Times New Roman ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  </span></span></span><span><font face="Calibri">Define the Ant task for running JUnit: </font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri">&lt;target name=&quot;test&quot;&gt;</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri"><span style="mso-spacerun: yes">  </span>&lt;junit fork=&quot;yes&quot; haltonfailure=&quot;yes&quot;&gt;</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;  </span>&lt;test name=&quot;${test.class.name}&quot; /&gt;</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;  </span>&lt;formatter type=&quot;plain&quot; usefile=&quot;false&quot; /&gt;</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;  </span>&lt;classpath refid=&quot;test.classpath&quot; /&gt;</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri"><span style="mso-spacerun: yes">  </span>&lt;/junit&gt;</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri">&lt;/target&gt;</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 42pt; text-indent: -21pt; mso-char-indent-count: 0; mso-list: l3 level1 lfo2"><span style="mso-fareast- mso-bidi- mso-fareast-theme-font: minor-latin; mso-bidi-theme-font: minor-latin"><span style="mso-list: Ignore"><font face="Calibri">4.</font><span style="font: 7pt  Times New Roman ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  </span></span></span><span><font face="Calibri">Run the test: </font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt; mso-char-indent-count: 0"><span><font face="Calibri">ant test</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt; text-indent: -21pt; mso-char-indent-count: 0; mso-list: l0 level1 lfo1"><span style=" mso-fareast- mso-bidi-"><span style="mso-list: Ignore">l<span style="font: 7pt  Times New Roman ">  </span></span></span><strong style="mso-bidi-font-weight: normal"><span><font face="Calibri">How do I use Ant to create HTML test reports? </font></span></strong></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 42pt; text-indent: -21pt; mso-char-indent-count: 0; mso-list: l2 level1 lfo3"><span style="mso-fareast- mso-bidi- mso-fareast-theme-font: minor-latin; mso-bidi-theme-font: minor-latin"><span style="mso-list: Ignore"><font face="Calibri">1.</font><span style="font: 7pt  Times New Roman ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  </span></span></span><span><font face="Calibri">Ensure that Ant's optional.jar file is either in your CLASSPATH or exists in your $ANT_HOME/lib directory. </font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 42pt; text-indent: -21pt; mso-char-indent-count: 0; mso-list: l2 level1 lfo3"><span style="mso-fareast- mso-bidi- mso-fareast-theme-font: minor-latin; mso-bidi-theme-font: minor-latin"><span style="mso-list: Ignore"><font face="Calibri">2.</font><span style="font: 7pt  Times New Roman ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  </span></span></span><span><font face="Calibri">Add an ANT property for the directory containing the HTML reports: </font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri">&lt;property name=&quot;test.reports&quot; value=&quot;./reports&quot; /&gt; </font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 42pt; text-indent: -21pt; mso-char-indent-count: 0; mso-list: l2 level1 lfo3"><span style="mso-fareast- mso-bidi- mso-fareast-theme-font: minor-latin; mso-bidi-theme-font: minor-latin"><span style="mso-list: Ignore"><font face="Calibri">3.</font><span style="font: 7pt  Times New Roman ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  </span></span></span><span><font face="Calibri">Define the Ant task for running JUnit and generating reports: </font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri">&lt;target name=&quot;test-html&quot;&gt;</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri"><span style="mso-spacerun: yes">  </span>&lt;junit fork=&quot;yes&quot; printsummary=&quot;no&quot; haltonfailure=&quot;no&quot;&gt;</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;  </span>&lt;batchtest fork=&quot;yes&quot; todir=&quot;${test.reports}&quot; &gt;</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  </span>&lt;fileset dir=&quot;${classes}&quot;&gt;</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  </span>&lt;include name=&quot;**/*Test.class&quot; /&gt;</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  </span>&lt;/fileset&gt;</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;  </span>&lt;/batchtest&gt;</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;  </span>&lt;formatter type=&quot;xml&quot; /&gt;</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;  </span>&lt;classpath refid=&quot;test.classpath&quot; /&gt;</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri"><span style="mso-spacerun: yes">  </span>&lt;/junit&gt;</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri"> </font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri"><span style="mso-spacerun: yes">  </span>&lt;junitreport todir=&quot;${test.reports}&quot;&gt;</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;  </span>&lt;fileset dir=&quot;${test.reports}&quot;&gt;</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  </span>&lt;include name=&quot;TEST-*.xml&quot; /&gt;</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;  </span>&lt;/fileset&gt;</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;  </span>&lt;report todir=&quot;${test.reports}&quot; /&gt;</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri"><span style="mso-spacerun: yes">  </span>&lt;/junitreport&gt;</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri">&lt;/target&gt;</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 42pt; text-indent: -21pt; mso-char-indent-count: 0; mso-list: l2 level1 lfo3"><span style="mso-fareast- mso-bidi- mso-fareast-theme-font: minor-latin; mso-bidi-theme-font: minor-latin"><span style="mso-list: Ignore"><font face="Calibri">4.</font><span style="font: 7pt  Times New Roman ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  </span></span></span><span><font face="Calibri">Run the test: </font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt; mso-char-indent-count: 0"><span><font face="Calibri">ant test-html</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt; text-indent: -21pt; mso-char-indent-count: 0; mso-list: l0 level1 lfo1"><span style=" mso-fareast- mso-bidi-"><span style="mso-list: Ignore">l<span style="font: 7pt  Times New Roman ">  </span></span></span><strong style="mso-bidi-font-weight: normal"><span><font face="Calibri">How do I organize all test classes in a TestSuite automatically and not use or manage a TestSuite explicitly? </font></span></strong></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-indent: 21pt"><span><font face="Calibri">There are a number of ways to do this: </font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 42pt; text-indent: -21pt; mso-char-indent-count: 0; mso-list: l1 level1 lfo4"><span style="mso-fareast- mso-bidi- mso-fareast-theme-font: minor-latin; mso-bidi-theme-font: minor-latin"><span style="mso-list: Ignore"><font face="Calibri">1.</font><span style="font: 7pt  Times New Roman ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  </span></span></span><span><font face="Calibri">In Ant, use the junit task and the batchtest element: </font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri">&lt;junit printsummary=&quot;yes&quot; haltonfailure=&quot;yes&quot;&gt;</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri"><span style="mso-spacerun: yes">  </span>...</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri"><span style="mso-spacerun: yes">  </span>&lt;batchtest fork=&quot;yes&quot;&gt;</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;  </span>&lt;fileset dir=&quot;${src.dir}&quot;&gt;</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  </span>&lt;include name=&quot;**/*Test.java&quot; /&gt;</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  </span>&lt;include name=&quot;**/Test*.java&quot; /&gt;</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;  </span>&lt;/fileset&gt;</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri"><span style="mso-spacerun: yes">  </span>&lt;/batchtest&gt;</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri">&lt;/junit&gt; </font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri">Idiomatic naming patterns for unit tests are Test*.java and *Test.java. Documentation and examples are at http://ant.apache.org/manual/OptionalTasks/junit.html. </font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri"> </font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 42pt; text-indent: -21pt; mso-char-indent-count: 0; mso-list: l1 level1 lfo4"><span style="mso-fareast- mso-bidi- mso-fareast-theme-font: minor-latin; mso-bidi-theme-font: minor-latin"><span style="mso-list: Ignore"><font face="Calibri">2.</font><span style="font: 7pt  Times New Roman ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  </span></span></span><span><font face="Calibri">Use the DirectorySuiteBuilder and ArchiveSuiteBuilder (for jar/zip files) classes provided by JUnit-addons project: </font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri"> </font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri">DirectorySuiteBuilder builder = new DirectorySuiteBuilder();</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri">builder.setSuffix(&quot;Test&quot;);</font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri">Test suite = builer.suite(&quot;/home/project/myproject/tests&quot;); </font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri"><span style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  </span><span style="mso-spacerun: yes">  </span>Documentation and examples are at http://junit-addons.sourceforge.net. </font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri"> </font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 42pt; text-indent: -21pt; mso-char-indent-count: 0; mso-list: l1 level1 lfo4"><span style="mso-fareast- mso-bidi- mso-fareast-theme-font: minor-latin; mso-bidi-theme-font: minor-latin"><span style="mso-list: Ignore"><font face="Calibri">3.</font><span style="font: 7pt  Times New Roman ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  </span></span></span><span><font face="Calibri">Write your own custom suite builder. </font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri"> </font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri">Have your test classes implement an interface and write a treewalker to load each class in a directory, inspect the class, and add any classes that implement the interface to a TestSuite. </font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri"> </font></span></p>
<p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt"><span><font face="Calibri">You might only want to do this if you are very uncomfortable with using a naming convention for test classes. Aside from being slow for larger suites, ultimately it's arguable whether it's more effort to follow a naming convention that have test classes implement an interface! </font></span></p> <a href="http://hi.baidu.com/amess/blog/item/02d60d3b85cdf7ed15cecba9.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/amess/blog/category/%BF%AA%B7%A2%B9%A4%BE%DF">开发工具</a>&nbsp;<a href="http://hi.baidu.com/amess/blog/item/02d60d3b85cdf7ed15cecba9.html#comment">查看评论</a>]]></description>
        <pubDate>2008-11-27  16:56</pubDate>
        <category><![CDATA[开发工具]]></category>
        <author><![CDATA[amess]]></author>
		<guid>http://hi.baidu.com/amess/blog/item/02d60d3b85cdf7ed15cecba9.html</guid>
</item>

<item>
        <title><![CDATA[JUnit Cook Book]]></title>
        <link><![CDATA[http://hi.baidu.com/amess/blog/item/6742d7f900095e5e252df21c.html]]></link>
        <description><![CDATA[
		
		<h1><font color="#33ff33">J</font><font color="#cc0000">U</font>nit Cookbook</h1>
<p>Kent Beck, Erich Gamma</p>
<h2>Simple Test Case</h2>
<p>When you need to test something, here is what you do:</p>
<ol>
    <li>Annotate a method with @org.junit.Test</li>
    <li>When you want to check a value, import org.junit.Assert.* statically, call <tt><font face="NSimsun">assertTrue</font></tt>() and pass a boolean that is true if the test succeeds</li>
</ol>
For example: <blockquote>
<pre><tt>@Test public void simpleAdd() {
&nbsp;&nbsp;&nbsp;   Money m12CHF= new Money(12, &quot;CHF&quot;); 
&nbsp;&nbsp;&nbsp;   Money m14CHF= new Money(14, &quot;CHF&quot;); 
&nbsp;&nbsp;&nbsp;   Money expected= new Money(26, &quot;CHF&quot;); 
&nbsp;&nbsp;&nbsp;   Money result= m12CHF.add(m14CHF); 
&nbsp;&nbsp;&nbsp;   assertTrue(expected.equals(result));
}</tt></pre>
</blockquote>If you want to write a test similar to one you have already written, write a Fixture instead.
<h2>Fixture</h2>
What if you have two or more tests that operate on the same or similar sets of objects? This set of objects is called a test fixture.
<p>When you have a common fixture, here is what you do:</p>
<ol>
    <li>Add a field for each part of the fixture</li>
    <li>Annotate a method with @org.junit.Before and initialize the variables in that method</li>
    <li>Annotate a method with @org.junit.After to release any permanent resources you allocated in setUp</li>
</ol>
For example:
<pre><tt>public class MoneyTest { 
&nbsp;&nbsp;&nbsp;   private Money f12CHF; 
&nbsp;&nbsp;&nbsp;   private Money f14CHF; 
&nbsp;&nbsp;&nbsp;   private Money f28USD; 
&nbsp;&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;   @Before public void setUp() { 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   f12CHF= new Money(12, &quot;CHF&quot;); 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   f14CHF= new Money(14, &quot;CHF&quot;); 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   f28USD= new Money(28, &quot;USD&quot;); 
&nbsp;&nbsp;&nbsp;   }
}</tt></pre>
<h2>Running Tests</h2>
<p>run this from a Java program:</p>
<p> </p>
<blockquote>
<pre>org.junit.runner.JUnitCore.runClasses(TestClass1.class, ...);</pre>
</blockquote>or this from the command line, with both your test class and junit on the classpath: <blockquote>
<pre>java org.junit.runner.JUnitCore TestClass1.class [...other test classes...]</pre>
</blockquote>
<p> </p>
<p>You make your JUnit 4 test classes accessible to a TestRunner designed to work with earlier versions of JUnit, declare a static method <em>suite</em> that returns a test.</p>
<blockquote>
<pre><tt>public static junit.framework.Test suite() { 
&nbsp;&nbsp;&nbsp;   return new JUnit4TestAdapter(Example.class); 
}</tt></pre>
</blockquote>
<p> </p>
<h2>Expected Exceptions</h2>
<p>Making sure the code behaves as expected in exceptional situations is part of the craft of programming too. For example:</p>
<blockquote>
<pre><tt>new ArrayList&lt;Object&gt;().get(0); 
</tt></pre>
</blockquote>This code should throw an IndexOutOfBoundsException. The @Test annotation has an optional parameter &quot;expected&quot; that takes as values subclasses of Throwable. If we wanted to verify that ArrayList throws the correct exception, we would write: <blockquote>
<pre><tt>@Test(expected= IndexOutOfBoundsException.class) public void empty() { 
&nbsp;&nbsp;&nbsp;   new ArrayList&lt;Object&gt;().get(0); 
}</tt></pre>
</blockquote> <a href="http://hi.baidu.com/amess/blog/item/6742d7f900095e5e252df21c.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/amess/blog/category/%BF%AA%B7%A2%B9%A4%BE%DF">开发工具</a>&nbsp;<a href="http://hi.baidu.com/amess/blog/item/6742d7f900095e5e252df21c.html#comment">查看评论</a>]]></description>
        <pubDate>2008-11-27  14:19</pubDate>
        <category><![CDATA[开发工具]]></category>
        <author><![CDATA[amess]]></author>
		<guid>http://hi.baidu.com/amess/blog/item/6742d7f900095e5e252df21c.html</guid>
</item>

<item>
        <title><![CDATA[Eclipse External Tools]]></title>
        <link><![CDATA[http://hi.baidu.com/amess/blog/item/8f7595505ac8e36785352438.html]]></link>
        <description><![CDATA[
		
		<p>外部工具可用workbench来配置和运行 程序、批处理文件、ant构建文件等。</p>
<p>外部工具的输出显示在控制台视图中。</p>
<p>在配置外部工具时可使用如下变量：<br>
${workspace_loc}：<br>
workspace的绝对路径</p>
<p>${workspace_loc:&lt;resource path&gt;}：<br>
所指定的resource的绝对路径。resource path是相对于workspace root的完整路径。<br>
注意：${workspace_loc:/myproject/myfile.txt}和${workspace_loc}/myproject/myfile.txt不一定相同，因为前者表示的myfile.txt可能位于workspace之外。</p>
<p>${project_loc}：<br>
当前所选择的resource所在的project或正构建的project或所选择的的绝对路径</p>
<p>${project_loc:&lt;resource path&gt;}：<br>
所指定的resource所在的project的绝对路径。resource path是相对于workspace root的相对路径。</p>
<p>${project_path}<br>
 当前选择的资源所在的project或者正构建的project的相对于workspace root的相对路径。</p>
<p>${project_name}<br>
 当前选择的资源所在的project或者正构建的project的名称</p>
<p>${container_loc}：<br>
 当前所选择的资源的parent的绝对路径</p>
<p>${container_loc:&lt;resource path&gt;}<br>
 所指定的resource的parent的绝对路径</p>
<p>${resource_loc} <br>
 当前选定的资源的绝对路径</p>
<p>${resource_loc:&lt;resource path&gt;} <br>
 所指定的资源的绝对路径</p>
<p>${container_path}<br>
 当前选定的资源的parent的相对于workspace root的路径</p>
<p>${resource_path}<br>
当前选定的资源的相对于workspace root的路径</p>
<p>${container_name}<br>
 当前选定的资源的parent的名称</p>
<p>${resource_name}<br>
 当前选定的资源的名称</p>
<p>${build_type} <br>
 在外部工具作为构建的一部分时表示构建的类型。值可以是&ldquo;full&rdquo;、&ldquo;incremental&rdquo;、&ldquo;auto&rdquo;。如果外部工具运行于构建之外，值为&ldquo;none&rdquo;</p>
<p>假设workspace目录为c:\eclipse\workspace。<br>
有两个project：MyProject1和MyProject2。<br>
MyProject1位于workspace之内。<br>
MyProject2位于workspace目录之外：c:\projects\MyProject2。<br>
选中资源/MyProject2/MyFolder/MyFile.txt，则运行外部工具时，各对应变量值如下：<br>
Variable Examples&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   Expanded Results<br>
${workspace_loc} c:\eclipse\workspace<br>
${workspace_loc:/MyProject1/MyFile.txt} c:\eclipse\workspace\MyProject\MyFile.txt<br>
${workspace_loc:/MyProject2/MyFile.txt} c:\projects\MyProject2\MyFile.txt<br>
${project_loc} c:\projects\MyProject2<br>
${project_loc:/MyProject1/MyFile.txt} c:\eclipse\workspace\MyProject<br>
${container_loc} c:\projects\MyProject2\MyFolder<br>
${resource_loc} c:\projects\MyProject2\MyFile.txt<br>
${project_path} /MyProject2<br>
${container_path} /MyProject2/MyFolder<br>
${resource_path} /MyProject2/MyFolder/MyFile.txt<br>
${project_name} MyProject2<br>
${container_name} MyFolder<br>
${resource_name} MyFile.txt<br>
${build_type} none</p>
<p><br>
 </p> <a href="http://hi.baidu.com/amess/blog/item/8f7595505ac8e36785352438.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/amess/blog/category/Eclipse">Eclipse</a>&nbsp;<a href="http://hi.baidu.com/amess/blog/item/8f7595505ac8e36785352438.html#comment">查看评论</a>]]></description>
        <pubDate>2008-04-30  00:15</pubDate>
        <category><![CDATA[Eclipse]]></category>
        <author><![CDATA[amess]]></author>
		<guid>http://hi.baidu.com/amess/blog/item/8f7595505ac8e36785352438.html</guid>
</item>

<item>
        <title><![CDATA[Eclipse Workbench 点滴]]></title>
        <link><![CDATA[http://hi.baidu.com/amess/blog/item/07e0c5ef73f57e33adafd52a.html]]></link>
        <description><![CDATA[
		
		1. Eclipse的整个窗口称为workbench window<br>
2. 右上角切换perspective的工具栏成为shortcut bar<br>
3. workbench window可同时打开多个。通过配置也可让每一个新打开的perspective显示在新window中<br>
4. 在一个window中，每个perspective可以用不同组的view，但所有的view共享同一组editor<br>
5. view重用于在信息的列表或层次结构中导航，如resources；或显示当前active的editor的属性<br>
6. 对view的修改马上会马上保存<br>
7. editor常用于编辑和浏览资源。可用文本表示，也可用图像表示<br>
8. editor的修改遵循open-save-close生命周期模型<br>
9. part用于统称view和editor<br>
10. 同一时间内，只能有一个active的part<br>
11. active的part是常用操作，如copy、past、cut的目标<br>
12. active的part也决定状态栏的内容<br>
13. 某一个editor不再active时，view仍可能显示该不再active的eidtor的相关信息。比如Hierarchy View。<br>
14. editor中，显示文件名的区域称为tab，asterisk表示未save，setDirty()。<br>
15. active part由editor变为view时，menu bar和tool bar的一些operation可能会被disable掉。<br>
16. editor可stack放置，也可side-by-side放置<br>
17. 当某一resource没有相关联的editor时，将试图启用外部工具<br>
18. 可用ctrl+F6来打开已启动的editor的列表<br>
19. view含有两个菜单，一个用于控制其位置，一个称为&rdquo;view pull-down menu&rdquo;，常含有排序、过滤等功能<br>
20. 文件导出的方式有：DND、Export、COPY/PAST<br>
21. 文件导入的方式有：DND、Import、COPY/PAST。(DND和COPY是否支持依赖于操作系统)<br>
22. 删除project时，可以仅从workspace中删除而仍保留在操作系统中，也可OS中也删除。File和Folder不支持此功能<br>
23. search中的show previous search可显示以前的搜索结果。其中的pin，可在再次搜索时另启动一个新的search view<br>
24. marker包括bookmark、task marker、debugging breakpoint、problem<br>
25. task可以关联到文件、关联到文件中的某一行、也可以没有任何关联。在task view中可以对已完成的task打勾<br>
26. dock cursor的种类<br>
27. 可自定义perspective的action set<br>
28. 开启一新的perspective后，window的标题栏会改变<br>
29. 可自定义perspective的command，以改变menu bar和tool bar中可显示的内容<br>
30. 可自己定义File-&gt;new菜单中显示那些内容、也可自定义window-&gt;open perspective中显示那些试图供选择<br>
31. 文件的每一次save动作均记录有变更信息，可在history视图中查看、比较<br>
32. universal welcome可自定义<br>
33. resource有三类：project、folder、file<br>
34. project可关闭，关闭的project占用更少的内存<br>
35. Folder和File可link到workspace以外的区域，称为linked resources<br>
36. Resource的层级结构：root、parent resources(仅可以是project或folder)、child resources(仅可以是folder或file)<br>
37. linked resources的用途之一：作为build的输出目录。一个资源可同属于两个project<br>
38. 只有file有local history。Folder和Project均没有<br>
39. navigation view、problem view、task view、bookmark view均支持working set；search的时候也可使用working set<br>
40. build，是由已存在的资源获得某个新资源、或者更新已存在的资源、或者两者均存在的过程。不一定是将java文件编译为class<br>
41. 对不同的project调用不同的builder。如java project<br>
42. 有两种类型的构建：增量构建(incremental build)和clean build。前者在上一次构建的基础上构建；后者清除前一次构建产生的state和problem<br>
43. edito左边的灰边可能含有标示error、warning或problem的图标。bookmark、breakpoint、record note等也可能显示<br>
44. Fast Views显示的视图在鼠标点到其它地方后自动最小化<br>
45. Help View由几个page组成。&rdquo;Related Topics&rdquo; page：跟踪workbench内容的变化并对应显示不同内容。其中的&rdquo;About&rdquo; section显示当前内容相关的help；&rdquo;Dynamic help&rdquo; section显示可能相关的搜索结果。<br>
46. 还有&rdquo;All Topics&rdquo;、&ldquo;Book marks&rdquo;、&rdquo;Search&rdquo;、&rdquo;Index&rdquo;几个page<br>
47. Problem View，各种builder可自动记录problem、error<br>
48. Outline View的内容是editor相关的<br>
49. properties view显示一个被选中的item(比如resource)的属性名称和值<br>
50. Toolbar有五种:<br>
ü main toolbar，称为workbench tool bar。其内容基于perspective的变化而不同。其中的item是否disable由active的view或editor决定。可通过鼠标拖放重新安排其section<br>
ü view toolbar。有些view tool bar还含有一个menu按钮，用倒三角表示<br>
ü perspective switcher。切换试图<br>
ü 最小化一个view stack时产生的tool bar<br>
ü fast view bar<br>
51. Label decorations。编辑一个item的label或icon以显示额外的信息。如CVS中的&rdquo;&gt;&rdquo;<br>
52. Help可在新window中查看，也可在同一window中用view查看。<br>
53. 内容相关的help(Context Sensitive Help)，选中后按&rdquo;F1&rdquo;，或点击帮助图标<br>
54. Infopops。帮助信息可以不显示在视图中，而是显示在弹出的信息框中。<br>
55. feature是单独下载和安装的最小单元<br>
56. 更新或下载会添加新文件，而不会删除或覆盖旧文件，因版本号不同，目录也不同<br>
57. 新下载的feature或plugin会被配置(configuration)，因此update和install的过程被简化为更新configuration的过程。重要的configuration应该被备份，以用于升级不成功时restore<br>
58. 大的基于Eclipse的product常将其feature组织为tree结构<br>
59. feature不必须的可标记为opitional<br>
60. eclipse默认分配256M作为heap内存，可通过指定vm参数改变其大小: <br>
eclipse &ndash;vmargs &ndash;Xmx&lt;memory size&gt;<br>
61. 也可指定permanent generation memory的大小。默认值最大为64M：<br>
eclipse &ndash;vmargs &ndash;XX:MaxPermSize=&lt;Memory Size&gt;<br>
62. 可通过-data指定workspace<br>
63. 可通过-vm指定该eclipse的vm<br>
eclipse &ndash;vm c:\j2sdk1.4.2\jre\bin\javaw<br>
如果未指定vm，将查找OS的path<br>
64. eclipse [platform options] [-vmargs [java vm arguments]]。-vmargs虚拟机参数一定要放在platform参数之后，-vmargs后面的参数均会被直接传递给虚拟机，如果放在其后会因不被虚拟机识别而出错。<br>
65. view、editor的tab位置也可以放在下方<br>
66. 在创建一个folder或file时，可以让其link到另外一个目录或文件<br>
67. 如某一workspace实际未被中用，却提示被占用，可删除其workspace/.metadata/.lock<br>
68. 外部工具的输出会显示在控制台视图中<br> <a href="http://hi.baidu.com/amess/blog/item/07e0c5ef73f57e33adafd52a.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/amess/blog/category/Eclipse">Eclipse</a>&nbsp;<a href="http://hi.baidu.com/amess/blog/item/07e0c5ef73f57e33adafd52a.html#comment">查看评论</a>]]></description>
        <pubDate>2008-04-29  23:39</pubDate>
        <category><![CDATA[Eclipse]]></category>
        <author><![CDATA[amess]]></author>
		<guid>http://hi.baidu.com/amess/blog/item/07e0c5ef73f57e33adafd52a.html</guid>
</item>

<item>
        <title><![CDATA[GMF FAQ (General)]]></title>
        <link><![CDATA[http://hi.baidu.com/amess/blog/item/7ca02073254f9a198701b08a.html]]></link>
        <description><![CDATA[
		
		<h3><span class="mw-headline">What can I do with GMF? </span></h3>
<p>Using GMF, you can produce graphical editors for Eclipse. For example, a UML modeling tool, workflow editor, etc. Basically, a graphical editing surface for any domain model in EMF you'd like. For some example eyecandy, visit the <a class="external text" title="http://www.eclipse.org/gmf/gallery/index.php" href="http://www.eclipse.org/gmf/gallery/index.php" rel="nofollow">gallery</a>.</p>
<a name="How_can_I_get_started_using_GMF.3F"></a>
<h3><span class="mw-headline">How can I get started using GMF? </span></h3>
<p>For the tooling side, the <a class="external text" title="http://www.eclipse.org/gmf/tutorial/index.php" href="http://www.eclipse.org/gmf/tutorial/index.php" rel="nofollow">tutorial</a> is a good place to start. For the runtime, which can be used without the tooling, an article posted <a class="external text" title="http://www.eclipse.org/articles/Article-Introducing-GMF/article.html" href="http://www.eclipse.org/articles/Article-Introducing-GMF/article.html" rel="nofollow">here</a> is a good place to get an overview. For more information, take a look at the documentation available on the <a class="external text" title="http://wiki.eclipse.org/index.php/GMF_Documentation" href="http://wiki.eclipse.org/index.php/GMF_Documentation" rel="nofollow">documentation site</a>.</p>
<a name="What_are_the_advantages_of_using_GMF_over_just_EMF_and_GEF.3F"></a>
<h3><span class="mw-headline">What are the advantages of using GMF over just EMF and GEF? </span></h3>
<p>This depends on what you are trying to accomplish. For full-featured graphical editors that require the rich capabilities of GEF working with an EMF domain model, GMF is a good option. But then, you may be interested in a lightweight implementation, read-only visualizations, etc. In fact, you may not even need GEF, as is the case with TPTP's visualization of profiling data. For an overview of the features and functionality you can achieve using GMF, look <a class="external text" title="http://www.eclipse.org/articles/Article-Introducing-GMF/article.html" href="http://www.eclipse.org/articles/Article-Introducing-GMF/article.html" rel="nofollow">here</a>. To get a sense of how the generative framework can get you going quicker, look <a class="external text" title="http://www.eclipse.org/gmf/tutorial/index.php" href="http://www.eclipse.org/gmf/tutorial/index.php" rel="nofollow">here</a>.</p>
<a name="What_are_the_prerequisites_for_using_GMF.3F"></a>
<h3><span class="mw-headline">What are the prerequisites for using GMF? </span></h3>
<p>If you look at the <a class="external text" title="http://download.eclipse.org/modeling/gmf/downloads/index.php" href="http://download.eclipse.org/modeling/gmf/downloads/index.php" rel="nofollow">download</a> page for a particular build, you will see a list of prerequisites with links to their download pages. The update site contains stable (milestone) builds and will require their corresponding milestone releases from the main GMF dependencies (EMF and GEF).</p>
<a name="What_is_the_relationship_between_semantic.2C_domain.2C_notation.2C_and_graphical_definition_models.3F"></a>
<h3><span class="mw-headline">What is the relationship between semantic, domain, notation, and graphical definition models? </span></h3>
<p>In general, the terms semantic and domain model are synonymous and refer to the information being visualized and edited. The information used to represent and persist the visual elements in the GMF runtime is referred to as the notation model. When defining the diagram nodes and figures for use in generating the graphical editor, the toolsmith works with a graphical definition model. This is similar to the notation model, but they are distinct. The graphical definition model is linked to the domain and tooling definition models using a mapping model, which is used to produce a generation model that is used to drive the code generation. Clear as mud? ;) A picture of the models and their workflow is found at the beginning of the <a class="external text" title="http://www.eclipse.org/gmf/tutorial/index.php" href="http://www.eclipse.org/gmf/tutorial/index.php" rel="nofollow">tutorial</a>.</p>
<a name="How_can_I_contribute_to_GMF.3F"></a>
<h3><span class="mw-headline">How can I contribute to GMF? </span></h3>
<p>The best place to start is by looking in Bugzilla. Either find a bug to work on, coordinating with a developer, or submit a patch for an enhancement. Participation in the newsgroup and mailing list is also encouraged, as is trying out builds and reporting bugs, feature requests, documentation, etc.</p>
<a name="What_is_the_release_plan_for_GMF.3F"></a>
<h3><span class="mw-headline">What is the release plan for GMF? </span></h3>
<p>You can find our project plan posted <a class="external text" title="http://www.eclipse.org/gmf/development/plan.php" href="http://www.eclipse.org/gmf/development/plan.php" rel="nofollow">here</a>.</p> <a href="http://hi.baidu.com/amess/blog/item/7ca02073254f9a198701b08a.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/amess/blog/category/Eclipse">Eclipse</a>&nbsp;<a href="http://hi.baidu.com/amess/blog/item/7ca02073254f9a198701b08a.html#comment">查看评论</a>]]></description>
        <pubDate>2008-04-25  03:20</pubDate>
        <category><![CDATA[Eclipse]]></category>
        <author><![CDATA[amess]]></author>
		<guid>http://hi.baidu.com/amess/blog/item/7ca02073254f9a198701b08a.html</guid>
</item>

<item>
        <title><![CDATA[EMF简介]]></title>
        <link><![CDATA[http://hi.baidu.com/amess/blog/item/a2a3fe1f684827f0e0fe0bd7.html]]></link>
        <description><![CDATA[
		
		<p>EMF：Eclipse Modeling Framework</p>
<p>在基于结构化数据模型(structured data model)构建工具和应用程序时，EMF可以充当<strong>模型框架</strong>(modeling framework)和<strong>代码生成工具</strong>(两种角色)。</p>
<p>从以XMI（<a target="_blank" href="http://www.omg.org/technology/documents/formal/xmi.htm">XML Meta Interchange</a>、基于XML的元数据交换）描述的model中，EMF能够生成model对应的类和一些适配类(adapter class)。model类用于代表模型本身；适配类能够查看和以命令的方式编辑model，并提供了一个基本的editor。</p>
<p>EMF构建包里面包括XML Schema Infoset Model（XSD）和一个基于EMF的Service Data Objects（SDO）实现。XSD现在已经是另外一个Eclipse项目Model Development Tools（MDT）的组成部分。XSD提供了处理XML Schema的模型和API。</p>
<p>EMF的子项目还包括：<br>
<strong>Model Query：</strong>查询Model的元素和内容<br>
<strong>Model Transaction：</strong>构建于EMF之上，为管理EMF资源提供管理层模型<br>
<strong>Validation Framework：</strong>保证model的完整性</p>
<p>EMF有三个组成部分：<br>
<strong>EMF：<br>
</strong>核心的EMF框架，<strong>meta model(Ecore).<br>
</strong>提供对model的支持，包括变化通知、持久化支持(默认的XMI方式)、处理EMF对象的API等<br>
<strong>EMF.Edit</strong>：<br>
包括为EMF model创建editor所需要的可重用类<br>
a)content provier and label provider、property source support、其它显示EMF model在桌面上的工具类<br>
b)command framework。包括完全支持redo undo操作的command实现类。<br>
<strong>EMF.Codegen：</strong><br>
能生成构建一个完全的EMF Model Editor所需的一切资源。<br>
含有一个可指定生成命令和选择生成器的图形界面。<br>
代码生成利用了Eclipse JDT（Java Development Tooling）</p>
<p>代码生成包括三个级别：<br>
<strong>1. Model<br>
</strong>提供model中所有class和interface的实现类，加上factory和package（meta data）实现类<br>
<strong>2. Adapters<br>
</strong>生成用于编辑和显示model class的实现类，这些实现类成为ItemProviders<br>
<strong>3. Editors</strong><br>
生成正确的结构化的Editor</p> <a href="http://hi.baidu.com/amess/blog/item/a2a3fe1f684827f0e0fe0bd7.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/amess/blog/category/%C4%AC%C8%CF%B7%D6%C0%E0">默认分类</a>&nbsp;<a href="http://hi.baidu.com/amess/blog/item/a2a3fe1f684827f0e0fe0bd7.html#comment">查看评论</a>]]></description>
        <pubDate>2008-04-12  09:51</pubDate>
        <category><![CDATA[默认分类]]></category>
        <author><![CDATA[amess]]></author>
		<guid>http://hi.baidu.com/amess/blog/item/a2a3fe1f684827f0e0fe0bd7.html</guid>
</item>

<item>
        <title><![CDATA[读《Oracle: The Complete Reference》序]]></title>
        <link><![CDATA[http://hi.baidu.com/amess/blog/item/2792a7ec777b902362d09fdf.html]]></link>
        <description><![CDATA[
		
		<p>Oracle: The Complete Reference已经有些年头了，不过今天才第一次看到。作者之一George Korch写的序挺有意思。<br>
 <br>
George第一次接触Oracle是1982年。不知道82年的时候，中国有几台电脑。<br>
 <br>
George之所以接触到oracle是因为他的公司要为设计和建立一个商务应用程序而评估数据库管理系统。最终决定采用什么数据库，是由评测结果决定的，而周围的现状往往是有决定权的那个人在主流数据库里面选择一个自己最熟悉的。<br>
 <br>
George他们的评估报告还被ComputerWorld定性为曾实施过的最&ldquo;重量级&rdquo;的DBMS研究报告。即使以研究本身为目的，出一个达到这种成就的报告恐怕也不容易，而这个报告本身居然只是开发一个系统的准备工作。<br>
 <br>
这份报告由于对有些开发商评价极不客气，居然被迫拿到新西兰去印刷。<br>
 <br>
他们调查的候选公司数量达到108个，最后压缩为16个，所涉及的数据库类型包括网状、层次、关系及其它类型。不知道国内到哪一年才能拥有108个数据库生产商。还不了解同关系数据库并列的网状、层次是什么概念的数据库。<br>
 <br>
Oracle当时叫做Relational Software公司，雇员不到25人。他们认为，从技术上讲，Oracle是当时市场上最好的产品。而且从其RSI指数上看,Oracle的管理团队有能力领导公司走向成功。技术的重要性还是相当重要的，而且在技术上领先别人，也许实际上未必就会马上发挥很大的经济效益，但至少会是一种挺美妙的感觉。还有，这儿提到的是团队，不是某一个单枪匹马冲锋陷阵的个人英雄。<br>
 <br>
艰难同样会有，他们的报告一样也受到了大量的批评。<br>
 <br>
George当时拥有和管理的公司叫做Koch Systems Corporation，它成为了Oracle的第一个增值分销商(Value Added Reseller)。他们开发的系统叫做THESIS，世界上第一个重要的商用关系应用程序。THESIS是一个证券交易和记账系统。许多公司用它来管理他们的投资证券。包括IBM,这样也需要IBM去安装Oracle，虽然他们有自己的数据库IMS和DB2。</p>
<p>在Oracle改进自己产品的过程中，Koch System的研究成果也为这些改进做出了贡献。产品的进步，来源于许多方面，产品实施人员、销售人员、最终用户，都能为产品的改进做出贡献。收集反馈意见。</p>
<p>The Complete Reference这本书构思与1988年。旧金山的一个知名出版代理商很欣赏George的想法，签订了出版合同，并计划于89年出第一版。但他们的一个高级主管否定了这个计划，因为他认为oracle仅会昙花一现。一年后，Oracle成倍增长，该主管也离职了，于是这个出版计划又重新启动，最终90年发布第一版。当达到一定水平之后，搭上出版社会是很容易的事情。虽然不出名的时候也能出书，但那仅能被视为侥幸。也不要因别人的侥幸而愤愤不平，把侥幸变为必然。</p>
<p>90年7月，George就职于Oracle公司，管理其Application部门。并在后来当上了公司的高级副总裁。在他任职期间，他把那个出版社又介绍给了oracle的高级管理层，在抵制住一位Oracle副总裁(不久离职)的反对后，成立了Oracle出版社。</p>
<p>92年，Bob Muller修订了这本书，产生了《Oracle 7：The Complete Reference》。</p>
<p>94年，George成就了自己的梦想，当上了一名专职牧师。这是达到一定高度之后，才能获得的自由。</p>
<p>94年，Kevin Loney，一个极知名的独立的Oracle顾问兼作者(<a href="http://www.kevinloney.com/">www.kevinloney.com</a>)修改和重写了第三版。出技术之外，知名度的优势在这儿得到了体现。George称，Kevin的才智和勤奋给他留下的深刻的印象。才智！勤奋！！！</p> <a href="http://hi.baidu.com/amess/blog/item/2792a7ec777b902362d09fdf.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/amess/blog/category/%CA%FD%BE%DD%BF%E2">数据库</a>&nbsp;<a href="http://hi.baidu.com/amess/blog/item/2792a7ec777b902362d09fdf.html#comment">查看评论</a>]]></description>
        <pubDate>2008-04-02  23:51</pubDate>
        <category><![CDATA[数据库]]></category>
        <author><![CDATA[amess]]></author>
		<guid>http://hi.baidu.com/amess/blog/item/2792a7ec777b902362d09fdf.html</guid>
</item>

<item>
        <title><![CDATA[一年不来]]></title>
        <link><![CDATA[http://hi.baidu.com/amess/blog/item/ab5bf3fac7e41ddab58f3163.html]]></link>
        <description><![CDATA[
		
		<p>上一篇是07年4月，再过几个小时就是08年四月了，一年过去了，这儿没添加什么东西。也有好多该记录的没记录下来。甚至于包括前不久刚看的的spring osgi都有些陌生，这样好多类似的需要花时间去了解，然后又因不常使用而又渐渐淡忘所做的无用功似乎有些太不值得，所以觉得似乎又有回到这儿的必要。</p>
<p>不必有什么逻辑、不必有什么条理、也不必追求什么完整性，只要大约记录我每天干了什么就OK了，先做到这一步吧。</p>
<p>今天订了本《如何掌控自己的时间和生活》，对它抱有挺大的期望，希望真的象所说的那样：这个世界上根本不存在&ldquo;没时间&rdquo;这回事，舒缓一下忙的有些焦头烂额然后无头乱窜的现在的我。</p>
<p>----------------------------------------------------------------------------------------------------</p>
<p>看着自家牛死而伤心落泪的老农，假若阴错阳差坐了龙庭，没准比朱元璋杀人还疯狂。</p>
<p>拉米多说：&ldquo;首先要在他们的心里装上一把锁，然后才能让他们主动来购买咱们的防盗门和防盗锁。他们心里那把锁的名字就叫贪欲。开始时，他们之所以能和平共处，是因为他们都不缺少食物，但是后来，当他们发现每人所得的食物分量不同时，便有了不愿与他人分享的想法了。这便是我多给一部分人羊肉，和少给一部分人羊肉的效果。&rdquo;</p>
<p>从赞扬和真诚赏识他人开始。（要由衷）</p>
<p>即使最小的改进，也要表扬；每有改进，都要表扬。&ldquo;赞赏要由衷，表扬要慷慨。&rdquo;</p>
<p>给他人一个好名声，使其与之相配。(这种名声，会是鞭策他前进的动力之一)</p>
<p>----------------------------------------------------------------------------------------------</p>
<p><strong>原来可以这样拼</strong></p>
<p>一个月前，老师布置了拼图作业。今天，孩子们带来了自己的作品。老师请大家谈谈拼图作业的体会和感受。</p>
<p>学生：我拼图的时候，先看一下包装上的图画，心中有一个轮廓，然后把外框拼好，再从外向内，这种方法拼得比较快。老师：很好。认识一个问题从总的概貌入手，然后去了解细节，就像我们面对一个陌生的城市，用一张地图，比一条街一条街去走要快得多。</p>
<p>学生：我拼了很长时间也拼不好，所以请爸爸妈妈和奶奶帮忙完成了拼图。老师：很好。这是一种teamwork（团队合作），记住：如果你遇到自己一个人难以解决的问题，可以求助别人，大家共同完成。</p>
<p>学生：我最高兴的时刻是把最后一片放进拼图的时候。老师：很好。享受成功是一种非常愉悦的感觉。</p>
<p>学生：我面前是一大堆杂乱不章的拼图片，我根本找不出它们的规律，我试了很多次也无法拼出图案，我心情很急躁、烦闷，干脆把它装起来，再也没有打开。老师：很好。有时放弃也是一种选择。</p> <a href="http://hi.baidu.com/amess/blog/item/ab5bf3fac7e41ddab58f3163.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/amess/blog/category/%C6%E4%CB%FC">其它</a>&nbsp;<a href="http://hi.baidu.com/amess/blog/item/ab5bf3fac7e41ddab58f3163.html#comment">查看评论</a>]]></description>
        <pubDate>2008-03-31  22:41</pubDate>
        <category><![CDATA[其它]]></category>
        <author><![CDATA[amess]]></author>
		<guid>http://hi.baidu.com/amess/blog/item/ab5bf3fac7e41ddab58f3163.html</guid>
</item>

<item>
        <title><![CDATA[Java与模式 第三章 软件的可维护性与可复用性]]></title>
        <link><![CDATA[http://hi.baidu.com/amess/blog/item/bccfb7012ec39002738da5c6.html]]></link>
        <description><![CDATA[
		
		<p><strong>设计原则和设计模式的关系：</strong><br>
设计原则更为抽象和基础。设计模式是设计原则在具体问题中的体现。设计原则为新设计模式的研究提供向导。</p>
<p><strong>OO软件系统设计的核心问题：</strong><br>
可维护性（Maintainability）<br>
可复用性 （Reuseability）</p>
<p><strong>3.1 软件系统的可维护性</strong><br>
开发半年，维护多年<br>
一个软件系统生命周期内，维护上面的钱，是开发上的钱的两倍</p>
<p><strong>软件的维护</strong><br>
维护的含义：错误的清除、功能的扩充</p>
<p>好的软件设计必须允许新需求以容易和平稳的方式加入到已有系统中</p>
<p>一个软件生命周期内，常因为小改动的累计导致系统臃肿</p>
<p><strong>设计师的辩解</strong><br>
常见辩解：用户需求变化无常。维护设计师和原始设计师不同时，理由更多。</p>
<p>首先，设计未必适合扩充；再者，即使适合扩充，维护设计师未必能理解原始设计师意图。</p>
<p><strong>真正的原因<br>
</strong>Rober C. Martin指出真正原因：<br>
1) 过于僵硬<br>
因新性能会波及多个模块而不敢轻易加入新功能<br>
2) 过于脆弱<br>
一个地方修改，可能导致未知地方发生错误<br>
3) 复用率低<br>
已有代码依赖于一堆东西，难以拆开<br>
最原始的服用方式：代码拷贝粘贴<br>
4) 黏度过高<br>
两种方式：以保存原始设计意图和原始设计框架的方式改动；破坏原始意图和框架的方式改动。涉及到短期利益和中长期利益的问题。如果总是第二种方式比第一种方式方便，就是黏度过高</p>
<p><strong>设计的目标</strong><br>
Peter Coad提出<br>
1) 可扩展性<br>
新新能很容易加入到系统中去<br>
2) 灵活性<br>
允许代码修改以很平稳的方式进行，不会涉及很多模块<br>
3) 可插入性<br>
很容易把一个类抽取，用一个同样接口的类替换</p>
<p><strong>3.2 系统的可复用性</strong></p>
<p><strong>复用的重要性<br>
</strong>好处：<br>
1) 较高的生产效率<br>
2) 较高的软件质量<br>
3) 可改善系统可维护性</p>
<p><strong>传统的复用方式<br>
</strong>代码拷贝粘贴、算法的复用、数据结构的复用</p>
<p>可维护性和复用性有时会发生冲突，想要的：支持可维护性的复用</p>
<p><strong>面向对象设计的复用</strong><br>
复用焦点的转移：不在集中在函数和算法等具体实现细节上，而是集中在含有商业逻辑的抽象层次上。 <br>
在面向对象的设计里面，可维护性复用是以设计原则和设计模式为基础的。</p>
<p><strong>常见OO设计原则</strong><br>
开闭原则<br>
里氏代换原则<br>
依赖倒转原则<br>
接口隔离原则<br>
组合/聚合原则<br>
迪米特法则</p>
<p> </p> <a href="http://hi.baidu.com/amess/blog/item/bccfb7012ec39002738da5c6.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/amess/blog/category/%C4%AC%C8%CF%B7%D6%C0%E0">默认分类</a>&nbsp;<a href="http://hi.baidu.com/amess/blog/item/bccfb7012ec39002738da5c6.html#comment">查看评论</a>]]></description>
        <pubDate>2007-04-23  00:57</pubDate>
        <category><![CDATA[默认分类]]></category>
        <author><![CDATA[amess]]></author>
		<guid>http://hi.baidu.com/amess/blog/item/bccfb7012ec39002738da5c6.html</guid>
</item>

<item>
        <title><![CDATA[测试模式笔记]]></title>
        <link><![CDATA[http://hi.baidu.com/amess/blog/item/cda0a5642374e3f0f73654ec.html]]></link>
        <description><![CDATA[
		
		<p>测试模式</p>
<p>1.&nbsp;黑盒测试模式(black&nbsp;box&nbsp;testing)<br>
也称为功能测试(functional&nbsp;testing)、闭箱测试(closed&nbsp;box&nbsp;testing)。</p>
<p>通过设计符合独立需求的测试来保证软件符合要求，测试不必基于所实现的方式。</p>
<p>从某种意义上讲，不按照软件实现或者内在结构进行的软件测试称为黑盒测试。</p>
<p>2.&nbsp;白盒测试模式<br>
也称为明箱测试(clear&nbsp;box&nbsp;testing)</p>
<p>根据软件的内部结构来确定必要情况。一个完整的测试将测试软件所有可能经过的路径。</p>
<p>但并不真正的需要测试所有条件，可以根据软件的内部结构来决定哪些测试是必须的和有意义的。</p>
<p>注意：<br>
&sup2;&nbsp;需保证软件在所有情况下的正确实现<br>
&sup2;&nbsp;最低限度的测试集合必须满足下面的条件：确保软件在所有的条件下实现，并且自始至终覆盖软件实现的所有可能路径。<br>
&sup2;&nbsp;仔细分析与每条实现路径相关的边界条件(boundary&nbsp;condition)，有利于减少测试数目。</p>
<p>一些通用的边界条件：<br>
&sup2;&nbsp;导致一个数字数据类型发生溢出的值<br>
&sup2;&nbsp;导致一个数据结构发生溢出的值<br>
&sup2;&nbsp;导致布尔表达式在一个if条件可能为真或为假时的值</p>
<p>为了确保能够测试所有软件经过的路径，采用一个覆盖分析(coverage&nbsp;analysis)工具保存已经测试过的路径轨迹。</p>
<p>白盒测试的成本可能会非常高。</p>
<p>3.&nbsp;单元测试模式<br>
将程序中的一个单独的类从其它类中隔离出来进行测试。</p>
<p>一个类的完整单元测试可以改善它的可重用性(reusability)。</p>
<p>如果一个将要进行单元测试的类与另外一个类相互依存，并且创建另一类的虚拟版本不太显示，单元测试可以考虑将这两个类一起进行测试。</p>
<p>4.&nbsp;集合测试模式<br>
首次将单独开发好的类集合到一起进行的测试。</p>
<p>每个类进行了单元测试，第一次把他们组装到一起，并检验工作协调性的过程称为集成测试(integration&nbsp;testing)。</p>
<p>在开始时，先将少量的一些类集合到一起进行测试，然后再不断将一些类加入来进行测试，通过这种方法可以将集合测试的杂乱程度降到最低。</p>
<p>设计一个集合测试计划时，首先应道确定一个用于组织测试的程序结构。通用方法是：<br>
&sup2;&nbsp;以自上而下或者自下而上的模式组织类，或者同时采用这两种模式组合类。这种技术易于理解，但是应用于面向对象设计时可能会困难，因为大多数面向对象设计层次性不强。<br>
&sup2;&nbsp;将与一个通用程序特征相关的众多类合并到一起，或者使用案例<br>
&sup2;&nbsp;将与一个公共线程相关的类合并到一起。</p>
<p>对于小型或中型工程的集合测试来说，常很少要求为它们做测试规划，大型工程的集合测试需要相对正规的规划。</p>
<p>集合测试常比系统测试所花的时间少，比单元测试所花的时间多。</p>
<p>5.&nbsp;系统测试模式<br>
把程序当成是一个完整的实体，在一个与它运行的环境相似的环境中测试，确保它符合规范。</p>
<p>6.&nbsp;回归测试模式</p>
<p><br>
7.&nbsp;验收测试模式(Acceptance&nbsp;Testing)<br>
验收测试是为了确保发布的软件符合用户的需求。这种测试常由用户实现。</p>
<p>软件开发人员希望新开发的定制软件可以满足用户的需求，但是有些需求是用户从来没有向开发人员表述过的。</p>
<p>验收软件的手续必须面对实际，因为开发者无法决定用户用何种办法验收该软件。比如“屏幕要求美观”的测试会带有很多的主观因素，而验收一个程序的屏幕是否符合编写规范的要求会显得比较合适一些。</p>
<p>解决方案：<br>
在开发者开始工程设计之前，经过讨论，在验收测试计划方面产生共识。</p>
<p>一个验收计划应包括下面的元素：<br>
&sup2;&nbsp;应包括一个指明验收测试范围的声明。如软件组件、操作环境或硬件。也可以明确验收测试的高级目标。一些经典的目标包括：<br>
ü&nbsp;新系统产生的结果应与现存系统产生的结果相同<br>
ü&nbsp;新软件必须具备没秒钟处理相当数量事务的工作能力<br>
ü&nbsp;必须采用一个最低级别精确度来实现计算<br>
&sup2;&nbsp;应当声明用于验收测试的测试数据。如可能，数据应当符合实际产品的数据<br>
&sup2;&nbsp;指出谁将负责开发必要的详细测试计划、测试环境和技术支持<br>
&sup2;&nbsp;还应说明谁来确保软件通过验收测试</p>
<p>负责验收测试的人员很自然的趋向于对将要测试的软件持怀疑态度。他们宁愿承认是软件缺陷导致出错也不愿承认是因为对软件的不熟悉而导致出错。<br>
可预先做一些工作使验收测试人员熟悉软件。</p>
<p>制定验收测试计划可能需要一些时间，但是这时还处于测试的开始阶段，成员之间没有过多的争论，还心平气和，便于测试人员和开发人员讨论尚未达成的共识。</p>
<p>8.&nbsp;静室测试模式<br>
软件的设计人员和软件测试的人员不应当讨论他们的设计规范或实现过程。</p>
<p>软件开发和测试开发都同样受详细规范的约束。如果测试设计人员和软件设计人员采用相同的方式描述规范，那么测试将无法发现那些不确定的东西。</p>
<p>采用静室测试模式相互不会被对方引诱到规范中不确定的部分中。不过有可能在发现问题的测试进行之前，不容易发现某些规范的不确定部分。<br>
</p> <a href="http://hi.baidu.com/amess/blog/item/cda0a5642374e3f0f73654ec.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/amess/blog/category/%C4%AC%C8%CF%B7%D6%C0%E0">默认分类</a>&nbsp;<a href="http://hi.baidu.com/amess/blog/item/cda0a5642374e3f0f73654ec.html#comment">查看评论</a>]]></description>
        <pubDate>2007-01-18  18:15</pubDate>
        <category><![CDATA[默认分类]]></category>
        <author><![CDATA[amess]]></author>
		<guid>http://hi.baidu.com/amess/blog/item/cda0a5642374e3f0f73654ec.html</guid>
</item>


</channel>
</rss>