[embjopr-commits] EMBJOPR SVN: r435 - trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ear.

embjopr-commits at lists.jboss.org embjopr-commits at lists.jboss.org
Mon May 18 10:40:40 EDT 2009


Author: ozizka at redhat.com
Date: 2009-05-18 10:40:39 -0400 (Mon, 18 May 2009)
New Revision: 435

Modified:
   trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ear/EarTest.java
Log:
EarTest - more cleanup.

Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ear/EarTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ear/EarTest.java	2009-05-18 12:29:19 UTC (rev 434)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ear/EarTest.java	2009-05-18 14:40:39 UTC (rev 435)
@@ -700,7 +700,7 @@
 		// Deploy the unpacked EAR.
 		// We have to use hotdeploy - can't upload a directory.
 		log.info("Unzipping ear/"+EAR_UNPACKED_ZIP);
-		unzipToDeployDir("ear/"+EAR_UNPACKED_ZIP, "");
+		ejtt.deployment.unzipToDeployDir("ear/"+EAR_UNPACKED_ZIP, "");
 		ejtt.sleep(5000); // 5 sec is default deployment scanner interval.
 
 		try {
@@ -723,7 +723,7 @@
 		}
 		finally {
 			// Delete the EAR dir.
-			deleteFromDeployDir(EAR_UNPACKED);
+			ejtt.deployment.deleteFromDeployDir(EAR_UNPACKED);
 		}
 	}
 
@@ -1217,123 +1217,9 @@
 	
 	
 
-	// TODO: Move to utils
-	/**
-	 * Unzips given archive from testdata dir to server's deploy/ dir.
-	 * @param relativeArchivePath  Path of the archive relative to testdata dir.
-	 * @param relativeDestDir      Path of the destination dir relative to deploy dir.
-	 */
-	private void unzipToDeployDir( String relativeArchivePath, String relativeDestDir )
-					throws FileNotFoundException, IOException
-	{
 
-		String destDir = System.getProperty(SYSPROP_DEPLOY_DIR)+"/"+relativeDestDir;
-		String archivePath = System.getProperty(SYSPROP_TESTDATA_DIR)+"/"+relativeArchivePath;
 
-		log.info("Unzipping '"+archivePath+"' to '"+destDir+"'.");
 
-		unzipArchive( archivePath, destDir );
-	}
-
-
-	
-	/**
-	 * Unzips archive from the given path to the given destination dir.
-	 */
-	private void unzipArchive(String archivePath, String destDir)
-					throws FileNotFoundException, IOException
-	{
-
-		FileInputStream fis = new FileInputStream( archivePath );
-		ZipInputStream zin = new ZipInputStream(new BufferedInputStream(fis));
-
-		ZipEntry entry;
-		while( null != (entry = zin.getNextEntry()) ){
-
-			if(entry.isDirectory()) {
-				// Assume directories are stored parents first then children.
-				log.info("Extracting directory: " + entry.getName());
-				// This is not robust, just for demonstration purposes.
-				(new File(destDir +"/"+ entry.getName())).mkdir();
-				continue;
-			}
-
-			log.info("Extracting file: " + entry.getName());
-
-			final int BUFFER = 2048;
-			FileOutputStream fos = new FileOutputStream( destDir +"/"+ entry.getName());
-			BufferedOutputStream dest = new BufferedOutputStream(fos, BUFFER);
-
-			int count;
-			byte[] data = new byte[BUFFER];
-			while ((count = zin.read(data, 0, BUFFER)) != -1) {
-				 dest.write(data, 0, count);
-			}
-			dest.flush();
-			dest.close();
-			zin.closeEntry();
-
-		}
-
-		zin.close();
-
-	}
-
-
-
-
-	// TODO: Moved to EJTT, remove from here.
-	private void deleteFromDeployDir( String deployableName ) throws IOException{
-
-		String deployDir = ejtt.getDeployDir();
-
-		File dirToDelete = new File( deployDir, deployableName);
-		// Just not to delete something accidentally...
-		// Not true for Cargo maven plugin.
-		//assertTrue( deployDir+" contains '/server/'", deployDir.contains("/server/"));
-
-		// Check if not outside deploy dir.
-		if( !dirToDelete.getCanonicalPath().startsWith( deployDir ) )
-			throw new IllegalArgumentException(
-							" The resulting path is outside deploy dir: "+dirToDelete.getCanonicalPath());
-
-		log.info("Deleting '"+dirToDelete.getPath()+"'...");
-		//deleteDirectory( dirToDelete );
-	}
-
-
-
-  public static void deleteDirectory(File path) throws EmbJoprTestException
-	{
-		List<String> undeletableFiles = new ArrayList();
-		deleteDirectory(path, undeletableFiles);
-		if( !undeletableFiles.isEmpty() ){
-			throw new EmbJoprTestException("Couldn't delete following files: \n  "+
-							StringUtils.join(undeletableFiles, "\n  ") + "\n");
-		}
-	}
-
-  public static void deleteDirectory(File path, List<String> undeletableFiles)
-	{
-    if( path.exists() ) {
-      File[] files = path.listFiles();
-      for(int i=0; i<files.length; i++) {
-         if(files[i].isDirectory()) {
-           deleteDirectory(files[i], undeletableFiles );
-         }
-         else {
-           if( !files[i].delete() ){
-						 undeletableFiles.add(files[i].getAbsolutePath());
-					 }
-         }
-      }
-    }
-    if( ! path.delete() )
-			undeletableFiles.add( path.getAbsolutePath() );
-  }
-
-
-	
 	private void deployEar( String earFilePath ) throws IOException, HtmlElementNotFoundException
 	{
 		if( !(new File(earFilePath)).exists())




More information about the embjopr-commits mailing list