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.proxy.model.RepositoryProxyConnectors;
38 import org.apache.archiva.repository.ManagedRepositoryContent;
39 import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
40 import org.apache.commons.io.FileUtils;
41 import org.apache.commons.lang.ArrayUtils;
42 import org.apache.maven.index.NexusIndexer;
43 import org.apache.maven.index.context.IndexingContext;
44 import org.apache.maven.wagon.Wagon;
45 import org.easymock.EasyMock;
46 import org.easymock.IMocksControl;
47 import org.junit.After;
48 import org.junit.Before;
49 import org.junit.runner.RunWith;
50 import org.slf4j.Logger;
51 import org.slf4j.LoggerFactory;
52 import org.springframework.context.ApplicationContext;
53 import org.springframework.test.context.ContextConfiguration;
55 import javax.inject.Inject;
56 import java.io.BufferedReader;
58 import java.io.FileReader;
59 import java.io.IOException;
60 import java.nio.charset.Charset;
61 import java.text.ParseException;
62 import java.text.SimpleDateFormat;
63 import java.util.ArrayList;
64 import java.util.Calendar;
65 import java.util.Collection;
66 import java.util.Date;
67 import java.util.Locale;
69 import static org.junit.Assert.*;
72 * AbstractProxyTestCase
74 @RunWith ( ArchivaSpringJUnit4ClassRunner.class )
75 @ContextConfiguration ( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } )
76 public abstract class AbstractProxyTestCase
79 protected ApplicationContext applicationContext;
81 protected static final String ID_LEGACY_PROXIED = "legacy-proxied";
83 protected static final String ID_PROXIED1 = "proxied1";
85 protected static final String ID_PROXIED1_TARGET = "proxied1-target";
87 protected static final String ID_PROXIED2 = "proxied2";
89 protected static final String ID_PROXIED2_TARGET = "proxied2-target";
91 protected static final String ID_DEFAULT_MANAGED = "default-managed-repository";
93 protected static final String ID_LEGACY_MANAGED = "legacy-managed-repository";
95 protected static final String REPOPATH_PROXIED_LEGACY = "src/test/repositories/legacy-proxied";
97 protected static final String REPOPATH_PROXIED1 = "src/test/repositories/proxied1";
99 protected static final String REPOPATH_PROXIED1_TARGET = "target/test-repository/proxied1";
101 protected static final String REPOPATH_PROXIED2 = "src/test/repositories/proxied2";
103 protected static final String REPOPATH_PROXIED2_TARGET = "target/test-repository/proxied2";
105 protected static final String REPOPATH_DEFAULT_MANAGED = "src/test/repositories/managed";
107 // protected static final String REPOPATH_DEFAULT_MANAGED_TARGET = "target/test-repository/managed";
109 protected static final String REPOPATH_LEGACY_MANAGED = "src/test/repositories/legacy-managed";
111 protected static final String REPOPATH_LEGACY_MANAGED_TARGET = "target/test-repository/legacy-managed";
113 protected IMocksControl wagonMockControl;
115 protected Wagon wagonMock;
118 protected RepositoryProxyConnectors proxyHandler;
120 protected ManagedRepositoryContent managedDefaultRepository;
122 protected File managedDefaultDir;
124 protected ManagedRepositoryContent managedLegacyRepository;
126 protected File managedLegacyDir;
128 protected MockConfiguration config;
130 protected Logger log = LoggerFactory.getLogger( getClass() );
132 WagonDelegate delegate;
135 protected ManagedRepositoryAdmin managedRepositoryAdmin;
138 protected PlexusSisuBridge plexusSisuBridge;
145 (MockConfiguration) applicationContext.getBean( "archivaConfiguration#mock", ArchivaConfiguration.class );
147 config.getConfiguration().setManagedRepositories( new ArrayList<>() );
148 config.getConfiguration().setRemoteRepositories( new ArrayList<>() );
149 config.getConfiguration().setProxyConnectors( new ArrayList<>() );
151 // Setup source repository (using default layout)
152 String name = getClass().getSimpleName();
153 String repoPath = "target/test-repository/managed/" + name;
154 File repoLocation = new File( repoPath );
156 managedDefaultRepository =
157 createRepository( ID_DEFAULT_MANAGED, "Default Managed Repository", repoPath, "default" );
159 managedDefaultDir = new File( managedDefaultRepository.getRepoRoot() );
161 ManagedRepository repoConfig = managedDefaultRepository.getRepository();
163 ( (DefaultManagedRepositoryAdmin) applicationContext.getBean(
164 ManagedRepositoryAdmin.class ) ).setArchivaConfiguration( config );
166 applicationContext.getBean( ManagedRepositoryAdmin.class ).addManagedRepository( repoConfig, false, null );
168 // to prevent windauze file leaking
169 removeMavenIndexes();
171 // Setup source repository (using legacy layout)
172 repoLocation = new File( REPOPATH_LEGACY_MANAGED_TARGET );
173 if ( repoLocation.exists() )
175 FileUtils.deleteDirectory( repoLocation );
177 copyDirectoryStructure( new File( REPOPATH_LEGACY_MANAGED ), repoLocation );
179 managedLegacyRepository =
180 createRepository( ID_LEGACY_MANAGED, "Legacy Managed Repository", REPOPATH_LEGACY_MANAGED_TARGET,
183 managedLegacyDir = new File( managedLegacyRepository.getRepoRoot() );
185 repoConfig = managedLegacyRepository.getRepository();
187 applicationContext.getBean( ManagedRepositoryAdmin.class ).addManagedRepository( repoConfig, false, null );
189 // Setup target (proxied to) repository.
190 saveRemoteRepositoryConfig( ID_PROXIED1, "Proxied Repository 1",
191 new File( REPOPATH_PROXIED1 ).toURL().toExternalForm(), "default" );
193 // Setup target (proxied to) repository.
194 saveRemoteRepositoryConfig( ID_PROXIED2, "Proxied Repository 2",
195 new File( REPOPATH_PROXIED2 ).toURL().toExternalForm(), "default" );
197 // Setup target (proxied to) repository using legacy layout.
198 saveRemoteRepositoryConfig( ID_LEGACY_PROXIED, "Proxied Legacy Repository",
199 new File( REPOPATH_PROXIED_LEGACY ).toURL().toExternalForm(), "legacy" );
201 // Setup the proxy handler.
202 //proxyHandler = applicationContext.getBean (RepositoryProxyConnectors) lookup( RepositoryProxyConnectors.class.getName() );
204 proxyHandler = applicationContext.getBean( "repositoryProxyConnectors#test", RepositoryProxyConnectors.class );
206 // Setup the wagon mock.
207 wagonMockControl = EasyMock.createNiceControl( );
208 wagonMock = wagonMockControl.createMock( Wagon.class );
210 delegate = (WagonDelegate) applicationContext.getBean( "wagon#test", Wagon.class );
212 delegate.setDelegate( wagonMock );
214 CacheManager.getInstance().clearAll();
216 log.info( "\n.\\ {}() \\._________________________________________\n", name );
220 public void shutdown()
223 removeMavenIndexes();
227 protected void removeMavenIndexes()
230 NexusIndexer nexusIndexer = plexusSisuBridge.lookup( NexusIndexer.class );
232 for ( IndexingContext indexingContext : nexusIndexer.getIndexingContexts().values() )
234 nexusIndexer.removeIndexingContext( indexingContext, false );
239 protected static final ArgumentsMatcher customWagonGetIfNewerMatcher = new ArgumentsMatcher()
242 public boolean matches( Object[] expected, Object[] actual )
244 if ( expected.length < 1 || actual.length < 1 )
248 return MockControl.ARRAY_MATCHER.matches( ArrayUtils.remove( expected, 1 ),
249 ArrayUtils.remove( actual, 1 ) );
252 public String toString( Object[] arguments )
254 return ArrayUtils.toString( arguments );
258 protected static final ArgumentsMatcher customWagonGetMatcher = new ArgumentsMatcher()
261 public boolean matches( Object[] expected, Object[] actual )
263 if ( expected.length == 2 && actual.length == 2 )
265 if ( expected[0] == null && actual[0] == null )
270 if ( expected[0] == null )
272 return actual[0] == null;
275 if ( actual[0] == null )
277 return expected[0] == null;
280 return expected[0].equals( actual[0] );
285 public String toString( Object[] arguments )
287 return ArrayUtils.toString( arguments );
292 protected void assertChecksums( File expectedFile, String expectedSha1Contents, String expectedMd5Contents )
295 File sha1File = new File( expectedFile.getAbsolutePath() + ".sha1" );
296 File md5File = new File( expectedFile.getAbsolutePath() + ".md5" );
298 if ( expectedSha1Contents == null )
300 assertFalse( "SHA1 File should NOT exist: " + sha1File.getPath(), sha1File.exists() );
304 assertTrue( "SHA1 File should exist: " + sha1File.getPath(), sha1File.exists() );
305 String actualSha1Contents = readChecksumFile( sha1File );
306 assertEquals( "SHA1 File contents: " + sha1File.getPath(), expectedSha1Contents, actualSha1Contents );
309 if ( expectedMd5Contents == null )
311 assertFalse( "MD5 File should NOT exist: " + md5File.getPath(), md5File.exists() );
315 assertTrue( "MD5 File should exist: " + md5File.getPath(), md5File.exists() );
316 String actualMd5Contents = readChecksumFile( md5File );
317 assertEquals( "MD5 File contents: " + md5File.getPath(), expectedMd5Contents, actualMd5Contents );
321 protected void assertFileEquals( File expectedFile, File actualFile, File sourceFile )
324 assertNotNull( "Expected File should not be null.", expectedFile );
325 assertNotNull( "Actual File should not be null.", actualFile );
327 assertTrue( "Check actual file exists.", actualFile.exists() );
328 assertEquals( "Check filename path is appropriate.", expectedFile.getCanonicalPath(),
329 actualFile.getCanonicalPath() );
330 assertEquals( "Check file path matches.", expectedFile.getAbsolutePath(), actualFile.getAbsolutePath() );
332 String expectedContents =
333 org.apache.commons.io.FileUtils.readFileToString( sourceFile, Charset.defaultCharset() );
334 String actualContents =
335 org.apache.commons.io.FileUtils.readFileToString( actualFile, Charset.defaultCharset() );
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 StringBuilder emsg = new StringBuilder();
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" );