<goal>shade</goal>
</goals>
<configuration>
+ <createDependencyReducedPom>false</createDependencyReducedPom>
<finalName>apache-archiva-cli-${project.version}</finalName>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
xmlns="http://maven.apache.org/SETTINGS/1.0.0">
<mirrors>
<mirror>
- <mirrorOf>external:*</mirrorOf>
+ <mirrorOf>external:*,!central</mirrorOf>
<id>local-mirror</id>
<name>local-mirror</name>
<url>@localRepositoryUrl@</url>
<enabled>true</enabled>
</snapshots>
</repository>
+ <repository>
+ <id>central</id>
+ <url>https://repo.maven.apache.org/maven2</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
+ <pluginRepository>
+ <id>central</id>
+ <url>https://repo.maven.apache.org/maven2</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </pluginRepository>
</pluginRepositories>
</profile>
</profiles>
{
try ( RepositorySession session = getSessionFactory( ).createSession( ) )
{
- tryAssert( ( ) -> {
- assertThat( getRepository( ).getRootNamespaces( session, TEST_REPO_ID ) ).isNotNull( ).isEmpty( );
- } );
+ tryAssert( ( ) -> assertThat( getRepository( ).getRootNamespaces( session, TEST_REPO_ID ) ).isNotNull( ).isEmpty( ));
getRepository( ).updateNamespace( session, TEST_REPO_ID, TEST_NAMESPACE );
- tryAssert( ( ) -> {
- assertThat( getRepository( ).getRootNamespaces( session, TEST_REPO_ID ) ).isNotNull( ).isNotEmpty( ).contains(
- TEST_NAMESPACE ).hasSize( 1 );
- } );
+ tryAssert( ( ) -> assertThat( getRepository( ).getRootNamespaces( session, TEST_REPO_ID ) ).isNotNull( ).isNotEmpty( )
+ .contains( TEST_NAMESPACE ).hasSize( 1 ));
getRepository( ).removeNamespace( session, TEST_REPO_ID, TEST_NAMESPACE );
- tryAssert( ( ) -> {
- assertThat( getRepository( ).getRootNamespaces( session, TEST_REPO_ID ) ).isNotNull( ).isEmpty( );
- } );
+ tryAssert( ( ) -> assertThat( getRepository( ).getRootNamespaces( session, TEST_REPO_ID ) ).isNotNull( ).isEmpty( ));
}
}
<groupId>org.apache.archiva</groupId>
<artifactId>metadata-repository-api</artifactId>
</dependency>
- <dependency>
- <groupId>org.apache.archiva</groupId>
- <artifactId>metadata-repository-api</artifactId>
- <classifier>tests</classifier>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-common</artifactId>
<artifactId>metadata-model</artifactId>
</dependency>
-
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<version>${datastax.driver.version}</version>
</dependency>
-
<!-- TEST Scope -->
<dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-api</artifactId>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>metadata-repository-api</artifactId>
+ <classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-1.2-api</artifactId>
+ <artifactId>log4j-core</artifactId>
<version>${log4j.version}</version>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-engine</artifactId>
+ <groupId>org.testcontainers</groupId>
+ <artifactId>cassandra</artifactId>
+ <version>1.17.1</version>
<scope>test</scope>
</dependency>
-
</dependencies>
<build>
- <testResources>
- <testResource>
- <directory>src/test/filtered-resources</directory>
- <filtering>true</filtering>
- </testResource>
- </testResources>
-
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>reserve-ports</id>
- <phase>process-test-resources</phase>
- <goals>
- <goal>reserve-network-port</goal>
- </goals>
- <configuration>
- <portNames>
- <portName>cassandra.rpcPort</portName>
- <portName>cassandra.storagePort</portName>
- <portName>cassandra.stopPort</portName>
- <portName>cassandra.jmxPort</portName>
- <portName>cassandra.nativeTransportPort</portName>
- </portNames>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>cassandra-maven-plugin</artifactId>
- <version>3.7-SNAPSHOT</version>
- <executions>
- <execution>
- <id>start-cassandra</id>
- <phase>pre-integration-test</phase>
- <goals>
- <goal>start</goal>
- </goals>
- <configuration>
- <nativeTransportPort>${cassandra.nativeTransportPort}</nativeTransportPort>
- <rpcPort>${cassandra.rpcPort}</rpcPort>
- <storagePort>${cassandra.storagePort}</storagePort>
- <stopPort>${cassandra.stopPort}</stopPort>
- <jmxPort>${cassandra.jmxPort}</jmxPort>
- <addMainClasspath>false</addMainClasspath>
- <addTestClasspath>false</addTestClasspath>
- <startWaitSeconds>500</startWaitSeconds>
- <startNativeTransport>true</startNativeTransport>
- <logLevel>INFO</logLevel>
- <loadAfterFirstStart>false</loadAfterFirstStart>
- <systemPropertyVariables>
- <cassandra.jmx.local.port>${cassandra.jmxPort}</cassandra.jmx.local.port>
- </systemPropertyVariables>
- <yaml><![CDATA[rpc_address: 127.0.0.1
-broadcast_rpc_address: 127.0.0.1
-listen_address: 127.0.0.1
-auto_snapshot: false
-snapshot_before_compaction: false
-num_tokens: 1
-]]></yaml>
- </configuration>
- </execution>
- <execution>
- <id>stop-cassandra</id>
- <phase>post-integration-test</phase>
- <goals>
- <goal>stop</goal>
- </goals>
- </execution>
- </executions>
- <dependencies>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- <version>${slf4j.version}</version>
- </dependency>
- <dependency>
- <groupId>net.java.dev.jna</groupId>
- <artifactId>jna</artifactId>
- <version>4.2.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cassandra</groupId>
- <artifactId>cassandra-all</artifactId>
- <version>${cassandraVersion}</version>
- </dependency>
- </dependencies>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-failsafe-plugin</artifactId>
- <version>3.0.0-M5</version>
- <executions>
- <execution>
- <goals>
- <goal>integration-test</goal>
- <goal>verify</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <includes>
- <include>**/*Test.java</include>
- </includes>
- <systemPropertyVariables>
- <cassandra.port>${cassandra.nativeTransportPort}</cassandra.port>
- <cassandra.host>127.0.0.1</cassandra.host>
- <archiva.repositorySessionFactory.id>cassandra</archiva.repositorySessionFactory.id>
- <appserver.base>${project.build.directory}/appserver-base</appserver.base>
- <java.net.preferIPv4Stack>true</java.net.preferIPv4Stack>
- </systemPropertyVariables>
- <trimStackTrace>false</trimStackTrace>
- <skip>false</skip>
- <classesDirectory>${project.build.outputDirectory}</classesDirectory>
- </configuration>
- <dependencies>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-engine</artifactId>
- <version>${junit.jupiter.version}</version>
- </dependency>
- </dependencies>
- </plugin>
-
- </plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
- <executions>
- </executions>
<configuration>
- <skip>true</skip>
+ <systemPropertyVariables>
+ <archiva.repositorySessionFactory.id>cassandra</archiva.repositorySessionFactory.id>
+ <appserver.base>${project.build.directory}/appserver-base</appserver.base>
+ <cassandraVersion>${cassandraVersion}</cassandraVersion>
+ </systemPropertyVariables>
</configuration>
</plugin>
<configuration>
<excludes>
<exclude>src/cassandra/**</exclude>
- <exclude>src/test/resources/cassandra-test.yaml</exclude>
</excludes>
</configuration>
</plugin>
</pluginManagement>
</build>
- <profiles>
- <profile>
- <id>jdk9+</id>
- <activation>
- <jdk>[1.9,)</jdk>
- </activation>
- <properties >
- <cassandra.addJdk11Options>true</cassandra.addJdk11Options>
- </properties>
- </profile>
- </profiles>
</project>
hostNames.add( cassandraHost + ":" + cassandraPort );
configLoader =
DriverConfigLoader.programmaticBuilder( )
-
.withStringList( DefaultDriverOption.CONTACT_POINTS, hostNames )
.withInt( DefaultDriverOption.CONNECTION_POOL_LOCAL_SIZE, maxActive )
.withInt( DefaultDriverOption.CONNECTION_POOL_REMOTE_SIZE, maxActive )
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
-
- <bean name="repositoryStorage#maven2" class="org.apache.archiva.metadata.repository.cassandra.MockRepositoryStorage"/>
-
- <bean name="mockrepo#listener" class="org.apache.archiva.metadata.repository.cassandra.MockRepositoryStorage"/>
-
-</beans>
\ No newline at end of file
import org.apache.archiva.metadata.repository.RepositorySession;
import org.apache.archiva.metadata.repository.RepositorySessionFactory;
import org.apache.archiva.metadata.repository.cassandra.model.ProjectVersionMetadataModel;
+import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.extension.ExtendWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
+import org.testcontainers.containers.CassandraContainer;
+import org.testcontainers.containers.output.Slf4jLogConsumer;
+import org.testcontainers.utility.DockerImageName;
import javax.inject.Inject;
import javax.inject.Named;
*/
@ExtendWith( SpringExtension.class )
@TestInstance( TestInstance.Lifecycle.PER_CLASS )
+@ContextConfiguration( locations = {"classpath*:/META-INF/spring-context.xml"} )
public class CassandraMetadataRepositoryTest
extends AbstractMetadataRepositoryTest
{
+
+ private static final Logger LOGGER = LoggerFactory.getLogger( CassandraMetadataRepositoryTest.class );
+
@Inject
@Named(value = "archivaEntityManagerFactory#cassandra")
CassandraArchivaManager cassandraArchivaManager;
RepositorySession session;
+ private static final CassandraContainer CASSANDRA =
+ new CassandraContainer(DockerImageName.parse("cassandra")
+ .withTag(System.getProperty("cassandraVersion","3.11.2")));
+
+ // because of @ExtendWith( SpringExtension.class ) @BeforeAll will not be executed before spring resolution so need to use this...
+ static {
+ LOGGER.info("initCassandra");
+ CASSANDRA.withLogConsumer(new Slf4jLogConsumer(LoggerFactory.getLogger("org.apache.archiva.metadata.repository.cassandra.logs")));
+ CASSANDRA.start();
+ System.setProperty("cassandra.host", CASSANDRA.getHost());
+ System.setProperty("cassandra.port", CASSANDRA.getMappedPort(9042).toString());
+ }
+
long cTime;
int testNum = 0;
final AtomicBoolean clearedTables = new AtomicBoolean( false );
return cmr;
}
+ @AfterAll
+ public static void stopCassandra()
+ throws Exception {
+ CASSANDRA.close();
+ }
+
@BeforeEach
- public void setUp( TestInfo testInfo )
+ @Override
+ public void setUp()
throws Exception
{
cTime = System.currentTimeMillis( );
@AfterEach
- public void shutdown(TestInfo testInfo)
+ public void shutdown()
throws Exception
{
clearReposAndNamespace( cassandraArchivaManager, clearedTables );
cassandraArchivaManager.getLicenseFamilyName( ),
cassandraArchivaManager.getDependencyFamilyName( )
);
- CompletableFuture.allOf( tables.stream( ).map( table -> session.executeAsync( truncate( table ).build( ) ) )
+ CompletableFuture.allOf(tables.stream()
+ .map(table -> session.executeAsync(truncate(table).build()))
.map( CompletionStage::toCompletableFuture ).collect( Collectors.toList( ) ).toArray( new CompletableFuture[0] ) )
.whenComplete( ( c, e ) -> {
if ( clearedFlag != null ) clearedFlag.set( true );
import org.apache.archiva.metadata.model.ProjectMetadata;
import org.apache.archiva.metadata.repository.cassandra.model.Namespace;
import org.apache.archiva.metadata.repository.cassandra.model.Repository;
+import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.slf4j.LoggerFactory;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
+import org.testcontainers.containers.CassandraContainer;
+import org.testcontainers.containers.output.Slf4jLogConsumer;
+import org.testcontainers.utility.DockerImageName;
import javax.inject.Inject;
import javax.inject.Named;
* @author Olivier Lamy
*/
@ExtendWith( SpringExtension.class )
-@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } )
+@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml" } )
public class RepositoriesNamespaceTest
{
- private Logger logger = LoggerFactory.getLogger( getClass() );
+ private static final Logger LOGGER = LoggerFactory.getLogger( RepositoriesNamespaceTest.class );
+
+ private static final CassandraContainer CASSANDRA =
+ new CassandraContainer(DockerImageName.parse("cassandra")
+ .withTag(System.getProperty("cassandraVersion","3.11.2")));
@Inject
@Named( value = "archivaEntityManagerFactory#cassandra" )
CassandraArchivaManager cassandraArchivaManager;
-
CassandraMetadataRepository cmr;
+ @BeforeAll
+ public static void initCassandra()
+ throws Exception {
+ CASSANDRA.withLogConsumer(new Slf4jLogConsumer(LoggerFactory.getLogger("org.apache.archiva.metadata.repository.cassandra.logs")));
+ CASSANDRA.start();
+ System.setProperty("cassandra.host", CASSANDRA.getHost());
+ System.setProperty("cassandra.port", CASSANDRA.getMappedPort(9042).toString());
+ }
+
+ @AfterAll
+ public static void stopCassandra()
+ throws Exception {
+ CASSANDRA.close();
+ }
+
@BeforeEach
public void setup()
throws Exception
}
catch ( Exception e )
{
- logger.error( e.getMessage(), e );
+ LOGGER.error( e.getMessage(), e );
throw e;
}
finally
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+ <bean name="repositoryStorage#maven2" class="org.apache.archiva.metadata.repository.cassandra.MockRepositoryStorage"/>
+
+ <bean name="mockrepo#listener" class="org.apache.archiva.metadata.repository.cassandra.MockRepositoryStorage"/>
+
+</beans>
\ No newline at end of file
-->
-<configuration status="debug">
-
-
-
+<configuration>
<appenders>
<Console name="console" target="SYSTEM_OUT">
- <!--PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/-->
<PatternLayout pattern="%highlight{%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n}" />
</Console>
-
</appenders>
<loggers>
-
-
- <logger name="org.apache.archiva.metadata.repository.cassandra" level="debug"/>
-
- <root level="debug" includeLocation="true">
+ <logger name="org.apache.archiva.metadata.repository.cassandra" level="info"/>
+ <logger name="org.apache.archiva.metadata.repository.cassandra.logs" level="error"/>
+ <root level="info" includeLocation="true">
<appender-ref ref="console"/>
</root>
</loggers>
-->
-<configuration status="debug">
+<configuration>
<appenders>
<Console name="console" target="SYSTEM_OUT">
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
- <version>3.2.4</version>
<executions>
<!-- Run shade goal on package phase -->
<execution>
<goal>shade</goal>
</goals>
<configuration>
+ <createDependencyReducedPom>false</createDependencyReducedPom>
<filters>
<filter>
<artifact>*:*</artifact>
</dependency>
<!-- JUNIT 5 -->
- <dependency>
- <groupId>org.junit.platform</groupId>
- <artifactId>junit-platform-launcher</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.junit.platform</groupId>
- <artifactId>junit-platform-console-standalone</artifactId>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-engine</artifactId>
+ <artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
+ <dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
-
-
+<!-- <dependency>-->
+<!-- <groupId>org.junit.platform</groupId>-->
+<!-- <artifactId>junit-platform-launcher</artifactId>-->
+<!-- <scope>test</scope>-->
+<!-- </dependency>-->
+<!-- <dependency>-->
+<!-- <groupId>org.junit.platform</groupId>-->
+<!-- <artifactId>junit-platform-console-standalone</artifactId>-->
+<!-- <scope>test</scope>-->
+<!-- </dependency>-->
+<!-- <dependency>-->
+<!-- <groupId>org.junit.jupiter</groupId>-->
+<!-- <artifactId>junit-jupiter-engine</artifactId>-->
+<!-- <scope>test</scope>-->
+<!-- </dependency>-->
+<!-- <dependency>-->
+<!-- <groupId>org.junit.vintage</groupId>-->
+<!-- <artifactId>junit-vintage-engine</artifactId>-->
+<!-- <scope>test</scope>-->
+<!-- </dependency>-->
</dependencies>