Skip to content

Commit 310c633

Browse files
committed
Removed psa dependecies in tests
1 parent 9b8c74b commit 310c633

File tree

18 files changed

+135
-100
lines changed

18 files changed

+135
-100
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#Target folder
22
**/target
3+
/test-shards
4+
/${env.M3_REPO}
35

46
#IDE settings
57
**/.idea
6-
*.impl
8+
*.iml

.gitlab-ci.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
variables:
2+
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository -Djava.awt.headless=true"
3+
MAVEN_CLI_OPTS: "--fail-at-end -B -s .m2/settings.xml"
4+
5+
stages:
6+
- prepare
7+
- build
8+
- deploy
9+
10+
11+
download-dependencies:
12+
image: maven:3.5-jdk-8
13+
stage: prepare
14+
script:
15+
- 'mvn $MAVEN_CLI_OPTS -Dsilent=true org.apache.maven.plugins:maven-dependency-plugin:3.0.2:go-offline'
16+
cache:
17+
paths:
18+
- .m2/repository
19+
20+
build_and_deploy:
21+
stage: build
22+
image: maven:3.5-jdk-8
23+
script:
24+
- 'mvn $MAVEN_CLI_OPTS deploy -Drat.skip=true'
25+
cache:
26+
paths:
27+
- .m2/repository
28+
policy: pull
29+
artifacts:
30+
paths:
31+
- 'target/maven-dependency-plugin-*.jar'

.m2/settings.xml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd"
2+
xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
3+
<localRepository>${env.CI_PROJECT_DIR}/.m2/repository</localRepository>
4+
<servers>
5+
<server>
6+
<id>${env.MAVEN_RELEASE_REPO}</id>
7+
<username>${env.MAVEN_REPO_USER}</username>
8+
<password>${env.MAVEN_REPO_PASS}</password>
9+
</server>
10+
<server>
11+
<id>${env.MAVEN_SNAPSHOT_REPO}</id>
12+
<username>${env.MAVEN_REPO_USER}</username>
13+
<password>${env.MAVEN_REPO_PASS}</password>
14+
</server>
15+
</servers>
16+
<profiles>
17+
<profile>
18+
<id>artifactory</id>
19+
<repositories>
20+
<repository>
21+
<id>${env.MAVEN_RELEASE_REPO}</id>
22+
<name>Maven Release</name>
23+
<url>${env.MAVEN_REPO_URL}/${env.MAVEN_RELEASE_REPO}</url>
24+
<snapshots>
25+
<enabled>false</enabled>
26+
</snapshots>
27+
</repository>
28+
<repository>
29+
<id>${env.MAVEN_SNAPSHOT_REPO}</id>
30+
<name>Maven Snapshot</name>
31+
<url>${env.MAVEN_REPO_URL}/${env.MAVEN_SNAPSHOT_REPO}</url>
32+
<snapshots/>
33+
</repository>
34+
</repositories>
35+
<pluginRepositories>
36+
<pluginRepository>
37+
<id>${env.MAVEN_RELEASE_REPO}</id>
38+
<name>Maven Release</name>
39+
<url>${env.MAVEN_REPO_URL}/${env.MAVEN_RELEASE_REPO}</url>
40+
<snapshots>
41+
<enabled>false</enabled>
42+
</snapshots>
43+
</pluginRepository>
44+
<pluginRepository>
45+
<id>${env.MAVEN_SNAPSHOT_REPO}</id>
46+
<name>Maven Snapshot</name>
47+
<url>${env.MAVEN_REPO_URL}/${env.MAVEN_SNAPSHOT_REPO}</url>
48+
<snapshots/>
49+
</pluginRepository>
50+
</pluginRepositories>
51+
</profile>
52+
</profiles>
53+
<activeProfiles>
54+
<activeProfile>artifactory</activeProfile>
55+
</activeProfiles>
56+
</settings>

pom.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
</build>
4343

4444
<dependencies>
45+
<!-- Maven dependencies -->
4546
<dependency>
4647
<groupId>org.apache.maven</groupId>
4748
<artifactId>maven-plugin-api</artifactId>
@@ -53,15 +54,12 @@
5354
<version>3.2.5</version>
5455
<scope>provided</scope>
5556
</dependency>
56-
5757
<dependency>
5858
<groupId>org.apache.maven.plugin-tools</groupId>
5959
<artifactId>maven-plugin-annotations</artifactId>
6060
<version>3.4</version>
6161
<scope>provided</scope>
6262
</dependency>
63-
64-
6563
<dependency>
6664
<groupId>org.apache.maven.plugin-testing</groupId>
6765
<artifactId>maven-plugin-testing-harness</artifactId>
@@ -75,6 +73,7 @@
7573
<scope>test</scope>
7674
</dependency>
7775

76+
<!-- Test dependencies -->
7877
<dependency>
7978
<groupId>junit</groupId>
8079
<artifactId>junit</artifactId>

src/main/java/com/telekom/gis/psa/test/shard/maven/plugin/TestFileReader.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public boolean accept(File file) {
7373
private void addTestFilePathsIn(String pathToPackage, String path, File dir, List<String> testFilePaths){
7474
String[] filePathArray = dir.list(filenameFilter);
7575
for (String filePath : filePathArray) {
76-
int i = filePath.lastIndexOf(".");
76+
int i = filePath.lastIndexOf('.');
7777
if(i > 0) {
7878
filePath = filePath.substring(0, i);
7979
}
@@ -86,13 +86,12 @@ private String getPackageName(String pathToPackage, String path) {
8686
if(index <= pathToPackage.length()){
8787
return path;
8888
}
89-
path = path.substring(index).replaceAll("[\\\\/]", ".");
90-
return path;
89+
return path.substring(index).replaceAll("[\\\\/]", ".");
9190
}
9291

9392
/**
9493
* Return all found test file paths. {@link TestFileReader#read(String, String...)} must be invoked first, otherwise it
95-
* will always retrun an empty list
94+
* will always return an empty list
9695
*
9796
* @return a list with test file paths ([package].[file]) without file ending
9897
*/

src/test/java/com/telekom/gis/psa/test/shard/maven/plugin/TestShardMojoTest.java

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/test/java/com/telekom/gis/psa/test/shard/maven/plugin/TestShardUnitTest.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,21 @@ public static void loadProperties() throws Exception {
3737

3838
//Creator properties
3939
properties.put("shardCount", 5);
40-
properties.put("includes", new String[]{"**/*Test.java"});
41-
properties.put("testFolders", new String[]{
42-
"P:\\codebase\\code\\test\\integration-tests\\src\\test\\java\\com\\telekom\\gis\\psa\\itest"});
40+
properties.put("includes", new String[]{"**/*Test*.java"});
41+
42+
String testFolder = TestShardUnitTest.class.getClassLoader().getResource("testClasses").getFile();
43+
testFolder = testFolder.replaceAll("%20", " ");
44+
45+
properties.put("testFolders", new String[]{testFolder});
4346
properties.put("pathToPackage", "src\\test\\java");
4447

4548
testShardCreatorMojo = new TestShardCreatorMojo();
4649
loadMojo(testShardCreatorMojo);
4750

4851
testShardCleanerMojo = new TestShardCleanerMojo();
4952
loadMojo(testShardCleanerMojo);
53+
54+
testShardCleanerMojo.execute();
5055
}
5156

5257
private static void loadMojo(Object mojo) throws Exception {
@@ -70,7 +75,7 @@ private static void loadMojo(Class<?> type, Object mojo) throws Exception {
7075
@Test
7176
public void testTestShardCreator() throws MojoFailureException, MojoExecutionException {
7277
testShardCreatorMojo.execute();
73-
Assert.assertEquals(5, testShardCreatorMojo.getReader().getTestFilePaths().size());
78+
Assert.assertEquals(10, testShardCreatorMojo.getReader().getTestFilePaths().size());
7479

7580
File file = new File("test-shards");
7681
Assert.assertTrue(file.isDirectory());
@@ -82,7 +87,7 @@ public static void testTestShardCleaner() throws MojoFailureException, MojoExecu
8287
testShardCleanerMojo.execute();
8388

8489
File file = new File("test-shards");
85-
if(file.isDirectory()){
90+
if (file.isDirectory()) {
8691
Assert.assertTrue(file.list((dir, name) -> name.startsWith("shard") && name.endsWith(".txt")).length == 0);
8792
Assert.assertTrue(file.delete());
8893
}

src/test/resources/test-project/pom.xml

Lines changed: 0 additions & 52 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/*
2+
Just a dummy test
3+
*/
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/*
2+
Just a dummy test
3+
*/

0 commit comments

Comments
 (0)