Methods Summary |
---|
public void | XXXXtestDownloadFile1()
printVerbose( "testDownloadFile1" );
testDownloadFile( "moduleID", "filename", MEGABYTE );
printVerbose( "testDownloadFile1 DONE" );
|
private void | addArchivesInDirectory(java.io.File dir, java.util.List archives)
assert dir.isDirectory();
final File[] contents = dir.listFiles();
for( final File f : contents )
{
if ( f.isDirectory() )
{
addArchivesInDirectory( f, archives );
}
else
{
final String name = f.getName();
final int idx = name.lastIndexOf( "." );
final String suffix = (idx <= 0 ? "" : name.substring( idx + 1, name.length() )).toLowerCase();
if ( ARCHIVE_SUFFIXES.contains(suffix ) )
{
archives.add( f );
}
}
}
|
private com.sun.appserv.management.deploy.DeploymentStatus | deploy(java.io.File theFile)
//printVerbose( "Uploading: " + quote( theFile ) );
final Object uploadID = uploadFile( theFile );
final DeploymentMgr mgr = getDeploymentMgr();
final Object deployID = mgr.initDeploy( );
assert( deployID instanceof String );
final MyNotificationListener myListener = new MyNotificationListener( deployID);
DeploymentStatus status = null;
mgr.addNotificationListener( myListener, null, null );
try
{
final Map<String,String> options = new HashMap<String,String>();
options.put( DeploymentMgr.DEPLOY_OPTION_FORCE_KEY, Boolean.TRUE.toString() );
options.put( DeploymentMgr.DEPLOY_OPTION_VERIFY_KEY, Boolean.TRUE.toString() );
options.put( DeploymentMgr.DEPLOY_OPTION_DESCRIPTION_KEY, "test deploy" );
options.put( DeploymentMgr.DEPLOY_OPTION_AVAILABILITY_ENABLED_KEY, Boolean.FALSE.toString() );
options.put( DeploymentMgr.DEPLOY_OPTION_ENABLE_KEY, Boolean.TRUE.toString() );
mgr.startDeploy( deployID, uploadID, null, null);
printVerbose( NEWLINE + "Deploying: " + quote( theFile ) +
", deploy options: " + MapUtil.toString( options, ", ") );
while ( ! myListener.isCompleted() )
{
try
{
//trace( "testDeployFile: sleeping for: " + deployID);
Thread.sleep( 500 );
}
catch( InterruptedException e )
{
}
}
final Map<String,Serializable> deploymentStatusMap = mgr.getFinalDeploymentStatus( deployID );
status = DeploymentSupport.mapToDeploymentStatus( deploymentStatusMap );
}
finally
{
try
{
mgr.removeNotificationListener( myListener );
}
catch( Exception e )
{
}
}
return( status );
|
protected java.util.List | deployModules(java.util.List files)Test deployment and undeployment of modules specified by PropertyKeys.ARCHIVES_TO_DEPLOY_KEY.
final List<String> moduleIDs = new ArrayList<String>();
if ( files.size() == 0 )
{
warning( "testDeployUndeployModules: no modules specified via property " +
PropertyKeys.ARCHIVES_TO_DEPLOY_KEY + ", NO MODULES WILL BE DEPLOYED." );
}
else
{
final Set<String> failedSet = new HashSet<String>();
final Set<String> successSet = new HashSet<String>();
for( final File theFile : files )
{
try
{
if ( theFile.exists() )
{
final long start = now();
final DeploymentStatus status = deploy( theFile );
final long elapsed = now() - start;
String msg = "Deployed: " +
quote( theFile ) + " in " + elapsed + "ms";
if ( getVerbose() )
{
msg = msg + ", DeploymentStatus = " + status;
}
println( msg );
if ( status.getStageStatus() != DeploymentStatus.STATUS_CODE_SUCCESS )
{
warning( "DeploymentMgrTest.testDeployUndeployModules: expected STATUS_CODE_SUCCESS " +
"for " + quote( theFile.toString() ) +
", got " + status.getStageStatus() );
failedSet.add( theFile.toString() );
continue;
}
String moduleID =
(String)status.getAdditionalStatus().get( DeploymentStatus.MODULE_ID_KEY );
if ( moduleID == null )
{
moduleID =(String) status.getAdditionalStatus().get( "moduleid" );
assert( moduleID != null );
warning( "WARNING: used 'moduleid' instead of " +
"DeploymentStatus.MODULE_ID_KEY (" + DeploymentStatus.MODULE_ID_KEY +
") as workaround for bug #6218705" );
}
moduleIDs.add( moduleID );
successSet.add( theFile.toString() );
}
else
{
warning( "testDeployUndeployModules: file " +
quote( theFile.toString() ) + " does not exist." );
}
}
catch( Throwable t )
{
warning( "Error deploying archive: " + quote( theFile.toString() ) );
}
}
if ( failedSet.size() != 0 )
{
failure( "testDeployUndeployModules: failure count = " +
failedSet.size() + " modules: " + toString( failedSet ) );
}
}
return moduleIDs;
|
public static com.sun.enterprise.management.Capabilities | getCapabilities()
return getOfflineCapableCapabilities( false );
|
public com.sun.appserv.management.deploy.DeploymentMgr | getDeploymentMgr()
return( getDomainRoot().getDeploymentMgr() );
|
protected void | removeAllRefs(java.lang.String moduleID)
final Set<DeployedItemRefConfig> refs =
getQueryMgr().queryJ2EETypeNameSet( XTypes.DEPLOYED_ITEM_REF_CONFIG, moduleID );
for( final DeployedItemRefConfig ref : refs )
{
final DeployedItemRefConfigCR container = (DeployedItemRefConfigCR)ref.getContainer();
container.removeDeployedItemRefConfig( ref.getName() );
}
|
public void | testDeployUndeployModules()
final String filesString = getEnvString( PropertyKeys.ARCHIVES_TO_DEPLOY_KEY, "" ).trim();
final String[] names = filesString.split( PropertyKeys.ARCHIVES_DELIM );
final List<File> archives = new ArrayList<File>();
for( int i = 0; i < names.length; ++i )
{
names[ i ] = names[i].trim();
final File f = new File( names[ i ] );
if ( ! f.exists() )
{
warning( "File " + f + " does not exist" );
}
if ( f.isDirectory() )
{
addArchivesInDirectory( f, archives);
}
else
{
archives.add( f );
}
}
List<String> moduleIDs = deployModules( archives );
final List<Exception> results = undeployModules( moduleIDs );
// now deploy again and leave in place, for the use of subsequent unit tests
moduleIDs = deployModules( archives );
// now add references to them in server
final StandaloneServerConfig server =
getDomainConfig().getStandaloneServerConfigMap().get( "server" );
for( final String moduleID : moduleIDs )
{
server.createDeployedItemRefConfig( moduleID );
println( "Added ref to: " + moduleID );
}
|
public void | testDownloadFile(java.lang.String moduleID, java.lang.String filename, int chunkSize)
final DeploymentMgr mgr =
getDomainRoot().getDeploymentMgr();
final Object id = mgr.initiateFileDownload( moduleID, filename );
//trace( "downloading for: " + id );
final int actualChunkSize = chunkSize < mgr.MAX_DOWNLOAD_CHUNK_SIZE ?
chunkSize : mgr.MAX_DOWNLOAD_CHUNK_SIZE;
final long length = mgr.getDownloadLength( id );
long doneSoFar = 0;
while ( doneSoFar < length )
{
final byte[] bytes = mgr.downloadBytes( id, actualChunkSize );
doneSoFar += bytes.length;
}
|
public void | testUndeployNonExistentModule()
printVerbose( "testUndeployNonExistentModule" );
try
{
getDeploymentMgr().undeploy( "does_not_exist", null );
}
catch( Exception e )
{
// good!
final Throwable t = ExceptionUtil.getRootCause( e );
assert( t instanceof IllegalArgumentException );
}
printVerbose( "testUndeployNonExistentModule DONE" );
|
public void | undeploy(java.lang.String moduleID)
removeAllRefs( moduleID );
final DeploymentMgr mgr = getDeploymentMgr();
final long start = now();
final DeploymentStatus status = DeploymentSupport.mapToDeploymentStatus( mgr.undeploy( moduleID, null ) );
assert( status.getStageStatus() == DeploymentStatus.STATUS_CODE_SUCCESS );
printElapsed( "undeploy " + moduleID, start );
|
protected java.util.List | undeployModules(java.util.List moduleIDs)
final List<Exception> results = new ArrayList<Exception>();
for ( final String moduleID : moduleIDs )
{
if ( moduleID != null )
{
try
{
undeploy( moduleID );
println( "Undeployed: " + moduleID );
results.add( null );
}
catch( Exception e )
{
warning( "FAILURE undeploying module " + moduleID );
results.add( e );
}
}
}
return results;
|
public java.lang.Object | uploadFile(java.lang.String name, java.io.InputStream is)
final DeploymentMgr mgr = getDeploymentMgr();
assert( mgr != null );
//mgr.setTrace( true );
final int totalSize = is.available();
final int chunkSize = 1 + 32 * 1024; // a screwball size
final Object uploadID = mgr.initiateFileUpload( name, totalSize );
int remaining = totalSize;
boolean done = false;
while ( remaining != 0 )
{
final int actual = remaining < chunkSize ? remaining : chunkSize;
final byte[] bytes = new byte[ actual ];
is.read( bytes );
done = mgr.uploadBytes( uploadID, bytes );
remaining -= actual;
}
assert( done );
return( uploadID );
|
public java.lang.Object | uploadFile(java.io.File theFile)
final FileInputStream is = new FileInputStream( theFile );
Object id = null;
try
{
id = uploadFile( theFile.getName(), is );
}
finally
{
is.close();
}
return( id );
|