Thread: [Mockpp-commits] mockpp/mockpp/docs/en customize-chunked.xsl,NONE,1.1 customize-flat.xsl,NONE,1.1 Ma
Brought to you by:
ewald-arnold
From: Ewald A. <ewa...@us...> - 2005-05-06 12:40:44
|
Update of /cvsroot/mockpp/mockpp/mockpp/docs/en In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31869/mockpp/docs/en Modified Files: Makefile.am customize.xsl dev_production.docbook Added Files: customize-chunked.xsl customize-flat.xsl Log Message: update docs --- NEW FILE: customize-chunked.xsl --- <?xml version='1.0'?> <!-- Customisation for chunked html files $Id: customize-chunked.xsl,v 1.1 2005/05/06 12:40:30 ewald-arnold Exp $ --> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:import href="customize.xsl"/> <xsl:param name="chunk.section.depth" select="2"/> </xsl:stylesheet> Index: customize.xsl =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/docs/en/customize.xsl,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- customize.xsl 4 May 2005 20:44:53 -0000 1.8 +++ customize.xsl 6 May 2005 12:40:30 -0000 1.9 @@ -1,5 +1,6 @@ <?xml version='1.0'?> -<!-- Custumisation + +<!-- Common custumisation options $Id$ --> @@ -29,8 +30,6 @@ --> <xsl:param name="html.stylesheet" select="'common/mockpp.css'"/> -<xsl:param name="use.extensions" select="1"/> -<xsl:param name="chunk.section.depth" select="2"/> <xsl:param name="admon.graphics" select="1"/> <xsl:param name="linenumbering.extension" select="1"/> <xsl:param name="chapter.autolabel" select="1"/> Index: dev_production.docbook =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/docs/en/dev_production.docbook,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- dev_production.docbook 5 May 2005 21:01:59 -0000 1.2 +++ dev_production.docbook 6 May 2005 12:40:30 -0000 1.3 @@ -20,7 +20,8 @@ Murphy (unintentional usage) and not from Machiavelli (evil abuse). A potential attacker can simply copy a class declaration, remove all <keysym>private</keysym> and <keysym>protected</keysym> keywords and then - access everything by doing a simple typecast.</para> + access everything by doing a simple typecast. C++does not have run-time + protection.</para> <sect2 id="reproducible-time-values"> <title>Reproducible Time Values</title> @@ -28,18 +29,21 @@ <para>Sometimes you need predictible time values. Either you want to minimize the impact of timeouts in error conditions or prevent idle times. <application>mockpp</application> contains a sample imlementation of how - to handle calls to <methodname>std::time()</methodname>.</para> - - <para><programlisting>// prototype for method under test: - void myTimedMethod(TimeServer *time); + to handle calls to <methodname>std::time()</methodname>. This only covers + a resolution of 1 second. If you need a more sophisticated solution you + have to create your own code similar to this example. See the sources and + documentation about <classname>RealTimeServer</classname> and + <classname>MockTimeServer</classname>.<programlisting>// prototype for the method under test: +void myTimedMethod(mockpp::TimeServer *time); // in production code: - myTimedMethod(getRealTimeServer()); +mockpp::RealTimeServer rt_server; +myTimedMethod(&rt_server); // in test code: - getMockTimeServer()->addUnixTime(0x123456); - myTimedMethod(getMockTimeServer()); - +mockpp::MockTimeServer mock_server; +mock_server.addUnixTime(0x123456); +myTimedMethod(&mock_server); </programlisting></para> </sect2> @@ -47,9 +51,12 @@ <title>Accessing protected elements</title> <para>Usually you will protect internal members in your classes. Variables - should almost always be <keysym>private</keysym>, in rare cases + should almost always be <keysym>private</keysym>, in very rare cases <keysym>protected</keysym>. So they are out of reach for your testing - code. Methods on the other hand may</para> + code. Since variables are very internal you should not try to make them + accessible somehow. The following sections show some patterns how to use + member methods to intentionally grant access to parts which are actually + internal. </para> <sect3> <title>Lifting class members</title> @@ -58,13 +65,11 @@ is to use a <keysym>using</keysym> declaration in a simple derived class to lift the member into <keysym>public</keysym> area. Of course this is only possible for <keysym>protected</keysym> methods and not for - <keysym>private</keysym> ones. But testing <keysym>private</keysym> - methods usually makes little sense anyway as they cover internal - details.</para> + <keysym>private</keysym> ones.</para> - <para>On the other hand it may be a nice compromise to make a - <keysym>private</keysym> method more general and more robust in order to - make it <keysym>protected</keysym> and test it this way.</para> + <para>It may be a nice compromise to make a <keysym>private</keysym> + method more general and more robust in order to make it + <keysym>protected</keysym> and test it this way.</para> <para><programlisting>class Sample { @@ -84,14 +89,14 @@ using Sample::interesting_internal_method; }; - TestSample sample; - sample.interesting_internal_method(); - +// in test code +TestSample sample; +sample.interesting_internal_method(); </programlisting></para> </sect3> <sect3> - <title>Inserting a Mock Object</title> + <title>Injecting a Mock Object</title> <para>Another possibility is to implement access to internal variables via getter and setter methods. If you make such methods @@ -115,6 +120,7 @@ class MockComplicated : public Complicated { + // mock needed capabilities }; Index: Makefile.am =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/docs/en/Makefile.am,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- Makefile.am 5 May 2005 21:01:59 -0000 1.22 +++ Makefile.am 6 May 2005 12:40:28 -0000 1.23 @@ -1,10 +1,10 @@ SUBDIRS = common images remote-install: html-files all - -scp var/*.html ewa...@mo...:/home/groups/m/mo/mockpp/htdocs/handbook - -scp $(srcdir)/common/* ewa...@mo...:/home/groups/m/mo/mockpp/htdocs/handbook/common - -scp $(srcdir)/images/* ewa...@mo...:/home/groups/m/mo/mockpp/htdocs/handbook/images - -scp $(srcdir)/images/callouts/* ewa...@mo...:/home/groups/m/mo/mockpp/htdocs/handbook/images/callouts + -scp var/*.html ewa...@mo...:/home/groups/m/mo/mockpp/htdocs/handbook + -scp $(srcdir)/common/*.css ewa...@mo...:/home/groups/m/mo/mockpp/htdocs/handbook/common + -scp $(srcdir)/images/*.png ewa...@mo...:/home/groups/m/mo/mockpp/htdocs/handbook/images + -scp $(srcdir)/images/callouts/*.png ewa...@mo...:/home/groups/m/mo/mockpp/htdocs/handbook/images/callouts CLEANFILES = *.~* *.~~* *~ @@ -20,8 +20,9 @@ test -f mockpp-$(VERSION)-handbook.zip && mv mockpp-$(VERSION)-handbook.zip $(top_builddir) rm -r mockpp-$(VERSION)-handbook +doc: html-files pdf-files -html-files doc: +html-chunk-files: -test -L tutorial && rm tutorial ln -s ../../examples/tutorial/html tutorial -test -L api-doc && rm api-doc @@ -35,19 +36,37 @@ ln -s ../common var/common; \ ln -s ../images var/images; \ fi - xsltproc -o var/ $(srcdir)/customize.xsl $(srcdir)/index.docbook + xsltproc -o var/ $(srcdir)/customize-chuked.xsl $(srcdir)/index.docbook + +html-files: html-flat-files + +html-flat-files: + -test -L tutorial && rm tutorial + ln -s ../../examples/tutorial/html tutorial + -test -L api-doc && rm api-doc + ln -s ../../docs/api/html api-doc + -test -d var || mkdir -p var + -rm var/common var/images + if test "$(srcdir)" "!=" "."; then \ + ln -s $(srcdir)/common var/common; \ + ln -s $(srcdir)/images var/images; \ + else \ + ln -s ../common var/common; \ + ln -s ../images var/images; \ + fi + xsltproc -o var/ $(srcdir)/customize-flat.xsl $(srcdir)/index.docbook pdf-files: xsltproc --output var/mockpp.fo /usr/share/xml/docbook/stylesheet/nwalsh/current/fo/docbook.xsl $(srcdir)/index.docbook - fop var/myfile.fo var/mockpp.pdf + fop var/mockpp.fo var/mockpp.pdf svg-files: xsltproc --output var/mockpp.fo /usr/share/xml/docbook/stylesheet/nwalsh/current/fo/docbook.xsl $(srcdir)/index.docbook - fop var/myfile.fo -svg var/mockpp.svg + fop var/mockpp.fo -svg var/mockpp.svg -.PHONY: html-files pdf-files doc-dist remote-install +.PHONY: html-files pdf-files doc-dist remote-install doc svg-files -EXTRA_DIST=appendix.docbook bookinfo.docbook credits.docbook customize.xsl \ - dev_advanced.docbook dev_advanced_easymock.docbook \ +EXTRA_DIST=appendix.docbook bookinfo.docbook credits.docbook customize.xsl customize-flat.xsl \ + dev_advanced.docbook dev_advanced_easymock.docbook customize-chunked.xsl \ dev_advanced_intro.docbook dev_poor_mans_mock.docbook dev_advanced_jmock.docbook dev_basic.docbook \ dev_helper.docbook dev_intro.docbook faq.docbook index.docbook dev_production.docbook --- NEW FILE: customize-flat.xsl --- <?xml version='1.0'?> <!-- Customisation for flat html-files $Id: customize-flat.xsl,v 1.1 2005/05/06 12:40:30 ewald-arnold Exp $ --> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:import href="customize.xsl"/> <xsl:param name="chunk.section.depth" select="0"/> </xsl:stylesheet> |