DefaultResPolicyTest.java :  » Content-Management-System » TransferCM » com » methodhead » res » Java Open Source

Java Open Source » Content Management System » TransferCM 
TransferCM » com » methodhead » res » DefaultResPolicyTest.java
/* 
 * Copyright (C) 2006 Methodhead Software LLC.  All rights reserved.
 * 
 * This file is part of TransferCM.
 * 
 * TransferCM is free software; you can redistribute it and/or modify it under the
 * terms of the GNU General Public License as published by the Free Software
 * Foundation; either version 2 of the License, or (at your option) any later
 * version.
 * 
 * TransferCM is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * TransferCM; if not, write to the Free Software Foundation, Inc., 51 Franklin St,
 * Fifth Floor, Boston, MA  02110-1301  USA
 */

package com.methodhead.res;

import java.util.*;
import java.io.*;
import junit.framework.*;
import org.apache.log4j.*;
import com.methodhead.persistable.*;
import com.methodhead.test.*;
import org.apache.cactus.*;
import servletunit.struts.*;
import org.apache.struts.*;

public class DefaultResPolicyTest extends CactusStrutsTestCase {

  static {
    TestUtils.initLogger();
    TestUtils.initDb();
  }

  private DefaultResPolicy policy = null;
  private FileManager fileManager = null;
  private File file = null;

  public DefaultResPolicyTest( String name ) {
    super( name );
  }

  public void setUp() {
    //setLogLevel( Level.DEBUG );
    try {
    }
    catch ( Exception e ) {
      fail( e.getMessage() );
    }
  }

  public void tearDown() {
  }

  public void testInitFileManager() {
    try {
      policy = new DefaultResPolicy();

      //
      // force the request messages to be the context messages (struts will do this when an action is envoked)
      //
      request.setAttribute( Globals.MESSAGES_KEY, session.getServletContext().getAttribute( Globals.MESSAGES_KEY ) );

      //
      // get the file manager and make sure its set up right
      //
      fileManager = new FileManager();
      policy.initFileManager( request, fileManager );
      assertNotNull( fileManager );

      file = fileManager.getFileForPath( "Files" );
      assertNotNull( file );
      assertEquals( request.getSession().getServletContext().getRealPath( "" ), file.getAbsolutePath() );
    }
    catch ( Exception e ) {
      e.printStackTrace();
      fail();
    }
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.