@Override public String toString() { return getState() + " " + getArtifact() + " - " + getFile(); }
/** * Creates a new upload with the specified properties. * * @param artifact The artifact to upload, may be {@code null}. * @param file The local file to upload the artifact from, may be {@code null}. */ public ArtifactUpload( Artifact artifact, File file ) { setArtifact( artifact ); setFile( file ); }
@Override public void put(Collection<? extends ArtifactUpload> artifactUploads, Collection<? extends MetadataUpload> metadataUploads) { if (artifactUploads != null) { for (ArtifactUpload a : artifactUploads) { a.setException(new ArtifactNotFoundException(a.getArtifact(), repository)); } } if (metadataUploads != null) { for (MetadataUpload m : metadataUploads) { m.setException(new MetadataNotFoundException(m.getMetadata(), repository)); } } }
String path = layout.getPath( upload.getArtifact() ).getPath(); PutTask<?> task = new PutTask<ArtifactTransfer>( path, upload.getFile(), latch, upload, ARTIFACT ); tasks.add( task ); task.run();
if ( upload.getException() != null ) throw new DeploymentException( "Failed to deploy artifacts: " + upload.getException().getMessage(), upload.getException() ); result.addArtifact( upload.getArtifact() );
ArtifactUpload upA = new ArtifactUpload( artifact, emptyFile ); File dir = TestFileUtils.createTempDir( "con-test" ); File downAFile = new File( dir, "downA.file" ); connector.get( Arrays.asList( downA ), Arrays.asList( downM ) ); assertNull( String.valueOf( upA.getException() ), upA.getException() ); assertNull( String.valueOf( upM.getException() ), upM.getException() ); assertNull( String.valueOf( downA.getException() ), downA.getException() );
@Test public void testBlocking() throws NoRepositoryConnectorException, IOException { RepositoryConnector connector = factory().newInstance( session, repository ); int count = 10; byte[] pattern = "tmpFile".getBytes( "UTF-8" ); File tmpFile = TestFileUtils.createTempFile( pattern, 100000 ); List<ArtifactUpload> artUps = ConnectorTestUtils.createTransfers( ArtifactUpload.class, count, tmpFile ); List<MetadataUpload> metaUps = ConnectorTestUtils.createTransfers( MetadataUpload.class, count, tmpFile ); List<ArtifactDownload> artDowns = ConnectorTestUtils.createTransfers( ArtifactDownload.class, count, null ); List<MetadataDownload> metaDowns = ConnectorTestUtils.createTransfers( MetadataDownload.class, count, null ); // this should block until all transfers are done - racing condition, better way to test this? connector.put( artUps, metaUps ); connector.get( artDowns, metaDowns ); for ( int i = 0; i < count; i++ ) { ArtifactUpload artUp = artUps.get( i ); MetadataUpload metaUp = metaUps.get( i ); ArtifactDownload artDown = artDowns.get( i ); MetadataDownload metaDown = metaDowns.get( i ); assertTrue( Transfer.State.DONE.equals( artUp.getState() ) ); assertTrue( Transfer.State.DONE.equals( artDown.getState() ) ); assertTrue( Transfer.State.DONE.equals( metaUp.getState() ) ); assertTrue( Transfer.State.DONE.equals( metaDown.getState() ) ); } connector.close(); }
obj = new ArtifactUpload( artifact, file );
String path = layout.getPath( upload.getArtifact() ).getPath(); PutTask<?> task = new PutTask<ArtifactTransfer>( path, upload.getFile(), latch, upload, ARTIFACT ); tasks.add( task ); task.run();
if ( upload.getException() != null ) throw new DeploymentException( "Failed to deploy artifacts: " + upload.getException().getMessage(), upload.getException() ); result.addArtifact( upload.getArtifact() );
ArtifactUpload upA = new ArtifactUpload( artifact, emptyFile ); File dir = TestFileUtils.createTempDir( "con-test" ); File downAFile = new File( dir, "downA.file" ); connector.get( Arrays.asList( downA ), Arrays.asList( downM ) ); assertNull( String.valueOf( upA.getException() ), upA.getException() ); assertNull( String.valueOf( upM.getException() ), upM.getException() ); assertNull( String.valueOf( downA.getException() ), downA.getException() );
@Test public void testBlocking() throws NoRepositoryConnectorException, IOException { RepositoryConnector connector = factory().newInstance( session, repository ); int count = 10; byte[] pattern = "tmpFile".getBytes( "UTF-8" ); File tmpFile = TestFileUtils.createTempFile( pattern, 100000 ); List<ArtifactUpload> artUps = ConnectorTestUtils.createTransfers( ArtifactUpload.class, count, tmpFile ); List<MetadataUpload> metaUps = ConnectorTestUtils.createTransfers( MetadataUpload.class, count, tmpFile ); List<ArtifactDownload> artDowns = ConnectorTestUtils.createTransfers( ArtifactDownload.class, count, null ); List<MetadataDownload> metaDowns = ConnectorTestUtils.createTransfers( MetadataDownload.class, count, null ); // this should block until all transfers are done - racing condition, better way to test this? connector.put( artUps, metaUps ); connector.get( artDowns, metaDowns ); for ( int i = 0; i < count; i++ ) { ArtifactUpload artUp = artUps.get( i ); MetadataUpload metaUp = metaUps.get( i ); ArtifactDownload artDown = artDowns.get( i ); MetadataDownload metaDown = metaDowns.get( i ); assertTrue( Transfer.State.DONE.equals( artUp.getState() ) ); assertTrue( Transfer.State.DONE.equals( artDown.getState() ) ); assertTrue( Transfer.State.DONE.equals( metaUp.getState() ) ); assertTrue( Transfer.State.DONE.equals( metaDown.getState() ) ); } connector.close(); }
obj = new ArtifactUpload( artifact, file );
public void put( Collection<? extends ArtifactUpload> artifactUploads, Collection<? extends MetadataUpload> metadataUploads ) { if ( closed ) { throw new IllegalStateException( "connector closed" ); } artifactUploads = safe( artifactUploads ); metadataUploads = safe( metadataUploads ); for ( ArtifactUpload upload : artifactUploads ) { String path = layout.getPath( upload.getArtifact() ).getPath(); PutTask<?> task = new PutTask<ArtifactTransfer>( path, upload.getFile(), upload, ARTIFACT ); task.run(); } for ( MetadataUpload upload : metadataUploads ) { String path = layout.getPath( upload.getMetadata() ).getPath(); PutTask<?> task = new PutTask<MetadataTransfer>( path, upload.getFile(), upload, METADATA ); task.run(); } }
@Test public void testFileHandleLeakage() throws IOException, NoRepositoryConnectorException { StubArtifact artifact = new StubArtifact( "testGroup", "testArtifact", "", "jar", "1-test" ); StubMetadata metadata = new StubMetadata( "testGroup", "testArtifact", "1-test", "maven-metadata.xml", Metadata.Nature.RELEASE_OR_SNAPSHOT ); RepositoryConnector connector = factory().newInstance( session, repository ); File tmpFile = TestFileUtils.createTempFile( "testFileHandleLeakage" ); ArtifactUpload artUp = new ArtifactUpload( artifact, tmpFile ); connector.put( Arrays.asList( artUp ), null ); assertTrue( "Leaking file handle in artifact upload", tmpFile.delete() ); tmpFile = TestFileUtils.createTempFile( "testFileHandleLeakage" ); MetadataUpload metaUp = new MetadataUpload( metadata, tmpFile ); connector.put( null, Arrays.asList( metaUp ) ); assertTrue( "Leaking file handle in metadata upload", tmpFile.delete() ); tmpFile = TestFileUtils.createTempFile( "testFileHandleLeakage" ); ArtifactDownload artDown = new ArtifactDownload( artifact, null, tmpFile, null ); connector.get( Arrays.asList( artDown ), null ); new File( tmpFile.getAbsolutePath() + ".sha1" ).deleteOnExit(); assertTrue( "Leaking file handle in artifact download", tmpFile.delete() ); tmpFile = TestFileUtils.createTempFile( "testFileHandleLeakage" ); MetadataDownload metaDown = new MetadataDownload( metadata, null, tmpFile, null ); connector.get( null, Arrays.asList( metaDown ) ); new File( tmpFile.getAbsolutePath() + ".sha1" ).deleteOnExit(); assertTrue( "Leaking file handle in metadata download", tmpFile.delete() ); connector.close(); }
@Test public void testFileHandleLeakage() throws IOException, NoRepositoryConnectorException { StubArtifact artifact = new StubArtifact( "testGroup", "testArtifact", "", "jar", "1-test" ); StubMetadata metadata = new StubMetadata( "testGroup", "testArtifact", "1-test", "maven-metadata.xml", Metadata.Nature.RELEASE_OR_SNAPSHOT ); RepositoryConnector connector = factory().newInstance( session, repository ); File tmpFile = TestFileUtils.createTempFile( "testFileHandleLeakage" ); ArtifactUpload artUp = new ArtifactUpload( artifact, tmpFile ); connector.put( Arrays.asList( artUp ), null ); assertTrue( "Leaking file handle in artifact upload", tmpFile.delete() ); tmpFile = TestFileUtils.createTempFile( "testFileHandleLeakage" ); MetadataUpload metaUp = new MetadataUpload( metadata, tmpFile ); connector.put( null, Arrays.asList( metaUp ) ); assertTrue( "Leaking file handle in metadata upload", tmpFile.delete() ); tmpFile = TestFileUtils.createTempFile( "testFileHandleLeakage" ); ArtifactDownload artDown = new ArtifactDownload( artifact, null, tmpFile, null ); connector.get( Arrays.asList( artDown ), null ); new File( tmpFile.getAbsolutePath() + ".sha1" ).deleteOnExit(); assertTrue( "Leaking file handle in artifact download", tmpFile.delete() ); tmpFile = TestFileUtils.createTempFile( "testFileHandleLeakage" ); MetadataDownload metaDown = new MetadataDownload( metadata, null, tmpFile, null ); connector.get( null, Arrays.asList( metaDown ) ); new File( tmpFile.getAbsolutePath() + ".sha1" ).deleteOnExit(); assertTrue( "Leaking file handle in metadata download", tmpFile.delete() ); connector.close(); }
ArtifactUpload upA = new ArtifactUpload( artifact, file );
ArtifactUpload upA = new ArtifactUpload( artifact, file );
Metadata.Nature.RELEASE_OR_SNAPSHOT ); ArtifactUpload artUp = new ArtifactUpload( art, artifactFile ); MetadataUpload metaUp = new MetadataUpload( meta, metadataFile );
Metadata.Nature.RELEASE_OR_SNAPSHOT ); ArtifactUpload artUp = new ArtifactUpload( art, artifactFile ); MetadataUpload metaUp = new MetadataUpload( meta, metadataFile );