You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by jk...@apache.org on 2007/04/24 22:52:13 UTC

svn commit: r532075 - in /tapestry/tapestry4/trunk: tapestry-contrib/src/java/org/apache/tapestry/contrib/services/impl/ tapestry-contrib/src/test/org/apache/tapestry/contrib/services/ tapestry-framework/src/java/org/apache/tapestry/util/ tapestry-fram...

Author: jkuhnert
Date: Tue Apr 24 13:52:12 2007
New Revision: 532075

URL: http://svn.apache.org/viewvc?view=rev&rev=532075
Log:
Fixes for TAPESTRY-1428 form validators string list regexp regression. Took out multiline parsing and regexp works again. 

Added previous class I've been using for testing image generation but forgot to check in.

Added:
    tapestry/tapestry4/trunk/tapestry-contrib/src/test/org/apache/tapestry/contrib/services/TestRoundedUtil.java   (with props)
Modified:
    tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/services/impl/RoundedCornerService.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/util/RegexpPoolObjectFactory.java
    tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/validator/TestValidatorFactory.java

Modified: tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/services/impl/RoundedCornerService.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/services/impl/RoundedCornerService.java?view=diff&rev=532075&r1=532074&r2=532075
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/services/impl/RoundedCornerService.java (original)
+++ tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/services/impl/RoundedCornerService.java Tue Apr 24 13:52:12 2007
@@ -102,7 +102,7 @@
         
         try {
             
-            String type = (bgColor != null) ? "gif" : "png";
+            String type = "png"; //(bgColor != null) ? "gif" : "png";
 
             byte[] data = (byte[])_imageCache.get(hashKey);
             if (data != null) {
@@ -179,7 +179,7 @@
     private int getIntParam(String value)
     {
         if (value == null)
-            return 0;
+            return -1;
         
         return Integer.valueOf(value).intValue();
     }
@@ -187,7 +187,7 @@
     private float getFloatParam(String value)
     {
         if (value == null)
-            return 0f;
+            return -1f;
         
         return Float.valueOf(value).floatValue();
     }

Added: tapestry/tapestry4/trunk/tapestry-contrib/src/test/org/apache/tapestry/contrib/services/TestRoundedUtil.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-contrib/src/test/org/apache/tapestry/contrib/services/TestRoundedUtil.java?view=auto&rev=532075
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-contrib/src/test/org/apache/tapestry/contrib/services/TestRoundedUtil.java (added)
+++ tapestry/tapestry4/trunk/tapestry-contrib/src/test/org/apache/tapestry/contrib/services/TestRoundedUtil.java Tue Apr 24 13:52:12 2007
@@ -0,0 +1,122 @@
+package org.apache.tapestry.contrib.services;
+
+import org.apache.tapestry.contrib.services.impl.RoundedCornerGenerator;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+
+/**
+ *
+ */
+public class TestRoundedUtil extends JComponent {
+
+    private static final int WIDTH = 100;
+    private static final int HEIGHT = 100;
+
+    public TestRoundedUtil()
+    {
+    }
+
+    public Dimension getPreferredSize() {
+
+        return new Dimension(200, 200);
+    }
+
+    public Dimension getMinimumSize() {
+
+        return new Dimension(200,200);
+    }
+/*
+    protected void paintComponent(Graphics g) {
+
+        Graphics2D g2 = (Graphics2D)g;
+
+        RoundedCornerGenerator generator = new RoundedCornerGenerator();
+        BufferedImage image = null;
+
+        try {
+
+            image = generator.buildShadow("white", 100, 100, 20f, 20f, 6, 0.5f);
+        }
+        catch (Exception e) {
+            e.printStackTrace();
+            System.exit(-1);
+        }
+
+        //g2.setColor(Color.white);
+        //g2.fillRect(0, 0, 100, 100);
+
+        g2.drawImage(image, 0, 0, null);
+    }
+*/
+    /*
+    protected void paintComponent(Graphics g) {
+
+        Graphics2D g2 = (Graphics2D)g;
+
+        RoundedCornerGenerator generator = new RoundedCornerGenerator();
+        BufferedImage image = null;
+
+        try {
+            
+            image = generator.buildSideShadow("top", 8, 0.5f);
+        }
+        catch (Exception e) {
+            e.printStackTrace();
+            System.exit(-1);
+        }
+
+        g2.setColor(Color.white);
+        g2.fillRect(0, 0, 100, 100);
+        
+        g2.drawImage(image, 0, 0, null);
+    }
+    */
+    
+
+    protected void paintComponent(Graphics g) {
+
+        Graphics2D g2 = (Graphics2D)g;
+
+        RoundedCornerGenerator generator = new RoundedCornerGenerator();
+        BufferedImage image = null;
+
+        try {
+
+            image = generator.buildCorner("FF7E00", "white", 60, 60, "tr", -1, -1);
+        }
+        catch (Exception e) {
+            e.printStackTrace();
+            System.exit(-1);
+        }
+
+        g2.drawImage(image, 0, 0, null);
+
+        
+    }
+
+    private static void createAndShowGUI() {
+        //Create and set up the window.
+        JFrame frame = new JFrame("Rounded Corner Viewer");
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+        //Create and set up the content pane.
+        TestRoundedUtil id = new TestRoundedUtil();
+        frame.getContentPane().add(id, BorderLayout.CENTER);
+
+        //Display the window.
+        frame.pack();
+        frame.setVisible(true);
+    }
+
+    public static void main(String[] args) {
+        //Schedule a job for the event-dispatching thread:
+        //creating and showing this application's GUI.
+        javax.swing.SwingUtilities.invokeLater(new Runnable() {
+            public void run() {
+                createAndShowGUI();
+            }
+        });
+    }
+}

Propchange: tapestry/tapestry4/trunk/tapestry-contrib/src/test/org/apache/tapestry/contrib/services/TestRoundedUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/util/RegexpPoolObjectFactory.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/util/RegexpPoolObjectFactory.java?view=diff&rev=532075&r1=532074&r2=532075
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/util/RegexpPoolObjectFactory.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/util/RegexpPoolObjectFactory.java Tue Apr 24 13:52:12 2007
@@ -16,8 +16,6 @@
 import org.apache.commons.pool.BaseKeyedPoolableObjectFactory;
 import org.apache.hivemind.util.Defense;
 
-import java.util.regex.Pattern;
-
 
 /**
  * Implementation of {@link BaseKeyedPoolableObjectFactory} for regexp patterns
@@ -37,7 +35,7 @@
         
         String regexp = (String)pattern;
 
-        return java.util.regex.Pattern.compile(regexp, java.util.regex.Pattern.COMMENTS | java.util.regex.Pattern.DOTALL | Pattern.MULTILINE);
+        return java.util.regex.Pattern.compile(regexp, java.util.regex.Pattern.COMMENTS | java.util.regex.Pattern.DOTALL);
     }
 
 }

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/validator/TestValidatorFactory.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/validator/TestValidatorFactory.java?view=diff&rev=532075&r1=532074&r2=532075
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/validator/TestValidatorFactory.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/validator/TestValidatorFactory.java Tue Apr 24 13:52:12 2007
@@ -55,7 +55,7 @@
         return vc;
     }
 
-    public void testEmpty()
+    public void test_Empty()
     {
         IComponent component = newComponent();
         ValidatorFactoryImpl vf = new ValidatorFactoryImpl();
@@ -69,7 +69,7 @@
         verify();
     }
 
-    public void testSingle()
+    public void test_Single()
     {
         IComponent component = newComponent();
 
@@ -87,7 +87,7 @@
         verify();
     }
 
-    public void testMessage()
+    public void test_Message()
     {
         IComponent component = newComponent();
 
@@ -105,7 +105,25 @@
         verify();
     }
 
-    public void testConfigureAndMessage()
+    public void test_Localized_Message()
+    {
+        IComponent component = newComponent();
+
+        replay();
+
+        ValidatorFactoryImpl vf = new ValidatorFactoryImpl();
+        vf.setValidators(buildContributions("value", true));
+
+        List result = vf.constructValidatorList(component, "value=199.9999999999999[%defaultProb-interestRate]");
+
+        ValidatorFixture fixture = (ValidatorFixture) result.get(0);
+
+        assertEquals(fixture.getMessage(), "%defaultProb-interestRate");
+
+        verify();
+    }
+
+    public void test_Configure_And_Message()
     {
         IComponent component = newComponent();
 
@@ -124,7 +142,7 @@
         verify();
     }
 
-    public void testMissingConfiguration()
+    public void test_Missing_Configuration()
     {
         IComponent component = newComponent();
 
@@ -147,7 +165,7 @@
         verify();
     }
 
-    public void testMultiple()
+    public void test_Multiple()
     {
         IComponent component = newComponent();
 
@@ -179,7 +197,42 @@
         verify();
     }
 
-    public void testUnparseable()
+    public void test_Multiple_Localized()
+    {
+        IComponent component = newComponent();
+
+        replay();
+
+        Map map = new HashMap();
+        map.put("required", newContribution(false, Required.class));
+        map.put("min", newContribution(true, Min.class));
+        map.put("max", newContribution(true, Max.class));
+
+        ValidatorFactoryImpl vf = new ValidatorFactoryImpl();
+        vf.setValidators(map);
+
+        List result = vf.constructValidatorList(component,
+                "required,min=0.000000000001[%defaultProbInterestRate],\n" +
+                "max=199.9999999999999[%defaultProb-interestRate]");
+
+        assertEquals(3, result.size());
+
+        Required r = (Required) result.get(0);
+        assert r.getMessage() == null;
+        assert r.isRequired();
+
+        Min min = (Min) result.get(1);
+        assertEquals(min.getMessage(), "%defaultProbInterestRate");
+        assertEquals(min.getMin(), 0.000000000001);
+
+        Max max = (Max) result.get(2);
+        assertEquals(max.getMessage(), "%defaultProb-interestRate");
+        assertEquals(max.getMax(), 199.9999999999999);
+       
+        verify();
+    }
+
+    public void test_Unparseable()
     {
         IComponent component = newComponent();
 
@@ -200,7 +253,7 @@
         verify();
     }
 
-    public void testUnwantedConfiguration()
+    public void test_Unwanted_Configuration()
     {
         IComponent component = newComponent();
 
@@ -223,7 +276,7 @@
         verify();
     }
 
-    public void testMissingValidator()
+    public void test_Missing_Validator()
     {
         IComponent component = newComponent();
 
@@ -245,7 +298,7 @@
         verify();
     }
 
-    public void testInstantiateFailure()
+    public void test_Instantiate_Failure()
     {
         IComponent component = newComponent();
 
@@ -296,7 +349,7 @@
         return component;
     }
 
-    public void testBeanReference()
+    public void test_Bean_Reference()
         throws Exception
     {
         Validator validator = newValidator();
@@ -335,7 +388,7 @@
         return newMock(IFormComponent.class);
     }
 
-    public void testBeanReferenceNotValidator()
+    public void test_Bean_Reference_Not_Validator()
     {
         Object bean = new Object();
         IBeanProvider provider = newBeanProvider("fred", bean);
@@ -366,7 +419,7 @@
         verify();
     }
 
-    public void testBeanReferenceWithValue()
+    public void test_Bean_Reference_With_Value()
     {
         IComponent component = newComponent();
 
@@ -390,7 +443,7 @@
         verify();
     }
 
-    public void testBeanReferenceWithMessage()
+    public void test_Bean_Reference_With_Message()
     {
         IComponent component = newComponent();