You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by cr...@apache.org on 2005/09/17 09:23:16 UTC

svn commit: r289712 - in /struts/shale/trunk/core-library: ./ src/java/org/apache/shale/dialog/faces/ src/java/org/apache/shale/util/

Author: craigmcc
Date: Sat Sep 17 00:23:11 2005
New Revision: 289712

URL: http://svn.apache.org/viewcvs?rev=289712&view=rev
Log:
Fun with assert statements, part 1. Since Shale depends on JDK 1.4 or later,
stick in some "assert" statements for the classes that currently have unit test
cases, and make sure that assertions are enabled during the unit test runs.
The assertions, of course, can also be enabled at runtime by including the
following option (for *all* assertions):

    -Denableassertions

or the following option (for Shale-only assertions):

    -Denableassertions:org.apache.shale...

to the command line that starts your application server instance.

Modified:
    struts/shale/trunk/core-library/build.xml
    struts/shale/trunk/core-library/src/java/org/apache/shale/dialog/faces/DialogNavigationHandler.java
    struts/shale/trunk/core-library/src/java/org/apache/shale/util/LoadBundle.java
    struts/shale/trunk/core-library/src/java/org/apache/shale/util/Messages.java
    struts/shale/trunk/core-library/src/java/org/apache/shale/util/TokenProcessor.java

Modified: struts/shale/trunk/core-library/build.xml
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/core-library/build.xml?rev=289712&r1=289711&r2=289712&view=diff
==============================================================================
--- struts/shale/trunk/core-library/build.xml (original)
+++ struts/shale/trunk/core-library/build.xml Sat Sep 17 00:23:11 2005
@@ -419,6 +419,7 @@
          haltonfailure="${test.haltonfailure}"
           printSummary="no">
 
+      <jvmarg    value="-enableassertions:org.apache.shale..."/>
       <classpath refid="test.classpath"/>
       <formatter  type="plain"
                usefile="false"/>

Modified: struts/shale/trunk/core-library/src/java/org/apache/shale/dialog/faces/DialogNavigationHandler.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/core-library/src/java/org/apache/shale/dialog/faces/DialogNavigationHandler.java?rev=289712&r1=289711&r2=289712&view=diff
==============================================================================
--- struts/shale/trunk/core-library/src/java/org/apache/shale/dialog/faces/DialogNavigationHandler.java (original)
+++ struts/shale/trunk/core-library/src/java/org/apache/shale/dialog/faces/DialogNavigationHandler.java Sat Sep 17 00:23:11 2005
@@ -222,6 +222,10 @@
      */
     private void action(FacesContext context, Status status, ActionState state) {
 
+        assert context != null;
+        assert status != null;
+        assert state != null;
+
         if (log.isDebugEnabled()) {
             log.debug("action(state=" + state + ")");
         }
@@ -250,6 +254,9 @@
      */
     private Dialog getDialog(FacesContext context, String dialogName) {
 
+        assert context != null;
+        assert dialogName != null;
+
         Map map = (Map)
           context.getExternalContext().getApplicationMap().get(Globals.DIALOGS);
         if (map == null) {
@@ -269,8 +276,11 @@
      */
     private Status getStatus(FacesContext context, boolean create) {
 
+        assert context != null;
+
         Map map = context.getExternalContext().getSessionMap();
-		  String key = getStatusKey(context);
+        String key = getStatusKey(context);
+        assert key != null;
         Status status = (Status) map.get(key);
         if (create && (status == null)) {
             status = new StatusImpl();
@@ -344,6 +354,10 @@
     private void preprocess(FacesContext context, Status status,
                             State state, String outcome) {
 
+        assert context != null;
+        assert status != null;
+        assert state != null;
+
         if (log.isDebugEnabled()) {
             log.debug("preprocess(state=" + state + ",outcome=" + outcome + ")");
         }
@@ -392,6 +406,8 @@
      */
     private void render(FacesContext context, String viewId) {
 
+        assert context != null;
+
         if (log.isDebugEnabled()) {
             log.debug("render(viewId=" + viewId + ")");
         }
@@ -436,6 +452,7 @@
         // Register this user as being in the specfied State
         // and perform any required preprocessing
         Status status = getStatus(context, true);
+        assert status != null;
         status.push(new Status.Position(dialog.getName(), state.getName()));
         preprocess(context, status, state, dialogName);
 

Modified: struts/shale/trunk/core-library/src/java/org/apache/shale/util/LoadBundle.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/core-library/src/java/org/apache/shale/util/LoadBundle.java?rev=289712&r1=289711&r2=289712&view=diff
==============================================================================
--- struts/shale/trunk/core-library/src/java/org/apache/shale/util/LoadBundle.java (original)
+++ struts/shale/trunk/core-library/src/java/org/apache/shale/util/LoadBundle.java Sat Sep 17 00:23:11 2005
@@ -123,7 +123,9 @@
            throw new IllegalStateException("The 'basename' property cannot be null"); // FIXME - i18n
        }
        FacesContext context = FacesContext.getCurrentInstance();
+       assert context != null;
        Locale locale = context.getViewRoot().getLocale();
+       assert locale != null;
 
        // Look up the requested resource bundle
        final ResourceBundle bundle =

Modified: struts/shale/trunk/core-library/src/java/org/apache/shale/util/Messages.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/core-library/src/java/org/apache/shale/util/Messages.java?rev=289712&r1=289711&r2=289712&view=diff
==============================================================================
--- struts/shale/trunk/core-library/src/java/org/apache/shale/util/Messages.java (original)
+++ struts/shale/trunk/core-library/src/java/org/apache/shale/util/Messages.java Sat Sep 17 00:23:11 2005
@@ -268,6 +268,7 @@
      */
     private ResourceBundle getBundle(Locale locale) {
 
+        assert locale != null;
         ResourceBundle rb = null;
         ClassLoader rbcl = cl;
         if (cl == null) {

Modified: struts/shale/trunk/core-library/src/java/org/apache/shale/util/TokenProcessor.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/core-library/src/java/org/apache/shale/util/TokenProcessor.java?rev=289712&r1=289711&r2=289712&view=diff
==============================================================================
--- struts/shale/trunk/core-library/src/java/org/apache/shale/util/TokenProcessor.java (original)
+++ struts/shale/trunk/core-library/src/java/org/apache/shale/util/TokenProcessor.java Sat Sep 17 00:23:11 2005
@@ -57,7 +57,9 @@
         // Acquire the session identifier for this request
         // (creating the session if necessary)
         Object session = context.getExternalContext().getSession(true);
+        assert session != null;
         PropertyResolver pr = context.getApplication().getPropertyResolver();
+        assert pr != null;
         byte id[] = ((String) pr.getValue(session, "id")).getBytes();
 
         // Acquire the timestamp we will use for this request



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: svn commit: r289712 - in /struts/shale/trunk/core-library: ./ src/java/org/apache/shale/dialog/faces/ src/java/org/apache/shale/util/

Posted by Craig McClanahan <cr...@apache.org>.
On 9/17/05, Wendy Smoak <ja...@wendysmoak.com> wrote:
> 
> Wrom: 
> KBRNVWWCUFPEGAUTFJMVRESKPNKMBIPBARHDMNNSKVFVWRKJVZCMHVIBGDADRZFSQHYUCDDJBLVLMHAALPTCXLYRWTQTIPWIGYOKSTTZRCLBDXRQBGJSNBOHMKHJYFMYXOEAIJJPHSCRTNHGSWZIDREXCAXZOWCONEUQZAAFXISHJEXXIMQZUIVOTQNQEMSFDULHPQQWOYIYZUNNYCGPKYLEJGDGVCJVTLBXFGGMEPYOQKEDOTWFAOBUZXUWLSZLKBRNVWWCUFPEGAUTFJMVRESKPNKMBIPBARHDMNNSKVFVWRKJVZCMHVIBGDADRZFSQHYUCDDJBLVLMHAALPTCXLYRWTQTIPWIGYOKSTTZRCLBDXRQBGJSNBOHMKHJYFMYXOEAIJJPHSCRTNHGSWZIDREXCAXZOWCONEUQZAAFXISHJEXXIMQZUIVOTQNQEMSFDULHPQQWOYIYZUNNYCGPK 
> Hmm ... I've seen it done both ways. But I did just check, and the original 
> form (without the "-D" does indeed trigger assertion execution, so I'm going 
> to put it back. 
> 
> --
> > Wendy
> 
> 
> Craig 
> 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> > For additional commands, e-mail: dev-help@struts.apache.org
> > 
> > 
>

Re: svn commit: r289712 - in /struts/shale/trunk/core-library: ./ src/java/org/apache/shale/dialog/faces/ src/java/org/apache/shale/util/

Posted by Wendy Smoak <ja...@wendysmoak.com>.
From: "Craig McClanahan" <cr...@apache.org>

On 9/17/05, Martin Cooper <mf...@gmail.com> wrote:
> > + <jvmarg value="-enableassertions:org.apache.shale..."/>
> >
> > I believe you meant -Denableassertions... (i.e. missing a 'D')

> Yep, good catch ... thanks.

Craig, I think you had it right.  The output of 'java -help' 
shows -enableassertions as a separate switch.

-- 
Wendy 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: svn commit: r289712 - in /struts/shale/trunk/core-library: ./ src/java/org/apache/shale/dialog/faces/ src/java/org/apache/shale/util/

Posted by Craig McClanahan <cr...@apache.org>.
On 9/17/05, Martin Cooper <mf...@gmail.com> wrote:
> 
> + <jvmarg value="-enableassertions:org.apache.shale..."/>
> 
> I believe you meant -Denableassertions... (i.e. missing a 'D')


Yep, good catch ... thanks. 

--
> Martin Cooper


Craig

Re: svn commit: r289712 - in /struts/shale/trunk/core-library: ./ src/java/org/apache/shale/dialog/faces/ src/java/org/apache/shale/util/

Posted by Martin Cooper <mf...@gmail.com>.
+ <jvmarg value="-enableassertions:org.apache.shale..."/>

I believe you meant -Denableassertions... (i.e. missing a 'D')

--
Martin Cooper


On 9/17/05, craigmcc@apache.org <cr...@apache.org> wrote:
> 
> Author: craigmcc
> Date: Sat Sep 17 00:23:11 2005
> New Revision: 289712
> 
> URL: http://svn.apache.org/viewcvs?rev=289712&view=rev
> Log:
> Fun with assert statements, part 1. Since Shale depends on JDK 1.4 or 
> later,
> stick in some "assert" statements for the classes that currently have unit 
> test
> cases, and make sure that assertions are enabled during the unit test 
> runs.
> The assertions, of course, can also be enabled at runtime by including the
> following option (for *all* assertions):
> 
> -Denableassertions
> 
> or the following option (for Shale-only assertions):
> 
> -Denableassertions:org.apache.shale...
> 
> to the command line that starts your application server instance.
> 
> Modified:
> struts/shale/trunk/core-library/build.xml
> 
> struts/shale/trunk/core-library/src/java/org/apache/shale/dialog/faces/DialogNavigationHandler.java
> 
> struts/shale/trunk/core-library/src/java/org/apache/shale/util/LoadBundle.java
> 
> struts/shale/trunk/core-library/src/java/org/apache/shale/util/Messages.java
> 
> struts/shale/trunk/core-library/src/java/org/apache/shale/util/TokenProcessor.java
> 
> Modified: struts/shale/trunk/core-library/build.xml
> URL: 
> http://svn.apache.org/viewcvs/struts/shale/trunk/core-library/build.xml?rev=289712&r1=289711&r2=289712&view=diff
> 
> ==============================================================================
> --- struts/shale/trunk/core-library/build.xml (original)
> +++ struts/shale/trunk/core-library/build.xml Sat Sep 17 00:23:11 2005
> @@ -419,6 +419,7 @@
> haltonfailure="${test.haltonfailure}"
> printSummary="no">
> 
> + <jvmarg value="-enableassertions:org.apache.shale..."/>
> <classpath refid="test.classpath"/>
> <formatter type="plain"
> usefile="false"/>
> 
> Modified: 
> struts/shale/trunk/core-library/src/java/org/apache/shale/dialog/faces/DialogNavigationHandler.java
> URL: 
> http://svn.apache.org/viewcvs/struts/shale/trunk/core-library/src/java/org/apache/shale/dialog/faces/DialogNavigationHandler.java?rev=289712&r1=289711&r2=289712&view=diff
> 
> ==============================================================================
> --- 
> struts/shale/trunk/core-library/src/java/org/apache/shale/dialog/faces/DialogNavigationHandler.java 
> (original)
> +++ 
> struts/shale/trunk/core-library/src/java/org/apache/shale/dialog/faces/DialogNavigationHandler.java 
> Sat Sep 17 00:23:11 2005
> @@ -222,6 +222,10 @@
> */
> private void action(FacesContext context, Status status, ActionState 
> state) {
> 
> + assert context != null;
> + assert status != null;
> + assert state != null;
> +
> if (log.isDebugEnabled()) {
> log.debug("action(state=" + state + ")");
> }
> @@ -250,6 +254,9 @@
> */
> private Dialog getDialog(FacesContext context, String dialogName) {
> 
> + assert context != null;
> + assert dialogName != null;
> +
> Map map = (Map)
> context.getExternalContext().getApplicationMap().get(Globals.DIALOGS);
> if (map == null) {
> @@ -269,8 +276,11 @@
> */
> private Status getStatus(FacesContext context, boolean create) {
> 
> + assert context != null;
> +
> Map map = context.getExternalContext().getSessionMap();
> - String key = getStatusKey(context);
> + String key = getStatusKey(context);
> + assert key != null;
> Status status = (Status) map.get(key);
> if (create && (status == null)) {
> status = new StatusImpl();
> @@ -344,6 +354,10 @@
> private void preprocess(FacesContext context, Status status,
> State state, String outcome) {
> 
> + assert context != null;
> + assert status != null;
> + assert state != null;
> +
> if (log.isDebugEnabled()) {
> log.debug("preprocess(state=" + state + ",outcome=" + outcome + ")");
> }
> @@ -392,6 +406,8 @@
> */
> private void render(FacesContext context, String viewId) {
> 
> + assert context != null;
> +
> if (log.isDebugEnabled()) {
> log.debug("render(viewId=" + viewId + ")");
> }
> @@ -436,6 +452,7 @@
> // Register this user as being in the specfied State
> // and perform any required preprocessing
> Status status = getStatus(context, true);
> + assert status != null;
> status.push(new Status.Position(dialog.getName(), state.getName()));
> preprocess(context, status, state, dialogName);
> 
> 
> Modified: 
> struts/shale/trunk/core-library/src/java/org/apache/shale/util/LoadBundle.java
> URL: 
> http://svn.apache.org/viewcvs/struts/shale/trunk/core-library/src/java/org/apache/shale/util/LoadBundle.java?rev=289712&r1=289711&r2=289712&view=diff
> 
> ==============================================================================
> --- 
> struts/shale/trunk/core-library/src/java/org/apache/shale/util/LoadBundle.java 
> (original)
> +++ 
> struts/shale/trunk/core-library/src/java/org/apache/shale/util/LoadBundle.java 
> Sat Sep 17 00:23:11 2005
> @@ -123,7 +123,9 @@
> throw new IllegalStateException("The 'basename' property cannot be null"); 
> // FIXME - i18n
> }
> FacesContext context = FacesContext.getCurrentInstance();
> + assert context != null;
> Locale locale = context.getViewRoot().getLocale();
> + assert locale != null;
> 
> // Look up the requested resource bundle
> final ResourceBundle bundle =
> 
> Modified: 
> struts/shale/trunk/core-library/src/java/org/apache/shale/util/Messages.java
> URL: 
> http://svn.apache.org/viewcvs/struts/shale/trunk/core-library/src/java/org/apache/shale/util/Messages.java?rev=289712&r1=289711&r2=289712&view=diff
> 
> ==============================================================================
> --- 
> struts/shale/trunk/core-library/src/java/org/apache/shale/util/Messages.java 
> (original)
> +++ 
> struts/shale/trunk/core-library/src/java/org/apache/shale/util/Messages.java 
> Sat Sep 17 00:23:11 2005
> @@ -268,6 +268,7 @@
> */
> private ResourceBundle getBundle(Locale locale) {
> 
> + assert locale != null;
> ResourceBundle rb = null;
> ClassLoader rbcl = cl;
> if (cl == null) {
> 
> Modified: 
> struts/shale/trunk/core-library/src/java/org/apache/shale/util/TokenProcessor.java
> URL: 
> http://svn.apache.org/viewcvs/struts/shale/trunk/core-library/src/java/org/apache/shale/util/TokenProcessor.java?rev=289712&r1=289711&r2=289712&view=diff
> 
> ==============================================================================
> --- 
> struts/shale/trunk/core-library/src/java/org/apache/shale/util/TokenProcessor.java 
> (original)
> +++ 
> struts/shale/trunk/core-library/src/java/org/apache/shale/util/TokenProcessor.java 
> Sat Sep 17 00:23:11 2005
> @@ -57,7 +57,9 @@
> // Acquire the session identifier for this request
> // (creating the session if necessary)
> Object session = context.getExternalContext().getSession(true);
> + assert session != null;
> PropertyResolver pr = context.getApplication().getPropertyResolver();
> + assert pr != null;
> byte id[] = ((String) pr.getValue(session, "id")).getBytes();
> 
> // Acquire the timestamp we will use for this request
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
> 
>