1 package org.apache.archiva.proxy;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import net.sf.ehcache.CacheManager;
23 import org.apache.archiva.admin.model.beans.ManagedRepository;
24 import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
25 import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
26 import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
27 import org.apache.archiva.configuration.ArchivaConfiguration;
28 import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
29 import org.apache.archiva.configuration.ProxyConnectorConfiguration;
30 import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
31 import org.apache.archiva.policies.CachedFailuresPolicy;
32 import org.apache.archiva.policies.ChecksumPolicy;
33 import org.apache.archiva.policies.PropagateErrorsDownloadPolicy;
34 import org.apache.archiva.policies.PropagateErrorsOnUpdateDownloadPolicy;
35 import org.apache.archiva.policies.ReleasesPolicy;
36 import org.apache.archiva.policies.SnapshotsPolicy;
37 import org.apache.archiva.repository.ManagedRepositoryContent;
38 import org.apache.commons.io.FileUtils;
39 import org.apache.commons.lang.ArrayUtils;
40 import org.apache.maven.index.NexusIndexer;
41 import org.apache.maven.index.context.IndexingContext;
42 import org.apache.maven.wagon.Wagon;
43 import org.easymock.ArgumentsMatcher;
44 import org.easymock.MockControl;
45 import org.junit.After;
46 import org.junit.Before;
47 import org.junit.runner.RunWith;
48 import org.slf4j.Logger;
49 import org.slf4j.LoggerFactory;
50 import org.springframework.context.ApplicationContext;
51 import org.springframework.test.context.ContextConfiguration;
52 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
54 import javax.inject.Inject;
55 import java.io.BufferedReader;
57 import java.io.FileReader;
58 import java.io.IOException;
59 import java.text.ParseException;
60 import java.text.SimpleDateFormat;
61 import java.util.ArrayList;
62 import java.util.Calendar;
63 import java.util.Collection;
64 import java.util.Date;
65 import java.util.Locale;
66 import org.apache.archiva.test.ArchivaSpringJUnit4ClassRunner;
68 import static org.junit.Assert.*;
71 * AbstractProxyTestCase
75 @RunWith( ArchivaSpringJUnit4ClassRunner.class )
76 @ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } )
77 public abstract class AbstractProxyTestCase
80 protected ApplicationContext applicationContext;
82 protected static final String ID_LEGACY_PROXIED = "legacy-proxied";
84 protected static final String ID_PROXIED1 = "proxied1";
86 protected static final String ID_PROXIED1_TARGET = "proxied1-target";
88 protected static final String ID_PROXIED2 = "proxied2";
90 protected static final String ID_PROXIED2_TARGET = "proxied2-target";
92 protected static final String ID_DEFAULT_MANAGED = "default-managed-repository";
94 protected static final String ID_LEGACY_MANAGED = "legacy-managed-repository";
96 protected static final String REPOPATH_PROXIED_LEGACY = "src/test/repositories/legacy-proxied";
98 protected static final String REPOPATH_PROXIED1 = "src/test/repositories/proxied1";
100 protected static final String REPOPATH_PROXIED1_TARGET = "target/test-repository/proxied1";
102 protected static final String REPOPATH_PROXIED2 = "src/test/repositories/proxied2";
104 protected static final String REPOPATH_PROXIED2_TARGET = "target/test-repository/proxied2";
106 protected static final String REPOPATH_DEFAULT_MANAGED = "src/test/repositories/managed";
108 // protected static final String REPOPATH_DEFAULT_MANAGED_TARGET = "target/test-repository/managed";
110 protected static final String REPOPATH_LEGACY_MANAGED = "src/test/repositories/legacy-managed";
112 protected static final String REPOPATH_LEGACY_MANAGED_TARGET = "target/test-repository/legacy-managed";
114 protected MockControl wagonMockControl;
116 protected Wagon wagonMock;
119 protected RepositoryProxyConnectors proxyHandler;
121 protected ManagedRepositoryContent managedDefaultRepository;
123 protected File managedDefaultDir;
125 protected ManagedRepositoryContent managedLegacyRepository;
127 protected File managedLegacyDir;
129 protected MockConfiguration config;
131 protected Logger log = LoggerFactory.getLogger( getClass() );
133 WagonDelegate delegate;
136 protected ManagedRepositoryAdmin managedRepositoryAdmin;
139 protected PlexusSisuBridge plexusSisuBridge;
146 (MockConfiguration) applicationContext.getBean( "archivaConfiguration#mock", ArchivaConfiguration.class );
148 config.getConfiguration().setManagedRepositories( new ArrayList<ManagedRepositoryConfiguration>() );
149 config.getConfiguration().setRemoteRepositories( new ArrayList<RemoteRepositoryConfiguration>() );
150 config.getConfiguration().setProxyConnectors( new ArrayList<ProxyConnectorConfiguration>() );
152 // Setup source repository (using default layout)
153 String name = getClass().getSimpleName();
154 String repoPath = "target/test-repository/managed/" + name;
155 File repoLocation = new File( repoPath );
157 managedDefaultRepository =
158 createRepository( ID_DEFAULT_MANAGED, "Default Managed Repository", repoPath, "default" );
160 managedDefaultDir = new File( managedDefaultRepository.getRepoRoot() );
162 ManagedRepository repoConfig = managedDefaultRepository.getRepository();
164 ( (DefaultManagedRepositoryAdmin) applicationContext.getBean(
165 ManagedRepositoryAdmin.class ) ).setArchivaConfiguration( config );
167 applicationContext.getBean( ManagedRepositoryAdmin.class ).addManagedRepository( repoConfig, false, null );
169 // to prevent windauze file leaking
170 removeMavenIndexes();
172 // Setup source repository (using legacy layout)
173 repoLocation = new File( REPOPATH_LEGACY_MANAGED_TARGET );
174 if ( repoLocation.exists() )
176 FileUtils.deleteDirectory( repoLocation );
178 copyDirectoryStructure( new File( REPOPATH_LEGACY_MANAGED ), repoLocation );
180 managedLegacyRepository =
181 createRepository( ID_LEGACY_MANAGED, "Legacy Managed Repository", REPOPATH_LEGACY_MANAGED_TARGET,
184 managedLegacyDir = new File( managedLegacyRepository.getRepoRoot() );
186 repoConfig = managedLegacyRepository.getRepository();
188 //config.getConfiguration().addManagedRepository( repoConfig );
189 applicationContext.getBean( ManagedRepositoryAdmin.class ).addManagedRepository( repoConfig, false, null );
191 // Setup target (proxied to) repository.
192 saveRemoteRepositoryConfig( ID_PROXIED1, "Proxied Repository 1",
193 new File( REPOPATH_PROXIED1 ).toURL().toExternalForm(), "default" );
195 // Setup target (proxied to) repository.
196 saveRemoteRepositoryConfig( ID_PROXIED2, "Proxied Repository 2",
197 new File( REPOPATH_PROXIED2 ).toURL().toExternalForm(), "default" );
199 // Setup target (proxied to) repository using legacy layout.
200 saveRemoteRepositoryConfig( ID_LEGACY_PROXIED, "Proxied Legacy Repository",
201 new File( REPOPATH_PROXIED_LEGACY ).toURL().toExternalForm(), "legacy" );
203 // Setup the proxy handler.
204 //proxyHandler = applicationContext.getBean (RepositoryProxyConnectors) lookup( RepositoryProxyConnectors.class.getName() );
206 proxyHandler = applicationContext.getBean( "repositoryProxyConnectors#test", RepositoryProxyConnectors.class );
208 // Setup the wagon mock.
209 wagonMockControl = MockControl.createNiceControl( Wagon.class );
210 wagonMock = (Wagon) wagonMockControl.getMock();
212 delegate = (WagonDelegate) applicationContext.getBean( "wagon#test", Wagon.class );
214 delegate.setDelegate( wagonMock );
216 CacheManager.getInstance().clearAll();
218 log.info( "\n.\\ " + name + "() \\._________________________________________\n" );
222 public void shutdown()
225 removeMavenIndexes();
229 protected void removeMavenIndexes()
232 NexusIndexer nexusIndexer = plexusSisuBridge.lookup( NexusIndexer.class );
234 for ( IndexingContext indexingContext : nexusIndexer.getIndexingContexts().values() )
236 nexusIndexer.removeIndexingContext( indexingContext, false );
241 protected static final ArgumentsMatcher customWagonGetIfNewerMatcher = new ArgumentsMatcher()
244 public boolean matches( Object[] expected, Object[] actual )
246 if ( expected.length < 1 || actual.length < 1 )
250 return MockControl.ARRAY_MATCHER.matches( ArrayUtils.remove( expected, 1 ),
251 ArrayUtils.remove( actual, 1 ) );
254 public String toString( Object[] arguments )
256 return ArrayUtils.toString( arguments );
260 protected static final ArgumentsMatcher customWagonGetMatcher = new ArgumentsMatcher()
263 public boolean matches( Object[] expected, Object[] actual )
265 if ( expected.length == 2 && actual.length == 2 )
267 if ( expected[0] == null && actual[0] == null )
272 if ( expected[0] == null )
274 return actual[0] == null;
277 if ( actual[0] == null )
279 return expected[0] == null;
282 return expected[0].equals( actual[0] );
287 public String toString( Object[] arguments )
289 return ArrayUtils.toString( arguments );
294 protected void assertChecksums( File expectedFile, String expectedSha1Contents, String expectedMd5Contents )
297 File sha1File = new File( expectedFile.getAbsolutePath() + ".sha1" );
298 File md5File = new File( expectedFile.getAbsolutePath() + ".md5" );
300 if ( expectedSha1Contents == null )
302 assertFalse( "SHA1 File should NOT exist: " + sha1File.getPath(), sha1File.exists() );
306 assertTrue( "SHA1 File should exist: " + sha1File.getPath(), sha1File.exists() );
307 String actualSha1Contents = readChecksumFile( sha1File );
308 assertEquals( "SHA1 File contents: " + sha1File.getPath(), expectedSha1Contents, actualSha1Contents );
311 if ( expectedMd5Contents == null )
313 assertFalse( "MD5 File should NOT exist: " + md5File.getPath(), md5File.exists() );
317 assertTrue( "MD5 File should exist: " + md5File.getPath(), md5File.exists() );
318 String actualMd5Contents = readChecksumFile( md5File );
319 assertEquals( "MD5 File contents: " + md5File.getPath(), expectedMd5Contents, actualMd5Contents );
323 protected void assertFileEquals( File expectedFile, File actualFile, File sourceFile )
326 assertNotNull( "Expected File should not be null.", expectedFile );
327 assertNotNull( "Actual File should not be null.", actualFile );
329 assertTrue( "Check actual file exists.", actualFile.exists() );
330 assertEquals( "Check filename path is appropriate.", expectedFile.getCanonicalPath(),
331 actualFile.getCanonicalPath() );
332 assertEquals( "Check file path matches.", expectedFile.getAbsolutePath(), actualFile.getAbsolutePath() );
334 String expectedContents = org.apache.commons.io.FileUtils.readFileToString( sourceFile, null );
335 String actualContents = org.apache.commons.io.FileUtils.readFileToString( actualFile, null );
336 assertEquals( "Check file contents.", expectedContents, actualContents );
339 protected void assertNotDownloaded( File downloadedFile )
341 assertNull( "Found file: " + downloadedFile + "; but was expecting a failure", downloadedFile );
344 @SuppressWarnings( "unchecked" )
345 protected void assertNoTempFiles( File expectedFile )
347 File workingDir = expectedFile.getParentFile();
348 if ( ( workingDir == null ) || !workingDir.isDirectory() )
353 Collection<File> tmpFiles =
354 org.apache.commons.io.FileUtils.listFiles( workingDir, new String[]{ "tmp" }, false );
355 if ( !tmpFiles.isEmpty() )
357 StringBuffer emsg = new StringBuffer();
358 emsg.append( "Found Temp Files in dir: " ).append( workingDir.getPath() );
359 for ( File tfile : tmpFiles )
361 emsg.append( "\n " ).append( tfile.getName() );
363 fail( emsg.toString() );
368 * A faster recursive copy that omits .svn directories.
370 * @param sourceDirectory the source directory to copy
371 * @param destDirectory the target location
372 * @throws java.io.IOException if there is a copying problem
373 * @todo get back into plexus-utils, share with converter module
375 protected void copyDirectoryStructure( File sourceDirectory, File destDirectory )
378 if ( !sourceDirectory.exists() )
380 throw new IOException( "Source directory doesn't exists (" + sourceDirectory.getAbsolutePath() + ")." );
383 File[] files = sourceDirectory.listFiles();
385 String sourcePath = sourceDirectory.getAbsolutePath();
387 for ( int i = 0; i < files.length; i++ )
389 File file = files[i];
391 String dest = file.getAbsolutePath();
393 dest = dest.substring( sourcePath.length() + 1 );
395 File destination = new File( destDirectory, dest );
399 destination = destination.getParentFile();
401 org.apache.commons.io.FileUtils.copyFile( file, new File( destination, file.getName() ), false );
402 // TODO: Change when there is a FileUtils.copyFileToDirectory(file, destination, boolean) option
403 //FileUtils.copyFileToDirectory( file, destination );
405 else if ( file.isDirectory() )
407 if ( !".svn".equals( file.getName() ) )
409 if ( !destination.exists() && !destination.mkdirs() )
411 throw new IOException(
412 "Could not create destination directory '" + destination.getAbsolutePath() + "'." );
415 copyDirectoryStructure( file, destination );
420 throw new IOException( "Unknown file type: " + file.getAbsolutePath() );
425 protected ManagedRepositoryContent createManagedLegacyRepository()
428 return createRepository( "testManagedLegacyRepo", "Test Managed (Legacy) Repository",
429 "src/test/repositories/legacy-managed", "legacy" );
432 protected ManagedRepositoryContent createProxiedLegacyRepository()
435 return createRepository( "testProxiedLegacyRepo", "Test Proxied (Legacy) Repository",
436 "src/test/repositories/legacy-proxied", "legacy" );
439 protected ManagedRepositoryContent createRepository( String id, String name, String path, String layout )
442 ManagedRepository repo = new ManagedRepository();
444 repo.setName( name );
445 repo.setLocation( path );
446 repo.setLayout( layout );
448 ManagedRepositoryContent repoContent =
449 applicationContext.getBean( "managedRepositoryContent#" + layout, ManagedRepositoryContent.class );
450 repoContent.setRepository( repo );
455 * Read the first line from the checksum file, and return it (trimmed).
457 protected String readChecksumFile( File checksumFile )
460 FileReader freader = null;
461 BufferedReader buf = null;
465 freader = new FileReader( checksumFile );
466 buf = new BufferedReader( freader );
467 return buf.readLine();
476 if ( freader != null )
483 protected void saveConnector( String sourceRepoId, String targetRepoId, boolean disabled )
485 saveConnector( sourceRepoId, targetRepoId, ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS, SnapshotsPolicy.ALWAYS,
486 CachedFailuresPolicy.NO, disabled );
489 protected void saveConnector( String sourceRepoId, String targetRepoId, String checksumPolicy, String releasePolicy,
490 String snapshotPolicy, String cacheFailuresPolicy, boolean disabled )
492 saveConnector( sourceRepoId, targetRepoId, checksumPolicy, releasePolicy, snapshotPolicy, cacheFailuresPolicy,
493 PropagateErrorsDownloadPolicy.QUEUE, disabled );
496 protected void saveConnector( String sourceRepoId, String targetRepoId, String checksumPolicy, String releasePolicy,
497 String snapshotPolicy, String cacheFailuresPolicy, String errorPolicy,
500 saveConnector( sourceRepoId, targetRepoId, checksumPolicy, releasePolicy, snapshotPolicy, cacheFailuresPolicy,
501 errorPolicy, PropagateErrorsOnUpdateDownloadPolicy.NOT_PRESENT, disabled );
504 protected void saveConnector( String sourceRepoId, String targetRepoId, String checksumPolicy, String releasePolicy,
505 String snapshotPolicy, String cacheFailuresPolicy, String errorPolicy,
506 String errorOnUpdatePolicy, boolean disabled )
508 ProxyConnectorConfiguration connectorConfig = new ProxyConnectorConfiguration();
509 connectorConfig.setSourceRepoId( sourceRepoId );
510 connectorConfig.setTargetRepoId( targetRepoId );
511 connectorConfig.addPolicy( ProxyConnectorConfiguration.POLICY_CHECKSUM, checksumPolicy );
512 connectorConfig.addPolicy( ProxyConnectorConfiguration.POLICY_RELEASES, releasePolicy );
513 connectorConfig.addPolicy( ProxyConnectorConfiguration.POLICY_SNAPSHOTS, snapshotPolicy );
514 connectorConfig.addPolicy( ProxyConnectorConfiguration.POLICY_CACHE_FAILURES, cacheFailuresPolicy );
515 connectorConfig.addPolicy( ProxyConnectorConfiguration.POLICY_PROPAGATE_ERRORS, errorPolicy );
516 connectorConfig.addPolicy( ProxyConnectorConfiguration.POLICY_PROPAGATE_ERRORS_ON_UPDATE, errorOnUpdatePolicy );
517 connectorConfig.setDisabled( disabled );
519 int count = config.getConfiguration().getProxyConnectors().size();
520 config.getConfiguration().addProxyConnector( connectorConfig );
522 // Proper Triggering ...
523 String prefix = "proxyConnectors.proxyConnector(" + count + ")";
524 config.triggerChange( prefix + ".sourceRepoId", connectorConfig.getSourceRepoId() );
525 config.triggerChange( prefix + ".targetRepoId", connectorConfig.getTargetRepoId() );
526 config.triggerChange( prefix + ".proxyId", connectorConfig.getProxyId() );
527 config.triggerChange( prefix + ".policies.releases", connectorConfig.getPolicy( "releases", "" ) );
528 config.triggerChange( prefix + ".policies.checksum", connectorConfig.getPolicy( "checksum", "" ) );
529 config.triggerChange( prefix + ".policies.snapshots", connectorConfig.getPolicy( "snapshots", "" ) );
530 config.triggerChange( prefix + ".policies.cache-failures", connectorConfig.getPolicy( "cache-failures", "" ) );
531 config.triggerChange( prefix + ".policies.propagate-errors",
532 connectorConfig.getPolicy( "propagate-errors", "" ) );
533 config.triggerChange( prefix + ".policies.propagate-errors-on-update",
534 connectorConfig.getPolicy( "propagate-errors-on-update", "" ) );
537 protected void saveManagedRepositoryConfig( String id, String name, String path, String layout )
539 ManagedRepositoryConfiguration repoConfig = new ManagedRepositoryConfiguration();
541 repoConfig.setId( id );
542 repoConfig.setName( name );
543 repoConfig.setLayout( layout );
545 repoConfig.setLocation( path );
547 int count = config.getConfiguration().getManagedRepositories().size();
548 config.getConfiguration().addManagedRepository( repoConfig );
550 String prefix = "managedRepositories.managedRepository(" + count + ")";
551 config.triggerChange( prefix + ".id", repoConfig.getId() );
552 config.triggerChange( prefix + ".name", repoConfig.getName() );
553 config.triggerChange( prefix + ".location", repoConfig.getLocation() );
554 config.triggerChange( prefix + ".layout", repoConfig.getLayout() );
557 protected void saveRemoteRepositoryConfig( String id, String name, String url, String layout )
559 RemoteRepositoryConfiguration repoConfig = new RemoteRepositoryConfiguration();
561 repoConfig.setId( id );
562 repoConfig.setName( name );
563 repoConfig.setLayout( layout );
564 repoConfig.setUrl( url );
566 int count = config.getConfiguration().getRemoteRepositories().size();
567 config.getConfiguration().addRemoteRepository( repoConfig );
569 String prefix = "remoteRepositories.remoteRepository(" + count + ")";
570 config.triggerChange( prefix + ".id", repoConfig.getId() );
571 config.triggerChange( prefix + ".name", repoConfig.getName() );
572 config.triggerChange( prefix + ".url", repoConfig.getUrl() );
573 config.triggerChange( prefix + ".layout", repoConfig.getLayout() );
576 protected File saveTargetedRepositoryConfig( String id, String originalPath, String targetPath, String layout )
579 File repoLocation = new File( targetPath );
580 FileUtils.deleteDirectory( repoLocation );
581 copyDirectoryStructure( new File( originalPath ), repoLocation );
583 saveRemoteRepositoryConfig( id, "Target Repo-" + id, targetPath, layout );
590 * Copy the specified resource directory from the src/test/repository/managed/ to
591 * the testable directory under target/test-repository/managed/${testName}/
593 * @param resourcePath
594 * @throws IOException
596 protected void setupTestableManagedRepository( String resourcePath )
599 String resourceDir = resourcePath;
601 if ( !resourcePath.endsWith( "/" ) )
603 int idx = resourcePath.lastIndexOf( '/' );
604 resourceDir = resourcePath.substring( 0, idx );
607 File sourceRepoDir = new File( REPOPATH_DEFAULT_MANAGED );
608 File sourceDir = new File( sourceRepoDir, resourceDir );
610 File destRepoDir = managedDefaultDir;
611 File destDir = new File( destRepoDir, resourceDir );
613 // Cleanout destination dirs.
614 if ( destDir.exists() )
616 FileUtils.deleteDirectory( destDir );
619 // Make the destination dir.
622 // Test the source dir.
623 if ( !sourceDir.exists() )
625 // This is just a warning.
627 "[WARN] Skipping setup of testable managed repository, source dir does not exist: " + sourceDir );
632 // Test that the source is a dir.
633 if ( !sourceDir.isDirectory() )
635 fail( "Unable to setup testable managed repository, source is not a directory: " + sourceDir );
638 // Copy directory structure.
639 copyDirectoryStructure( sourceDir, destDir );
643 protected void setManagedNewerThanRemote( File managedFile, File remoteFile )
645 setManagedNewerThanRemote( managedFile, remoteFile, 55000 );
648 protected void setManagedNewerThanRemote( File managedFile, File remoteFile, long time )
650 assertTrue( "Managed File should exist: ", managedFile.exists() );
651 assertTrue( "Remote File should exist: ", remoteFile.exists() );
653 managedFile.setLastModified( remoteFile.lastModified() + time );
655 assertTrue( managedFile.lastModified() > remoteFile.lastModified() );
658 protected void setManagedOlderThanRemote( File managedFile, File remoteFile )
660 setManagedOlderThanRemote( managedFile, remoteFile, 55000 );
663 protected void setManagedOlderThanRemote( File managedFile, File remoteFile, long time )
665 assertTrue( "Managed File should exist: ", managedFile.exists() );
666 assertTrue( "Remote File should exist: ", remoteFile.exists() );
668 managedFile.setLastModified( remoteFile.lastModified() - time );
670 assertTrue( managedFile.lastModified() < remoteFile.lastModified() );
674 protected void assertNotModified( File file, long expectedModificationTime )
676 assertEquals( "File <" + file.getAbsolutePath() + "> not have been modified.", expectedModificationTime,
677 file.lastModified() );
680 protected void assertNotExistsInManagedLegacyRepo( File file )
683 String managedLegacyPath = managedLegacyDir.getCanonicalPath();
684 String testFile = file.getCanonicalPath();
687 "Unit Test Failure: File <" + testFile + "> should be have been defined within the legacy managed path of <"
688 + managedLegacyPath + ">", testFile.startsWith( managedLegacyPath ) );
690 assertFalse( "File < " + testFile + "> should not exist in managed legacy repository.", file.exists() );
693 protected void assertNotExistsInManagedDefaultRepo( File file )
696 String managedDefaultPath = managedDefaultDir.getCanonicalPath();
697 String testFile = file.getCanonicalPath();
699 assertTrue( "Unit Test Failure: File <" + testFile
700 + "> should be have been defined within the managed default path of <" + managedDefaultPath
701 + ">", testFile.startsWith( managedDefaultPath ) );
703 assertFalse( "File < " + testFile + "> should not exist in managed default repository.", file.exists() );
706 protected static Date getFutureDate()
707 throws ParseException
709 Calendar cal = Calendar.getInstance();
710 cal.add( Calendar.YEAR, 1 );
711 return cal.getTime();
714 protected static Date getPastDate()
715 throws ParseException
717 return new SimpleDateFormat( "yyyy-MM-dd", Locale.US ).parse( "2000-01-01" );