svn commit: r1157353 - /struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/AbstractUITag.java

2011-08-13 Thread mcucchiara
Author: mcucchiara
Date: Sat Aug 13 09:04:19 2011
New Revision: 1157353

URL: http://svn.apache.org/viewvc?rev=1157353&view=rev
Log:
dynamic attributes became again a map of String (see http://s.apache.org/dyn)

Modified:

struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/AbstractUITag.java

Modified: 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/AbstractUITag.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/AbstractUITag.java?rev=1157353&r1=1157352&r2=1157353&view=diff
==
--- 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/AbstractUITag.java
 (original)
+++ 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/AbstractUITag.java
 Sat Aug 13 09:04:19 2011
@@ -21,6 +21,7 @@
 
 package org.apache.struts2.views.jsp.ui;
 
+import org.apache.commons.lang.ObjectUtils;
 import org.apache.struts2.components.UIBean;
 import org.apache.struts2.views.jsp.ComponentTagSupport;
 
@@ -291,19 +292,9 @@ public abstract class AbstractUITag exte
 
 public void setDynamicAttribute(String uri, String localName, Object 
value) throws JspException {
 if (value != null && value instanceof String) {
-evaluateValue(localName, value);
+dynamicAttributes.put(localName, 
String.valueOf(ObjectUtils.defaultIfNull(findValue(value.toString()), value)));
 } else {
 dynamicAttributes.put(localName, value);
 }
 }
-
-private void evaluateValue(String localName, Object value) {
-Object evaluatedValue = findValue(value.toString());
-if (evaluatedValue != null) {
-dynamicAttributes.put(localName, evaluatedValue);
-} else {
-dynamicAttributes.put(localName, value);
-}
-}
-
 }




svn commit: r1157359 - in /struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp: AbstractUITagTest.java ui/AnchorTest.java

2011-08-13 Thread mcucchiara
Author: mcucchiara
Date: Sat Aug 13 09:27:10 2011
New Revision: 1157359

URL: http://svn.apache.org/viewvc?rev=1157359&view=rev
Log:
* small optimizations
* removed duplicate code

Modified:

struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/AbstractUITagTest.java

struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/AnchorTest.java

Modified: 
struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/AbstractUITagTest.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/AbstractUITagTest.java?rev=1157359&r1=1157358&r2=1157359&view=diff
==
--- 
struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/AbstractUITagTest.java
 (original)
+++ 
struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/AbstractUITagTest.java
 Sat Aug 13 09:27:10 2011
@@ -21,26 +21,19 @@
 
 package org.apache.struts2.views.jsp;
 
+import com.opensymphony.xwork2.ActionContext;
+import com.opensymphony.xwork2.util.logging.Logger;
+import com.opensymphony.xwork2.util.logging.LoggerFactory;
+import org.apache.struts2.ServletActionContext;
+import org.apache.struts2.views.jsp.ui.AbstractUITag;
+
 import java.beans.IntrospectionException;
 import java.beans.Introspector;
 import java.beans.PropertyDescriptor;
 import java.io.InputStream;
 import java.lang.reflect.InvocationTargetException;
 import java.net.URL;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import org.apache.struts2.ServletActionContext;
-import org.apache.struts2.views.jsp.ui.AbstractUITag;
-
-import com.opensymphony.xwork2.ActionContext;
-import com.opensymphony.xwork2.util.logging.Logger;
-import com.opensymphony.xwork2.util.logging.LoggerFactory;
+import java.util.*;
 
 
 /**
@@ -255,6 +248,17 @@ public abstract class AbstractUITagTest 
 }
 
 /**
+ * Attempt to verify the contents of this.writer against the contents of 
the resource specified.  verify() performs a
+ * trim on both ends
+ *
+ * @param resource the HTML snippet that we want to validate against
+ * @throws Exception if the validation failed
+ */
+public void verifyResource(String resource) throws Exception {
+verify(this.getClass().getResource(resource));
+}
+
+/**
  * Attempt to verify the contents of this.writer against the contents of 
the URL specified.  verify() performs a
  * trim on both ends
  *
@@ -262,31 +266,7 @@ public abstract class AbstractUITagTest 
  * @throws Exception if the validation failed
  */
 public void verify(URL url) throws Exception {
-if (url == null) {
-fail("unable to verify a null URL");
-} else if (this.writer == null) {
-fail("AbstractJspWriter.writer not initialized.  Unable to 
verify");
-}
-
-StringBuilder buffer = new StringBuilder(128);
-InputStream in = url.openStream();
-byte[] buf = new byte[4096];
-int nbytes;
-
-while ((nbytes = in.read(buf)) > 0) {
-buffer.append(new String(buf, 0, nbytes));
-}
-
-in.close();
-
-/**
- * compare the trimmed values of each buffer and make sure they're 
equivalent.  however, let's make sure to
- * normalize the strings first to account for line termination 
differences between platforms.
- */
-String writerString = normalize(writer.toString(), true);
-String bufferString = normalize(buffer.toString(), true);
-
-assertEquals(bufferString, writerString);
+verify(url,null);
 }
 
 /**
@@ -294,10 +274,11 @@ public abstract class AbstractUITagTest 
  * trim on both ends
  *
  * @param url the HTML snippet that we want to validate against
+ * @param excluded
  * @throws Exception if the validation failed
  */
 public void verify(URL url, String[] excluded) throws Exception {
-if (url == null) {
+ if (url == null) {
 fail("unable to verify a null URL");
 } else if (this.writer == null) {
 fail("AbstractJspWriter.writer not initialized.  Unable to 
verify");

Modified: 
struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/AnchorTest.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/AnchorTest.java?rev=1157359&r1=1157358&r2=1157359&view=diff
==
--- 
struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/AnchorTest.java
 (original)
+++ 
struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/AnchorTest.java
 Sat Aug 13 09:27:10 2011
@@ -30,43 +30,31 @@ import org

svn commit: r1157393 - /struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/AbstractUITagTest.java

2011-08-13 Thread mcucchiara
Author: mcucchiara
Date: Sat Aug 13 16:58:39 2011
New Revision: 1157393

URL: http://svn.apache.org/viewvc?rev=1157393&view=rev
Log:
* small improvements
* removed duplicate code

Modified:

struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/AbstractUITagTest.java

Modified: 
struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/AbstractUITagTest.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/AbstractUITagTest.java?rev=1157393&r1=1157392&r2=1157393&view=diff
==
--- 
struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/AbstractUITagTest.java
 (original)
+++ 
struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/AbstractUITagTest.java
 Sat Aug 13 16:58:39 2011
@@ -24,12 +24,10 @@ package org.apache.struts2.views.jsp;
 import com.opensymphony.xwork2.ActionContext;
 import com.opensymphony.xwork2.util.logging.Logger;
 import com.opensymphony.xwork2.util.logging.LoggerFactory;
+import org.apache.commons.beanutils.BeanUtils;
 import org.apache.struts2.ServletActionContext;
 import org.apache.struts2.views.jsp.ui.AbstractUITag;
 
-import java.beans.IntrospectionException;
-import java.beans.Introspector;
-import java.beans.PropertyDescriptor;
 import java.io.InputStream;
 import java.lang.reflect.InvocationTargetException;
 import java.net.URL;
@@ -100,7 +98,7 @@ public abstract class AbstractUITagTest 
  *
  * @param map The map to place this instance in.
  */
-public void addToMap(Map map) {
+public void addToMap(Map map) {
 if (map != null) {
 map.put(this.name, this);
 }
@@ -114,32 +112,17 @@ public abstract class AbstractUITagTest 
  * TODO: Check how we can remove this crap again.
  *
  * @author mailto:gie...@it-neering.net";>Rene Gielen
+ * @deprecated use BeanUtils#setProperty
  */
 public class BeanHelper {
-Map propDescriptors;
 Object bean;
 
 public BeanHelper(Object bean) {
 this.bean = bean;
-
-try {
-PropertyDescriptor[] pds;
-pds = 
Introspector.getBeanInfo(bean.getClass()).getPropertyDescriptors();
-propDescriptors = new HashMap(pds.length + 1, 1f);
-for (int i = 0; i < pds.length; i ++) {
-propDescriptors.put(pds[i].getName(), pds[i]);
-}
-} catch (IntrospectionException e) {
-e.printStackTrace();
-}
 }
 
 public void set(String name, Object value) throws 
IllegalAccessException, InvocationTargetException {
-PropertyDescriptor pd = (PropertyDescriptor) 
propDescriptors.get(name);
-
-if (pd != null) {
-pd.getWriteMethod().invoke(bean, new Object[]{value});
-}
+BeanUtils.setProperty(this.bean, name, value);
 }
 
 }
@@ -153,8 +136,8 @@ public abstract class AbstractUITagTest 
  * @return A Map of PropertyHolders values bound to {@link 
org.apache.struts2.views.jsp.AbstractUITagTest.PropertyHolder#getName()}
  * as key.
  */
-protected Map initializedGenericTagTestProperties() {
-Map result = new HashMap();
+protected Map 
initializedGenericTagTestProperties() {
+Map result = new HashMap();
 new PropertyHolder("name", "someName").addToMap(result);
 new PropertyHolder("id", "someId").addToMap(result);
 new PropertyHolder("cssClass", "cssClass1", 
"class=\"cssClass1\"").addToMap(result);
@@ -193,7 +176,7 @@ public abstract class AbstractUITagTest 
  * @param exclude  Names of properties to exclude from particular 
test.
  * @throws Exception
  */
-public void verifyGenericProperties(AbstractUITag tag, String theme, Map 
propertiesToTest, String[] exclude) throws Exception {
+public void verifyGenericProperties(AbstractUITag tag, String theme, 
Map propertiesToTest, String[] exclude) throws 
Exception {
 if (tag != null && propertiesToTest != null) {
 List excludeList;
 if (exclude != null) {
@@ -207,12 +190,9 @@ public abstract class AbstractUITagTest 
 tag.setTheme(theme);
 }
 
-BeanHelper beanHelper = new BeanHelper(tag);
-Iterator it = propertiesToTest.values().iterator();
-while (it.hasNext()) {
-PropertyHolder propertyHolder = (PropertyHolder) it.next();
-if (! excludeList.contains(propertyHolder.getName())) {
-beanHelper.set(propertyHolder.getName(), 
propertyHolder.getValue());
+for (PropertyHolder propertyHolder : propertiesToTest.values()) {
+if (!excludeList.contains(propertyHolder.getName())) {
+BeanUtils.setProperty(tag, pr

svn commit: r1157396 - in /struts/struts2/trunk/plugins/junit/src: main/java/org/apache/struts2/ test/java/org/apache/struts2/ test/resources/

2011-08-13 Thread mcucchiara
Author: mcucchiara
Date: Sat Aug 13 17:41:59 2011
New Revision: 1157396

URL: http://svn.apache.org/viewvc?rev=1157396&view=rev
Log:
WW-3669 - TestCase for StrutsJUnit4TestCase

Added:

struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/StrutsSpringJUnit4TestCaseTest.java
   (with props)
Modified:

struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsJUnit4TestCase.java

struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/StrutsSpringTestCaseTest.java
   (props changed)

struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/StrutsTestCaseTest.java
   (contents, props changed)

struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/TestAction.java
   (props changed)

struts/struts2/trunk/plugins/junit/src/test/resources/applicationContext.xml   
(props changed)
struts/struts2/trunk/plugins/junit/src/test/resources/struts.xml   (props 
changed)
struts/struts2/trunk/plugins/junit/src/test/resources/template.ftl   (props 
changed)

Modified: 
struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsJUnit4TestCase.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsJUnit4TestCase.java?rev=1157396&r1=1157395&r2=1157396&view=diff
==
--- 
struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsJUnit4TestCase.java
 (original)
+++ 
struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsJUnit4TestCase.java
 Sat Aug 13 17:41:59 2011
@@ -152,7 +152,7 @@ public abstract class StrutsJUnit4TestCa
 namespace, name, method, new HashMap(), true, 
false);
 
 ActionContext invocationContext = 
proxy.getInvocation().getInvocationContext();
-invocationContext.setParameters(new 
HashMap(request.getParameterMap()));
+invocationContext.setParameters(new 
HashMap(request.getParameterMap()));
 // set the action context to the one used by the proxy
 ActionContext.setContext(invocationContext);
 

Added: 
struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/StrutsSpringJUnit4TestCaseTest.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/StrutsSpringJUnit4TestCaseTest.java?rev=1157396&view=auto
==
--- 
struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/StrutsSpringJUnit4TestCaseTest.java
 (added)
+++ 
struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/StrutsSpringJUnit4TestCaseTest.java
 Sat Aug 13 17:41:59 2011
@@ -0,0 +1,76 @@
+/*
+ * $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.struts2;
+
+import com.opensymphony.xwork2.Action;
+import com.opensymphony.xwork2.ActionProxy;
+import org.apache.struts2.dispatcher.mapper.ActionMapping;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import javax.servlet.ServletException;
+import java.io.UnsupportedEncodingException;
+
+@RunWith(SpringJUnit4ClassRunner.class) 
+@ContextConfiguration(locations={"classpath*:applicationContext.xml"})
+public class StrutsSpringJUnit4TestCaseTest extends 
StrutsSpringJUnit4TestCase {
+   
+   @Test
+public void getActionMapping() {
+ActionMapping mapping = getActionMapping("/test/testAction.action");
+Assert.assertNotNull(mapping);
+Assert.assertEquals("/test", mapping.getNamespace());
+Assert.assertEquals("testAction", mapping.getName());
+}
+
+   @Test
+public void getActionProxy() throws Exception {
+//set parameters before calling getActionProxy
+request.setParameter("name", "FD");
+
+ActionProxy proxy = getActionProxy("/test/testAction.action");
+Assert.assertNotNull(proxy);
+
+TestAction action = (TestAction) proxy.getAction();
+Assert.assertNotNull(a

[CONF] Confluence Changes in the last 24 hours

2011-08-13 Thread confluence
This is a daily summary of all recent changes in Confluence.

-
Updated Spaces:
-


Apache Bigtop (incubating) (https://cwiki.apache.org/confluence/display/BIGTOP)

Pages
-
Meetings edited by  eli  (01:48 PM)
https://cwiki.apache.org/confluence/display/BIGTOP/Meetings



Apache Camel (https://cwiki.apache.org/confluence/display/CAMEL)

Pages
-
Contributing edited by  davsclaus  (07:27 AM)
https://cwiki.apache.org/confluence/display/CAMEL/Contributing

Camel 3.0 - Roadmap edited by  davsclaus  (06:35 AM)
https://cwiki.apache.org/confluence/display/CAMEL/Camel+3.0+-+Roadmap

Camel 2.9.0 Release edited by  davsclaus  (05:18 AM)
https://cwiki.apache.org/confluence/display/CAMEL/Camel+2.9.0+Release



Apache CXF (https://cwiki.apache.org/confluence/display/CXF)

Pages
-
Index edited by  gliesian  (09:08 AM)
https://cwiki.apache.org/confluence/display/CXF/Index



Apache Flume (https://cwiki.apache.org/confluence/display/FLUME)

Pages
-
Flume NG edited by  esammer  (08:04 PM)
https://cwiki.apache.org/confluence/display/FLUME/Flume+NG




Change your notification preferences: 
https://cwiki.apache.org/confluence/users/viewnotifications.action