You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sk...@apache.org on 2008/07/03 23:48:00 UTC
svn commit: r673829 [3/3] - in /myfaces/shared/trunk_3.0.x/core/src:
main/java/org/apache/myfaces/shared/component/
main/java/org/apache/myfaces/shared/renderkit/html/
main/java/org/apache/myfaces/shared/taglib/core/
main/java/org/apache/myfaces/shared...
Modified: myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/renderkit/html/util/HTMLEncoderTest.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/renderkit/html/util/HTMLEncoderTest.java?rev=673829&r1=673828&r2=673829&view=diff
==============================================================================
--- myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/renderkit/html/util/HTMLEncoderTest.java (original)
+++ myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/renderkit/html/util/HTMLEncoderTest.java Thu Jul 3 14:47:59 2008
@@ -1,239 +1,239 @@
-/*
- * Copyright 2007 The Apache Software Foundation.
- *
- * Licensed 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.myfaces.shared.renderkit.html.util;
-
-import java.io.CharArrayWriter;
-import java.io.IOException;
-import java.io.Writer;
-
-import org.apache.shale.test.base.AbstractJsfTestCase;
-
-/**
- * <code>HTMLEncoderTest</code> tests <code>org.apache.myfaces.shared.renderkit.html.util.HTMLEncoder</code>.
- *
- * @author Michael Kurz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-public class HTMLEncoderTest extends AbstractJsfTestCase {
- private String stringNoSpecialChars = "Hello, this is MyFaces speaking!";
- private String stringNoSpecialCharsEncoded = "Hello, this is MyFaces speaking!";
- private String stringNoSpecialCharsEncodedPartial = "lo, this is MyFaces speakin";
- private String stringSpecialChars1 = "<\"Hello\", this is MyFaces speaking!>";
- private String stringSpecialChars1Encoded = "<"Hello", this is MyFaces speaking!>";
- private String stringSpecialChars2 = "Hello & this is MyFaces speaking!>";
- private String stringSpecialChars2Encoded = "Hello & this is MyFaces speaking!>";
- private String stringLineBreak = "Hell\u00F6\nthis is MyFaces speaking!>";
- private String stringLineBreakEncoded1 = "Hellö<br/>this is MyFaces speaking!>";
- private String stringLineBreakEncoded2 = "Hellö\nthis is MyFaces speaking!>";
- private String stringLineBreakEncoded2Partial = "ö\nthis is MyFaces speaking!";
- private String stringBlanks = "<Hello this is MyFaces speaking!>";
- private String stringBlanksEncoded = "<Hello this is MyFaces speaking!>";
-
- public HTMLEncoderTest(String name) {
- super(name);
- }
-
- /**
- * Test method for
- * {@link org.apache.myfaces.shared.renderkit.html.util.HTMLEncoder#encode(String)}.
- */
- public void testEncodeStringNoSpecialChars() {
- String encodedStr = HTMLEncoder.encode(stringNoSpecialChars);
- assertEquals(stringNoSpecialCharsEncoded, encodedStr);
- }
-
- public void testEncodeStringSpecialChars1() {
- String encodedStr = HTMLEncoder.encode(stringSpecialChars1);
- assertEquals(stringSpecialChars1Encoded, encodedStr);
- }
-
- public void testEncodeStringSpecialChars2() {
- String encodedStr = HTMLEncoder.encode(stringSpecialChars2);
- assertEquals(stringSpecialChars2Encoded, encodedStr);
- }
-
- public void testEncodeStringLineBreak1() {
- String encodedStr = HTMLEncoder.encode(stringLineBreak, true);
- assertEquals(stringLineBreakEncoded1, encodedStr);
- }
-
- public void testEncodeStringLineBreak2() {
- String encodedStr = HTMLEncoder.encode(stringLineBreak, false);
- assertEquals(stringLineBreakEncoded2, encodedStr);
- }
-
- public void testEncodeStringEmpty() {
- String encodedStr = HTMLEncoder.encode("");
- assertEquals("", encodedStr);
- }
-
- public void testEncodeStringNull() {
- String encodedStr = HTMLEncoder.encode(null);
- assertEquals("", encodedStr);
- }
-
- public void testEncodeArrayNoSpecialChars() {
- try {
- CharArrayWriter writer = new CharArrayWriter();
- char[] source = stringNoSpecialChars.toCharArray();
- HTMLEncoder.encode(source, 0, source.length, writer);
- assertEquals(stringNoSpecialCharsEncoded.toCharArray(), writer.toCharArray());
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- public void testEncodeArrayNoSpecialCharsPartial() {
- try {
- CharArrayWriter writer = new CharArrayWriter();
- char[] source = stringNoSpecialChars.toCharArray();
- HTMLEncoder.encode(source, 3, source.length - 5, writer);
- assertEquals(stringNoSpecialCharsEncodedPartial.toCharArray(), writer.toCharArray());
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- public void testEncodeArraySpecialChars1() {
- try {
- CharArrayWriter writer = new CharArrayWriter();
- char[] source = stringSpecialChars1.toCharArray();
- HTMLEncoder.encode(source, 0, source.length, writer);
- assertEquals(stringSpecialChars1Encoded.toCharArray(), writer.toCharArray());
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- public void testEncodeArraySpecialChars2() {
- try {
- CharArrayWriter writer = new CharArrayWriter();
- char[] source = stringSpecialChars2.toCharArray();
- HTMLEncoder.encode(source, 0, source.length, writer);
- assertEquals(stringSpecialChars2Encoded.toCharArray(), writer.toCharArray());
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- public void testEncodeArrayEmpty() {
- try {
- CharArrayWriter writer = new CharArrayWriter();
- HTMLEncoder.encode(new char[]{}, 0, 1, writer);
- assertEquals(new char[]{}, writer.toCharArray());
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- public void testEncodeArrayNull() {
- try {
- CharArrayWriter writer = new CharArrayWriter();
- HTMLEncoder.encode(null, 0, 0, writer);
- assertEquals(new char[]{}, writer.toCharArray());
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- public void testEncodeArrayWrongIndex1() {
- try {
- CharArrayWriter writer = new CharArrayWriter();
- char[] source = stringSpecialChars2.toCharArray();
- HTMLEncoder.encode(source, 0, source.length - 100, writer);
- assertEquals(new char[]{}, writer.toCharArray());
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- public void testEncodeArrayWrongIndex2() {
- try {
- CharArrayWriter writer = new CharArrayWriter();
- char[] source = stringSpecialChars2.toCharArray();
- HTMLEncoder.encode(source, -100, source.length, writer);
- assertEquals(stringSpecialChars2Encoded.toCharArray(), writer.toCharArray());
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- public void testEncodeArrayWrongIndex3() {
- try {
- CharArrayWriter writer = new CharArrayWriter();
- char[] source = stringSpecialChars2.toCharArray();
- HTMLEncoder.encode(source, 100000, source.length, writer);
- assertEquals(new char[]{}, writer.toCharArray());
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- public void testEncodeArrayLineBreak1() {
- try {
- CharArrayWriter writer = new CharArrayWriter();
- char[] source = stringLineBreak.toCharArray();
- HTMLEncoder.encode(source, 0, source.length, true, writer);
- assertEquals(stringLineBreakEncoded1.toCharArray(), writer.toCharArray());
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- public void testEncodeArrayLineBreak2() {
- try {
- CharArrayWriter writer = new CharArrayWriter();
- char[] source = stringLineBreak.toCharArray();
- HTMLEncoder.encode(source, 0, source.length, false, writer);
- assertEquals(stringLineBreakEncoded2.toCharArray(), writer.toCharArray());
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- public void testEncodeArrayLineBreak2WrongIndex() {
- try {
- CharArrayWriter writer = new CharArrayWriter();
- char[] source = stringLineBreak.toCharArray();
- HTMLEncoder.encode(source, 0, source.length + 5, false, writer);
- assertEquals(stringLineBreakEncoded2.toCharArray(), writer.toCharArray());
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- public void testEncodeArrayLineBreakPartial() {
- try {
- CharArrayWriter writer = new CharArrayWriter();
- char[] source = stringLineBreak.toCharArray();
- HTMLEncoder.encode(source, 4, source.length - 5, writer);
- char[] expected = stringLineBreakEncoded2Partial.toCharArray();
- assertEquals(expected, writer.toCharArray());
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- private void assertEquals(char[] expected, char[] actual) {
- if ((expected == null ^ actual == null) || expected.length != actual.length) {
- fail();
- }
- for (int i = 0; i < expected.length; i++) {
- assertEquals(expected[i], actual[i]);
- }
- }
+/*
+ * Copyright 2007 The Apache Software Foundation.
+ *
+ * Licensed 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.myfaces.shared.renderkit.html.util;
+
+import java.io.CharArrayWriter;
+import java.io.IOException;
+import java.io.Writer;
+
+import org.apache.shale.test.base.AbstractJsfTestCase;
+
+/**
+ * <code>HTMLEncoderTest</code> tests <code>org.apache.myfaces.shared.renderkit.html.util.HTMLEncoder</code>.
+ *
+ * @author Michael Kurz (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public class HTMLEncoderTest extends AbstractJsfTestCase {
+ private String stringNoSpecialChars = "Hello, this is MyFaces speaking!";
+ private String stringNoSpecialCharsEncoded = "Hello, this is MyFaces speaking!";
+ private String stringNoSpecialCharsEncodedPartial = "lo, this is MyFaces speakin";
+ private String stringSpecialChars1 = "<\"Hello\", this is MyFaces speaking!>";
+ private String stringSpecialChars1Encoded = "<"Hello", this is MyFaces speaking!>";
+ private String stringSpecialChars2 = "Hello & this is MyFaces speaking!>";
+ private String stringSpecialChars2Encoded = "Hello & this is MyFaces speaking!>";
+ private String stringLineBreak = "Hell\u00F6\nthis is MyFaces speaking!>";
+ private String stringLineBreakEncoded1 = "Hellö<br/>this is MyFaces speaking!>";
+ private String stringLineBreakEncoded2 = "Hellö\nthis is MyFaces speaking!>";
+ private String stringLineBreakEncoded2Partial = "ö\nthis is MyFaces speaking!";
+ private String stringBlanks = "<Hello this is MyFaces speaking!>";
+ private String stringBlanksEncoded = "<Hello this is MyFaces speaking!>";
+
+ public HTMLEncoderTest(String name) {
+ super(name);
+ }
+
+ /**
+ * Test method for
+ * {@link org.apache.myfaces.shared.renderkit.html.util.HTMLEncoder#encode(String)}.
+ */
+ public void testEncodeStringNoSpecialChars() {
+ String encodedStr = HTMLEncoder.encode(stringNoSpecialChars);
+ assertEquals(stringNoSpecialCharsEncoded, encodedStr);
+ }
+
+ public void testEncodeStringSpecialChars1() {
+ String encodedStr = HTMLEncoder.encode(stringSpecialChars1);
+ assertEquals(stringSpecialChars1Encoded, encodedStr);
+ }
+
+ public void testEncodeStringSpecialChars2() {
+ String encodedStr = HTMLEncoder.encode(stringSpecialChars2);
+ assertEquals(stringSpecialChars2Encoded, encodedStr);
+ }
+
+ public void testEncodeStringLineBreak1() {
+ String encodedStr = HTMLEncoder.encode(stringLineBreak, true);
+ assertEquals(stringLineBreakEncoded1, encodedStr);
+ }
+
+ public void testEncodeStringLineBreak2() {
+ String encodedStr = HTMLEncoder.encode(stringLineBreak, false);
+ assertEquals(stringLineBreakEncoded2, encodedStr);
+ }
+
+ public void testEncodeStringEmpty() {
+ String encodedStr = HTMLEncoder.encode("");
+ assertEquals("", encodedStr);
+ }
+
+ public void testEncodeStringNull() {
+ String encodedStr = HTMLEncoder.encode(null);
+ assertEquals("", encodedStr);
+ }
+
+ public void testEncodeArrayNoSpecialChars() {
+ try {
+ CharArrayWriter writer = new CharArrayWriter();
+ char[] source = stringNoSpecialChars.toCharArray();
+ HTMLEncoder.encode(source, 0, source.length, writer);
+ assertEquals(stringNoSpecialCharsEncoded.toCharArray(), writer.toCharArray());
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ }
+
+ public void testEncodeArrayNoSpecialCharsPartial() {
+ try {
+ CharArrayWriter writer = new CharArrayWriter();
+ char[] source = stringNoSpecialChars.toCharArray();
+ HTMLEncoder.encode(source, 3, source.length - 5, writer);
+ assertEquals(stringNoSpecialCharsEncodedPartial.toCharArray(), writer.toCharArray());
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ }
+
+ public void testEncodeArraySpecialChars1() {
+ try {
+ CharArrayWriter writer = new CharArrayWriter();
+ char[] source = stringSpecialChars1.toCharArray();
+ HTMLEncoder.encode(source, 0, source.length, writer);
+ assertEquals(stringSpecialChars1Encoded.toCharArray(), writer.toCharArray());
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ }
+
+ public void testEncodeArraySpecialChars2() {
+ try {
+ CharArrayWriter writer = new CharArrayWriter();
+ char[] source = stringSpecialChars2.toCharArray();
+ HTMLEncoder.encode(source, 0, source.length, writer);
+ assertEquals(stringSpecialChars2Encoded.toCharArray(), writer.toCharArray());
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ }
+
+ public void testEncodeArrayEmpty() {
+ try {
+ CharArrayWriter writer = new CharArrayWriter();
+ HTMLEncoder.encode(new char[]{}, 0, 1, writer);
+ assertEquals(new char[]{}, writer.toCharArray());
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ }
+
+ public void testEncodeArrayNull() {
+ try {
+ CharArrayWriter writer = new CharArrayWriter();
+ HTMLEncoder.encode(null, 0, 0, writer);
+ assertEquals(new char[]{}, writer.toCharArray());
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ }
+
+ public void testEncodeArrayWrongIndex1() {
+ try {
+ CharArrayWriter writer = new CharArrayWriter();
+ char[] source = stringSpecialChars2.toCharArray();
+ HTMLEncoder.encode(source, 0, source.length - 100, writer);
+ assertEquals(new char[]{}, writer.toCharArray());
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ }
+
+ public void testEncodeArrayWrongIndex2() {
+ try {
+ CharArrayWriter writer = new CharArrayWriter();
+ char[] source = stringSpecialChars2.toCharArray();
+ HTMLEncoder.encode(source, -100, source.length, writer);
+ assertEquals(stringSpecialChars2Encoded.toCharArray(), writer.toCharArray());
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ }
+
+ public void testEncodeArrayWrongIndex3() {
+ try {
+ CharArrayWriter writer = new CharArrayWriter();
+ char[] source = stringSpecialChars2.toCharArray();
+ HTMLEncoder.encode(source, 100000, source.length, writer);
+ assertEquals(new char[]{}, writer.toCharArray());
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ }
+
+ public void testEncodeArrayLineBreak1() {
+ try {
+ CharArrayWriter writer = new CharArrayWriter();
+ char[] source = stringLineBreak.toCharArray();
+ HTMLEncoder.encode(source, 0, source.length, true, writer);
+ assertEquals(stringLineBreakEncoded1.toCharArray(), writer.toCharArray());
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ }
+
+ public void testEncodeArrayLineBreak2() {
+ try {
+ CharArrayWriter writer = new CharArrayWriter();
+ char[] source = stringLineBreak.toCharArray();
+ HTMLEncoder.encode(source, 0, source.length, false, writer);
+ assertEquals(stringLineBreakEncoded2.toCharArray(), writer.toCharArray());
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ }
+
+ public void testEncodeArrayLineBreak2WrongIndex() {
+ try {
+ CharArrayWriter writer = new CharArrayWriter();
+ char[] source = stringLineBreak.toCharArray();
+ HTMLEncoder.encode(source, 0, source.length + 5, false, writer);
+ assertEquals(stringLineBreakEncoded2.toCharArray(), writer.toCharArray());
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ }
+
+ public void testEncodeArrayLineBreakPartial() {
+ try {
+ CharArrayWriter writer = new CharArrayWriter();
+ char[] source = stringLineBreak.toCharArray();
+ HTMLEncoder.encode(source, 4, source.length - 5, writer);
+ char[] expected = stringLineBreakEncoded2Partial.toCharArray();
+ assertEquals(expected, writer.toCharArray());
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ }
+
+ private void assertEquals(char[] expected, char[] actual) {
+ if ((expected == null ^ actual == null) || expected.length != actual.length) {
+ fail();
+ }
+ for (int i = 0; i < expected.length; i++) {
+ assertEquals(expected[i], actual[i]);
+ }
+ }
}
\ No newline at end of file
Propchange: myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/renderkit/html/util/HTMLEncoderTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/util/AbstractStateUtilsTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/util/InitVector_CBCTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/util/InitVector_CBCTestCase.java?rev=673829&r1=673828&r2=673829&view=diff
==============================================================================
--- myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/util/InitVector_CBCTestCase.java (original)
+++ myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/util/InitVector_CBCTestCase.java Thu Jul 3 14:47:59 2008
@@ -1,86 +1,86 @@
-/*
- * Copyright 2004-2006 The Apache Software Foundation.
- *
- * Licensed 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.myfaces.shared.util;
-
-import junit.framework.Test;
-import org.apache.shale.test.base.AbstractJsfTestCase;
-
-import javax.faces.FacesException;
-
-/**
- * @author Dennis C. Byrne
- */
-
-public class InitVector_CBCTestCase extends AbstractJsfTestCase {
-
- public InitVector_CBCTestCase(String name) {
- super(name);
- }
-
- public static Test suite() {
- return null; // keep this method or maven won't run it
- }
-
- public void setUp() throws Exception{
-
- super.setUp();
-
- servletContext.addInitParameter(StateUtils.INIT_SECRET, "shouldn't matter");
- servletContext.addInitParameter(StateUtils.INIT_ALGORITHM, "shouldn't matter either");
- servletContext.addInitParameter(StateUtils.INIT_ALGORITHM_PARAM, "CBC/PKCS5Padding");
- servletContext.addInitParameter(StateUtils.INIT_SECRET_KEY_CACHE, "false");
- // DO NOT UNCOMMENT THIS ! we are simulating a bad conf
- //servletContext.addInitParameter(org.apache.myfaces.shared.util.StateUtils.INIT_ALGORITHM_IV, BASE64_KEY_SIZE_16);
-
- }
-
- public void testDecryption() {
-
- byte[] sensitiveBytes = "bound to fail".getBytes();
-
- try{
-
- StateUtils.decrypt(sensitiveBytes, externalContext);
-
- fail("MyFaces should throw a meaningful " +
- "exception when users opt for CBC mode " +
- "encryption w/out an initialization vector.");
-
- }catch(FacesException fe){
- }
-
- }
-
- public void testEncryption() {
-
- byte[] sensitiveBytes = "bound to fail".getBytes();
-
- try{
-
- StateUtils.encrypt(sensitiveBytes, externalContext);
-
- fail("MyFaces should throw a meaningful " +
- "exception when users opt for CBC mode " +
- "encryption w/out an initialization vector.");
-
- }catch(FacesException fe){
- }
-
- }
-
-}
+/*
+ * Copyright 2004-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.myfaces.shared.util;
+
+import junit.framework.Test;
+import org.apache.shale.test.base.AbstractJsfTestCase;
+
+import javax.faces.FacesException;
+
+/**
+ * @author Dennis C. Byrne
+ */
+
+public class InitVector_CBCTestCase extends AbstractJsfTestCase {
+
+ public InitVector_CBCTestCase(String name) {
+ super(name);
+ }
+
+ public static Test suite() {
+ return null; // keep this method or maven won't run it
+ }
+
+ public void setUp() throws Exception{
+
+ super.setUp();
+
+ servletContext.addInitParameter(StateUtils.INIT_SECRET, "shouldn't matter");
+ servletContext.addInitParameter(StateUtils.INIT_ALGORITHM, "shouldn't matter either");
+ servletContext.addInitParameter(StateUtils.INIT_ALGORITHM_PARAM, "CBC/PKCS5Padding");
+ servletContext.addInitParameter(StateUtils.INIT_SECRET_KEY_CACHE, "false");
+ // DO NOT UNCOMMENT THIS ! we are simulating a bad conf
+ //servletContext.addInitParameter(org.apache.myfaces.shared.util.StateUtils.INIT_ALGORITHM_IV, BASE64_KEY_SIZE_16);
+
+ }
+
+ public void testDecryption() {
+
+ byte[] sensitiveBytes = "bound to fail".getBytes();
+
+ try{
+
+ StateUtils.decrypt(sensitiveBytes, externalContext);
+
+ fail("MyFaces should throw a meaningful " +
+ "exception when users opt for CBC mode " +
+ "encryption w/out an initialization vector.");
+
+ }catch(FacesException fe){
+ }
+
+ }
+
+ public void testEncryption() {
+
+ byte[] sensitiveBytes = "bound to fail".getBytes();
+
+ try{
+
+ StateUtils.encrypt(sensitiveBytes, externalContext);
+
+ fail("MyFaces should throw a meaningful " +
+ "exception when users opt for CBC mode " +
+ "encryption w/out an initialization vector.");
+
+ }catch(FacesException fe){
+ }
+
+ }
+
+}
Propchange: myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/util/InitVector_CBCTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/util/MessageUtilsTest.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/util/MessageUtilsTest.java?rev=673829&r1=673828&r2=673829&view=diff
==============================================================================
--- myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/util/MessageUtilsTest.java (original)
+++ myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/util/MessageUtilsTest.java Thu Jul 3 14:47:59 2008
@@ -1,213 +1,213 @@
-/*
- * Copyright 2004 The Apache Software Foundation.
- *
- * Licensed 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.myfaces.shared.util;
-
-import java.util.Locale;
-import java.util.ResourceBundle;
-
-import javax.faces.application.FacesMessage;
-
-import junit.framework.Test;
-import org.apache.myfaces.shared.util.MessageUtils;
-import org.apache.shale.test.base.AbstractJsfTestCase;
-
-/**
- * TestCase for MessageUtils
- *
- * @author Stephan Strittmatter
- */
-public class MessageUtilsTest extends AbstractJsfTestCase
-{
-
- private static final String DEFAULT_BUNDLE = "javax.faces.Messages";
-
- public MessageUtilsTest(String name)
- {
- super(name);
- }
-
- public static Test suite() {
- return null; // keep this method or maven won't run it
- }
-
- /**
- * Test method for 'org.apache.myfaces.shared.util.MessageUtils.getMessage(Severity, String, Object)'
- */
- public void testGetMessageSeverityStringObject()
- {
- facesContext.getViewRoot().setLocale(Locale.ENGLISH);
-
- FacesMessage msg = MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR,
- "javax.faces.component.UIInput.CONVERSION", null);
- assertEquals("Conversion Error", msg.getSummary());
-
- facesContext.getViewRoot().setLocale(Locale.GERMAN);
-
- msg = MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR,
- "javax.faces.component.UIInput.CONVERSION",
- "blubb");
- assertEquals("Konvertierungsfehler", msg.getSummary());
- }
-
- /**
- * Test method for 'org.apache.myfaces.shared.util.MessageUtils.getMessage(Severity, String, Object[])'
- */
- public void testGetMessageSeverityStringObjectArray()
- {
- facesContext.getViewRoot().setLocale(Locale.ENGLISH);
-
- FacesMessage msg = MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR,
- "javax.faces.component.UIInput.CONVERSION", null);
- assertEquals("Conversion Error", msg.getSummary());
-
- facesContext.getViewRoot().setLocale(Locale.GERMAN);
-
- msg = MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR,
- "javax.faces.component.UIInput.CONVERSION", null);
- assertEquals("Konvertierungsfehler", msg.getSummary());
- }
-
- /**
- * Test method for 'org.apache.myfaces.shared.util.MessageUtils.getMessage(Severity, String, Object[], FacesContext)'
- */
- public void testGetMessageSeverityStringObjectArrayFacesContext()
- {
- facesContext.getViewRoot().setLocale(Locale.ENGLISH);
-
- FacesMessage msg = MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR,
- "javax.faces.component.UIInput.CONVERSION", null, facesContext);
- assertEquals("Conversion Error", msg.getSummary());
-
- facesContext.getViewRoot().setLocale(Locale.GERMAN);
-
- msg = MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR,
- "javax.faces.component.UIInput.CONVERSION", null,
- facesContext);
- assertEquals("Konvertierungsfehler", msg.getSummary());
- }
-
- /**
- * Test method for 'org.apache.myfaces.shared.util.MessageUtils.getMessage(Locale, String, Object[])'
- */
- public void testGetMessageLocaleStringObjectArray()
- {
- facesContext.getViewRoot().setLocale(Locale.ENGLISH);
-
- FacesMessage msg = org.apache.myfaces.shared.util.MessageUtils.getMessage(Locale.ENGLISH,
- "javax.faces.component.UIInput.CONVERSION", null);
- assertEquals("Conversion Error", msg.getSummary());
-
- msg = MessageUtils.getMessage(Locale.GERMAN,
- "javax.faces.component.UIInput.CONVERSION", null);
- assertEquals("Konvertierungsfehler", msg.getSummary());
-
- }
-
- /**
- * Test method for 'org.apache.myfaces.shared.util.MessageUtils.getMessage(FacesContext, String)'
- */
- public void testGetMessageFacesContextString()
- {
- facesContext.getViewRoot().setLocale(Locale.ENGLISH);
-
- FacesMessage msg = MessageUtils.getMessage(facesContext,
- "javax.faces.component.UIInput.CONVERSION");
- assertEquals("Conversion Error", msg.getSummary());
-
- facesContext.getViewRoot().setLocale(Locale.GERMAN);
-
- msg = MessageUtils.getMessage(facesContext,
- "javax.faces.component.UIInput.CONVERSION");
- assertEquals("Konvertierungsfehler", msg.getSummary());
- }
-
- /**
- * Test method for 'org.apache.myfaces.shared.util.MessageUtils.getMessage(FacesContext, String, Object[])'
- */
- public void testGetMessageFacesContextStringObjectArray()
- {
- facesContext.getViewRoot().setLocale(Locale.ENGLISH);
-
- FacesMessage msg = MessageUtils.getMessage(facesContext,
- "javax.faces.component.UIInput.CONVERSION", null);
- assertEquals("Conversion Error", msg.getSummary());
-
- facesContext.getViewRoot().setLocale(Locale.GERMAN);
-
- msg = MessageUtils.getMessage(facesContext,
- "javax.faces.component.UIInput.CONVERSION", null);
- assertEquals("Konvertierungsfehler", msg.getSummary());
- }
-
- /**
- * testGetMessageWithBundle
- */
- public void testGetMessageWithBundle()
- {
- facesContext.getViewRoot().setLocale(Locale.ENGLISH);
-
- ResourceBundle bundle = ResourceBundle.getBundle(DEFAULT_BUNDLE,
- Locale.ENGLISH);
- FacesMessage msg = MessageUtils.getMessage(bundle,
- "javax.faces.component.UIInput.CONVERSION", null);
-
- assertEquals("Conversion Error", msg.getSummary());
- }
-
- /**
- * testGetMessageWithBundleName
- */
- public void testGetMessageWithBundleName()
- {
- facesContext.getViewRoot().setLocale(Locale.ENGLISH);
-
- FacesMessage msg = MessageUtils.getMessage(DEFAULT_BUNDLE,
- "javax.faces.component.UIInput.CONVERSION", null);
-
- assertEquals("Conversion Error", msg.getSummary());
- }
-
- /**
- * testGetMessageWithBundleNameLocale
- */
- public void testGetMessageWithBundleNameLocale()
- {
- FacesMessage msg = MessageUtils.getMessage(DEFAULT_BUNDLE,
- Locale.GERMAN, "javax.faces.component.UIInput.CONVERSION", null);
-
- assertEquals("Konvertierungsfehler", msg.getSummary());
- }
-
- /**
- * testSubstituteParamsWithDELocale(
- */
- public void testSubstituteParamsWithDELocale() {
- String paramString = MessageUtils.substituteParams(Locale.GERMANY, "currency {0,number,currency}", new Object[]{100});
-
- assertEquals("currency 100,00 \u20ac",paramString);
- }
-
- /**
- * testSubstituteParamsWithGBLocale(
- */
- public void testSubstituteParamsWithGBLocale() {
- String paramString = MessageUtils.substituteParams(Locale.UK, "currency {0,number,currency}", new Object[]{100});
-
- System.out.println(paramString);
- assertEquals("currency \u00a3100.00",paramString);
- }
-
-}
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed 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.myfaces.shared.util;
+
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import javax.faces.application.FacesMessage;
+
+import junit.framework.Test;
+import org.apache.myfaces.shared.util.MessageUtils;
+import org.apache.shale.test.base.AbstractJsfTestCase;
+
+/**
+ * TestCase for MessageUtils
+ *
+ * @author Stephan Strittmatter
+ */
+public class MessageUtilsTest extends AbstractJsfTestCase
+{
+
+ private static final String DEFAULT_BUNDLE = "javax.faces.Messages";
+
+ public MessageUtilsTest(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite() {
+ return null; // keep this method or maven won't run it
+ }
+
+ /**
+ * Test method for 'org.apache.myfaces.shared.util.MessageUtils.getMessage(Severity, String, Object)'
+ */
+ public void testGetMessageSeverityStringObject()
+ {
+ facesContext.getViewRoot().setLocale(Locale.ENGLISH);
+
+ FacesMessage msg = MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR,
+ "javax.faces.component.UIInput.CONVERSION", null);
+ assertEquals("Conversion Error", msg.getSummary());
+
+ facesContext.getViewRoot().setLocale(Locale.GERMAN);
+
+ msg = MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR,
+ "javax.faces.component.UIInput.CONVERSION",
+ "blubb");
+ assertEquals("Konvertierungsfehler", msg.getSummary());
+ }
+
+ /**
+ * Test method for 'org.apache.myfaces.shared.util.MessageUtils.getMessage(Severity, String, Object[])'
+ */
+ public void testGetMessageSeverityStringObjectArray()
+ {
+ facesContext.getViewRoot().setLocale(Locale.ENGLISH);
+
+ FacesMessage msg = MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR,
+ "javax.faces.component.UIInput.CONVERSION", null);
+ assertEquals("Conversion Error", msg.getSummary());
+
+ facesContext.getViewRoot().setLocale(Locale.GERMAN);
+
+ msg = MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR,
+ "javax.faces.component.UIInput.CONVERSION", null);
+ assertEquals("Konvertierungsfehler", msg.getSummary());
+ }
+
+ /**
+ * Test method for 'org.apache.myfaces.shared.util.MessageUtils.getMessage(Severity, String, Object[], FacesContext)'
+ */
+ public void testGetMessageSeverityStringObjectArrayFacesContext()
+ {
+ facesContext.getViewRoot().setLocale(Locale.ENGLISH);
+
+ FacesMessage msg = MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR,
+ "javax.faces.component.UIInput.CONVERSION", null, facesContext);
+ assertEquals("Conversion Error", msg.getSummary());
+
+ facesContext.getViewRoot().setLocale(Locale.GERMAN);
+
+ msg = MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR,
+ "javax.faces.component.UIInput.CONVERSION", null,
+ facesContext);
+ assertEquals("Konvertierungsfehler", msg.getSummary());
+ }
+
+ /**
+ * Test method for 'org.apache.myfaces.shared.util.MessageUtils.getMessage(Locale, String, Object[])'
+ */
+ public void testGetMessageLocaleStringObjectArray()
+ {
+ facesContext.getViewRoot().setLocale(Locale.ENGLISH);
+
+ FacesMessage msg = org.apache.myfaces.shared.util.MessageUtils.getMessage(Locale.ENGLISH,
+ "javax.faces.component.UIInput.CONVERSION", null);
+ assertEquals("Conversion Error", msg.getSummary());
+
+ msg = MessageUtils.getMessage(Locale.GERMAN,
+ "javax.faces.component.UIInput.CONVERSION", null);
+ assertEquals("Konvertierungsfehler", msg.getSummary());
+
+ }
+
+ /**
+ * Test method for 'org.apache.myfaces.shared.util.MessageUtils.getMessage(FacesContext, String)'
+ */
+ public void testGetMessageFacesContextString()
+ {
+ facesContext.getViewRoot().setLocale(Locale.ENGLISH);
+
+ FacesMessage msg = MessageUtils.getMessage(facesContext,
+ "javax.faces.component.UIInput.CONVERSION");
+ assertEquals("Conversion Error", msg.getSummary());
+
+ facesContext.getViewRoot().setLocale(Locale.GERMAN);
+
+ msg = MessageUtils.getMessage(facesContext,
+ "javax.faces.component.UIInput.CONVERSION");
+ assertEquals("Konvertierungsfehler", msg.getSummary());
+ }
+
+ /**
+ * Test method for 'org.apache.myfaces.shared.util.MessageUtils.getMessage(FacesContext, String, Object[])'
+ */
+ public void testGetMessageFacesContextStringObjectArray()
+ {
+ facesContext.getViewRoot().setLocale(Locale.ENGLISH);
+
+ FacesMessage msg = MessageUtils.getMessage(facesContext,
+ "javax.faces.component.UIInput.CONVERSION", null);
+ assertEquals("Conversion Error", msg.getSummary());
+
+ facesContext.getViewRoot().setLocale(Locale.GERMAN);
+
+ msg = MessageUtils.getMessage(facesContext,
+ "javax.faces.component.UIInput.CONVERSION", null);
+ assertEquals("Konvertierungsfehler", msg.getSummary());
+ }
+
+ /**
+ * testGetMessageWithBundle
+ */
+ public void testGetMessageWithBundle()
+ {
+ facesContext.getViewRoot().setLocale(Locale.ENGLISH);
+
+ ResourceBundle bundle = ResourceBundle.getBundle(DEFAULT_BUNDLE,
+ Locale.ENGLISH);
+ FacesMessage msg = MessageUtils.getMessage(bundle,
+ "javax.faces.component.UIInput.CONVERSION", null);
+
+ assertEquals("Conversion Error", msg.getSummary());
+ }
+
+ /**
+ * testGetMessageWithBundleName
+ */
+ public void testGetMessageWithBundleName()
+ {
+ facesContext.getViewRoot().setLocale(Locale.ENGLISH);
+
+ FacesMessage msg = MessageUtils.getMessage(DEFAULT_BUNDLE,
+ "javax.faces.component.UIInput.CONVERSION", null);
+
+ assertEquals("Conversion Error", msg.getSummary());
+ }
+
+ /**
+ * testGetMessageWithBundleNameLocale
+ */
+ public void testGetMessageWithBundleNameLocale()
+ {
+ FacesMessage msg = MessageUtils.getMessage(DEFAULT_BUNDLE,
+ Locale.GERMAN, "javax.faces.component.UIInput.CONVERSION", null);
+
+ assertEquals("Konvertierungsfehler", msg.getSummary());
+ }
+
+ /**
+ * testSubstituteParamsWithDELocale(
+ */
+ public void testSubstituteParamsWithDELocale() {
+ String paramString = MessageUtils.substituteParams(Locale.GERMANY, "currency {0,number,currency}", new Object[]{100});
+
+ assertEquals("currency 100,00 \u20ac",paramString);
+ }
+
+ /**
+ * testSubstituteParamsWithGBLocale(
+ */
+ public void testSubstituteParamsWithGBLocale() {
+ String paramString = MessageUtils.substituteParams(Locale.UK, "currency {0,number,currency}", new Object[]{100});
+
+ System.out.println(paramString);
+ assertEquals("currency \u00a3100.00",paramString);
+ }
+
+}
Propchange: myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/util/MessageUtilsTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/util/SecretKeyCacheTest.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/util/SecretKeyCacheTest.java?rev=673829&r1=673828&r2=673829&view=diff
==============================================================================
--- myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/util/SecretKeyCacheTest.java (original)
+++ myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/util/SecretKeyCacheTest.java Thu Jul 3 14:47:59 2008
@@ -1,76 +1,76 @@
-/*
- * Copyright 2004-2006 The Apache Software Foundation.
- *
- * Licensed 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.myfaces.shared.util;
-
-import junit.framework.Test;
-import org.apache.shale.test.base.AbstractJsfTestCase;
-
-import javax.crypto.SecretKey;
-
-/**
- * @author Dennis C. Byrne
- */
-
-public class SecretKeyCacheTest extends AbstractJsfTestCase
-{
-
- public SecretKeyCacheTest(String name)
- {
- super(name);
- }
-
- public static Test suite() {
- return null; // keep this method or maven won't run it
- }
-
- public void setUp() throws Exception
- {
- super.setUp();
-
- servletContext.addInitParameter(StateUtils.INIT_SECRET,
- AbstractStateUtilsTest.BASE64_KEY_SIZE_8);
-
- }
-
- public void testDefaultAlgorithmUse(){
-
- StateUtils.initSecret(servletContext);
-
- SecretKey secretKey = (SecretKey) servletContext.getAttribute(StateUtils.INIT_SECRET_KEY_CACHE);
-
- assertTrue("Making sure MyFaces uses the " +
- "default algorithm when one is not specified",
- StateUtils.DEFAULT_ALGORITHM.equals(secretKey.getAlgorithm()));
-
- }
-
- public void testInitFacesWithCache(){
-
- StateUtils.initSecret(servletContext);
-
- Object object = servletContext.getAttribute(StateUtils.INIT_SECRET_KEY_CACHE);
-
- assertFalse("Making sure StateUtils.initSecret() puts an object in application scope",
- object == null);
-
- assertTrue("Making sure StateUtils.initSecret() is creating a SecretKey",
- object instanceof SecretKey);
-
- }
-
-}
+/*
+ * Copyright 2004-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.myfaces.shared.util;
+
+import junit.framework.Test;
+import org.apache.shale.test.base.AbstractJsfTestCase;
+
+import javax.crypto.SecretKey;
+
+/**
+ * @author Dennis C. Byrne
+ */
+
+public class SecretKeyCacheTest extends AbstractJsfTestCase
+{
+
+ public SecretKeyCacheTest(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite() {
+ return null; // keep this method or maven won't run it
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ servletContext.addInitParameter(StateUtils.INIT_SECRET,
+ AbstractStateUtilsTest.BASE64_KEY_SIZE_8);
+
+ }
+
+ public void testDefaultAlgorithmUse(){
+
+ StateUtils.initSecret(servletContext);
+
+ SecretKey secretKey = (SecretKey) servletContext.getAttribute(StateUtils.INIT_SECRET_KEY_CACHE);
+
+ assertTrue("Making sure MyFaces uses the " +
+ "default algorithm when one is not specified",
+ StateUtils.DEFAULT_ALGORITHM.equals(secretKey.getAlgorithm()));
+
+ }
+
+ public void testInitFacesWithCache(){
+
+ StateUtils.initSecret(servletContext);
+
+ Object object = servletContext.getAttribute(StateUtils.INIT_SECRET_KEY_CACHE);
+
+ assertFalse("Making sure StateUtils.initSecret() puts an object in application scope",
+ object == null);
+
+ assertTrue("Making sure StateUtils.initSecret() is creating a SecretKey",
+ object instanceof SecretKey);
+
+ }
+
+}
Propchange: myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/util/SecretKeyCacheTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/util/SecretKeyConfigurationTest.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/util/SecretKeyConfigurationTest.java?rev=673829&r1=673828&r2=673829&view=diff
==============================================================================
--- myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/util/SecretKeyConfigurationTest.java (original)
+++ myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/util/SecretKeyConfigurationTest.java Thu Jul 3 14:47:59 2008
@@ -1,99 +1,99 @@
-/*
- * Copyright 2004-2006 The Apache Software Foundation.
- *
- * Licensed 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.myfaces.shared.util;
-
-import junit.framework.Test;
-import org.apache.shale.test.base.AbstractJsfTestCase;
-
-/**
- * @author Dennis C. Byrne
- */
-
-public class SecretKeyConfigurationTest extends AbstractJsfTestCase
-{
-
- public SecretKeyConfigurationTest(String name)
- {
- super(name);
- }
-
- public static Test suite() {
- return null; // keep this method or maven won't run it
- }
-
- public void setUp() throws Exception
- {
- super.setUp();
- servletContext.addInitParameter(StateUtils.INIT_SECRET, "shouldn't matter");
-
- }
-
- public void testMissingSecretKeyEncrypt(){
-
- try{
- StateUtils.encrypt("serialized objects".getBytes(), externalContext);
- fail("An exception should be thrown if there" +
- " is no SecretKey in application scope and cacheing is enabled ");
- }catch(NullPointerException e){
- }
-
- }
-
- public void testNonSecretKeyEncrypt(){
-
- servletContext.setAttribute(StateUtils.INIT_SECRET_KEY_CACHE, new Integer(8));
-
- try{
-
- StateUtils.encrypt("serialized objects".getBytes(), externalContext);
- fail("An exception should be thrown if there" +
- " is no SecretKey in application scope and cacheing is enabled ");
- }catch(ClassCastException cce){
- }
-
- }
-
- public void testMissingSecretKeyDecrypt(){
-
- boolean npeThrown = false;
-
- try{
- StateUtils.decrypt("serialized objects".getBytes(), externalContext);
- }catch(NullPointerException e){
- npeThrown = true;
- }
-
- assertTrue("An exception should be thrown if there" +
- " is no SecretKey in application scope and cacheing is enabled ", npeThrown);
- }
-
- public void testNonSecretKeyDecrypt(){
-
- servletContext.setAttribute(StateUtils.INIT_SECRET_KEY_CACHE, new Integer(8));
-
- try{
-
- StateUtils.decrypt("serialized objects".getBytes(), externalContext);
- fail("An exception should be thrown if there" +
- " is no SecretKey in application scope and cacheing is enabled ");
- }catch(ClassCastException cce){
- }
-
- }
-
-}
+/*
+ * Copyright 2004-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.myfaces.shared.util;
+
+import junit.framework.Test;
+import org.apache.shale.test.base.AbstractJsfTestCase;
+
+/**
+ * @author Dennis C. Byrne
+ */
+
+public class SecretKeyConfigurationTest extends AbstractJsfTestCase
+{
+
+ public SecretKeyConfigurationTest(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite() {
+ return null; // keep this method or maven won't run it
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ servletContext.addInitParameter(StateUtils.INIT_SECRET, "shouldn't matter");
+
+ }
+
+ public void testMissingSecretKeyEncrypt(){
+
+ try{
+ StateUtils.encrypt("serialized objects".getBytes(), externalContext);
+ fail("An exception should be thrown if there" +
+ " is no SecretKey in application scope and cacheing is enabled ");
+ }catch(NullPointerException e){
+ }
+
+ }
+
+ public void testNonSecretKeyEncrypt(){
+
+ servletContext.setAttribute(StateUtils.INIT_SECRET_KEY_CACHE, new Integer(8));
+
+ try{
+
+ StateUtils.encrypt("serialized objects".getBytes(), externalContext);
+ fail("An exception should be thrown if there" +
+ " is no SecretKey in application scope and cacheing is enabled ");
+ }catch(ClassCastException cce){
+ }
+
+ }
+
+ public void testMissingSecretKeyDecrypt(){
+
+ boolean npeThrown = false;
+
+ try{
+ StateUtils.decrypt("serialized objects".getBytes(), externalContext);
+ }catch(NullPointerException e){
+ npeThrown = true;
+ }
+
+ assertTrue("An exception should be thrown if there" +
+ " is no SecretKey in application scope and cacheing is enabled ", npeThrown);
+ }
+
+ public void testNonSecretKeyDecrypt(){
+
+ servletContext.setAttribute(StateUtils.INIT_SECRET_KEY_CACHE, new Integer(8));
+
+ try{
+
+ StateUtils.decrypt("serialized objects".getBytes(), externalContext);
+ fail("An exception should be thrown if there" +
+ " is no SecretKey in application scope and cacheing is enabled ");
+ }catch(ClassCastException cce){
+ }
+
+ }
+
+}
Propchange: myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/util/SecretKeyConfigurationTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/util/StateUtilsAES_CBCTest.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/util/StateUtilsAES_CBCTest.java?rev=673829&r1=673828&r2=673829&view=diff
==============================================================================
--- myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/util/StateUtilsAES_CBCTest.java (original)
+++ myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/util/StateUtilsAES_CBCTest.java Thu Jul 3 14:47:59 2008
@@ -1,57 +1,57 @@
-/*
- * Copyright 2004-2006 The Apache Software Foundation.
- *
- * Licensed 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.myfaces.shared.util;
-
-import junit.framework.Test;
-
-/**
- * <p>This TestCase uses the Advanced Encryption Standard with
- * Cipher Block Chaining mode and PKCS5 padding.</p>
- * <p/>
- * <p/>
- * If you are getting a SecurityException complaining about keysize,
- * you most likely need to get the unlimited strength jurisdiction
- * policy files from a place like http://java.sun.com/j2se/1.4.2/download.html .
- * </p>
- *
- * @see pom.xml <excludes>
- * @author Dennis C. Byrne
- */
-
-public class StateUtilsAES_CBCTest extends AbstractStateUtilsTest
-{
-
- public StateUtilsAES_CBCTest(String name) {
- super(name);
- }
-
- public static Test suite() {
- return null; // keep this method or maven won't run it
- }
-
- public void setUp() throws Exception
- {
- super.setUp();
-
- servletContext.addInitParameter(StateUtils.INIT_SECRET, BASE64_KEY_SIZE_24);
- servletContext.addInitParameter(StateUtils.INIT_ALGORITHM, "AES");
- servletContext.addInitParameter(StateUtils.INIT_ALGORITHM_PARAM, "CBC/PKCS5Padding");
- servletContext.addInitParameter(StateUtils.INIT_ALGORITHM_IV, BASE64_KEY_SIZE_16);
- StateUtils.initSecret(servletContext);// should do nothing
-
- }
-
-}
+/*
+ * Copyright 2004-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.myfaces.shared.util;
+
+import junit.framework.Test;
+
+/**
+ * <p>This TestCase uses the Advanced Encryption Standard with
+ * Cipher Block Chaining mode and PKCS5 padding.</p>
+ * <p/>
+ * <p/>
+ * If you are getting a SecurityException complaining about keysize,
+ * you most likely need to get the unlimited strength jurisdiction
+ * policy files from a place like http://java.sun.com/j2se/1.4.2/download.html .
+ * </p>
+ *
+ * @see pom.xml <excludes>
+ * @author Dennis C. Byrne
+ */
+
+public class StateUtilsAES_CBCTest extends AbstractStateUtilsTest
+{
+
+ public StateUtilsAES_CBCTest(String name) {
+ super(name);
+ }
+
+ public static Test suite() {
+ return null; // keep this method or maven won't run it
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ servletContext.addInitParameter(StateUtils.INIT_SECRET, BASE64_KEY_SIZE_24);
+ servletContext.addInitParameter(StateUtils.INIT_ALGORITHM, "AES");
+ servletContext.addInitParameter(StateUtils.INIT_ALGORITHM_PARAM, "CBC/PKCS5Padding");
+ servletContext.addInitParameter(StateUtils.INIT_ALGORITHM_IV, BASE64_KEY_SIZE_16);
+ StateUtils.initSecret(servletContext);// should do nothing
+
+ }
+
+}
Propchange: myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/util/StateUtilsAES_CBCTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/util/StateUtilsBlowfish_ECBTest.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/util/StateUtilsBlowfish_ECBTest.java?rev=673829&r1=673828&r2=673829&view=diff
==============================================================================
--- myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/util/StateUtilsBlowfish_ECBTest.java (original)
+++ myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/util/StateUtilsBlowfish_ECBTest.java Thu Jul 3 14:47:59 2008
@@ -1,55 +1,55 @@
-/*
- * Copyright 2004-2006 The Apache Software Foundation.
- *
- * Licensed 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.myfaces.shared.util;
-
-import junit.framework.Test;
-
-/**
- * This TestCase uses Blowfish in Electronic CodeBook mode
- * with PKCS5 padding.
- * <p/>
- * <p/>
- * If you are getting a SecurityException complaining about keysize,
- * you most likely need to get the unlimited strength jurisdiction
- * policy files from a place like http://java.sun.com/j2se/1.4.2/download.html .
- * </p>
- *
- * @author Dennis C. Byrne
- */
-
-public class StateUtilsBlowfish_ECBTest extends AbstractStateUtilsTest
-{
-
- public StateUtilsBlowfish_ECBTest(String name) {
- super(name);
- }
-
- public static Test suite() {
- return null; // keep this method or maven won't run it
- }
-
- public void setUp() throws Exception
- {
- super.setUp();
-
- servletContext.addInitParameter(StateUtils.INIT_SECRET, BASE64_KEY_SIZE_16);
- servletContext.addInitParameter(StateUtils.INIT_ALGORITHM, "Blowfish");
- servletContext.addInitParameter(StateUtils.INIT_ALGORITHM_PARAM, "ECB/PKCS5Padding");
- StateUtils.initSecret(servletContext);// should do nothing
-
- }
-
-}
+/*
+ * Copyright 2004-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.myfaces.shared.util;
+
+import junit.framework.Test;
+
+/**
+ * This TestCase uses Blowfish in Electronic CodeBook mode
+ * with PKCS5 padding.
+ * <p/>
+ * <p/>
+ * If you are getting a SecurityException complaining about keysize,
+ * you most likely need to get the unlimited strength jurisdiction
+ * policy files from a place like http://java.sun.com/j2se/1.4.2/download.html .
+ * </p>
+ *
+ * @author Dennis C. Byrne
+ */
+
+public class StateUtilsBlowfish_ECBTest extends AbstractStateUtilsTest
+{
+
+ public StateUtilsBlowfish_ECBTest(String name) {
+ super(name);
+ }
+
+ public static Test suite() {
+ return null; // keep this method or maven won't run it
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ servletContext.addInitParameter(StateUtils.INIT_SECRET, BASE64_KEY_SIZE_16);
+ servletContext.addInitParameter(StateUtils.INIT_ALGORITHM, "Blowfish");
+ servletContext.addInitParameter(StateUtils.INIT_ALGORITHM_PARAM, "ECB/PKCS5Padding");
+ StateUtils.initSecret(servletContext);// should do nothing
+
+ }
+
+}
Propchange: myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/util/StateUtilsBlowfish_ECBTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/util/StateUtilsDefaultTest.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/util/StateUtilsDefaultTest.java?rev=673829&r1=673828&r2=673829&view=diff
==============================================================================
--- myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/util/StateUtilsDefaultTest.java (original)
+++ myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/util/StateUtilsDefaultTest.java Thu Jul 3 14:47:59 2008
@@ -1,48 +1,48 @@
-/*
- * Copyright 2004-2006 The Apache Software Foundation.
- *
- * Licensed 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.myfaces.shared.util;
-
-import junit.framework.Test;
-
-/**
- * This TestCase uses the the default algorithm/mode/padding of
- * StateUtils.
- *
- * @author Dennis C. Byrne
- */
-
-public class StateUtilsDefaultTest extends AbstractStateUtilsTest
-{
-
- public StateUtilsDefaultTest(String name) {
- super(name);
- }
-
- public static Test suite() {
- return null; // keep this method or maven won't run it
- }
-
- public void setUp() throws Exception
- {
- super.setUp();
-
- servletContext.addInitParameter(StateUtils.INIT_SECRET, BASE64_KEY_SIZE_8);
- servletContext.addInitParameter(StateUtils.INIT_ALGORITHM, StateUtils.DEFAULT_ALGORITHM);
- servletContext.addInitParameter(StateUtils.INIT_ALGORITHM_PARAM, StateUtils.DEFAULT_ALGORITHM_PARAMS);
- StateUtils.initSecret(servletContext);// should do nothing
-
- }
-}
+/*
+ * Copyright 2004-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.myfaces.shared.util;
+
+import junit.framework.Test;
+
+/**
+ * This TestCase uses the the default algorithm/mode/padding of
+ * StateUtils.
+ *
+ * @author Dennis C. Byrne
+ */
+
+public class StateUtilsDefaultTest extends AbstractStateUtilsTest
+{
+
+ public StateUtilsDefaultTest(String name) {
+ super(name);
+ }
+
+ public static Test suite() {
+ return null; // keep this method or maven won't run it
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ servletContext.addInitParameter(StateUtils.INIT_SECRET, BASE64_KEY_SIZE_8);
+ servletContext.addInitParameter(StateUtils.INIT_ALGORITHM, StateUtils.DEFAULT_ALGORITHM);
+ servletContext.addInitParameter(StateUtils.INIT_ALGORITHM_PARAM, StateUtils.DEFAULT_ALGORITHM_PARAMS);
+ StateUtils.initSecret(servletContext);// should do nothing
+
+ }
+}
Propchange: myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/util/StateUtilsDefaultTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/util/StateUtilsTripleDES_ECBTest.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/util/StateUtilsTripleDES_ECBTest.java?rev=673829&r1=673828&r2=673829&view=diff
==============================================================================
--- myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/util/StateUtilsTripleDES_ECBTest.java (original)
+++ myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/util/StateUtilsTripleDES_ECBTest.java Thu Jul 3 14:47:59 2008
@@ -1,55 +1,55 @@
-/*
- * Copyright 2004-2006 The Apache Software Foundation.
- *
- * Licensed 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.myfaces.shared.util;
-
-import junit.framework.Test;
-
-/**
- * This TestCase uses the 3DES algorithm in Electronic CodeBook mode
- * with PKCS5 padding.
- * <p/>
- * <p/>
- * If you are getting a SecurityException complaining about keysize,
- * you most likely need to get the unlimited strength jurisdiction
- * policy files from a place like http://java.sun.com/j2se/1.4.2/download.html .
- * </p>
- *
- * @author Dennis C. Byrne
- */
-
-public class StateUtilsTripleDES_ECBTest extends AbstractStateUtilsTest
-{
-
- public StateUtilsTripleDES_ECBTest(String name) {
- super(name);
- }
-
- public static Test suite() {
- return null; // keep this method or maven won't run it
- }
-
- public void setUp() throws Exception
- {
- super.setUp();
-
- servletContext.addInitParameter(StateUtils.INIT_SECRET, BASE64_KEY_SIZE_24);
- servletContext.addInitParameter(StateUtils.INIT_ALGORITHM, "DESede");
- servletContext.addInitParameter(StateUtils.INIT_ALGORITHM_PARAM, "ECB/PKCS5Padding");
- StateUtils.initSecret(servletContext); // should do nothing
-
- }
-
-}
+/*
+ * Copyright 2004-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.myfaces.shared.util;
+
+import junit.framework.Test;
+
+/**
+ * This TestCase uses the 3DES algorithm in Electronic CodeBook mode
+ * with PKCS5 padding.
+ * <p/>
+ * <p/>
+ * If you are getting a SecurityException complaining about keysize,
+ * you most likely need to get the unlimited strength jurisdiction
+ * policy files from a place like http://java.sun.com/j2se/1.4.2/download.html .
+ * </p>
+ *
+ * @author Dennis C. Byrne
+ */
+
+public class StateUtilsTripleDES_ECBTest extends AbstractStateUtilsTest
+{
+
+ public StateUtilsTripleDES_ECBTest(String name) {
+ super(name);
+ }
+
+ public static Test suite() {
+ return null; // keep this method or maven won't run it
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ servletContext.addInitParameter(StateUtils.INIT_SECRET, BASE64_KEY_SIZE_24);
+ servletContext.addInitParameter(StateUtils.INIT_ALGORITHM, "DESede");
+ servletContext.addInitParameter(StateUtils.INIT_ALGORITHM_PARAM, "ECB/PKCS5Padding");
+ StateUtils.initSecret(servletContext); // should do nothing
+
+ }
+
+}
Propchange: myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/util/StateUtilsTripleDES_ECBTest.java
------------------------------------------------------------------------------
svn:eol-style = native