From: <mk...@us...> - 2007-08-27 16:04:17
|
Revision: 23 http://components4oaw.svn.sourceforge.net/components4oaw/?rev=23&view=rev Author: mklink Date: 2007-08-25 12:56:15 -0700 (Sat, 25 Aug 2007) Log Message: ----------- added new tests Modified Paths: -------------- trunk/jar/pom.xml trunk/jar/src/main/java/net/components4oaw/jar/JarCompress.java Added Paths: ----------- trunk/jar/src/test/java/net/components4oaw/jar/JarCompressTest.java Modified: trunk/jar/pom.xml =================================================================== --- trunk/jar/pom.xml 2007-08-25 19:56:02 UTC (rev 22) +++ trunk/jar/pom.xml 2007-08-25 19:56:15 UTC (rev 23) @@ -1,4 +1,6 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <parent> <artifactId>components4oaw-parent</artifactId> <groupId>net.components4oaw</groupId> @@ -9,9 +11,9 @@ <groupId>net.components4oaw</groupId> <artifactId>jar</artifactId> <name>jar</name> - + <url>/${artifactId}</url> - + <version>1.0.1</version> <description> Extract and compress jar files with this component Modified: trunk/jar/src/main/java/net/components4oaw/jar/JarCompress.java =================================================================== --- trunk/jar/src/main/java/net/components4oaw/jar/JarCompress.java 2007-08-25 19:56:02 UTC (rev 22) +++ trunk/jar/src/main/java/net/components4oaw/jar/JarCompress.java 2007-08-25 19:56:15 UTC (rev 23) @@ -1,6 +1,5 @@ package net.components4oaw.jar; - import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -12,14 +11,17 @@ import java.util.jar.JarEntry; import java.util.jar.JarOutputStream; +import org.openarchitectureware.workflow.WfCHelper; import org.openarchitectureware.workflow.WorkflowContext; import org.openarchitectureware.workflow.issues.Issues; import org.openarchitectureware.workflow.lib.AbstractWorkflowComponent; import org.openarchitectureware.workflow.monitor.ProgressMonitor; + /** * Compress the contents of a specified directory into a jar file. + * * @author MarkusK - * + * */ public class JarCompress extends AbstractWorkflowComponent { @@ -27,7 +29,8 @@ private String outputFile; public void checkConfiguration(Issues arg0) { - // TODO Auto-generated method stub + if (getInputDir() == null || getOutputFile() == null) + arg0.addError("InputDir or OutputFile not set correctly."); } @@ -42,30 +45,30 @@ public void invoke(WorkflowContext arg0, ProgressMonitor arg1, Issues arg2) { System.out.println("Invoking JarCompress Component."); URI inputDirURI = new File(inputDir).toURI(); - + try { FileOutputStream stream = new FileOutputStream(new File( getOutputFile())); JarOutputStream out = new JarOutputStream(stream); - - + File dir = new File(new File(getInputDir()).getAbsolutePath()); byte buffer[] = new byte[1024]; for (File input : listFiles(dir)) { if (input.isDirectory()) continue; - JarEntry jarAdd = new JarEntry(inputDirURI.relativize(input.toURI()).toString()); + JarEntry jarAdd = new JarEntry(inputDirURI.relativize( + input.toURI()).toString()); jarAdd.setTime(input.lastModified()); - -// if (input.isDirectory()) { -// jarAdd.setSize(0); -// jarAdd.setCrc(0); -// out.putNextEntry(jarAdd); -// continue; -// } - + + // if (input.isDirectory()) { + // jarAdd.setSize(0); + // jarAdd.setCrc(0); + // out.putNextEntry(jarAdd); + // continue; + // } + out.putNextEntry(jarAdd); // Write file to archive Added: trunk/jar/src/test/java/net/components4oaw/jar/JarCompressTest.java =================================================================== --- trunk/jar/src/test/java/net/components4oaw/jar/JarCompressTest.java (rev 0) +++ trunk/jar/src/test/java/net/components4oaw/jar/JarCompressTest.java 2007-08-25 19:56:15 UTC (rev 23) @@ -0,0 +1,43 @@ +package net.components4oaw.jar; + +import static org.junit.Assert.assertTrue; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.openarchitectureware.workflow.issues.Issues; +import org.openarchitectureware.workflow.issues.IssuesImpl; + +public class JarCompressTest { + + private JarCompress compress; + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + @Before + public void setUp() throws Exception { + compress = new JarCompress(); + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testCheckConfiguration() { + compress.setInputDir(null); + compress.setOutputFile(null); + Issues issues = new IssuesImpl(); + compress.checkConfiguration(issues); + assertTrue(issues.hasErrors()); + } + +} Property changes on: trunk/jar/src/test/java/net/components4oaw/jar/JarCompressTest.java ___________________________________________________________________ Name: svn:mime-type + text/plain This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |