Skip to content

Commit c24c221

Browse files
committed
Properly assign boolean to is_resolved #3152
* Add new test Signed-off-by: Jono Yang <[email protected]>
1 parent a410f6e commit c24c221

File tree

4 files changed

+222
-1
lines changed

4 files changed

+222
-1
lines changed

src/packagedcode/maven.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,7 @@ def get_dependencies(pom):
895895
if dversion == 'latest.release':
896896
dversion = None
897897

898-
is_resolved = dversion and not any(c in dversion for c in '$[,]')
898+
is_resolved = bool(dversion and not any(c in dversion for c in '$[,]'))
899899

900900
dqualifiers = {}
901901
# FIXME: this is missing from the original Pom parser
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
2+
<parent>
3+
<groupId>com.wordnik</groupId>
4+
<artifactId>swagger-project_2.10</artifactId>
5+
<version>1.3.1</version>
6+
<relativePath>../..</relativePath>
7+
</parent>
8+
<modelVersion>4.0.0</modelVersion>
9+
<groupId>com.wordnik</groupId>
10+
<artifactId>swagger-java-sample-app_2.10</artifactId>
11+
<packaging>war</packaging>
12+
<name>swagger-java-jaxrs-app</name>
13+
<version>1.3.1</version>
14+
<build>
15+
<sourceDirectory>src/main/java</sourceDirectory>
16+
<plugins>
17+
<plugin>
18+
<groupId>org.apache.maven.plugins</groupId>
19+
<artifactId>maven-war-plugin</artifactId>
20+
<version>2.1.1</version>
21+
</plugin>
22+
<plugin>
23+
<artifactId>maven-failsafe-plugin</artifactId>
24+
<version>2.6</version>
25+
<executions>
26+
<execution>
27+
<goals>
28+
<goal>integration-test</goal>
29+
<goal>verify</goal>
30+
</goals>
31+
</execution>
32+
</executions>
33+
</plugin>
34+
<plugin>
35+
<groupId>org.mortbay.jetty</groupId>
36+
<artifactId>jetty-maven-plugin</artifactId>
37+
<version>${jetty-version}</version>
38+
<configuration>
39+
<webAppConfig>
40+
<contextPath>/api</contextPath>
41+
</webAppConfig>
42+
<webAppSourceDirectory>target/${project.artifactId}-${project.version}</webAppSourceDirectory>
43+
<webDefaultXml>${project.basedir}/conf/jetty/webdefault.xml</webDefaultXml>
44+
<stopPort>8079</stopPort>
45+
<stopKey>stopit</stopKey>
46+
<connectors>
47+
<connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
48+
<port>8002</port>
49+
<maxIdleTime>60000</maxIdleTime>
50+
<confidentialPort>8443</confidentialPort>
51+
</connector>
52+
</connectors>
53+
</configuration>
54+
<executions>
55+
<execution>
56+
<id>start-jetty</id>
57+
<phase>pre-integration-test</phase>
58+
<goals>
59+
<goal>run</goal>
60+
</goals>
61+
<configuration>
62+
<scanIntervalSeconds>0</scanIntervalSeconds>
63+
<daemon>true</daemon>
64+
</configuration>
65+
</execution>
66+
<execution>
67+
<id>stop-jetty</id>
68+
<phase>post-integration-test</phase>
69+
<goals>
70+
<goal>stop</goal>
71+
</goals>
72+
</execution>
73+
</executions>
74+
</plugin>
75+
</plugins>
76+
</build>
77+
<dependencies>
78+
<dependency>
79+
<groupId>com.wordnik</groupId>
80+
<artifactId>swagger-jaxrs_2.10</artifactId>
81+
<scope>compile</scope>
82+
</dependency>
83+
<dependency>
84+
<groupId>ch.qos.logback</groupId>
85+
<artifactId>logback-classic</artifactId>
86+
<version>${logback-version}</version>
87+
<scope>compile</scope>
88+
</dependency>
89+
<dependency>
90+
<groupId>ch.qos.logback</groupId>
91+
<artifactId>logback-core</artifactId>
92+
<version>${logback-version}</version>
93+
<scope>compile</scope>
94+
</dependency>
95+
<dependency>
96+
<groupId>org.scalatest</groupId>
97+
<artifactId>scalatest_2.10</artifactId>
98+
<scope>test</scope>
99+
</dependency>
100+
<dependency>
101+
<groupId>junit</groupId>
102+
<artifactId>junit</artifactId>
103+
<scope>test</scope>
104+
</dependency>
105+
<dependency>
106+
<groupId>javax.servlet</groupId>
107+
<artifactId>servlet-api</artifactId>
108+
</dependency>
109+
</dependencies>
110+
</project>
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
{
2+
"type": "maven",
3+
"namespace": "com.wordnik",
4+
"name": "swagger-java-sample-app_2.10",
5+
"version": "1.3.1",
6+
"qualifiers": {
7+
"type": "war"
8+
},
9+
"subpath": null,
10+
"primary_language": "Java",
11+
"description": "swagger-java-jaxrs-app",
12+
"release_date": null,
13+
"parties": [],
14+
"keywords": [],
15+
"homepage_url": null,
16+
"download_url": null,
17+
"size": null,
18+
"sha1": null,
19+
"md5": null,
20+
"sha256": null,
21+
"sha512": null,
22+
"bug_tracking_url": null,
23+
"code_view_url": null,
24+
"vcs_url": null,
25+
"copyright": null,
26+
"declared_license_expression": null,
27+
"declared_license_expression_spdx": null,
28+
"license_detections": [],
29+
"other_license_expression": null,
30+
"other_license_expression_spdx": null,
31+
"other_license_detections": [],
32+
"extracted_license_statement": null,
33+
"notice_text": null,
34+
"source_packages": [
35+
"pkg:maven/com.wordnik/[email protected]?classifier=sources"
36+
],
37+
"file_references": [],
38+
"extra_data": {},
39+
"dependencies": [
40+
{
41+
"purl": "pkg:maven/com.wordnik/swagger-jaxrs_2.10",
42+
"extracted_requirement": null,
43+
"scope": "compile",
44+
"is_runtime": false,
45+
"is_optional": true,
46+
"is_resolved": false,
47+
"resolved_package": {},
48+
"extra_data": {}
49+
},
50+
{
51+
"purl": "pkg:maven/ch.qos.logback/logback-classic",
52+
"extracted_requirement": "${logback-version}",
53+
"scope": "compile",
54+
"is_runtime": false,
55+
"is_optional": true,
56+
"is_resolved": false,
57+
"resolved_package": {},
58+
"extra_data": {}
59+
},
60+
{
61+
"purl": "pkg:maven/ch.qos.logback/logback-core",
62+
"extracted_requirement": "${logback-version}",
63+
"scope": "compile",
64+
"is_runtime": false,
65+
"is_optional": true,
66+
"is_resolved": false,
67+
"resolved_package": {},
68+
"extra_data": {}
69+
},
70+
{
71+
"purl": "pkg:maven/javax.servlet/servlet-api",
72+
"extracted_requirement": null,
73+
"scope": "compile",
74+
"is_runtime": false,
75+
"is_optional": true,
76+
"is_resolved": false,
77+
"resolved_package": {},
78+
"extra_data": {}
79+
},
80+
{
81+
"purl": "pkg:maven/org.scalatest/scalatest_2.10",
82+
"extracted_requirement": null,
83+
"scope": "test",
84+
"is_runtime": false,
85+
"is_optional": true,
86+
"is_resolved": false,
87+
"resolved_package": {},
88+
"extra_data": {}
89+
},
90+
{
91+
"purl": "pkg:maven/junit/junit",
92+
"extracted_requirement": null,
93+
"scope": "test",
94+
"is_runtime": false,
95+
"is_optional": true,
96+
"is_resolved": false,
97+
"resolved_package": {},
98+
"extra_data": {}
99+
}
100+
],
101+
"repository_homepage_url": "https://repo1.maven.org/maven2/com/wordnik/swagger-java-sample-app_2.10/1.3.1/",
102+
"repository_download_url": "https://repo1.maven.org/maven2/com/wordnik/swagger-java-sample-app_2.10/1.3.1/swagger-java-sample-app_2.10-1.3.1.war",
103+
"api_data_url": "https://repo1.maven.org/maven2/com/wordnik/swagger-java-sample-app_2.10/1.3.1/swagger-java-sample-app_2.10-1.3.1.pom",
104+
"datasource_id": "maven_pom",
105+
"purl": "pkg:maven/com.wordnik/[email protected]?type=war"
106+
}

tests/packagedcode/test_maven.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,11 @@ def test_package_dependency_not_missing(self):
218218
test_file = self.get_test_loc('maven2/log4j/log4j-pom.xml')
219219
self.check_parse_to_package(test_file, regen=REGEN_TEST_FIXTURES)
220220

221+
def test_package_dependency_populate_is_resolved_field(self):
222+
test_file = self.get_test_loc('maven_misc/parse/swagger-java-sample-app_2.10-1.3.1.pom')
223+
self.check_parse_to_package(test_file, regen=REGEN_TEST_FIXTURES)
224+
225+
221226

222227
class TestPomProperties(testcase.FileBasedTesting):
223228
test_data_dir = os.path.join(os.path.dirname(__file__), 'data')

0 commit comments

Comments
 (0)