You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tiles.apache.org by nl...@apache.org on 2012/07/11 21:45:41 UTC

svn commit: r1360370 - in /tiles/framework/branches/TILES_3_0_X: assembly/ src/site/apt/dev/ tiles-extras/src/main/java/org/apache/tiles/extras/renderer/ tiles-extras/src/test/java/org/apache/tiles/extras/renderer/

Author: nlebas
Date: Wed Jul 11 19:45:40 2012
New Revision: 1360370

URL: http://svn.apache.org/viewvc?rev=1360370&view=rev
Log:
TILES-549 - Improve code quality (post 3.0 release)
TILES-552: Update the poms and the documentation on the release process
TILES-548: mvn release:perfom fails on Maven 3.0.4

Added:
    tiles/framework/branches/TILES_3_0_X/tiles-extras/src/main/java/org/apache/tiles/extras/renderer/package-info.java
    tiles/framework/branches/TILES_3_0_X/tiles-extras/src/test/java/org/apache/tiles/extras/renderer/
    tiles/framework/branches/TILES_3_0_X/tiles-extras/src/test/java/org/apache/tiles/extras/renderer/OptionsRendererTest.java
Modified:
    tiles/framework/branches/TILES_3_0_X/assembly/pom.xml
    tiles/framework/branches/TILES_3_0_X/src/site/apt/dev/release.apt
    tiles/framework/branches/TILES_3_0_X/tiles-extras/src/main/java/org/apache/tiles/extras/renderer/OptionsRenderer.java

Modified: tiles/framework/branches/TILES_3_0_X/assembly/pom.xml
URL: http://svn.apache.org/viewvc/tiles/framework/branches/TILES_3_0_X/assembly/pom.xml?rev=1360370&r1=1360369&r2=1360370&view=diff
==============================================================================
--- tiles/framework/branches/TILES_3_0_X/assembly/pom.xml (original)
+++ tiles/framework/branches/TILES_3_0_X/assembly/pom.xml Wed Jul 11 19:45:40 2012
@@ -123,7 +123,14 @@
           <plugin>
             <groupId>org.codehaus.mojo</groupId>
             <artifactId>wagon-maven-plugin</artifactId>
-            <version>1.0-beta-4</version>
+            <version>1.0</version>
+            <dependencies>
+              <dependency>
+                <groupId>org.apache.maven.wagon</groupId>
+                <artifactId>wagon-ssh</artifactId>
+                <version>1.0</version>
+              </dependency>
+            </dependencies>
             <executions>
               <execution>
                 <phase>deploy</phase>

Modified: tiles/framework/branches/TILES_3_0_X/src/site/apt/dev/release.apt
URL: http://svn.apache.org/viewvc/tiles/framework/branches/TILES_3_0_X/src/site/apt/dev/release.apt?rev=1360370&r1=1360369&r2=1360370&view=diff
==============================================================================
--- tiles/framework/branches/TILES_3_0_X/src/site/apt/dev/release.apt (original)
+++ tiles/framework/branches/TILES_3_0_X/src/site/apt/dev/release.apt Wed Jul 11 19:45:40 2012
@@ -136,8 +136,10 @@ mvn release:prepare -Dusername=YOUR_SVN_
 -----------------------------------
 
   The plugin interactively will ask you the version to release, the Subversion
-  tag to use and the next snapshot version. It is reccomended to use the tag:
+  tag to use and the next snapshot version. It is recommended to use the tag:
   <<tiles-X.X.X>>.
+  
+  See also {{{http://www.apache.org/dev/publishing-maven-artifacts.html}the recommendations of the ASF}}.
 
 * Perform the Release
 
@@ -146,6 +148,8 @@ mvn release:prepare -Dusername=YOUR_SVN_
 -----------------------------------
 mvn release:perform
 -----------------------------------
+  
+  It should compile and test everything, build and upload the artifacts and the website for the project. 
 
 * Close the staging repository
 
@@ -168,32 +172,11 @@ mvn release:perform
 
   Note the repository URL, you will need this in your vote email.
 
-* Digest and upload assemblies
+* Verify the uploaded assemblies
 
-  * Go into the release assembly target directory:
-
------------------------------------
-cd target/checkout/assembly/target/assembly/out
------------------------------------
-
-  * Create MD5 and SHA1 files for each files (including ASC files). You can do
-  it with this simple shell script:
-
------------------------------------
-#!/bin/sh
-
-for fileitem in *
-do
-  openssl md5 < $fileitem > $fileitem.md5
-  openssl sha1 < $fileitem > $fileitem.sha1
-done
------------------------------------
-
-  * Upload everything to the build site:
-
------------------------------------
-scp * user@people.apache.org:/www/people.apache.org/builds/tiles/${version}
------------------------------------
+  * go to the destination directory on people.apache.org (cd /www/people.apache.org/builds/tiles/${version}).
+  
+  * check the presence of the 3 distributions (bin, doc and src), and their signature files (*.asc, *.md5, *sha1). 
 
 * Release the JIRA version
 
@@ -334,11 +317,11 @@ http://tiles.apache.org/download.html
 It is also available in the central Maven repository under Group ID
 "org.apache.tiles".
 
-The 2.0.x series of the Apache Tiles framework has a minimum
+The 3.0.x series of the Apache Tiles framework has a minimum
 requirement of the following specification versions:
 
-* Java Servlet 2.4 and JavaServer Pages (JSP) 2.0
-* Java Standard Edition (Java SE) 1.5
+* Java Servlet 2.5 and JavaServer Pages (JSP) 2.1
+* Java Standard Edition (Java SE) 1.6
 
 The release notes are available online at:
 

Modified: tiles/framework/branches/TILES_3_0_X/tiles-extras/src/main/java/org/apache/tiles/extras/renderer/OptionsRenderer.java
URL: http://svn.apache.org/viewvc/tiles/framework/branches/TILES_3_0_X/tiles-extras/src/main/java/org/apache/tiles/extras/renderer/OptionsRenderer.java?rev=1360370&r1=1360369&r2=1360370&view=diff
==============================================================================
--- tiles/framework/branches/TILES_3_0_X/tiles-extras/src/main/java/org/apache/tiles/extras/renderer/OptionsRenderer.java (original)
+++ tiles/framework/branches/TILES_3_0_X/tiles-extras/src/main/java/org/apache/tiles/extras/renderer/OptionsRenderer.java Wed Jul 11 19:45:40 2012
@@ -40,30 +40,33 @@ import org.slf4j.LoggerFactory;
 /**
  * Provides a custom "options" syntax for attributes.
  * The first option that can be rendered is.
- * Comes from http://tech.finn.no/the-ultimate-view/<p/>
+ * Comes from <a href="http://tech.finn.no/the-ultimate-view/">The Ultimate View</a> article.<p/>
  *
- * Actual rendering is delegated to the TypeDetectingRenderer that's supplied in the constructor.
+ * Actual rendering is delegated to the TypeDetectingRenderer that's supplied in the constructor.<p/>
  *
  * For example:
  * "/WEB-INF/tiles/fragments/${options[myoptions]}/content.jsp"
  * given the myptions list-attribute is defined like:
  * <pre>
-        <put-list-attribute name="myoptions">
-            <add-list-attribute>
-                <add-attribute value="car"/>
-                <add-attribute value="vechile"/>
-                <add-attribute value="advert"/>
-            </add-list-attribute>
-        </put-list-attribute>
+        &lt;put-list-attribute name="myoptions">
+            &lt;add-list-attribute>
+                &lt;add-attribute value="car"/>
+                &lt;add-attribute value="vechile"/>
+                &lt;add-attribute value="advert"/>
+            &lt;/add-list-attribute>
+        &lt;/put-list-attribute>
    </pre>
- * will look for content.jsp
- * first in "/WEB-INF/tiles/fragments/car/" then
- * second in "/WEB-INF/tiles/fragments/vechile/" and
+ * will look for content.jsp <br/>
+ * first in "/WEB-INF/tiles/fragments/car/" then <br/>
+ * second in "/WEB-INF/tiles/fragments/vechile/" and <br/>
  * last in "/WEB-INF/tiles/fragments/advert".
  * <p/>
  * <p/>
  * Currently only supports one occurrance of such an "option" pattern in the attribute's value.
  *
+ * Limitation: "looking" for templates is implemented using applicationContext.getResource(..)
+ * therefore the option values in the options list need to be visible as applicationResources.
+ *
  */
 public final class OptionsRenderer implements Renderer {
 
@@ -75,7 +78,7 @@ public final class OptionsRenderer imple
     private final ApplicationContext applicationContext;
     private final Renderer renderer;
 
-    public OptionsRenderer(final ApplicationContext applicationContext, final Renderer renderer){
+    public OptionsRenderer(final ApplicationContext applicationContext, final Renderer renderer) {
         this.applicationContext = applicationContext;
         this.renderer = renderer;
     }
@@ -98,16 +101,17 @@ public final class OptionsRenderer imple
                     .getAttributeContext(request)
                     .getAttribute(match);
 
-            if(null == fallbacks){
+            if (null == fallbacks) {
                 throw new IllegalStateException("A matching list-attribute name=\"" + match + "\" must be defined.");
-            }else if(fallbacks.getValue().isEmpty()){
-                throw new IllegalStateException("list-attribute name=\"" + match + "\" must have minimum one attribute");
+            } else if (fallbacks.getValue().isEmpty()) {
+                throw new IllegalStateException(
+                        "list-attribute name=\"" + match + "\" must have minimum one attribute");
             }
 
             for (Attribute option : (List<Attribute>) fallbacks.getValue()) {
-                String template = path.replaceFirst(Pattern.quote(matcher.group()), (String)option.getValue());
+                String template = path.replaceFirst(Pattern.quote(matcher.group()), (String) option.getValue());
                 done = renderAttempt(template, request);
-                if(done){ break; }
+                if (done) { break; }
             }
             if (!done) {
               throw new IOException("None of the options existed for " + path);
@@ -117,9 +121,9 @@ public final class OptionsRenderer imple
         }
     }
 
-    private boolean renderAttempt(final String template, final Request request) throws IOException{
+    private boolean renderAttempt(final String template, final Request request) throws IOException {
         boolean result = false;
-        if(!Cache.isTemplateMissing(template)){
+        if (!Cache.isTemplateMissing(template)) {
             try {
                 if (null != applicationContext.getResource(template)) { // can throw FileNotFoundException !
                     renderer.render(template, request); // can throw FileNotFoundException !
@@ -127,14 +131,14 @@ public final class OptionsRenderer imple
                     Cache.setIfAbsentTemplateFound(template, true);
                 }
             } catch (FileNotFoundException ex) {
-                if(ex.getMessage().contains(template)){
+                if (ex.getMessage().contains(template)) {
                     // expected outcome. continue loop.
                     LOG.trace(ex.getMessage());
-                }else{
+                } else {
                     // comes from an inner templateAttribute.render(..) so throw on
                     throw ex;
                 }
-            } catch(IOException ex){ //xxx ???
+            } catch (IOException ex) { //xxx ???
                 throw ex;
             }
             Cache.setIfAbsentTemplateFound(template, false);
@@ -142,14 +146,14 @@ public final class OptionsRenderer imple
         return result;
     }
 
-    private static final class Cache{
+    private static final class Cache {
 
         /** It takes CACHE_LIFE milliseconds for any hot deployments to register.
          */
         private static final ConcurrentMap<String,Boolean> TEMPLATE_EXISTS
                 = new ConcurrentHashMap<String,Boolean>();
 
-        private volatile static long cacheLastCleaned = System.currentTimeMillis();
+        private static volatile long cacheLastCleaned = System.currentTimeMillis();
 
         private static final String CACHE_LIFE_PROPERTY = Cache.class.getName() + ".ttl_ms";
 
@@ -163,22 +167,22 @@ public final class OptionsRenderer imple
                 ? Long.getLong(CACHE_LIFE_PROPERTY)
                 : 1000 * 60 * 5;
 
-        static boolean isTemplateMissing(final String template){
-            if(0 < CACHE_LIFE && System.currentTimeMillis() > cacheLastCleaned + CACHE_LIFE){
+        static boolean isTemplateMissing(final String template) {
+            if (0 < CACHE_LIFE && System.currentTimeMillis() > cacheLastCleaned + CACHE_LIFE) {
                 cacheLastCleaned = System.currentTimeMillis();
                 TEMPLATE_EXISTS.clear();
                 return false;
-            }else{
+            } else {
                 return TEMPLATE_EXISTS.containsKey(template) && !TEMPLATE_EXISTS.get(template);
             }
         }
 
-        static void setIfAbsentTemplateFound(final String template, final boolean found){
-            if(0 < CACHE_LIFE && !TEMPLATE_EXISTS.containsKey(template)){
+        static void setIfAbsentTemplateFound(final String template, final boolean found) {
+            if (0 < CACHE_LIFE && !TEMPLATE_EXISTS.containsKey(template)) {
                 TEMPLATE_EXISTS.putIfAbsent(template, found);
             }
         }
 
-        private Cache(){}
+        private Cache() {}
     }
 }

Added: tiles/framework/branches/TILES_3_0_X/tiles-extras/src/main/java/org/apache/tiles/extras/renderer/package-info.java
URL: http://svn.apache.org/viewvc/tiles/framework/branches/TILES_3_0_X/tiles-extras/src/main/java/org/apache/tiles/extras/renderer/package-info.java?rev=1360370&view=auto
==============================================================================
--- tiles/framework/branches/TILES_3_0_X/tiles-extras/src/main/java/org/apache/tiles/extras/renderer/package-info.java (added)
+++ tiles/framework/branches/TILES_3_0_X/tiles-extras/src/main/java/org/apache/tiles/extras/renderer/package-info.java Wed Jul 11 19:45:40 2012
@@ -0,0 +1,27 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/**
+ * Provides a custom "options" syntax for attributes.
+ * The first option from a list that can be rendered is.
+ *
+ * Comes from <a href="http://tech.finn.no/the-ultimate-view/">The Ultimate View</a> article.
+ */
+package org.apache.tiles.extras.renderer;

Added: tiles/framework/branches/TILES_3_0_X/tiles-extras/src/test/java/org/apache/tiles/extras/renderer/OptionsRendererTest.java
URL: http://svn.apache.org/viewvc/tiles/framework/branches/TILES_3_0_X/tiles-extras/src/test/java/org/apache/tiles/extras/renderer/OptionsRendererTest.java?rev=1360370&view=auto
==============================================================================
--- tiles/framework/branches/TILES_3_0_X/tiles-extras/src/test/java/org/apache/tiles/extras/renderer/OptionsRendererTest.java (added)
+++ tiles/framework/branches/TILES_3_0_X/tiles-extras/src/test/java/org/apache/tiles/extras/renderer/OptionsRendererTest.java Wed Jul 11 19:45:40 2012
@@ -0,0 +1,139 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tiles.extras.renderer;
+
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import org.apache.tiles.Attribute;
+import org.apache.tiles.ListAttribute;
+import org.apache.tiles.access.TilesAccess;
+import org.apache.tiles.impl.BasicTilesContainer;
+import org.apache.tiles.request.ApplicationContext;
+import org.apache.tiles.request.ApplicationResource;
+
+import org.apache.tiles.request.Request;
+import org.apache.tiles.request.locale.PostfixedApplicationResource;
+import org.apache.tiles.request.render.StringRenderer;
+import org.junit.Test;
+
+/**
+ * Tests {@link OptionsRenderer}.
+ *
+ * @version $Rev$ $Date$
+ */
+public final class OptionsRendererTest {
+
+    private final BasicTilesContainer container = new BasicTilesContainer();
+
+    private final Map<String, Object> appScope = new HashMap<String, Object>(){{
+        put(TilesAccess.CONTAINER_ATTRIBUTE, container);
+    }};
+
+    private final Map<String, Object> requestScope = new HashMap<String, Object>();
+
+    private final ApplicationResource template = new PostfixedApplicationResource("Result"){
+        @Override
+        public InputStream getInputStream() throws IOException {
+            throw new AssertionError("Shouldn't be called.");
+        }
+        @Override
+        public long getLastModified() throws IOException {
+            return 0;
+        }
+    };
+
+    private final ApplicationContext context = new ApplicationContext(){
+        @Override
+        public Object getContext() {
+            throw new AssertionError("Shouldn't be called.");
+        }
+        @Override
+        public Map<String, Object> getApplicationScope() {
+            return appScope;
+        }
+        @Override
+        public Map<String, String> getInitParams() {
+            throw new AssertionError("Shouldn't be called.");
+        }
+        @Override
+        public ApplicationResource getResource(String string) {
+            return template;
+        }
+        @Override
+        public ApplicationResource getResource(ApplicationResource ar, Locale locale) {
+            throw new AssertionError("Shouldn't be called.");
+        }
+        @Override
+        public Collection<ApplicationResource> getResources(String string) {
+            throw new AssertionError("Shouldn't be called.");
+        }
+    };
+
+    /**
+     * Tests
+     * {@link OptionsRenderer#render(String, Request)}.
+     *
+     * @throws IOException If something goes wrong during rendition.
+     */
+    @Test
+    public void testWrite() throws IOException {
+        StringWriter writer = new StringWriter();
+        Request request = createMock(Request.class);
+
+        requestScope.put(TilesAccess.CURRENT_CONTAINER_ATTRIBUTE_NAME, container);
+
+        expect(request.getContext(matches("request"))).andReturn(requestScope).anyTimes();
+        expect(request.getApplicationContext()).andReturn(context);
+        expect(request.getWriter()).andReturn(writer);
+        replay(request);
+
+        container
+                .getAttributeContext(request)
+                .putAttribute("test-fallback", new ListAttribute(){{
+                    add(new Attribute("Result"));
+                }});
+
+        OptionsRenderer renderer = new OptionsRenderer(context, new StringRenderer());
+        renderer.render("{options[test-fallback]}", request);
+        writer.close();
+        assertEquals("Not written 'Result'", "Result", writer.toString());
+        verify(request);
+    }
+
+    /**
+     * Tests
+     * {@link OptionsRenderer#isRenderable(String, Request)}.
+     */
+    @Test
+    public void testIsRenderable() {
+        Request requestContext = createMock(Request.class);
+        OptionsRenderer renderer = new OptionsRenderer(context, new StringRenderer());
+        assertTrue(renderer.isRenderable("any-string", requestContext));
+    }
+}