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.

TestRepositorySessionFactory.java 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package org.apache.archiva.web.webtest.memory;
  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. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. import org.apache.archiva.metadata.repository.MetadataRepositoryException;
  20. import org.apache.archiva.metadata.repository.RepositorySession;
  21. import org.apache.archiva.metadata.repository.RepositorySessionFactory;
  22. import org.springframework.beans.factory.config.AbstractFactoryBean;
  23. import org.springframework.stereotype.Service;
  24. @Service("repositorySessionFactory#test")
  25. public class TestRepositorySessionFactory
  26. extends AbstractFactoryBean<RepositorySessionFactory>
  27. implements RepositorySessionFactory
  28. {
  29. private RepositorySession repositorySession;
  30. public void setRepositorySession( RepositorySession repositorySession )
  31. {
  32. this.repositorySession = repositorySession;
  33. }
  34. @Override
  35. public void open() {
  36. }
  37. @Override
  38. public boolean isOpen() {
  39. return false;
  40. }
  41. @Override
  42. public RepositorySession createSession() throws MetadataRepositoryException
  43. {
  44. return repositorySession != null ? repositorySession : new RepositorySession( new TestMetadataRepository(),
  45. new TestMetadataResolver() );
  46. }
  47. @Override
  48. public Class<RepositorySessionFactory> getObjectType()
  49. {
  50. return RepositorySessionFactory.class;
  51. }
  52. @Override
  53. protected RepositorySessionFactory createInstance()
  54. throws Exception
  55. {
  56. return this;
  57. }
  58. @Override
  59. public void close()
  60. {
  61. // no op
  62. }
  63. }