Skip to content

Commit 2c8b2c5

Browse files
committed
v0.12.0 + add tests for Maven
1 parent 506dcde commit 2c8b2c5

File tree

14 files changed

+142
-38
lines changed

14 files changed

+142
-38
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,22 @@ is recommended for better performances on disk operations (detection of physical
1717
[![Codecov](https://codecov.io/gh/lecousin/java-framework-core/graph/badge.svg)](https://codecov.io/gh/lecousin/java-framework-core/branch/master)
1818

1919
- core [![Maven Central](https://img.shields.io/maven-central/v/net.lecousin/core.svg)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22net.lecousin%22%20AND%20a%3A%22core%22)
20-
[![Javadoc](https://img.shields.io/badge/javadoc-0.11.0-brightgreen.svg)](https://www.javadoc.io/doc/net.lecousin/core/0.11.0)
20+
[![Javadoc](https://img.shields.io/badge/javadoc-0.12.0-brightgreen.svg)](https://www.javadoc.io/doc/net.lecousin/core/0.12.0)
2121

2222
- core.javaee [![Maven Central](https://img.shields.io/maven-central/v/net.lecousin/core.javaee.svg)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22net.lecousin%22%20AND%20a%3A%22core.javaee%22)
23-
[![Javadoc](https://img.shields.io/badge/javadoc-0.11.0-brightgreen.svg)](https://www.javadoc.io/doc/net.lecousin/core.javaee/0.11.0)
23+
[![Javadoc](https://img.shields.io/badge/javadoc-0.12.0-brightgreen.svg)](https://www.javadoc.io/doc/net.lecousin/core.javaee/0.12.0)
2424

2525
- log.bridges.commons-logging [![Maven Central](https://img.shields.io/maven-central/v/net.lecousin.framework/log.bridges.commons-logging.svg)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22net.lecousin.framework%22%20AND%20a%3A%22log.bridges.commons-logging%22)
26-
[![Javadoc](https://img.shields.io/badge/javadoc-0.11.0-brightgreen.svg)](https://www.javadoc.io/doc/net.lecousin.framework/log.bridges.commons-logging/0.11.0)
26+
[![Javadoc](https://img.shields.io/badge/javadoc-0.12.0-brightgreen.svg)](https://www.javadoc.io/doc/net.lecousin.framework/log.bridges.commons-logging/0.12.0)
2727

2828
- log.bridges.slf4j [![Maven Central](https://img.shields.io/maven-central/v/net.lecousin.framework/log.bridges.slf4j.svg)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22net.lecousin.framework%22%20AND%20a%3A%22log.bridges.slf4j%22)
29-
[![Javadoc](https://img.shields.io/badge/javadoc-0.11.0-brightgreen.svg)](https://www.javadoc.io/doc/net.lecousin.framework/log.bridges.slf4j/0.11.0)
29+
[![Javadoc](https://img.shields.io/badge/javadoc-0.12.0-brightgreen.svg)](https://www.javadoc.io/doc/net.lecousin.framework/log.bridges.slf4j/0.12.0)
3030

31-
### Branch 0.11
31+
### Branch 0.12
3232

33-
![build status](https://travis-ci.org/lecousin/java-framework-core.svg?branch=0.11 "Build Status")
34-
![build status](https://ci.appveyor.com/api/projects/status/github/lecousin/java-framework-core?branch=0.11&svg=true "Build Status")
35-
[![Codecov](https://codecov.io/gh/lecousin/java-framework-core/branch/0.11/graph/badge.svg)](https://codecov.io/gh/lecousin/java-framework-core/branch/0.11)
33+
![build status](https://travis-ci.org/lecousin/java-framework-core.svg?branch=0.12 "Build Status")
34+
![build status](https://ci.appveyor.com/api/projects/status/github/lecousin/java-framework-core?branch=0.12&svg=true "Build Status")
35+
[![Codecov](https://codecov.io/gh/lecousin/java-framework-core/branch/0.12/graph/badge.svg)](https://codecov.io/gh/lecousin/java-framework-core/branch/0.12)
3636

3737
## Multi-threading
3838

core.javaee/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
<parent>
44
<groupId>net.lecousin</groupId>
55
<artifactId>core-parent-pom</artifactId>
6-
<version>0.11.0</version>
6+
<version>0.12.0</version>
77
</parent>
88
<artifactId>core.javaee</artifactId>
9-
<version>0.11.0</version>
9+
<version>0.12.0</version>
1010
<dependencies>
1111
<dependency>
1212
<groupId>net.lecousin</groupId>
1313
<artifactId>core</artifactId>
14-
<version>0.11.0</version>
14+
<version>0.12.0</version>
1515
</dependency>
1616
<dependency>
1717
<groupId>javax.enterprise.concurrent</groupId>

net.lecousin.core/.settings/org.eclipse.jdt.core.prefs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@ org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
44
org.eclipse.jdt.core.compiler.compliance=1.8
55
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
66
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
7-
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
87
org.eclipse.jdt.core.compiler.release=disabled
98
org.eclipse.jdt.core.compiler.source=1.8

net.lecousin.core/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
33
<modelVersion>4.0.0</modelVersion>
44
<artifactId>core</artifactId>
5-
<version>0.11.0</version>
5+
<version>0.12.0</version>
66

77
<parent>
88
<groupId>net.lecousin</groupId>
99
<artifactId>core-parent-pom</artifactId>
10-
<version>0.11.0</version>
10+
<version>0.12.0</version>
1111
</parent>
1212

1313
<name>lecousin.net Java core framework</name>

net.lecousin.core/src/main/java/net/lecousin/framework/application/libraries/artifacts/maven/MavenPOM.java

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -877,40 +877,66 @@ private String resolve(String value, Map<String, String> properties) {
877877
private boolean checkProfile(Profile profile, Map<String, String> finalProperties) {
878878
if (profile.activationOS != null) {
879879
if (profile.activationOS.name != null) {
880-
if (!System.getProperty("os.name").toLowerCase(Locale.US).equals(profile.activationOS.name.toLowerCase()))
880+
String name = System.getProperty("os.name").toLowerCase(Locale.US);
881+
String s = profile.activationOS.name.toLowerCase();
882+
if (s.startsWith("!"))
883+
if (name.equals(s.substring(1)))
884+
return false;
885+
if (!name.equals(s))
881886
return false;
882887
}
883888
if (profile.activationOS.arch != null) {
884-
if (!System.getProperty("os.arch").toLowerCase(Locale.US).equals(profile.activationOS.arch.toLowerCase()))
889+
String arch = System.getProperty("os.arch").toLowerCase(Locale.US);
890+
String s = profile.activationOS.arch.toLowerCase();
891+
if (s.startsWith("!"))
892+
if (arch.equals(s.substring(1)))
893+
return false;
894+
if (!arch.equals(s))
885895
return false;
886896
}
887897
if (profile.activationOS.family != null) {
888898
OSFamily family = SystemEnvironment.getOSFamily();
889899
if (family == null)
890900
return false;
891-
if (!profile.activationOS.family.toLowerCase().equals(family.getName()))
901+
String fam = profile.activationOS.family.toLowerCase();
902+
String s = family.getName();
903+
if (s.startsWith("!"))
904+
if (fam.equals(s.substring(1)))
905+
return false;
906+
if (!fam.equals(s))
892907
return false;
893908
}
894909
if (profile.activationOS.version != null) {
895-
if (!System.getProperty("os.version").toLowerCase(Locale.US).equals(profile.activationOS.version.toLowerCase()))
910+
String ver = System.getProperty("os.version").toLowerCase(Locale.US);
911+
String s = profile.activationOS.version.toLowerCase();
912+
if (s.startsWith("!"))
913+
if (ver.equals(s.substring(1)))
914+
return false;
915+
if (!ver.equals(s))
896916
return false;
897917
}
898918
}
899919
if (profile.activationPropertyName != null) {
900920
if (profile.activationPropertyValue == null) {
901-
if (!properties.containsKey(profile.activationPropertyName) &&
902-
!finalProperties.containsKey(profile.activationPropertyName))
921+
String s = profile.activationPropertyName;
922+
boolean presentExpected = !s.startsWith("!");
923+
if (!presentExpected) s = s.substring(1);
924+
if (presentExpected != properties.containsKey(s) &&
925+
presentExpected != finalProperties.containsKey(s))
903926
return false;
904927
} else {
905928
String p1 = properties.get(profile.activationPropertyName);
906929
String p2 = finalProperties.get(profile.activationPropertyName);
930+
String value = profile.activationPropertyName;
931+
boolean presentExpected = !value.startsWith("!");
932+
if (!presentExpected) value = value.substring(1);
907933
if (p1 == null) {
908934
if (p2 == null) return false;
909-
if (!p2.equals(profile.activationPropertyName)) return false;
935+
if (presentExpected != p2.equals(value)) return false;
910936
}
911-
if (!p1.equals(profile.activationPropertyName)) {
937+
if (presentExpected != p1.equals(value)) {
912938
if (p2 == null) return false;
913-
if (!p2.equals(profile.activationPropertyName)) return false;
939+
if (presentExpected != p2.equals(value)) return false;
914940
}
915941
}
916942
}

net.lecousin.core/src/main/java/net/lecousin/framework/io/buffering/BufferedIO.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1194,7 +1194,7 @@ protected AsyncWork<ByteBuffer, IOException> readNextBufferAsync(RunnableWithPar
11941194
public ByteBuffer run() throws IOException, CancelException {
11951195
if (buffer.error != null)
11961196
throw buffer.error;
1197-
if (sp != null && sp.isCancelled())
1197+
if (sp.isCancelled())
11981198
throw sp.getCancelEvent();
11991199
int start = getBufferOffset(pos);
12001200
ByteBuffer buf = ByteBuffer.allocate(buffer.len - start);

net.lecousin.core/src/main/java/net/lecousin/framework/memory/MemoryManager.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,13 @@ private static void checkMemory() {
183183
if (logger.debug())
184184
logMemory(Level.DEBUG);
185185

186+
/*
186187
if (System.currentTimeMillis() - lastGC[0] > 15 * 60 * 1000) {
187188
if (logger.debug()) logger.debug("No garbage collection since 15 minutes => force it");
188189
System.gc();
189190
if (logger.debug())
190191
logMemory(Level.DEBUG);
191-
}
192+
}*/
192193
}
193194
}
194195

net.lecousin.core/src/test/java/net/lecousin/framework/core/tests/application/TestMaven.java

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,39 @@
11
package net.lecousin.framework.core.tests.application;
22

33
import java.io.File;
4+
import java.io.InputStream;
45
import java.util.List;
56
import java.util.zip.ZipFile;
67

8+
import org.junit.Assert;
9+
import org.junit.Test;
10+
711
import net.lecousin.framework.application.libraries.artifacts.LibraryDescriptor.Dependency;
812
import net.lecousin.framework.application.libraries.artifacts.maven.MavenLocalRepository;
913
import net.lecousin.framework.application.libraries.artifacts.maven.MavenPOM;
1014
import net.lecousin.framework.application.libraries.artifacts.maven.MavenPOMLoader;
1115
import net.lecousin.framework.application.libraries.artifacts.maven.MavenRemoteRepository;
16+
import net.lecousin.framework.application.libraries.artifacts.maven.MavenSettings;
1217
import net.lecousin.framework.concurrent.Task;
1318
import net.lecousin.framework.core.test.LCCoreAbstractTest;
1419

15-
import org.junit.Assert;
16-
import org.junit.Test;
17-
1820
public class TestMaven extends LCCoreAbstractTest {
1921

2022
@Test(timeout=120000)
2123
public void testLocalRepository() throws Exception {
22-
File repoDir = new File(new File(System.getProperty("user.home")), ".m2/repository");
24+
File settings = new File(System.getProperty("user.home") + "/.m2/settings.xml");
25+
String localRepo = System.getProperty("user.home") + "/.m2/repository";
26+
if (settings.exists()) {
27+
try {
28+
MavenSettings ms = MavenSettings.load(settings);
29+
if (ms.localRepository != null)
30+
localRepo = ms.localRepository;
31+
} catch (Exception e) {
32+
System.err.println("Error reading Maven settings.xml");
33+
e.printStackTrace(System.err);
34+
}
35+
}
36+
File repoDir = new File(localRepo);
2337
MavenLocalRepository repo = new MavenLocalRepository(repoDir, true, true);
2438
repo.toString();
2539

@@ -140,8 +154,45 @@ public void testRemoteRepository() throws Exception {
140154
pom.getDependenciesAdditionalRepositories();
141155
pom.getLoader();
142156
pom.getDirectory();
157+
158+
159+
pom = repo.load("org.javassist", "javassist", "3.16.1-GA", pomLoader, Task.PRIORITY_NORMAL).blockResult(0);
160+
for (Dependency dep : pom.getDependencies()) {
161+
dep.getGroupId();
162+
dep.getArtifactId();
163+
dep.getClassifier();
164+
dep.getVersionSpecification();
165+
dep.getExcludedDependencies();
166+
dep.getKnownLocation();
167+
dep.isOptional();
168+
}
169+
pom.getDependenciesAdditionalRepositories();
170+
pom.getLoader();
171+
pom.getDirectory();
172+
173+
pom = repo.load("org.apache.maven.shared", "maven-filtering", "1.3", pomLoader, Task.PRIORITY_NORMAL).blockResult(0);
174+
for (Dependency dep : pom.getDependencies()) {
175+
dep.getGroupId();
176+
dep.getArtifactId();
177+
dep.getClassifier();
178+
dep.getVersionSpecification();
179+
dep.getExcludedDependencies();
180+
dep.getKnownLocation();
181+
dep.isOptional();
182+
}
183+
pom.getDependenciesAdditionalRepositories();
184+
pom.getLoader();
185+
pom.getDirectory();
143186

144187
repo = new MavenRemoteRepository("http://repo.maven.apache.org/maven2", false, true);
145188
}
146189

190+
@Test
191+
public void testSettings() throws Exception {
192+
InputStream in = getClass().getClassLoader().getResourceAsStream("app/maven/settings.xml");
193+
MavenSettings settings = MavenSettings.load(in);
194+
in.close();
195+
Assert.assertEquals("/test/maven/local/repo", settings.localRepository);
196+
}
197+
147198
}

net.lecousin.core/src/test/java/net/lecousin/framework/core/tests/util/TestStringUtil.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package net.lecousin.framework.core.tests.util;
22

33
import java.math.BigInteger;
4+
import java.util.Locale;
45

56
import net.lecousin.framework.core.test.LCCoreAbstractTest;
67
import net.lecousin.framework.util.StringUtil;
@@ -132,12 +133,15 @@ public void testSize() {
132133
}
133134

134135
private static void testSize(long size, String str) {
136+
Locale def = Locale.getDefault();
137+
Locale.setDefault(Locale.US);
135138
String s = StringUtil.size(size);
136139
Assert.assertEquals(str, s);
137140
s = StringUtil.size(new BigInteger(Long.toString(size)));
138141
Assert.assertEquals(str, s);
139142
long si = StringUtil.parseSize(s);
140143
Assert.assertEquals(size, si);
144+
Locale.setDefault(def);
141145
}
142146

143147
public static enum E1 {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
4+
https://maven.apache.org/xsd/settings-1.0.0.xsd">
5+
6+
<localRepository>/test/maven/local/repo</localRepository>
7+
8+
<servers>
9+
<server>
10+
<id>test</id>
11+
<username>test</username>
12+
</server>
13+
</servers>
14+
15+
<profiles>
16+
<profile>
17+
<id>test</id>
18+
<activation>
19+
<activeByDefault>true</activeByDefault>
20+
</activation>
21+
</profile>
22+
</profiles>
23+
</settings>

0 commit comments

Comments
 (0)