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.commons.lang.ArrayUtils;
28 import org.apache.archiva.configuration.ArchivaConfiguration;
29 import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
30 import org.apache.archiva.configuration.ProxyConnectorConfiguration;
31 import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
32 import org.apache.archiva.policies.CachedFailuresPolicy;
33 import org.apache.archiva.policies.ChecksumPolicy;
34 import org.apache.archiva.policies.PropagateErrorsDownloadPolicy;
35 import org.apache.archiva.policies.PropagateErrorsOnUpdateDownloadPolicy;
36 import org.apache.archiva.policies.ReleasesPolicy;
37 import org.apache.archiva.policies.SnapshotsPolicy;
38 import org.apache.archiva.repository.ManagedRepositoryContent;
39 import org.apache.maven.wagon.Wagon;
40 import org.codehaus.plexus.util.FileUtils;
41 import org.easymock.ArgumentsMatcher;
42 import org.easymock.MockControl;
43 import org.junit.Before;
44 import org.junit.runner.RunWith;
45 import org.slf4j.Logger;
46 import org.slf4j.LoggerFactory;
47 import org.springframework.context.ApplicationContext;
48 import org.springframework.test.context.ContextConfiguration;
49 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
51 import javax.inject.Inject;
52 import java.io.BufferedReader;
54 import java.io.FileReader;
55 import java.io.IOException;
56 import java.text.ParseException;
57 import java.text.SimpleDateFormat;
58 import java.util.ArrayList;
59 import java.util.Calendar;
60 import java.util.Collection;
61 import java.util.Date;
62 import java.util.Locale;
64 import static org.junit.Assert.*;
67 * AbstractProxyTestCase
71 @RunWith( SpringJUnit4ClassRunner.class )
72 @ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } )
73 public abstract class AbstractProxyTestCase
76 protected ApplicationContext applicationContext;
78 protected static final String ID_LEGACY_PROXIED = "legacy-proxied";
80 protected static final String ID_PROXIED1 = "proxied1";
82 protected static final String ID_PROXIED1_TARGET = "proxied1-target";
84 protected static final String ID_PROXIED2 = "proxied2";
86 protected static final String ID_PROXIED2_TARGET = "proxied2-target";
88 protected static final String ID_DEFAULT_MANAGED = "default-managed-repository";
90 protected static final String ID_LEGACY_MANAGED = "legacy-managed-repository";
92 protected static final String REPOPATH_PROXIED_LEGACY = "src/test/repositories/legacy-proxied";
94 protected static final String REPOPATH_PROXIED1 = "src/test/repositories/proxied1";
96 protected static final String REPOPATH_PROXIED1_TARGET = "target/test-repository/proxied1";
98 protected static final String REPOPATH_PROXIED2 = "src/test/repositories/proxied2";
100 protected static final String REPOPATH_PROXIED2_TARGET = "target/test-repository/proxied2";
102 protected static final String REPOPATH_DEFAULT_MANAGED = "src/test/repositories/managed";
104 // protected static final String REPOPATH_DEFAULT_MANAGED_TARGET = "target/test-repository/managed";
106 protected static final String REPOPATH_LEGACY_MANAGED = "src/test/repositories/legacy-managed";
108 protected static final String REPOPATH_LEGACY_MANAGED_TARGET = "target/test-repository/legacy-managed";
110 protected MockControl wagonMockControl;
112 protected Wagon wagonMock;
115 protected RepositoryProxyConnectors proxyHandler;
117 protected ManagedRepositoryContent managedDefaultRepository;
119 protected File managedDefaultDir;
121 protected ManagedRepositoryContent managedLegacyRepository;
123 protected File managedLegacyDir;
125 protected MockConfiguration config;
127 protected Logger log = LoggerFactory.getLogger( getClass() );
129 WagonDelegate delegate;
132 protected ManagedRepositoryAdmin managedRepositoryAdmin;
135 PlexusSisuBridge plexusSisuBridge;
142 (MockConfiguration) applicationContext.getBean( "archivaConfiguration#mock", ArchivaConfiguration.class );
144 config.getConfiguration().setManagedRepositories( new ArrayList<ManagedRepositoryConfiguration>() );
145 config.getConfiguration().setRemoteRepositories( new ArrayList<RemoteRepositoryConfiguration>() );
146 config.getConfiguration().setProxyConnectors( new ArrayList<ProxyConnectorConfiguration>() );
148 // Setup source repository (using default layout)
149 String name = getClass().getSimpleName();
150 String repoPath = "target/test-repository/managed/" + name;
151 File repoLocation = new File( repoPath );
153 managedDefaultRepository =
154 createRepository( ID_DEFAULT_MANAGED, "Default Managed Repository", repoPath, "default" );
156 managedDefaultDir = new File( managedDefaultRepository.getRepoRoot() );
158 ManagedRepository repoConfig = managedDefaultRepository.getRepository();
160 ( (DefaultManagedRepositoryAdmin) applicationContext.getBean(
161 ManagedRepositoryAdmin.class ) ).setArchivaConfiguration( config );
163 applicationContext.getBean( ManagedRepositoryAdmin.class ).addManagedRepository( repoConfig, false, null );
164 //config.getConfiguration().addManagedRepository( repoConfig );
166 // Setup source repository (using legacy layout)
167 repoLocation = new File( REPOPATH_LEGACY_MANAGED_TARGET );
168 if ( repoLocation.exists() )
170 FileUtils.deleteDirectory( repoLocation );
172 copyDirectoryStructure( new File( REPOPATH_LEGACY_MANAGED ), repoLocation );
174 managedLegacyRepository =
175 createRepository( ID_LEGACY_MANAGED, "Legacy Managed Repository", REPOPATH_LEGACY_MANAGED_TARGET,
178 managedLegacyDir = new File( managedLegacyRepository.getRepoRoot() );
180 repoConfig = managedLegacyRepository.getRepository();
182 //config.getConfiguration().addManagedRepository( repoConfig );
183 applicationContext.getBean( ManagedRepositoryAdmin.class ).addManagedRepository( repoConfig, false, null );
185 // Setup target (proxied to) repository.
186 saveRemoteRepositoryConfig( ID_PROXIED1, "Proxied Repository 1",
187 new File( REPOPATH_PROXIED1 ).toURL().toExternalForm(), "default" );
189 // Setup target (proxied to) repository.
190 saveRemoteRepositoryConfig( ID_PROXIED2, "Proxied Repository 2",
191 new File( REPOPATH_PROXIED2 ).toURL().toExternalForm(), "default" );
193 // Setup target (proxied to) repository using legacy layout.
194 saveRemoteRepositoryConfig( ID_LEGACY_PROXIED, "Proxied Legacy Repository",
195 new File( REPOPATH_PROXIED_LEGACY ).toURL().toExternalForm(), "legacy" );
197 // Setup the proxy handler.
198 //proxyHandler = applicationContext.getBean (RepositoryProxyConnectors) lookup( RepositoryProxyConnectors.class.getName() );
200 proxyHandler = applicationContext.getBean( "repositoryProxyConnectors#test", RepositoryProxyConnectors.class );
202 // Setup the wagon mock.
203 wagonMockControl = MockControl.createNiceControl( Wagon.class );
204 wagonMock = (Wagon) wagonMockControl.getMock();
206 delegate = (WagonDelegate) plexusSisuBridge.lookup( Wagon.class, "test" );
208 delegate.setDelegate( wagonMock );
210 CacheManager.getInstance().clearAll();
212 log.info( "\n.\\ " + name + "() \\._________________________________________\n" );
215 protected static final ArgumentsMatcher customWagonGetIfNewerMatcher = new ArgumentsMatcher()
218 public boolean matches( Object[] expected, Object[] actual )
220 if ( expected.length < 1 || actual.length < 1 )
224 return MockControl.ARRAY_MATCHER.matches( ArrayUtils.remove( expected, 1 ),
225 ArrayUtils.remove( actual, 1 ) );
228 public String toString( Object[] arguments )
230 return ArrayUtils.toString( arguments );
234 protected static final ArgumentsMatcher customWagonGetMatcher = new ArgumentsMatcher()
237 public boolean matches( Object[] expected, Object[] actual )
239 if ( expected.length == 2 && actual.length == 2 )
241 if ( expected[0] == null && actual[0] == null )
246 if ( expected[0] == null )
248 return actual[0] == null;
251 if ( actual[0] == null )
253 return expected[0] == null;
256 return expected[0].equals( actual[0] );
261 public String toString( Object[] arguments )
263 return ArrayUtils.toString( arguments );
268 protected void assertChecksums( File expectedFile, String expectedSha1Contents, String expectedMd5Contents )
271 File sha1File = new File( expectedFile.getAbsolutePath() + ".sha1" );
272 File md5File = new File( expectedFile.getAbsolutePath() + ".md5" );
274 if ( expectedSha1Contents == null )
276 assertFalse( "SHA1 File should NOT exist: " + sha1File.getPath(), sha1File.exists() );
280 assertTrue( "SHA1 File should exist: " + sha1File.getPath(), sha1File.exists() );
281 String actualSha1Contents = readChecksumFile( sha1File );
282 assertEquals( "SHA1 File contents: " + sha1File.getPath(), expectedSha1Contents, actualSha1Contents );
285 if ( expectedMd5Contents == null )
287 assertFalse( "MD5 File should NOT exist: " + md5File.getPath(), md5File.exists() );
291 assertTrue( "MD5 File should exist: " + md5File.getPath(), md5File.exists() );
292 String actualMd5Contents = readChecksumFile( md5File );
293 assertEquals( "MD5 File contents: " + md5File.getPath(), expectedMd5Contents, actualMd5Contents );
297 protected void assertFileEquals( File expectedFile, File actualFile, File sourceFile )
300 assertNotNull( "Expected File should not be null.", expectedFile );
301 assertNotNull( "Actual File should not be null.", actualFile );
303 assertTrue( "Check actual file exists.", actualFile.exists() );
304 assertEquals( "Check filename path is appropriate.", expectedFile.getCanonicalPath(),
305 actualFile.getCanonicalPath() );
306 assertEquals( "Check file path matches.", expectedFile.getAbsolutePath(), actualFile.getAbsolutePath() );
308 String expectedContents = org.apache.commons.io.FileUtils.readFileToString( sourceFile, null );
309 String actualContents = org.apache.commons.io.FileUtils.readFileToString( actualFile, null );
310 assertEquals( "Check file contents.", expectedContents, actualContents );
313 protected void assertNotDownloaded( File downloadedFile )
315 assertNull( "Found file: " + downloadedFile + "; but was expecting a failure", downloadedFile );
318 @SuppressWarnings( "unchecked" )
319 protected void assertNoTempFiles( File expectedFile )
321 File workingDir = expectedFile.getParentFile();
322 if ( ( workingDir == null ) || !workingDir.isDirectory() )
327 Collection<File> tmpFiles =
328 org.apache.commons.io.FileUtils.listFiles( workingDir, new String[]{ "tmp" }, false );
329 if ( !tmpFiles.isEmpty() )
331 StringBuffer emsg = new StringBuffer();
332 emsg.append( "Found Temp Files in dir: " ).append( workingDir.getPath() );
333 for ( File tfile : tmpFiles )
335 emsg.append( "\n " ).append( tfile.getName() );
337 fail( emsg.toString() );
342 * A faster recursive copy that omits .svn directories.
344 * @param sourceDirectory the source directory to copy
345 * @param destDirectory the target location
346 * @throws java.io.IOException if there is a copying problem
347 * @todo get back into plexus-utils, share with converter module
349 protected void copyDirectoryStructure( File sourceDirectory, File destDirectory )
352 if ( !sourceDirectory.exists() )
354 throw new IOException( "Source directory doesn't exists (" + sourceDirectory.getAbsolutePath() + ")." );
357 File[] files = sourceDirectory.listFiles();
359 String sourcePath = sourceDirectory.getAbsolutePath();
361 for ( int i = 0; i < files.length; i++ )
363 File file = files[i];
365 String dest = file.getAbsolutePath();
367 dest = dest.substring( sourcePath.length() + 1 );
369 File destination = new File( destDirectory, dest );
373 destination = destination.getParentFile();
375 org.apache.commons.io.FileUtils.copyFile( file, new File( destination, file.getName() ), false );
376 // TODO: Change when there is a FileUtils.copyFileToDirectory(file, destination, boolean) option
377 //FileUtils.copyFileToDirectory( file, destination );
379 else if ( file.isDirectory() )
381 if ( !".svn".equals( file.getName() ) )
383 if ( !destination.exists() && !destination.mkdirs() )
385 throw new IOException(
386 "Could not create destination directory '" + destination.getAbsolutePath() + "'." );
389 copyDirectoryStructure( file, destination );
394 throw new IOException( "Unknown file type: " + file.getAbsolutePath() );
399 protected ManagedRepositoryContent createManagedLegacyRepository()
402 return createRepository( "testManagedLegacyRepo", "Test Managed (Legacy) Repository",
403 "src/test/repositories/legacy-managed", "legacy" );
406 protected ManagedRepositoryContent createProxiedLegacyRepository()
409 return createRepository( "testProxiedLegacyRepo", "Test Proxied (Legacy) Repository",
410 "src/test/repositories/legacy-proxied", "legacy" );
413 protected ManagedRepositoryContent createRepository( String id, String name, String path, String layout )
416 ManagedRepository repo = new ManagedRepository();
418 repo.setName( name );
419 repo.setLocation( path );
420 repo.setLayout( layout );
422 ManagedRepositoryContent repoContent =
423 applicationContext.getBean( "managedRepositoryContent#" + layout, ManagedRepositoryContent.class );
424 repoContent.setRepository( repo );
429 * Read the first line from the checksum file, and return it (trimmed).
431 protected String readChecksumFile( File checksumFile )
434 FileReader freader = null;
435 BufferedReader buf = null;
439 freader = new FileReader( checksumFile );
440 buf = new BufferedReader( freader );
441 return buf.readLine();
450 if ( freader != null )
457 protected void saveConnector( String sourceRepoId, String targetRepoId, boolean disabled )
459 saveConnector( sourceRepoId, targetRepoId, ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS, SnapshotsPolicy.ALWAYS,
460 CachedFailuresPolicy.NO, disabled );
463 protected void saveConnector( String sourceRepoId, String targetRepoId, String checksumPolicy, String releasePolicy,
464 String snapshotPolicy, String cacheFailuresPolicy, boolean disabled )
466 saveConnector( sourceRepoId, targetRepoId, checksumPolicy, releasePolicy, snapshotPolicy, cacheFailuresPolicy,
467 PropagateErrorsDownloadPolicy.QUEUE, disabled );
470 protected void saveConnector( String sourceRepoId, String targetRepoId, String checksumPolicy, String releasePolicy,
471 String snapshotPolicy, String cacheFailuresPolicy, String errorPolicy,
474 saveConnector( sourceRepoId, targetRepoId, checksumPolicy, releasePolicy, snapshotPolicy, cacheFailuresPolicy,
475 errorPolicy, PropagateErrorsOnUpdateDownloadPolicy.NOT_PRESENT, disabled );
478 protected void saveConnector( String sourceRepoId, String targetRepoId, String checksumPolicy, String releasePolicy,
479 String snapshotPolicy, String cacheFailuresPolicy, String errorPolicy,
480 String errorOnUpdatePolicy, boolean disabled )
482 ProxyConnectorConfiguration connectorConfig = new ProxyConnectorConfiguration();
483 connectorConfig.setSourceRepoId( sourceRepoId );
484 connectorConfig.setTargetRepoId( targetRepoId );
485 connectorConfig.addPolicy( ProxyConnectorConfiguration.POLICY_CHECKSUM, checksumPolicy );
486 connectorConfig.addPolicy( ProxyConnectorConfiguration.POLICY_RELEASES, releasePolicy );
487 connectorConfig.addPolicy( ProxyConnectorConfiguration.POLICY_SNAPSHOTS, snapshotPolicy );
488 connectorConfig.addPolicy( ProxyConnectorConfiguration.POLICY_CACHE_FAILURES, cacheFailuresPolicy );
489 connectorConfig.addPolicy( ProxyConnectorConfiguration.POLICY_PROPAGATE_ERRORS, errorPolicy );
490 connectorConfig.addPolicy( ProxyConnectorConfiguration.POLICY_PROPAGATE_ERRORS_ON_UPDATE, errorOnUpdatePolicy );
491 connectorConfig.setDisabled( disabled );
493 int count = config.getConfiguration().getProxyConnectors().size();
494 config.getConfiguration().addProxyConnector( connectorConfig );
496 // Proper Triggering ...
497 String prefix = "proxyConnectors.proxyConnector(" + count + ")";
498 config.triggerChange( prefix + ".sourceRepoId", connectorConfig.getSourceRepoId() );
499 config.triggerChange( prefix + ".targetRepoId", connectorConfig.getTargetRepoId() );
500 config.triggerChange( prefix + ".proxyId", connectorConfig.getProxyId() );
501 config.triggerChange( prefix + ".policies.releases", connectorConfig.getPolicy( "releases", "" ) );
502 config.triggerChange( prefix + ".policies.checksum", connectorConfig.getPolicy( "checksum", "" ) );
503 config.triggerChange( prefix + ".policies.snapshots", connectorConfig.getPolicy( "snapshots", "" ) );
504 config.triggerChange( prefix + ".policies.cache-failures", connectorConfig.getPolicy( "cache-failures", "" ) );
505 config.triggerChange( prefix + ".policies.propagate-errors",
506 connectorConfig.getPolicy( "propagate-errors", "" ) );
507 config.triggerChange( prefix + ".policies.propagate-errors-on-update",
508 connectorConfig.getPolicy( "propagate-errors-on-update", "" ) );
511 protected void saveManagedRepositoryConfig( String id, String name, String path, String layout )
513 ManagedRepositoryConfiguration repoConfig = new ManagedRepositoryConfiguration();
515 repoConfig.setId( id );
516 repoConfig.setName( name );
517 repoConfig.setLayout( layout );
519 repoConfig.setLocation( path );
521 int count = config.getConfiguration().getManagedRepositories().size();
522 config.getConfiguration().addManagedRepository( repoConfig );
524 String prefix = "managedRepositories.managedRepository(" + count + ")";
525 config.triggerChange( prefix + ".id", repoConfig.getId() );
526 config.triggerChange( prefix + ".name", repoConfig.getName() );
527 config.triggerChange( prefix + ".location", repoConfig.getLocation() );
528 config.triggerChange( prefix + ".layout", repoConfig.getLayout() );
531 protected void saveRemoteRepositoryConfig( String id, String name, String url, String layout )
533 RemoteRepositoryConfiguration repoConfig = new RemoteRepositoryConfiguration();
535 repoConfig.setId( id );
536 repoConfig.setName( name );
537 repoConfig.setLayout( layout );
538 repoConfig.setUrl( url );
540 int count = config.getConfiguration().getRemoteRepositories().size();
541 config.getConfiguration().addRemoteRepository( repoConfig );
543 String prefix = "remoteRepositories.remoteRepository(" + count + ")";
544 config.triggerChange( prefix + ".id", repoConfig.getId() );
545 config.triggerChange( prefix + ".name", repoConfig.getName() );
546 config.triggerChange( prefix + ".url", repoConfig.getUrl() );
547 config.triggerChange( prefix + ".layout", repoConfig.getLayout() );
550 protected File saveTargetedRepositoryConfig( String id, String originalPath, String targetPath, String layout )
553 File repoLocation = new File( targetPath );
554 FileUtils.deleteDirectory( repoLocation );
555 copyDirectoryStructure( new File( originalPath ), repoLocation );
557 saveRemoteRepositoryConfig( id, "Target Repo-" + id, targetPath, layout );
564 * Copy the specified resource directory from the src/test/repository/managed/ to
565 * the testable directory under target/test-repository/managed/${testName}/
567 * @param resourcePath
568 * @throws IOException
570 protected void setupTestableManagedRepository( String resourcePath )
573 String resourceDir = resourcePath;
575 if ( !resourcePath.endsWith( "/" ) )
577 int idx = resourcePath.lastIndexOf( '/' );
578 resourceDir = resourcePath.substring( 0, idx );
581 File sourceRepoDir = new File( REPOPATH_DEFAULT_MANAGED );
582 File sourceDir = new File( sourceRepoDir, resourceDir );
584 File destRepoDir = managedDefaultDir;
585 File destDir = new File( destRepoDir, resourceDir );
587 // Cleanout destination dirs.
588 if ( destDir.exists() )
590 FileUtils.deleteDirectory( destDir );
593 // Make the destination dir.
596 // Test the source dir.
597 if ( !sourceDir.exists() )
599 // This is just a warning.
601 "[WARN] Skipping setup of testable managed repository, source dir does not exist: " + sourceDir );
606 // Test that the source is a dir.
607 if ( !sourceDir.isDirectory() )
609 fail( "Unable to setup testable managed repository, source is not a directory: " + sourceDir );
612 // Copy directory structure.
613 copyDirectoryStructure( sourceDir, destDir );
617 protected void setManagedNewerThanRemote( File managedFile, File remoteFile )
619 setManagedNewerThanRemote( managedFile, remoteFile, 55000 );
622 protected void setManagedNewerThanRemote( File managedFile, File remoteFile, long time )
624 assertTrue( "Managed File should exist: ", managedFile.exists() );
625 assertTrue( "Remote File should exist: ", remoteFile.exists() );
627 managedFile.setLastModified( remoteFile.lastModified() + time );
629 assertTrue( managedFile.lastModified() > remoteFile.lastModified() );
632 protected void setManagedOlderThanRemote( File managedFile, File remoteFile )
634 setManagedOlderThanRemote( managedFile, remoteFile, 55000 );
637 protected void setManagedOlderThanRemote( File managedFile, File remoteFile, long time )
639 assertTrue( "Managed File should exist: ", managedFile.exists() );
640 assertTrue( "Remote File should exist: ", remoteFile.exists() );
642 managedFile.setLastModified( remoteFile.lastModified() - time );
644 assertTrue( managedFile.lastModified() < remoteFile.lastModified() );
648 protected void assertNotModified( File file, long expectedModificationTime )
650 assertEquals( "File <" + file.getAbsolutePath() + "> not have been modified.", expectedModificationTime,
651 file.lastModified() );
654 protected void assertNotExistsInManagedLegacyRepo( File file )
657 String managedLegacyPath = managedLegacyDir.getCanonicalPath();
658 String testFile = file.getCanonicalPath();
661 "Unit Test Failure: File <" + testFile + "> should be have been defined within the legacy managed path of <"
662 + managedLegacyPath + ">", testFile.startsWith( managedLegacyPath ) );
664 assertFalse( "File < " + testFile + "> should not exist in managed legacy repository.", file.exists() );
667 protected void assertNotExistsInManagedDefaultRepo( File file )
670 String managedDefaultPath = managedDefaultDir.getCanonicalPath();
671 String testFile = file.getCanonicalPath();
673 assertTrue( "Unit Test Failure: File <" + testFile
674 + "> should be have been defined within the managed default path of <" + managedDefaultPath
675 + ">", testFile.startsWith( managedDefaultPath ) );
677 assertFalse( "File < " + testFile + "> should not exist in managed default repository.", file.exists() );
680 protected static Date getFutureDate()
681 throws ParseException
683 Calendar cal = Calendar.getInstance();
684 cal.add( Calendar.YEAR, 1 );
685 return cal.getTime();
688 protected static Date getPastDate()
689 throws ParseException
691 return new SimpleDateFormat( "yyyy-MM-dd", Locale.US ).parse( "2000-01-01" );