You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

RepositoryServletNoProxyMetadataTest.java 5.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. package org.apache.archiva.webdav;
  2. /*
  3. * Licensed to the Apache Software Foundation (ASF) under one
  4. * or more contributor license agreements. See the NOTICE file
  5. * distributed with this work for additional information
  6. * regarding copyright ownership. The ASF licenses this file
  7. * to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance
  9. * with the License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing,
  14. * software distributed under the License is distributed on an
  15. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16. * KIND, either express or implied. See the License for the
  17. * specific language governing permissions and limitations
  18. * under the License.
  19. */
  20. import com.gargoylesoftware.htmlunit.WebRequest;
  21. import com.gargoylesoftware.htmlunit.WebResponse;
  22. import org.junit.After;
  23. import org.junit.Before;
  24. import org.junit.Test;
  25. import java.nio.charset.Charset;
  26. import java.nio.file.Files;
  27. import java.nio.file.Path;
  28. /**
  29. * RepositoryServletTest
  30. */
  31. public class RepositoryServletNoProxyMetadataTest
  32. extends AbstractRepositoryServletTestCase
  33. {
  34. @Before
  35. @Override
  36. public void setUp() throws Exception
  37. {
  38. super.setUp();
  39. startRepository();
  40. }
  41. @Override
  42. @After
  43. public void tearDown( ) throws Exception
  44. {
  45. super.tearDown( );
  46. }
  47. @Test
  48. public void testGetVersionMetadataDefaultLayout()
  49. throws Exception
  50. {
  51. String commonsLangMetadata = "commons-lang/commons-lang/2.1/maven-metadata.xml";
  52. String expectedMetadataContents = "metadata-for-commons-lang-version-2.1";
  53. Path checksumFile = repoRootInternal.resolve(commonsLangMetadata);
  54. Files.createDirectories(checksumFile.getParent());
  55. org.apache.archiva.common.utils.FileUtils.writeStringToFile( checksumFile, Charset.defaultCharset(), expectedMetadataContents );
  56. WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
  57. WebResponse response = getServletUnitClient().getResponse( request );
  58. assertResponseOK( response );
  59. assertEquals( "Expected file contents", expectedMetadataContents, response.getContentAsString() );
  60. }
  61. @Test
  62. public void testGetProjectMetadataDefaultLayout()
  63. throws Exception
  64. {
  65. String commonsLangMetadata = "commons-lang/commons-lang/maven-metadata.xml";
  66. String expectedMetadataContents = "metadata-for-commons-lang-version-for-project";
  67. Path checksumFile = repoRootInternal.resolve(commonsLangMetadata);
  68. Files.createDirectories(checksumFile.getParent());
  69. org.apache.archiva.common.utils.FileUtils.writeStringToFile( checksumFile, Charset.defaultCharset(), expectedMetadataContents );
  70. WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
  71. WebResponse response = getServletUnitClient().getResponse( request );
  72. assertResponseOK( response );
  73. assertEquals( "Expected file contents", expectedMetadataContents, response.getContentAsString() );
  74. }
  75. @Test
  76. public void testGetGroupMetadataDefaultLayout()
  77. throws Exception
  78. {
  79. String commonsLangMetadata = "commons-lang/maven-metadata.xml";
  80. String expectedMetadataContents = "metadata-for-commons-lang-group";
  81. Path checksumFile = repoRootInternal.resolve(commonsLangMetadata);
  82. Files.createDirectories(checksumFile.getParent());
  83. org.apache.archiva.common.utils.FileUtils.writeStringToFile( checksumFile, Charset.defaultCharset() , expectedMetadataContents);
  84. WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
  85. WebResponse response = getServletUnitClient().getResponse( request );
  86. assertResponseOK( response );
  87. assertEquals( "Expected file contents", expectedMetadataContents, response.getContentAsString() );
  88. }
  89. @Test
  90. public void testGetSnapshotVersionMetadataDefaultLayout()
  91. throws Exception
  92. {
  93. String assemblyPluginMetadata =
  94. "org/apache/maven/plugins/maven-assembly-plugin/2.2-beta-2-SNAPSHOT/maven-metadata.xml";
  95. String expectedMetadataContents = "metadata-for-assembly-plugin-version-2.2-beta-2-SNAPSHOT";
  96. Path checksumFile = repoRootInternal.resolve(assemblyPluginMetadata);
  97. Files.createDirectories(checksumFile.getParent());
  98. org.apache.archiva.common.utils.FileUtils.writeStringToFile( checksumFile, Charset.defaultCharset(), expectedMetadataContents );
  99. WebRequest request =
  100. new GetMethodWebRequest( "http://machine.com/repository/internal/" + assemblyPluginMetadata );
  101. WebResponse response = getServletUnitClient().getResponse( request );
  102. assertResponseOK( response );
  103. assertEquals( "Expected file contents", expectedMetadataContents, response.getContentAsString() );
  104. }
  105. }