Return-Path: Delivered-To: apmail-maven-commits-archive@www.apache.org Received: (qmail 56990 invoked from network); 19 Nov 2006 14:26:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 19 Nov 2006 14:26:45 -0000 Received: (qmail 93439 invoked by uid 500); 19 Nov 2006 14:26:54 -0000 Delivered-To: apmail-maven-commits-archive@maven.apache.org Received: (qmail 93198 invoked by uid 500); 19 Nov 2006 14:26:53 -0000 Mailing-List: contact commits-help@maven.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@maven.apache.org Delivered-To: mailing list commits@maven.apache.org Received: (qmail 93181 invoked by uid 99); 19 Nov 2006 14:26:53 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 19 Nov 2006 06:26:53 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 19 Nov 2006 06:26:41 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id 20CA21A984F; Sun, 19 Nov 2006 06:26:09 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r476826 [2/2] - in /maven/plugins/trunk/maven-ejb-plugin/src/test: java/org/apache/maven/plugin/ejb/ java/org/apache/maven/plugin/ejb/stub/ java/org/apache/maven/plugin/ejb/utils/ resources/unit/ejbmojotest/ Date: Sun, 19 Nov 2006 14:26:08 -0000 To: commits@maven.apache.org From: dennisl@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20061119142609.20CA21A984F@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: maven/plugins/trunk/maven-ejb-plugin/src/test/java/org/apache/maven/plugin/ejb/stub/MavenProjectBuildStub.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ejb-plugin/src/test/java/org/apache/maven/plugin/ejb/stub/MavenProjectBuildStub.java?view=diff&rev=476826&r1=476825&r2=476826 ============================================================================== --- maven/plugins/trunk/maven-ejb-plugin/src/test/java/org/apache/maven/plugin/ejb/stub/MavenProjectBuildStub.java (original) +++ maven/plugins/trunk/maven-ejb-plugin/src/test/java/org/apache/maven/plugin/ejb/stub/MavenProjectBuildStub.java Sun Nov 19 06:26:07 2006 @@ -1,343 +1,343 @@ -package org.apache.maven.plugin.ejb.stub; - -/* - * Copyright 2001-2006 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -import org.apache.maven.model.Build; -import org.codehaus.plexus.util.FileUtils; - -/** - * Stub - */ -public class MavenProjectBuildStub - extends MavenProjectBasicStub -{ - public static final int RESOURCES_FILE = 1; - - public static final int ROOT_FILE = 2; - - public static final int OUTPUT_FILE = 3; - - public static final int SOURCE_FILE = 4; - - protected Build build; - - protected String srcDirectory; - - protected String targetDirectory; - - protected String buildDirectory; - - protected String outputDirectory; - - protected String testOutputDirectory; - - protected String resourcesDirectory; - - protected String testResourcesDirectory; - - protected String targetResourceDirectory; - - protected String targetTestResourcesDirectory; - - protected ArrayList targetClassesList; - - protected ArrayList sourceFileList; - - protected ArrayList resourcesFileList; - - protected ArrayList rootFileList; - - protected ArrayList directoryList; - - protected HashMap dataMap; - - public MavenProjectBuildStub( String key ) - throws Exception - { - super( key ); - - build = new Build(); - resourcesFileList = new ArrayList(); - sourceFileList = new ArrayList(); - rootFileList = new ArrayList(); - directoryList = new ArrayList(); - targetClassesList = new ArrayList(); - dataMap = new HashMap(); - setupBuild(); - } - - public void addDirectory( String name ) - { - if ( isValidPath( name ) ) - { - directoryList.add( name ); - } - } - - public void setOutputDirectory( String dir ) - { - outputDirectory = buildDirectory + "/" + dir; - build.setOutputDirectory( outputDirectory ); - } - - public void addFile( String name, int type ) - { - if ( isValidPath( name ) ) - { - List list = getList( type ); - - list.add( name ); - } - } - - public void addFile( String name, String data, int type ) - { - File fileName = new File( name ); - - addFile( name, type ); - dataMap.put( fileName.getName(), data ); - } - - public String getOutputDirectory() - { - return outputDirectory; - } - - public String getTestOutputDirectory() - { - return testOutputDirectory; - } - - public String getResourcesDirectory() - { - return resourcesDirectory; - } - - public String getTestResourcesDirectory() - { - return testResourcesDirectory; - } - - public Build getBuild() - { - return build; - } - - /** - * returns true if the path is relative - * and false if absolute - * also returns false if it is relative to - * the parent - * - * @param path - * @return - */ - private boolean isValidPath( String path ) - { - boolean bRetVal = true; - - if ( path.startsWith( "c:" ) || path.startsWith( ".." ) || path.startsWith( "/" ) || path.startsWith( "\\" ) ) - { - bRetVal = false; - } - - return bRetVal; - } - - private void setupBuild() - { - // check getBasedir method for the exact path - // we need to recreate the dir structure in - // an isolated environment - srcDirectory = testRootDir + "/src"; - buildDirectory = testRootDir + "/target"; - outputDirectory = buildDirectory + "/classes"; - testOutputDirectory = buildDirectory + "/test-classes"; - resourcesDirectory = srcDirectory + "/main/resources/"; - testResourcesDirectory = srcDirectory + "/test/resources/"; - - build.setDirectory( buildDirectory ); - build.setOutputDirectory( outputDirectory ); - build.setTestOutputDirectory( testOutputDirectory ); - } - - public void setupBuildEnvironment() - throws Exception - { - // populate dummy resources and dummy test resources - - // setup src dir - if ( !FileUtils.fileExists( resourcesDirectory ) ) - { - FileUtils.mkdir( resourcesDirectory ); - } - - if ( !FileUtils.fileExists( testResourcesDirectory ) ) - { - FileUtils.mkdir( testResourcesDirectory ); - } - - createDirectories( resourcesDirectory, testResourcesDirectory ); - createFiles( resourcesDirectory, testResourcesDirectory ); - setupRootFiles(); - - // setup target dir - if ( !FileUtils.fileExists( outputDirectory ) ) - { - FileUtils.mkdir( outputDirectory ); - } - - if ( !FileUtils.fileExists( testOutputDirectory ) ) - { - FileUtils.mkdir( testOutputDirectory ); - } - - setupTargetFiles(); - } - - private void createDirectories( String parent, String testparent ) - { - File currentDirectory; - - for ( int nIndex = 0; nIndex < directoryList.size(); nIndex++ ) - { - currentDirectory = new File( parent, "/" + (String) directoryList.get( nIndex ) ); - - if ( !currentDirectory.exists() ) - { - currentDirectory.mkdirs(); - } - - // duplicate dir structure in test resources - currentDirectory = new File( testparent, "/" + (String) directoryList.get( nIndex ) ); - - if ( !currentDirectory.exists() ) - { - currentDirectory.mkdirs(); - } - } - } - - private List getList( int type ) - { - ArrayList retVal = null; - - switch ( type ) - { - case SOURCE_FILE : - retVal = sourceFileList; - break; - case OUTPUT_FILE : - retVal = targetClassesList; - break; - case RESOURCES_FILE : - retVal = resourcesFileList; - break; - case ROOT_FILE : - retVal = rootFileList; - break; - } - - return retVal; - } - - private void createFiles( String parent, int type ) - { - File currentFile; - ArrayList list = (ArrayList) getList( type ); - - // guard - if ( list == null ) - { - return; - } - - for ( int nIndex = 0; nIndex < list.size(); nIndex++ ) - { - currentFile = new File( parent, (String) list.get( nIndex ) ); - - // create the necessary parent directories - // before we create the files - if ( !currentFile.getParentFile().exists() ) - { - currentFile.getParentFile().mkdirs(); - } - - if ( !currentFile.exists() ) - { - try - { - currentFile.createNewFile(); - populateFile( currentFile, RESOURCES_FILE ); - } - catch ( IOException io ) - { - //TODO: handle exception - } - } - } - } - - private void setupRootFiles() - { - createFiles( testRootDir, ROOT_FILE ); - } - - private void setupTargetFiles() - { - createFiles( getOutputDirectory(), OUTPUT_FILE ); - } - - private void setupSourceFiles() - { - createFiles( srcDirectory, SOURCE_FILE ); - } - - private void createFiles( String parent, String testparent ) - { - createFiles( parent, RESOURCES_FILE ); - createFiles( testparent, RESOURCES_FILE ); - } - - private void populateFile( File file, int type ) - { - FileOutputStream outputStream; - String data = data = (String) dataMap.get( file.getName() ); - - if ( ( data != null ) && file.exists() ) - { - try - { - outputStream = new FileOutputStream( file ); - outputStream.write( data.getBytes() ); - outputStream.flush(); - outputStream.close(); - } - catch ( IOException ex ) - { - // TODO: handle exception here - } - } - } -} +package org.apache.maven.plugin.ejb.stub; + +/* + * Copyright 2001-2006 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import org.apache.maven.model.Build; +import org.codehaus.plexus.util.FileUtils; + +/** + * Stub + */ +public class MavenProjectBuildStub + extends MavenProjectBasicStub +{ + public static final int RESOURCES_FILE = 1; + + public static final int ROOT_FILE = 2; + + public static final int OUTPUT_FILE = 3; + + public static final int SOURCE_FILE = 4; + + protected Build build; + + protected String srcDirectory; + + protected String targetDirectory; + + protected String buildDirectory; + + protected String outputDirectory; + + protected String testOutputDirectory; + + protected String resourcesDirectory; + + protected String testResourcesDirectory; + + protected String targetResourceDirectory; + + protected String targetTestResourcesDirectory; + + protected ArrayList targetClassesList; + + protected ArrayList sourceFileList; + + protected ArrayList resourcesFileList; + + protected ArrayList rootFileList; + + protected ArrayList directoryList; + + protected HashMap dataMap; + + public MavenProjectBuildStub( String key ) + throws Exception + { + super( key ); + + build = new Build(); + resourcesFileList = new ArrayList(); + sourceFileList = new ArrayList(); + rootFileList = new ArrayList(); + directoryList = new ArrayList(); + targetClassesList = new ArrayList(); + dataMap = new HashMap(); + setupBuild(); + } + + public void addDirectory( String name ) + { + if ( isValidPath( name ) ) + { + directoryList.add( name ); + } + } + + public void setOutputDirectory( String dir ) + { + outputDirectory = buildDirectory + "/" + dir; + build.setOutputDirectory( outputDirectory ); + } + + public void addFile( String name, int type ) + { + if ( isValidPath( name ) ) + { + List list = getList( type ); + + list.add( name ); + } + } + + public void addFile( String name, String data, int type ) + { + File fileName = new File( name ); + + addFile( name, type ); + dataMap.put( fileName.getName(), data ); + } + + public String getOutputDirectory() + { + return outputDirectory; + } + + public String getTestOutputDirectory() + { + return testOutputDirectory; + } + + public String getResourcesDirectory() + { + return resourcesDirectory; + } + + public String getTestResourcesDirectory() + { + return testResourcesDirectory; + } + + public Build getBuild() + { + return build; + } + + /** + * returns true if the path is relative + * and false if absolute + * also returns false if it is relative to + * the parent + * + * @param path + * @return + */ + private boolean isValidPath( String path ) + { + boolean bRetVal = true; + + if ( path.startsWith( "c:" ) || path.startsWith( ".." ) || path.startsWith( "/" ) || path.startsWith( "\\" ) ) + { + bRetVal = false; + } + + return bRetVal; + } + + private void setupBuild() + { + // check getBasedir method for the exact path + // we need to recreate the dir structure in + // an isolated environment + srcDirectory = testRootDir + "/src"; + buildDirectory = testRootDir + "/target"; + outputDirectory = buildDirectory + "/classes"; + testOutputDirectory = buildDirectory + "/test-classes"; + resourcesDirectory = srcDirectory + "/main/resources/"; + testResourcesDirectory = srcDirectory + "/test/resources/"; + + build.setDirectory( buildDirectory ); + build.setOutputDirectory( outputDirectory ); + build.setTestOutputDirectory( testOutputDirectory ); + } + + public void setupBuildEnvironment() + throws Exception + { + // populate dummy resources and dummy test resources + + // setup src dir + if ( !FileUtils.fileExists( resourcesDirectory ) ) + { + FileUtils.mkdir( resourcesDirectory ); + } + + if ( !FileUtils.fileExists( testResourcesDirectory ) ) + { + FileUtils.mkdir( testResourcesDirectory ); + } + + createDirectories( resourcesDirectory, testResourcesDirectory ); + createFiles( resourcesDirectory, testResourcesDirectory ); + setupRootFiles(); + + // setup target dir + if ( !FileUtils.fileExists( outputDirectory ) ) + { + FileUtils.mkdir( outputDirectory ); + } + + if ( !FileUtils.fileExists( testOutputDirectory ) ) + { + FileUtils.mkdir( testOutputDirectory ); + } + + setupTargetFiles(); + } + + private void createDirectories( String parent, String testparent ) + { + File currentDirectory; + + for ( int nIndex = 0; nIndex < directoryList.size(); nIndex++ ) + { + currentDirectory = new File( parent, "/" + (String) directoryList.get( nIndex ) ); + + if ( !currentDirectory.exists() ) + { + currentDirectory.mkdirs(); + } + + // duplicate dir structure in test resources + currentDirectory = new File( testparent, "/" + (String) directoryList.get( nIndex ) ); + + if ( !currentDirectory.exists() ) + { + currentDirectory.mkdirs(); + } + } + } + + private List getList( int type ) + { + ArrayList retVal = null; + + switch ( type ) + { + case SOURCE_FILE : + retVal = sourceFileList; + break; + case OUTPUT_FILE : + retVal = targetClassesList; + break; + case RESOURCES_FILE : + retVal = resourcesFileList; + break; + case ROOT_FILE : + retVal = rootFileList; + break; + } + + return retVal; + } + + private void createFiles( String parent, int type ) + { + File currentFile; + ArrayList list = (ArrayList) getList( type ); + + // guard + if ( list == null ) + { + return; + } + + for ( int nIndex = 0; nIndex < list.size(); nIndex++ ) + { + currentFile = new File( parent, (String) list.get( nIndex ) ); + + // create the necessary parent directories + // before we create the files + if ( !currentFile.getParentFile().exists() ) + { + currentFile.getParentFile().mkdirs(); + } + + if ( !currentFile.exists() ) + { + try + { + currentFile.createNewFile(); + populateFile( currentFile, RESOURCES_FILE ); + } + catch ( IOException io ) + { + //TODO: handle exception + } + } + } + } + + private void setupRootFiles() + { + createFiles( testRootDir, ROOT_FILE ); + } + + private void setupTargetFiles() + { + createFiles( getOutputDirectory(), OUTPUT_FILE ); + } + + private void setupSourceFiles() + { + createFiles( srcDirectory, SOURCE_FILE ); + } + + private void createFiles( String parent, String testparent ) + { + createFiles( parent, RESOURCES_FILE ); + createFiles( testparent, RESOURCES_FILE ); + } + + private void populateFile( File file, int type ) + { + FileOutputStream outputStream; + String data = data = (String) dataMap.get( file.getName() ); + + if ( ( data != null ) && file.exists() ) + { + try + { + outputStream = new FileOutputStream( file ); + outputStream.write( data.getBytes() ); + outputStream.flush(); + outputStream.close(); + } + catch ( IOException ex ) + { + // TODO: handle exception here + } + } + } +} Propchange: maven/plugins/trunk/maven-ejb-plugin/src/test/java/org/apache/maven/plugin/ejb/stub/MavenProjectBuildStub.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: maven/plugins/trunk/maven-ejb-plugin/src/test/java/org/apache/maven/plugin/ejb/stub/MavenProjectResourcesStub.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ejb-plugin/src/test/java/org/apache/maven/plugin/ejb/stub/MavenProjectResourcesStub.java?view=diff&rev=476826&r1=476825&r2=476826 ============================================================================== --- maven/plugins/trunk/maven-ejb-plugin/src/test/java/org/apache/maven/plugin/ejb/stub/MavenProjectResourcesStub.java (original) +++ maven/plugins/trunk/maven-ejb-plugin/src/test/java/org/apache/maven/plugin/ejb/stub/MavenProjectResourcesStub.java Sun Nov 19 06:26:07 2006 @@ -1,112 +1,112 @@ -package org.apache.maven.plugin.ejb.stub; - -/* - * Copyright 2001-2006 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import org.apache.maven.model.Resource; - - -/** - * Stub - */ -public class MavenProjectResourcesStub - extends MavenProjectBuildStub -{ - - public MavenProjectResourcesStub( String id ) - throws Exception - { - super( id ); - setupResources(); - setupTestResources(); - } - - public void addInclude( String pattern ) - { - ( (Resource) build.getResources().get( 0 ) ).addInclude( pattern ); - } - - public void addExclude( String pattern ) - { - ( (Resource) build.getResources().get( 0 ) ).addExclude( pattern ); - } - - public void addTestInclude( String pattern ) - { - ( (Resource) build.getTestResources().get( 0 ) ).addInclude( pattern ); - } - - public void addTestExclude( String pattern ) - { - ( (Resource) build.getTestResources().get( 0 ) ).addExclude( pattern ); - } - - public void setTargetPath( String path ) - { - ( (Resource) build.getResources().get( 0 ) ).setTargetPath( path ); - } - - public void setTestTargetPath( String path ) - { - ( (Resource) build.getTestResources().get( 0 ) ).setTargetPath( path ); - } - - public void setDirectory( String dir ) - { - ( (Resource) build.getResources().get( 0 ) ).setDirectory( dir ); - } - - public void setTestDirectory( String dir ) - { - ( (Resource) build.getTestResources().get( 0 ) ).setDirectory( dir ); - } - - public void setResourceFiltering( int nIndex, boolean filter ) - { - if ( build.getResources().size() > nIndex ) - { - ( (Resource) build.getResources().get( nIndex ) ).setFiltering( filter ); - } - } - - private void setupResources() - { - Resource resource = new Resource(); - - // see MavenProjectBasicStub for details - // of getBasedir - - // setup default resources - resource.setDirectory( getBasedir().getPath() + "/src/main/resources" ); - resource.setFiltering( false ); - resource.setTargetPath( null ); - build.addResource( resource ); - } - - private void setupTestResources() - { - Resource resource = new Resource(); - - // see MavenProjectBasicStub for details - // of getBasedir - - // setup default test resources - resource.setDirectory( getBasedir().getPath() + "/src/test/resources" ); - resource.setFiltering( false ); - resource.setTargetPath( null ); - build.addTestResource( resource ); - } -} +package org.apache.maven.plugin.ejb.stub; + +/* + * Copyright 2001-2006 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import org.apache.maven.model.Resource; + + +/** + * Stub + */ +public class MavenProjectResourcesStub + extends MavenProjectBuildStub +{ + + public MavenProjectResourcesStub( String id ) + throws Exception + { + super( id ); + setupResources(); + setupTestResources(); + } + + public void addInclude( String pattern ) + { + ( (Resource) build.getResources().get( 0 ) ).addInclude( pattern ); + } + + public void addExclude( String pattern ) + { + ( (Resource) build.getResources().get( 0 ) ).addExclude( pattern ); + } + + public void addTestInclude( String pattern ) + { + ( (Resource) build.getTestResources().get( 0 ) ).addInclude( pattern ); + } + + public void addTestExclude( String pattern ) + { + ( (Resource) build.getTestResources().get( 0 ) ).addExclude( pattern ); + } + + public void setTargetPath( String path ) + { + ( (Resource) build.getResources().get( 0 ) ).setTargetPath( path ); + } + + public void setTestTargetPath( String path ) + { + ( (Resource) build.getTestResources().get( 0 ) ).setTargetPath( path ); + } + + public void setDirectory( String dir ) + { + ( (Resource) build.getResources().get( 0 ) ).setDirectory( dir ); + } + + public void setTestDirectory( String dir ) + { + ( (Resource) build.getTestResources().get( 0 ) ).setDirectory( dir ); + } + + public void setResourceFiltering( int nIndex, boolean filter ) + { + if ( build.getResources().size() > nIndex ) + { + ( (Resource) build.getResources().get( nIndex ) ).setFiltering( filter ); + } + } + + private void setupResources() + { + Resource resource = new Resource(); + + // see MavenProjectBasicStub for details + // of getBasedir + + // setup default resources + resource.setDirectory( getBasedir().getPath() + "/src/main/resources" ); + resource.setFiltering( false ); + resource.setTargetPath( null ); + build.addResource( resource ); + } + + private void setupTestResources() + { + Resource resource = new Resource(); + + // see MavenProjectBasicStub for details + // of getBasedir + + // setup default test resources + resource.setDirectory( getBasedir().getPath() + "/src/test/resources" ); + resource.setFiltering( false ); + resource.setTargetPath( null ); + build.addTestResource( resource ); + } +} Propchange: maven/plugins/trunk/maven-ejb-plugin/src/test/java/org/apache/maven/plugin/ejb/stub/MavenProjectResourcesStub.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: maven/plugins/trunk/maven-ejb-plugin/src/test/java/org/apache/maven/plugin/ejb/stub/ModelStub.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ejb-plugin/src/test/java/org/apache/maven/plugin/ejb/stub/ModelStub.java?view=diff&rev=476826&r1=476825&r2=476826 ============================================================================== --- maven/plugins/trunk/maven-ejb-plugin/src/test/java/org/apache/maven/plugin/ejb/stub/ModelStub.java (original) +++ maven/plugins/trunk/maven-ejb-plugin/src/test/java/org/apache/maven/plugin/ejb/stub/ModelStub.java Sun Nov 19 06:26:07 2006 @@ -1,87 +1,87 @@ -package org.apache.maven.plugin.ejb.stub; - -/* - * Copyright 2001-2006 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.util.LinkedList; -import java.util.List; -import java.util.Properties; - -import org.apache.maven.model.Model; -import org.apache.maven.model.Parent; - -/** - * Stub - */ -public class ModelStub - extends Model -{ - public ModelStub() - { - - } - - public String getVersion() - { - return "0.0-TEST"; - } - - public String getModelVersion() - { - return "0.0-TEST"; - } - - public String getName() - { - return "Test Model"; - } - - public String getGroupId() - { - return "org.apache.maven.test"; - } - - public String getPackaging() - { - return "jar"; - } - - public Parent getParent() - { - //return new Parent(); - return null; - } - - public String getArtifactId() - { - return "maven-test-plugin"; - } - - public Properties getProperties() - { - return new Properties(); - } - - public List getPackages() - { - return new LinkedList(); - } - - public List getProfiles() - { - return new LinkedList(); - } -} +package org.apache.maven.plugin.ejb.stub; + +/* + * Copyright 2001-2006 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.util.LinkedList; +import java.util.List; +import java.util.Properties; + +import org.apache.maven.model.Model; +import org.apache.maven.model.Parent; + +/** + * Stub + */ +public class ModelStub + extends Model +{ + public ModelStub() + { + + } + + public String getVersion() + { + return "0.0-TEST"; + } + + public String getModelVersion() + { + return "0.0-TEST"; + } + + public String getName() + { + return "Test Model"; + } + + public String getGroupId() + { + return "org.apache.maven.test"; + } + + public String getPackaging() + { + return "jar"; + } + + public Parent getParent() + { + //return new Parent(); + return null; + } + + public String getArtifactId() + { + return "maven-test-plugin"; + } + + public Properties getProperties() + { + return new Properties(); + } + + public List getPackages() + { + return new LinkedList(); + } + + public List getProfiles() + { + return new LinkedList(); + } +} Propchange: maven/plugins/trunk/maven-ejb-plugin/src/test/java/org/apache/maven/plugin/ejb/stub/ModelStub.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: maven/plugins/trunk/maven-ejb-plugin/src/test/java/org/apache/maven/plugin/ejb/utils/JarContentChecker.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ejb-plugin/src/test/java/org/apache/maven/plugin/ejb/utils/JarContentChecker.java?view=diff&rev=476826&r1=476825&r2=476826 ============================================================================== --- maven/plugins/trunk/maven-ejb-plugin/src/test/java/org/apache/maven/plugin/ejb/utils/JarContentChecker.java (original) +++ maven/plugins/trunk/maven-ejb-plugin/src/test/java/org/apache/maven/plugin/ejb/utils/JarContentChecker.java Sun Nov 19 06:26:07 2006 @@ -1,177 +1,177 @@ -package org.apache.maven.plugin.ejb.utils; - -/* - * Copyright 2001-2006 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Iterator; -import java.util.jar.JarFile; -import java.util.zip.ZipEntry; - -/** - * Jar Content Checker - */ -public class JarContentChecker -{ - private final static String FOUND = "1"; - - private final static String NOT_FOUND = "0"; - - private HashMap fileMap; - - private HashMap directoryMap; - - private HashMap dataMap; - - - public JarContentChecker() - { - fileMap = new HashMap(); - directoryMap = new HashMap(); - dataMap = new HashMap(); - } - - public void addDirectory( File dir ) - { - directoryMap.put( dir, NOT_FOUND ); - } - - public void addFile( File file ) - { - fileMap.put( file, NOT_FOUND ); - } - - public void addFile( String file, String data ) - { - fileMap.put( file, NOT_FOUND ); - dataMap.put( file, data ); - } - - - /** - * checks whether the jar file contains the files for this checker, - * files with the same file name but with different data will not - * be considered. - * - * @param File - * @return boolean - */ - public boolean isOK( JarFile jarFile ) - { - boolean bRetVal = false; - Enumeration zipentries = jarFile.entries(); - ZipEntry entry; - File entryFile; - - resetList(); - - while ( zipentries.hasMoreElements() ) - { - entry = (ZipEntry) zipentries.nextElement(); - entryFile = new File( entry.getName() ); - - if ( entry.isDirectory() ) - { - // cross out all files found in the jar file - // found files with incorrect content will not - // be counted - if ( directoryMap.containsKey( entryFile ) ) - { - directoryMap.put( entryFile, FOUND ); - } - } - else if ( fileMap.containsKey( entryFile ) ) - { - try - { - if ( checkContent( entryFile, jarFile.getInputStream( entry ) ) ) - { - fileMap.put( entryFile, FOUND ); - } - } - catch ( IOException ex ) - { - // TODO: handle exception - } - } - } - - bRetVal = checkFinalResult(); - - return bRetVal; - } - - - private boolean checkContent( File file, InputStream istream ) - { - boolean bRetVal = true; - - if ( dataMap.containsKey( file ) ) - { - // TODO: do content checking here - } - - return bRetVal; - } - - private boolean checkFinalResult() - { - boolean bRetVal = true; - - Iterator keys = fileMap.keySet().iterator(); - - while ( keys.hasNext() && bRetVal ) - { - if ( fileMap.get( keys.next() ).equals( NOT_FOUND ) ) - { - bRetVal = false; - } - } - - keys = directoryMap.keySet().iterator(); - - while ( keys.hasNext() && bRetVal ) - { - if ( directoryMap.get( keys.next() ).equals( NOT_FOUND ) ) - { - bRetVal = false; - } - } - - return bRetVal; - } - - private void resetList() - { - Iterator keys = fileMap.keySet().iterator(); - - while ( keys.hasNext() ) - { - fileMap.put( keys.next(), NOT_FOUND ); - } - - keys = directoryMap.keySet().iterator(); - - while ( keys.hasNext() ) - { - directoryMap.put( keys.next(), NOT_FOUND ); - } - } -} +package org.apache.maven.plugin.ejb.utils; + +/* + * Copyright 2001-2006 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Iterator; +import java.util.jar.JarFile; +import java.util.zip.ZipEntry; + +/** + * Jar Content Checker + */ +public class JarContentChecker +{ + private final static String FOUND = "1"; + + private final static String NOT_FOUND = "0"; + + private HashMap fileMap; + + private HashMap directoryMap; + + private HashMap dataMap; + + + public JarContentChecker() + { + fileMap = new HashMap(); + directoryMap = new HashMap(); + dataMap = new HashMap(); + } + + public void addDirectory( File dir ) + { + directoryMap.put( dir, NOT_FOUND ); + } + + public void addFile( File file ) + { + fileMap.put( file, NOT_FOUND ); + } + + public void addFile( String file, String data ) + { + fileMap.put( file, NOT_FOUND ); + dataMap.put( file, data ); + } + + + /** + * checks whether the jar file contains the files for this checker, + * files with the same file name but with different data will not + * be considered. + * + * @param File + * @return boolean + */ + public boolean isOK( JarFile jarFile ) + { + boolean bRetVal = false; + Enumeration zipentries = jarFile.entries(); + ZipEntry entry; + File entryFile; + + resetList(); + + while ( zipentries.hasMoreElements() ) + { + entry = (ZipEntry) zipentries.nextElement(); + entryFile = new File( entry.getName() ); + + if ( entry.isDirectory() ) + { + // cross out all files found in the jar file + // found files with incorrect content will not + // be counted + if ( directoryMap.containsKey( entryFile ) ) + { + directoryMap.put( entryFile, FOUND ); + } + } + else if ( fileMap.containsKey( entryFile ) ) + { + try + { + if ( checkContent( entryFile, jarFile.getInputStream( entry ) ) ) + { + fileMap.put( entryFile, FOUND ); + } + } + catch ( IOException ex ) + { + // TODO: handle exception + } + } + } + + bRetVal = checkFinalResult(); + + return bRetVal; + } + + + private boolean checkContent( File file, InputStream istream ) + { + boolean bRetVal = true; + + if ( dataMap.containsKey( file ) ) + { + // TODO: do content checking here + } + + return bRetVal; + } + + private boolean checkFinalResult() + { + boolean bRetVal = true; + + Iterator keys = fileMap.keySet().iterator(); + + while ( keys.hasNext() && bRetVal ) + { + if ( fileMap.get( keys.next() ).equals( NOT_FOUND ) ) + { + bRetVal = false; + } + } + + keys = directoryMap.keySet().iterator(); + + while ( keys.hasNext() && bRetVal ) + { + if ( directoryMap.get( keys.next() ).equals( NOT_FOUND ) ) + { + bRetVal = false; + } + } + + return bRetVal; + } + + private void resetList() + { + Iterator keys = fileMap.keySet().iterator(); + + while ( keys.hasNext() ) + { + fileMap.put( keys.next(), NOT_FOUND ); + } + + keys = directoryMap.keySet().iterator(); + + while ( keys.hasNext() ) + { + directoryMap.put( keys.next(), NOT_FOUND ); + } + } +} Propchange: maven/plugins/trunk/maven-ejb-plugin/src/test/java/org/apache/maven/plugin/ejb/utils/JarContentChecker.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: maven/plugins/trunk/maven-ejb-plugin/src/test/resources/unit/ejbmojotest/plugin-config.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ejb-plugin/src/test/resources/unit/ejbmojotest/plugin-config.xml?view=diff&rev=476826&r1=476825&r2=476826 ============================================================================== --- maven/plugins/trunk/maven-ejb-plugin/src/test/resources/unit/ejbmojotest/plugin-config.xml (original) +++ maven/plugins/trunk/maven-ejb-plugin/src/test/resources/unit/ejbmojotest/plugin-config.xml Sun Nov 19 06:26:07 2006 @@ -1,11 +1,11 @@ - - ejb-plugin-test - - - - maven-ejb-plugin - - - - - + + ejb-plugin-test + + + + maven-ejb-plugin + + + + + Propchange: maven/plugins/trunk/maven-ejb-plugin/src/test/resources/unit/ejbmojotest/plugin-config.xml ------------------------------------------------------------------------------ svn:eol-style = native