/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://glassfish.java.net/public/CDDL+GPL_1_1.html
* or packager/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at packager/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
// TestRestoreViewFromPage.java
package com.sun.faces.lifecycle;
import com.sun.faces.cactus.CompareFiles;
import com.sun.faces.cactus.FileOutputResponseWriter;
import com.sun.faces.cactus.ServletFacesTestCase;
import org.apache.cactus.WebRequest;
import javax.faces.render.RenderKitFactory;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
/**
* <B>TestRestoreViewFromPage</B> is a class ...
* <p/>
* <B>Lifetime And Scope</B> <P>
*
*/
public class TestRestoreViewFromPage extends ServletFacesTestCase {
//
// Protected Constants
//
//
// Class Variables
//
//
// Instance Variables
//
public static final String TEST_URI = "/greeting.jsp";
public static final String RESTORE_VIEW_OUTPUT_FILE = FileOutputResponseWriter.FACES_RESPONSE_ROOT +
"RestoreView_output";
public static final String RESTORE_VIEW_CORRECT_FILE = FileOutputResponseWriter.FACES_RESPONSE_ROOT +
"RestoreView_correct";
public static final String ignore[] = {
"value=[Ljava.lang.Object;@14a18d"
};
// Attribute Instance Variables
// Relationship Instance Variables
//
// Constructors and Initializers
//
public TestRestoreViewFromPage() {
super("TestRestoreViewFromPage");
initLocalHostPath();
}
public TestRestoreViewFromPage(String name) {
super(name);
initLocalHostPath();
}
private String localHostPath = "localhost:8080";
private void initLocalHostPath() {
String containerPort = System.getProperty("container.port");
if (null == containerPort || 0 == containerPort.length()) {
containerPort = "8080";
}
localHostPath = "localhost:" + containerPort;
}
//
// Class methods
//
//
// General Methods
//
public void beginRestoreViewFromPage(WebRequest theRequest) {
// theRequest.setURL(localHostPath, null, null, TEST_URI, null);
// theRequest.addParameter("javax.faces.ViewState",
// "rO0ABXNyACBjb20uc3VuLmZhY2VzLnV0aWwuVHJlZVN0cnVjdHVyZRRmG0QclWAgAgAETAAIY2hpbGRyZW50ABVMamF2YS91dGlsL0FycmF5TGlzdDtMAAljbGFzc05hbWV0ABJMamF2YS9sYW5nL1N0cmluZztMAAZmYWNldHN0ABNMamF2YS91dGlsL0hhc2hNYXA7TAACaWRxAH4AAnhwc3IAE2phdmEudXRpbC5BcnJheUxpc3R4gdIdmcdhnQMAAUkABHNpemV4cAAAAAF3BAAAAApzcQB+AABzcQB+AAUAAAACdwQAAAAKc3EAfgAAcHQAJmphdmF4LmZhY2VzLmNvbXBvbmVudC5iYXNlLlVJSW5wdXRCYXNlcHQABnVzZXJOb3NxAH4AAHB0AChqYXZheC5mYWNlcy5jb21wb25lbnQuYmFzZS5VSUNvbW1hbmRCYXNlcHQABnN1Ym1pdHh0ACVqYXZheC5mYWNlcy5jb21wb25lbnQuYmFzZS5VSUZvcm1CYXNlcHQACWhlbGxvRm9ybXh0AClqYXZheC5mYWN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C5Mb2NhbGV++BFgnDD57AMABEkACGhhc2hjb2RlTAAHY291bnRyeXEAfgACTAAIbGFuZ3VhZ2VxAH4AAkwAB3ZhcmlhbnRxAH4AAnhw/////3QAAlVTdAACZW50AAB4");
}
public void testRestoreViewFromPage() {
// Phase restoreView = new RestoreViewPhase();
//
// try {
// restoreView.execute(getFacesContext());
// } catch (Throwable e) {
// e.printStackTrace();
// assertTrue(false);
// }
// assertTrue(!(getFacesContext().getRenderResponse()) &&
// !(getFacesContext().getResponseComplete()));
//
// assertTrue(null != getFacesContext().getViewRoot());
// assertTrue(RenderKitFactory.HTML_BASIC_RENDER_KIT.equals(
// getFacesContext().getViewRoot().getRenderKitId()));
// assertTrue(
// getFacesContext().getViewRoot().getLocale().equals(Locale.US));
// CompareFiles cf = new CompareFiles();
// try {
// FileOutputStream os = new FileOutputStream(
// RESTORE_VIEW_OUTPUT_FILE);
// PrintStream ps = new PrintStream(os);
// com.sun.faces.util.DebugUtil.printTree(
// getFacesContext().getViewRoot(), ps);
//
// List ignoreList = new ArrayList();
// for (int i = 0; i < ignore.length; i++) {
// ignoreList.add(ignore[i]);
// }
// boolean status = cf.filesIdentical(RESTORE_VIEW_OUTPUT_FILE,
// RESTORE_VIEW_CORRECT_FILE,
// ignoreList);
// assertTrue(status);
// // PENDING (visvan) test case to verify nothing is persisted if the root
// // is marked transient for both client tand server case.
// } catch (IOException e) {
// System.out.println(e.getMessage());
// e.printStackTrace();
// }
}
} // end of class TestRestoreViewFromPage