I will send you my patches for fixing the tests first
Please rename impl/src/test/java/org/apache/myfaces/el/TestBean.java
to DummyBean.java
see surefire-plugin documentation.
Please delete StateUtilsTestCase and add StateUtilsAbstractCase
or rename StateUtilsTestCase to StateUtilsAbstractCase and replace it
with the attached file.
I'm not sure that I send you all required patches.
Please test it.
Tomorrow I will send you the patches for the tlddoc(and the assembly
stuff). Preparing the patches takes some more time :-(
Best Regards
Bernd
Sean Schofield schrieb:
That's great! Do you have a patch for me?
Sean
On 1/11/06, Bernd Bohmann <[EMAIL PROTECTED]> wrote:
Hello Sean,
I have deployed the site with javadoc and tlddoc on
http://people.apache.org/~bommel/
You find the tlddoc report under 'Project Reports' on the site of the
project pages.
Regards
Bernd
Bernd Bohmann schrieb:
Hello Sean
I fixed the other tests except two test cases.
Should I open an issue or send you the patches?
OK this is fixed. I thought it sounded familiar and it was. I had
already fixed one issue with MessageUtilsTest by copying the
Message.properties over to a new test/resources dir. It turns out
that the rest of the properties are needed as well so I copied them
over too.
Is a copy of properties a good idea or should the properties moved to
commons/src/main/resources ?
Sean
Regards
Bernd
--
Dipl.-Ing. Bernd Bohmann - Atanion GmbH - Software Development
Bismarckstr. 13, 26122 Oldenburg, http://www.atanion.com
phone: +49 441 4082312, mobile: +49 173 8839471, fax: +49 441 4082333
--
Dipl.-Ing. Bernd Bohmann - Atanion GmbH - Software Development
Bismarckstr. 13, 26122 Oldenburg, http://www.atanion.com
phone: +49 441 4082312, mobile: +49 173 8839471, fax: +49 441 4082333
Index: pom.xml
===================================================================
--- pom.xml (Revision 368132)
+++ pom.xml (Arbeitskopie)
@@ -22,19 +22,6 @@
<build>
<defaultGoal>install</defaultGoal>
-
- <plugins>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <skip>true</skip>
- </configuration>
- </plugin>
-
- </plugins>
-
<extensions>
<!-- Note: We're using scpexe protocol instead of scp because
jsch has an issue (already reported) that makes it fail.
@@ -45,7 +32,6 @@
<artifactId>wagon-ssh-external</artifactId>
<version>1.0-alpha-5</version>
</extension>
-
</extensions>
</build>
Index: src/test/java/org/apache/myfaces/util/StateUtilsDefaultTestCase.java
===================================================================
--- src/test/java/org/apache/myfaces/util/StateUtilsDefaultTestCase.java (Revision 368132)
+++ src/test/java/org/apache/myfaces/util/StateUtilsDefaultTestCase.java (Arbeitskopie)
@@ -7,10 +7,13 @@
* @author Dennis C. Byrne
*/
-public class StateUtilsDefaultTestCase extends StateUtilsTestCase {
+public class StateUtilsDefaultTestCase extends StateUtilsAbstractCase {
protected void setUp() throws Exception {
super.setUp();
- System.setProperty(StateUtils.INIT_SECRET, BASE64_KEY_SIZE_8);
- }
+ StateUtils.setSecret(BASE64_KEY_SIZE_8);
+ StateUtils.setAlgorithm("DES");
+ StateUtils.setAlgorithmParams( "ECB/PKCS5Padding");
+ StateUtils.setIv((byte [])null);
+ }
}
Index: src/test/java/org/apache/myfaces/util/StateUtilsTripleDES_ECBTestCase.java
===================================================================
--- src/test/java/org/apache/myfaces/util/StateUtilsTripleDES_ECBTestCase.java (Revision 368132)
+++ src/test/java/org/apache/myfaces/util/StateUtilsTripleDES_ECBTestCase.java (Arbeitskopie)
@@ -13,13 +13,14 @@
* @author Dennis C. Byrne
*/
-public class StateUtilsTripleDES_ECBTestCase extends StateUtilsTestCase {
+public class StateUtilsTripleDES_ECBTestCase extends StateUtilsAbstractCase {
protected void setUp() throws Exception {
super.setUp();
- System.setProperty(StateUtils.INIT_SECRET, BASE64_KEY_SIZE_24);
- System.setProperty(StateUtils.INIT_ALGORITHM, "DESede");
- System.setProperty(StateUtils.INIT_ALGORITHM_PARAM, "ECB/PKCS5Padding");
- }
+ StateUtils.setSecret(BASE64_KEY_SIZE_24);
+ StateUtils.setAlgorithm("DESede");
+ StateUtils.setAlgorithmParams( "ECB/PKCS5Padding");
+ StateUtils.setIv((byte [])null);
+ }
}
Index: src/test/java/org/apache/myfaces/util/StateUtilsBlowfish_ECBTestCase.java
===================================================================
--- src/test/java/org/apache/myfaces/util/StateUtilsBlowfish_ECBTestCase.java (Revision 368132)
+++ src/test/java/org/apache/myfaces/util/StateUtilsBlowfish_ECBTestCase.java (Arbeitskopie)
@@ -14,13 +14,15 @@
*
*/
-public class StateUtilsBlowfish_ECBTestCase extends StateUtilsTestCase {
+public class StateUtilsBlowfish_ECBTestCase extends StateUtilsAbstractCase {
protected void setUp() throws Exception {
super.setUp();
- System.setProperty(StateUtils.INIT_SECRET, BASE64_KEY_SIZE_16);
- System.setProperty(StateUtils.INIT_ALGORITHM, "Blowfish");
- System.setProperty(StateUtils.INIT_ALGORITHM_PARAM, "ECB/PKCS5Padding");
- }
+ StateUtils.setSecret(BASE64_KEY_SIZE_16);
+ StateUtils.setAlgorithm("Blowfish");
+ StateUtils.setAlgorithmParams( "ECB/PKCS5Padding");
+ StateUtils.setIv((byte [])null);
+ }
+
}
Index: src/test/java/org/apache/myfaces/util/MessageUtilsTest.java
===================================================================
--- src/test/java/org/apache/myfaces/util/MessageUtilsTest.java (Revision 368132)
+++ src/test/java/org/apache/myfaces/util/MessageUtilsTest.java (Arbeitskopie)
@@ -19,14 +19,17 @@
import java.util.ResourceBundle;
import javax.faces.FactoryFinder;
+import javax.faces.render.RenderKit;
import javax.faces.application.Application;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIViewRoot;
import javax.faces.context.*;
+import javax.faces.context.ResponseStream;
import junit.framework.Assert;
import junit.framework.TestCase;
import org.apache.myfaces.test.MockResponseWriter;
+import org.apache.myfaces.test.FacesContextHelper;
import org.easymock.MockControl;
import org.easymock.classextension.MockClassControl;
@@ -42,6 +45,7 @@
private MockResponseWriter writer;
+
private static final String DEFAULT_BUNDLE = "javax.faces.Messages";
/**
@@ -181,8 +185,15 @@
{
this.writer = new MockResponseWriter();
this.context = createMockFacesContext(this.writer);
+ FacesContextHelper.setCurrentInstance(context);
}
+ protected void tearDown() throws Exception
+ {
+ FacesContextHelper.setCurrentInstance(null);
+ super.tearDown();
+ }
+
/**
* create the Mock object for FacesContext and required sub objects.
*
@@ -240,20 +251,5 @@
return mockFacesCtx;
}
-
- /**
- * Mock for FacesContext
- * @author Stephan Strittmatter
- */
- abstract class MockFacesContext extends FacesContext
- {
-
- /**
- * default constructor setting itself as current Instance of FacesContext.
- */
- public MockFacesContext()
- {
- FacesContext.setCurrentInstance(this);
- }
- }
}
+
Index: src/test/java/org/apache/myfaces/util/StateUtilsAES_CBCTestCase.java
===================================================================
--- src/test/java/org/apache/myfaces/util/StateUtilsAES_CBCTestCase.java (Revision 368132)
+++ src/test/java/org/apache/myfaces/util/StateUtilsAES_CBCTestCase.java (Arbeitskopie)
@@ -13,14 +13,14 @@
* @author Dennis C. Byrne
*/
-public class StateUtilsAES_CBCTestCase extends StateUtilsTestCase {
+public class StateUtilsAES_CBCTestCase extends StateUtilsAbstractCase {
protected void setUp() throws Exception {
super.setUp();
- System.setProperty(StateUtils.INIT_SECRET, BASE64_KEY_SIZE_24);
- System.setProperty(StateUtils.INIT_ALGORITHM, "AES");
- System.setProperty(StateUtils.INIT_ALGORITHM_PARAM, "CBC/PKCS5Padding");
- System.setProperty(StateUtils.INIT_ALGORITHM_IV, BASE64_KEY_SIZE_16);
+ StateUtils.setSecret(BASE64_KEY_SIZE_24);
+ StateUtils.setAlgorithm("AES");
+ StateUtils.setAlgorithmParams("CBC/PKCS5Padding");
+ StateUtils.setIv(BASE64_KEY_SIZE_16);
}
}
Index: src/main/java/org/apache/myfaces/util/StateUtils.java
===================================================================
--- src/main/java/org/apache/myfaces/util/StateUtils.java (Revision 368132)
+++ src/main/java/org/apache/myfaces/util/StateUtils.java (Arbeitskopie)
@@ -87,6 +87,7 @@
static
{
+ try {
FacesContext ctx = FacesContext.getCurrentInstance();
String _secret;
String _algorithm;
@@ -98,16 +99,16 @@
_algorithm = ctx.getExternalContext().getInitParameter(INIT_ALGORITHM);
_algorithmParams = ctx.getExternalContext().getInitParameter(INIT_ALGORITHM_PARAM);
_iv = ctx.getExternalContext().getInitParameter(INIT_ALGORITHM_IV);
- }else{ // not recommended for users ... mostly here for testing
+ } else{ // not recommended for users ... mostly here for testing
_secret = System.getProperty(INIT_SECRET);
_algorithm = System.getProperty(INIT_ALGORITHM);
_algorithmParams = System.getProperty(INIT_ALGORITHM_PARAM);
_iv = System.getProperty(INIT_ALGORITHM_IV);
}
- if(_secret == null){
+ if (_secret == null){
log.debug("secret for " + INIT_SECRET + " not located, encryption disabled");
- }else{
+ } else{
if(_algorithmParams != null && _algorithmParams.startsWith("CBC") & _iv == null){
throw new FacesException(INIT_ALGORITHM_PARAM +
" parameter has been set with CBC mode," +
@@ -124,6 +125,9 @@
secure = true;
log.debug("encryption enabled using " + algorithm + "/" + algorithmParams);
}
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
}
public static boolean isSecure()
@@ -339,7 +343,43 @@
}
}
- public static void main (String[] args) throws UnsupportedEncodingException
+ public static byte[] getSecret() {
+ return secret;
+ }
+ public static void setSecret(String _secret) {
+ secret =new Base64().decode(_secret.getBytes());
+ }
+ public static void setSecret(byte[] secret) {
+ StateUtils.secret = secret;
+ }
+
+ public static String getAlgorithm() {
+ return algorithm;
+ }
+
+ public static void setAlgorithm(String algorithm) {
+ StateUtils.algorithm = algorithm;
+ }
+
+ public static String getAlgorithmParams() {
+ return algorithmParams;
+ }
+
+ public static void setAlgorithmParams(String algorithmParams) {
+ StateUtils.algorithmParams = algorithmParams;
+ }
+
+ public static byte[] getIv() {
+ return iv;
+ }
+ public static void setIv(String _iv) {
+ iv = new Base64().decode(_iv.getBytes());
+ }
+ public static void setIv(byte[] iv) {
+ StateUtils.iv = iv;
+ }
+
+ public static void main (String[] args) throws UnsupportedEncodingException
{
byte[] bytes = encode(args[0].getBytes(ZIP_CHARSET));
System.out.println(new String(bytes, ZIP_CHARSET));
Index: pom.xml
===================================================================
--- pom.xml (Revision 368132)
+++ pom.xml (Arbeitskopie)
@@ -119,6 +119,26 @@
</dependencies>
+ <build>
+
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.1.2</version>
+ <configuration>
+ <excludes>
+ <exclude>**/*StateUtilsAES_CBCTestCase*</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+
+ </plugins>
+
+ </build>
+
+
<reporting>
<plugins>
Index: src/test/java/org/apache/myfaces/el/ValueBindingImplCactus.java
===================================================================
--- src/test/java/org/apache/myfaces/el/ValueBindingImplCactus.java (Revision 367834)
+++ src/test/java/org/apache/myfaces/el/ValueBindingImplCactus.java (Arbeitskopie)
@@ -88,7 +88,7 @@
public void testSetValueSimpleBeanInRequestMapNoInitialValue() {
Map map = new HashMap();
- TestBean bean = new TestBean(map);
+ DummyBean bean = new DummyBean(map);
facesContext.getExternalContext().getRequestMap().put("bean", bean);
ValueBinding binding = application.createValueBinding("#{bean.map['baz']}");
Integer value = new Integer(14);
@@ -100,7 +100,7 @@
Map map = new HashMap();
String initialValue = "hello world";
map.put("baz", initialValue);
- TestBean bean = new TestBean(map);
+ DummyBean bean = new DummyBean(map);
facesContext.getExternalContext().getRequestMap().put("bean", bean);
ValueBinding binding = application.createValueBinding("#{bean.map['baz']}");
assertEquals(initialValue, binding.getValue(facesContext));
@@ -111,7 +111,7 @@
public void testSetValueSimpleBeanInRequestMapWithConverter() {
Map map = new HashMap();
- TestBean bean = new TestBean(map);
+ DummyBean bean = new DummyBean(map);
facesContext.getExternalContext().getRequestMap().put("bean", bean);
ValueBinding binding = application.createValueBinding("#{bean.map['baz']}");
binding.setValue(facesContext, new Integer(14));
@@ -119,7 +119,7 @@
}
public void testSetValueSimpleBeanInSessionMap() {
- TestBean bean = new TestBean(new HashMap());
+ DummyBean bean = new DummyBean(new HashMap());
facesContext.getExternalContext().getSessionMap().put("bean", bean);
ValueBinding binding = application.createValueBinding("#{bean.map['baz']}");
Integer value = new Integer(14);
@@ -128,7 +128,7 @@
}
public void setSetIntegerPrimitive() {
- TestBean bean = new TestBean(new HashMap());
+ DummyBean bean = new DummyBean(new HashMap());
facesContext.getExternalContext().getSessionMap().put("bean", bean);
ValueBinding binding = application.createValueBinding("#{bean.integerPrimitive}");
Integer value = new Integer(14);
Index: src/site/site.xml
===================================================================
--- src/site/site.xml (Revision 368132)
+++ src/site/site.xml (Arbeitskopie)
@@ -14,8 +14,17 @@
<menu name="Apache MyFaces">
<item name="Overview" href="index.html"/>
<item name="News archive" href="news-archive.html"/>
+ <item name="Download" href="download.html" />
</menu>
-
+
+ <menu name="MyFaces Projects">
+ <item name="MyFaces Api" href="projects/myfaces-api/index.html"/>
+ <item name="MyFaces Impl" href="projects/myfaces-impl/index.html"/>
+ <item name="MyFaces Commons" href="projects/myfaces-commons/index.html"/>
+ <item name="MyFaces Tomahawk" href="projects/myfaces-tomahawk/tomahawk/index.html"/>
+ <item name="MyFaces Sandbox" href="projects/myfaces-sandbox/sandbox/index.html"/>
+ </menu>
+
<menu name="Documentation">
<item name="Getting Started" href="gettingstarted.html"/>
<item name="MyFaces and RI" href="risamples.html"/>
@@ -26,12 +35,6 @@
<item name="Tomcat Configuration" href="tomcat.html"/>
</menu>
- <menu name="Download">
- <item name="Binary Distributions" href="http://myfaces.apache.org/binary.cgi"/>
- <item name="Source Distributions" href="http://myfaces.apache.org/source.cgi"/>
- <item name="Nightly Builds" href="http://cvs.apache.org/builds/myfaces/nightly/"/>
- </menu>
-
${reports}
</body>
Index: tomahawk/pom.xml
===================================================================
--- tomahawk/pom.xml (Revision 367834)
+++ tomahawk/pom.xml (Arbeitskopie)
@@ -121,7 +121,18 @@
</resources>
<plugins>
+
<plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <exclude>**/*HtmlDateRendererTest*</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+
+ <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xslt-maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
package org.apache.myfaces.util;
/**
* This TestCase is not meant to be run, it's children are. It is
* nevertheless concrete because it creates instances of itself
* for testing. Running this TestCase directly will blow up.
*
* @author Dennis C. Byrne
*/
import java.io.Serializable;
import java.util.Arrays;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.myfaces.test.FacesContextHelper;
import junit.framework.TestCase;
public abstract class StateUtilsAbstractCase extends TestCase implements Serializable{
private static final Log log = LogFactory.getLog(StateUtilsAbstractCase.class);
protected String sensitiveString;
private static final String TEST_DATA = "This is the test data.";
private String dummy ;
// 76543210
public static final String BASE64_KEY_SIZE_8 = "NzY1NDMyMTA=";
// 7654321076543210
public static final String BASE64_KEY_SIZE_16 = "NzY1NDMyMTA3NjU0MzIxMA==";
// 012345678901234567890123
public static final String BASE64_KEY_SIZE_24 = "MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIz";
protected void setUp() throws Exception {
FacesContextHelper.setCurrentInstance(null);
sensitiveString = "this is my secret";
}
protected void tearDown() throws Exception {
sensitiveString = null;
}
/**
* Test for Restore View phase.
*/
public void testConstructionString(){
String constructed = StateUtils.construct(sensitiveString);
Object object = StateUtils.reconstruct(constructed);
assertTrue(object instanceof String);
String string = (String)object;
string.equals(sensitiveString);
}
/**
* Test for Restore View phase. This method actually runs an instance of
* StateUtilsTestCase through the construct/reconstruct process.
*/
public void testConstruction(){
String constructed = StateUtils.construct(TEST_DATA);
Object object = StateUtils.reconstruct(constructed);
assertTrue(TEST_DATA.equals(object));
}
public void testSerialization(){
byte[] bytes = StateUtils.getAsByteArray(TEST_DATA);
Object object = StateUtils.getAsObject(bytes);
assertTrue(TEST_DATA.equals(object));
}
public void testCryptography(){
byte[] sensitiveBytes = sensitiveString.getBytes();
byte[] secure = StateUtils.encrypt(sensitiveBytes);
byte[] insecure = StateUtils.decrypt(secure);
secure = StateUtils.encrypt(insecure); // * 2
insecure = StateUtils.decrypt(secure);
assertTrue(Arrays.equals(insecure, sensitiveBytes));
}
public void testCompression(){
int size = 2049;
byte[] orginalBytes = new byte[size];
byte[] lessBytes = StateUtils.compress(orginalBytes);
assertTrue(lessBytes.length < orginalBytes.length);
byte[] moreBytes = StateUtils.decompress(lessBytes);
assertTrue(moreBytes.length > lessBytes.length);
assertTrue(Arrays.equals(moreBytes, orginalBytes));
}
public void testEncoding(){
byte[] orginalBytes = sensitiveString.getBytes();
byte[] encoded = StateUtils.encode(orginalBytes);
byte[] decoded = StateUtils.decode(encoded);
assertTrue(Arrays.equals(decoded, orginalBytes));
}
/**
* Simulates testConstruction w/ corrupt data.
*/
public void testConstructionNegative(){
String constructed = StateUtils.construct(TEST_DATA);
constructed = constructed.substring(1, constructed.length());
try{
Object object = StateUtils.reconstruct(constructed);
assertFalse(TEST_DATA.equals(object));
} catch (Exception e) {
// do nothing
}
}
/**
* Simulates testSerialization w/ corrput data.
*/
public void testSerializationNegative(){
byte[] bytes = StateUtils.getAsByteArray(TEST_DATA);
bytes[1] = (byte)3;
try{
Object object = StateUtils.getAsObject(bytes);
assertFalse(TEST_DATA.equals(object));
} catch (Exception e) {
// do nothing
}
}
/**
* Simulates testCryptography w/ corrupt data.
*/
public void testCryptographyNegative(){
byte[] sensitiveBytes = sensitiveString.getBytes();
byte[] secure = StateUtils.encrypt(sensitiveBytes);
secure[3] = (byte)1;
try{
byte[] insecure = StateUtils.decrypt(secure);
assertFalse(Arrays.equals(insecure, sensitiveBytes));
} catch (Exception e) {
// do nothing
}
}
/**
* Simulates testCompression w/ corrupt data.
*/
public void testCompressionNegative(){
int size = 2049;
byte[] orginalBytes = new byte[size];
byte[] lessBytes = StateUtils.compress(orginalBytes);
lessBytes[1] = (byte)3;
try{
byte[] moreBytes = StateUtils.decompress(lessBytes);
assertFalse(Arrays.equals(moreBytes, orginalBytes));
} catch (Exception e){
// do nothing
}
}
/**
* Simulates testEncoding w/ corrupt data.
*/
public void testEncodingNegative(){
byte[] orginalBytes = sensitiveString.getBytes();
byte[] encoded = StateUtils.encode(orginalBytes);
encoded[1] = (byte)9;
try{
byte[] decoded = StateUtils.decode(encoded);
assertFalse(Arrays.equals(decoded, orginalBytes));
} catch (Exception e){
// do nothing
}
}
}
package org.apache.myfaces.el;
import java.util.Map;
public class DummyBean {
private Map map;
private int integerPrimitive = 0;
public DummyBean(Map map) {
this.map = map;
}
public Map getMap() {
return map;
}
public void setMap(Map map) {
this.map = map;
}
public int getIntegerPrimitive(){
return integerPrimitive;
}
public void setIntegerPrimitive(int integerPrimitive){
this.integerPrimitive = integerPrimitive;
}
}