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<ManagedRepositoryConfiguration>() );
148 config.getConfiguration().setRemoteRepositories( new ArrayList<RemoteRepositoryConfiguration>() );
149 config.getConfiguration().setProxyConnectors( new ArrayList<ProxyConnectorConfiguration>() );
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 //config.getConfiguration().addManagedRepository( repoConfig );
188 applicationContext.getBean( ManagedRepositoryAdmin.class ).addManagedRepository( repoConfig, false, null );
190 // Setup target (proxied to) repository.
191 saveRemoteRepositoryConfig( ID_PROXIED1, "Proxied Repository 1",
192 new File( REPOPATH_PROXIED1 ).toURL().toExternalForm(), "default" );
194 // Setup target (proxied to) repository.
195 saveRemoteRepositoryConfig( ID_PROXIED2, "Proxied Repository 2",
196 new File( REPOPATH_PROXIED2 ).toURL().toExternalForm(), "default" );
198 // Setup target (proxied to) repository using legacy layout.
199 saveRemoteRepositoryConfig( ID_LEGACY_PROXIED, "Proxied Legacy Repository",
200 new File( REPOPATH_PROXIED_LEGACY ).toURL().toExternalForm(), "legacy" );
202 // Setup the proxy handler.
203 //proxyHandler = applicationContext.getBean (RepositoryProxyConnectors) lookup( RepositoryProxyConnectors.class.getName() );
205 proxyHandler = applicationContext.getBean( "repositoryProxyConnectors#test", RepositoryProxyConnectors.class );
207 // Setup the wagon mock.
208 wagonMockControl = EasyMock.createNiceControl( );
209 wagonMock = wagonMockControl.createMock( Wagon.class );
211 delegate = (WagonDelegate) applicationContext.getBean( "wagon#test", Wagon.class );
213 delegate.setDelegate( wagonMock );
215 CacheManager.getInstance().clearAll();
217 log.info( "\n.\\ " + name + "() \\._________________________________________\n" );
221 public void shutdown()
224 removeMavenIndexes();
228 protected void removeMavenIndexes()
231 NexusIndexer nexusIndexer = plexusSisuBridge.lookup( NexusIndexer.class );
233 for ( IndexingContext indexingContext : nexusIndexer.getIndexingContexts().values() )
235 nexusIndexer.removeIndexingContext( indexingContext, false );
240 protected static final ArgumentsMatcher customWagonGetIfNewerMatcher = new ArgumentsMatcher()
243 public boolean matches( Object[] expected, Object[] actual )
245 if ( expected.length < 1 || actual.length < 1 )
249 return MockControl.ARRAY_MATCHER.matches( ArrayUtils.remove( expected, 1 ),
250 ArrayUtils.remove( actual, 1 ) );
253 public String toString( Object[] arguments )
255 return ArrayUtils.toString( arguments );
259 protected static final ArgumentsMatcher customWagonGetMatcher = new ArgumentsMatcher()
262 public boolean matches( Object[] expected, Object[] actual )
264 if ( expected.length == 2 && actual.length == 2 )
266 if ( expected[0] == null && actual[0] == null )
271 if ( expected[0] == null )
273 return actual[0] == null;
276 if ( actual[0] == null )
278 return expected[0] == null;
281 return expected[0].equals( actual[0] );
286 public String toString( Object[] arguments )
288 return ArrayUtils.toString( arguments );
293 protected void assertChecksums( File expectedFile, String expectedSha1Contents, String expectedMd5Contents )
296 File sha1File = new File( expectedFile.getAbsolutePath() + ".sha1" );
297 File md5File = new File( expectedFile.getAbsolutePath() + ".md5" );
299 if ( expectedSha1Contents == null )
301 assertFalse( "SHA1 File should NOT exist: " + sha1File.getPath(), sha1File.exists() );
305 assertTrue( "SHA1 File should exist: " + sha1File.getPath(), sha1File.exists() );
306 String actualSha1Contents = readChecksumFile( sha1File );
307 assertEquals( "SHA1 File contents: " + sha1File.getPath(), expectedSha1Contents, actualSha1Contents );
310 if ( expectedMd5Contents == null )
312 assertFalse( "MD5 File should NOT exist: " + md5File.getPath(), md5File.exists() );
316 assertTrue( "MD5 File should exist: " + md5File.getPath(), md5File.exists() );
317 String actualMd5Contents = readChecksumFile( md5File );
318 assertEquals( "MD5 File contents: " + md5File.getPath(), expectedMd5Contents, actualMd5Contents );
322 protected void assertFileEquals( File expectedFile, File actualFile, File sourceFile )
325 assertNotNull( "Expected File should not be null.", expectedFile );
326 assertNotNull( "Actual File should not be null.", actualFile );
328 assertTrue( "Check actual file exists.", actualFile.exists() );
329 assertEquals( "Check filename path is appropriate.", expectedFile.getCanonicalPath(),
330 actualFile.getCanonicalPath() );
331 assertEquals( "Check file path matches.", expectedFile.getAbsolutePath(), actualFile.getAbsolutePath() );
333 String expectedContents =
334 org.apache.commons.io.FileUtils.readFileToString( sourceFile, Charset.defaultCharset() );
335 String actualContents =
336 org.apache.commons.io.FileUtils.readFileToString( actualFile, Charset.defaultCharset() );
337 assertEquals( "Check file contents.", expectedContents, actualContents );
340 protected void assertNotDownloaded( File downloadedFile )
342 assertNull( "Found file: " + downloadedFile + "; but was expecting a failure", downloadedFile );
345 @SuppressWarnings ( "unchecked" )
346 protected void assertNoTempFiles( File expectedFile )
348 File workingDir = expectedFile.getParentFile();
349 if ( ( workingDir == null ) || !workingDir.isDirectory() )
354 Collection<File> tmpFiles =
355 org.apache.commons.io.FileUtils.listFiles( workingDir, new String[]{ "tmp" }, false );
356 if ( !tmpFiles.isEmpty() )
358 StringBuilder emsg = new StringBuilder();
359 emsg.append( "Found Temp Files in dir: " ).append( workingDir.getPath() );
360 for ( File tfile : tmpFiles )
362 emsg.append( "\n " ).append( tfile.getName() );
364 fail( emsg.toString() );
369 * A faster recursive copy that omits .svn directories.
371 * @param sourceDirectory the source directory to copy
372 * @param destDirectory the target location
373 * @throws java.io.IOException if there is a copying problem
374 * @todo get back into plexus-utils, share with converter module
376 protected void copyDirectoryStructure( File sourceDirectory, File destDirectory )
379 if ( !sourceDirectory.exists() )
381 throw new IOException( "Source directory doesn't exists (" + sourceDirectory.getAbsolutePath() + ")." );
384 File[] files = sourceDirectory.listFiles();
386 String sourcePath = sourceDirectory.getAbsolutePath();
388 for ( int i = 0; i < files.length; i++ )
390 File file = files[i];
392 String dest = file.getAbsolutePath();
394 dest = dest.substring( sourcePath.length() + 1 );
396 File destination = new File( destDirectory, dest );
400 destination = destination.getParentFile();
402 org.apache.commons.io.FileUtils.copyFile( file, new File( destination, file.getName() ), false );
403 // TODO: Change when there is a FileUtils.copyFileToDirectory(file, destination, boolean) option
404 //FileUtils.copyFileToDirectory( file, destination );
406 else if ( file.isDirectory() )
408 if ( !".svn".equals( file.getName() ) )
410 if ( !destination.exists() && !destination.mkdirs() )
412 throw new IOException(
413 "Could not create destination directory '" + destination.getAbsolutePath() + "'." );
416 copyDirectoryStructure( file, destination );
421 throw new IOException( "Unknown file type: " + file.getAbsolutePath() );
426 protected ManagedRepositoryContent createManagedLegacyRepository()
429 return createRepository( "testManagedLegacyRepo", "Test Managed (Legacy) Repository",
430 "src/test/repositories/legacy-managed", "legacy" );
433 protected ManagedRepositoryContent createProxiedLegacyRepository()
436 return createRepository( "testProxiedLegacyRepo", "Test Proxied (Legacy) Repository",
437 "src/test/repositories/legacy-proxied", "legacy" );
440 protected ManagedRepositoryContent createRepository( String id, String name, String path, String layout )
443 ManagedRepository repo = new ManagedRepository();
445 repo.setName( name );
446 repo.setLocation( path );
447 repo.setLayout( layout );
449 ManagedRepositoryContent repoContent =
450 applicationContext.getBean( "managedRepositoryContent#" + layout, ManagedRepositoryContent.class );
451 repoContent.setRepository( repo );
456 * Read the first line from the checksum file, and return it (trimmed).
458 protected String readChecksumFile( File checksumFile )
461 FileReader freader = null;
462 BufferedReader buf = null;
466 freader = new FileReader( checksumFile );
467 buf = new BufferedReader( freader );
468 return buf.readLine();
477 if ( freader != null )
484 protected void saveConnector( String sourceRepoId, String targetRepoId, boolean disabled )
486 saveConnector( sourceRepoId, targetRepoId, ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS, SnapshotsPolicy.ALWAYS,
487 CachedFailuresPolicy.NO, disabled );
490 protected void saveConnector( String sourceRepoId, String targetRepoId, String checksumPolicy, String releasePolicy,
491 String snapshotPolicy, String cacheFailuresPolicy, boolean disabled )
493 saveConnector( sourceRepoId, targetRepoId, checksumPolicy, releasePolicy, snapshotPolicy, cacheFailuresPolicy,
494 PropagateErrorsDownloadPolicy.QUEUE, disabled );
497 protected void saveConnector( String sourceRepoId, String targetRepoId, String checksumPolicy, String releasePolicy,
498 String snapshotPolicy, String cacheFailuresPolicy, String errorPolicy,
501 saveConnector( sourceRepoId, targetRepoId, checksumPolicy, releasePolicy, snapshotPolicy, cacheFailuresPolicy,
502 errorPolicy, PropagateErrorsOnUpdateDownloadPolicy.NOT_PRESENT, disabled );
505 protected void saveConnector( String sourceRepoId, String targetRepoId, String checksumPolicy, String releasePolicy,
506 String snapshotPolicy, String cacheFailuresPolicy, String errorPolicy,
507 String errorOnUpdatePolicy, boolean disabled )
509 ProxyConnectorConfiguration connectorConfig = new ProxyConnectorConfiguration();
510 connectorConfig.setSourceRepoId( sourceRepoId );
511 connectorConfig.setTargetRepoId( targetRepoId );
512 connectorConfig.addPolicy( ProxyConnectorConfiguration.POLICY_CHECKSUM, checksumPolicy );
513 connectorConfig.addPolicy( ProxyConnectorConfiguration.POLICY_RELEASES, releasePolicy );
514 connectorConfig.addPolicy( ProxyConnectorConfiguration.POLICY_SNAPSHOTS, snapshotPolicy );
515 connectorConfig.addPolicy( ProxyConnectorConfiguration.POLICY_CACHE_FAILURES, cacheFailuresPolicy );
516 connectorConfig.addPolicy( ProxyConnectorConfiguration.POLICY_PROPAGATE_ERRORS, errorPolicy );
517 connectorConfig.addPolicy( ProxyConnectorConfiguration.POLICY_PROPAGATE_ERRORS_ON_UPDATE, errorOnUpdatePolicy );
518 connectorConfig.setDisabled( disabled );
520 int count = config.getConfiguration().getProxyConnectors().size();
521 config.getConfiguration().addProxyConnector( connectorConfig );
523 // Proper Triggering ...
524 String prefix = "proxyConnectors.proxyConnector(" + count + ")";
525 config.triggerChange( prefix + ".sourceRepoId", connectorConfig.getSourceRepoId() );
526 config.triggerChange( prefix + ".targetRepoId", connectorConfig.getTargetRepoId() );
527 config.triggerChange( prefix + ".proxyId", connectorConfig.getProxyId() );
528 config.triggerChange( prefix + ".policies.releases", connectorConfig.getPolicy( "releases", "" ) );
529 config.triggerChange( prefix + ".policies.checksum", connectorConfig.getPolicy( "checksum", "" ) );
530 config.triggerChange( prefix + ".policies.snapshots", connectorConfig.getPolicy( "snapshots", "" ) );
531 config.triggerChange( prefix + ".policies.cache-failures", connectorConfig.getPolicy( "cache-failures", "" ) );
532 config.triggerChange( prefix + ".policies.propagate-errors",
533 connectorConfig.getPolicy( "propagate-errors", "" ) );
534 config.triggerChange( prefix + ".policies.propagate-errors-on-update",
535 connectorConfig.getPolicy( "propagate-errors-on-update", "" ) );
538 protected void saveManagedRepositoryConfig( String id, String name, String path, String layout )
540 ManagedRepositoryConfiguration repoConfig = new ManagedRepositoryConfiguration();
542 repoConfig.setId( id );
543 repoConfig.setName( name );
544 repoConfig.setLayout( layout );
546 repoConfig.setLocation( path );
548 int count = config.getConfiguration().getManagedRepositories().size();
549 config.getConfiguration().addManagedRepository( repoConfig );
551 String prefix = "managedRepositories.managedRepository(" + count + ")";
552 config.triggerChange( prefix + ".id", repoConfig.getId() );
553 config.triggerChange( prefix + ".name", repoConfig.getName() );
554 config.triggerChange( prefix + ".location", repoConfig.getLocation() );
555 config.triggerChange( prefix + ".layout", repoConfig.getLayout() );
558 protected void saveRemoteRepositoryConfig( String id, String name, String url, String layout )
560 RemoteRepositoryConfiguration repoConfig = new RemoteRepositoryConfiguration();
562 repoConfig.setId( id );
563 repoConfig.setName( name );
564 repoConfig.setLayout( layout );
565 repoConfig.setUrl( url );
567 int count = config.getConfiguration().getRemoteRepositories().size();
568 config.getConfiguration().addRemoteRepository( repoConfig );
570 String prefix = "remoteRepositories.remoteRepository(" + count + ")";
571 config.triggerChange( prefix + ".id", repoConfig.getId() );
572 config.triggerChange( prefix + ".name", repoConfig.getName() );
573 config.triggerChange( prefix + ".url", repoConfig.getUrl() );
574 config.triggerChange( prefix + ".layout", repoConfig.getLayout() );
577 protected File saveTargetedRepositoryConfig( String id, String originalPath, String targetPath, String layout )
580 File repoLocation = new File( targetPath );
581 FileUtils.deleteDirectory( repoLocation );
582 copyDirectoryStructure( new File( originalPath ), repoLocation );
584 saveRemoteRepositoryConfig( id, "Target Repo-" + id, targetPath, layout );
591 * Copy the specified resource directory from the src/test/repository/managed/ to
592 * the testable directory under target/test-repository/managed/${testName}/
594 * @param resourcePath
595 * @throws IOException
597 protected void setupTestableManagedRepository( String resourcePath )
600 String resourceDir = resourcePath;
602 if ( !resourcePath.endsWith( "/" ) )
604 int idx = resourcePath.lastIndexOf( '/' );
605 resourceDir = resourcePath.substring( 0, idx );
608 File sourceRepoDir = new File( REPOPATH_DEFAULT_MANAGED );
609 File sourceDir = new File( sourceRepoDir, resourceDir );
611 File destRepoDir = managedDefaultDir;
612 File destDir = new File( destRepoDir, resourceDir );
614 // Cleanout destination dirs.
615 if ( destDir.exists() )
617 FileUtils.deleteDirectory( destDir );
620 // Make the destination dir.
623 // Test the source dir.
624 if ( !sourceDir.exists() )
626 // This is just a warning.
628 "[WARN] Skipping setup of testable managed repository, source dir does not exist: " + sourceDir );
633 // Test that the source is a dir.
634 if ( !sourceDir.isDirectory() )
636 fail( "Unable to setup testable managed repository, source is not a directory: " + sourceDir );
639 // Copy directory structure.
640 copyDirectoryStructure( sourceDir, destDir );
644 protected void setManagedNewerThanRemote( File managedFile, File remoteFile )
646 setManagedNewerThanRemote( managedFile, remoteFile, 55000 );
649 protected void setManagedNewerThanRemote( File managedFile, File remoteFile, long time )
651 assertTrue( "Managed File should exist: ", managedFile.exists() );
652 assertTrue( "Remote File should exist: ", remoteFile.exists() );
654 managedFile.setLastModified( remoteFile.lastModified() + time );
656 assertTrue( managedFile.lastModified() > remoteFile.lastModified() );
659 protected void setManagedOlderThanRemote( File managedFile, File remoteFile )
661 setManagedOlderThanRemote( managedFile, remoteFile, 55000 );
664 protected void setManagedOlderThanRemote( File managedFile, File remoteFile, long time )
666 assertTrue( "Managed File should exist: ", managedFile.exists() );
667 assertTrue( "Remote File should exist: ", remoteFile.exists() );
669 managedFile.setLastModified( remoteFile.lastModified() - time );
671 assertTrue( managedFile.lastModified() < remoteFile.lastModified() );
675 protected void assertNotModified( File file, long expectedModificationTime )
677 assertEquals( "File <" + file.getAbsolutePath() + "> not have been modified.", expectedModificationTime,
678 file.lastModified() );
681 protected void assertNotExistsInManagedLegacyRepo( File file )
684 String managedLegacyPath = managedLegacyDir.getCanonicalPath();
685 String testFile = file.getCanonicalPath();
688 "Unit Test Failure: File <" + testFile + "> should be have been defined within the legacy managed path of <"
689 + managedLegacyPath + ">", testFile.startsWith( managedLegacyPath ) );
691 assertFalse( "File < " + testFile + "> should not exist in managed legacy repository.", file.exists() );
694 protected void assertNotExistsInManagedDefaultRepo( File file )
697 String managedDefaultPath = managedDefaultDir.getCanonicalPath();
698 String testFile = file.getCanonicalPath();
700 assertTrue( "Unit Test Failure: File <" + testFile
701 + "> should be have been defined within the managed default path of <" + managedDefaultPath
702 + ">", testFile.startsWith( managedDefaultPath ) );
704 assertFalse( "File < " + testFile + "> should not exist in managed default repository.", file.exists() );
707 protected static Date getFutureDate()
708 throws ParseException
710 Calendar cal = Calendar.getInstance();
711 cal.add( Calendar.YEAR, 1 );
712 return cal.getTime();
715 protected static Date getPastDate()
716 throws ParseException
718 return new SimpleDateFormat( "yyyy-MM-dd", Locale.US ).parse( "2000-01-01" );