2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing,
12 * software distributed under the License is distributed on an
13 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 * KIND, either express or implied. See the License for the
15 * specific language governing permissions and limitations
19 package org.apache.archiva.repository.content.base;
21 import org.apache.archiva.common.filelock.DefaultFileLockManager;
22 import org.apache.archiva.repository.content.ContentItem;
23 import org.apache.archiva.repository.content.base.builder.OptBuilder;
24 import org.apache.archiva.repository.mock.ManagedRepositoryContentMock;
25 import org.apache.archiva.repository.storage.FilesystemStorage;
26 import org.apache.archiva.repository.storage.StorageAsset;
27 import org.junit.jupiter.api.BeforeEach;
28 import org.junit.jupiter.api.Test;
30 import java.io.IOException;
31 import java.nio.file.Paths;
33 import static org.junit.jupiter.api.Assertions.*;
37 * @author Martin Stockhammer <martin_s@apache.org>
39 public abstract class ContentItemTest
41 protected ManagedRepositoryContentMock repository;
42 protected FilesystemStorage storage;
43 protected StorageAsset asset;
46 public void setup() throws IOException
48 this.repository = new ManagedRepositoryContentMock( );
50 this.storage = new FilesystemStorage( Paths.get( "target" ), new DefaultFileLockManager( ) );
52 this.asset = storage.getAsset( "" );
56 public abstract OptBuilder getBuilder();
59 void testWithAttribute() {
60 ContentItem test = getBuilder( ).withAttribute( "testkey1", "testvalue1" ).withAttribute( "testkey2", "testvalue2" ).build( );
62 assertNotNull( test.getAttributes( ) );
63 assertEquals( 2, test.getAttributes( ).size( ) );
64 assertEquals( "testvalue1", test.getAttribute( "testkey1" ) );
65 assertEquals( "testvalue2", test.getAttribute( "testkey2" ) );
66 assertNull( test.getAttribute( "key123" ) );