You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by cl...@apache.org on 2015/06/06 21:46:04 UTC
jena git commit: Fixes for JENA-958 Includes new integration test.
Repository: jena
Updated Branches:
refs/heads/master c010002fe -> e1a6a8363
Fixes for JENA-958
Includes new integration test.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/e1a6a836
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/e1a6a836
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/e1a6a836
Branch: refs/heads/master
Commit: e1a6a8363398dcb0919974c56c3cb4fb7a91e90f
Parents: c010002
Author: Claude Warren <cl...@apache.org>
Authored: Sat Jun 6 20:40:19 2015 +0100
Committer: Claude Warren <cl...@apache.org>
Committed: Sat Jun 6 20:40:19 2015 +0100
----------------------------------------------------------------------
.../src/it/schemagen-integration-4/pom.xml | 66 ++++++++++++++++++++
.../src/main/vocabs/test1.ttl | 33 ++++++++++
.../src/it/schemagen-integration-4/verify.bsh | 29 +++++++++
.../jena/tools/schemagen/SchemagenOptions.java | 2 +
.../org/apache/jena/tools/schemagen/Source.java | 6 +-
.../tools/schemagen/SourceParameterTest.java | 14 ++++-
6 files changed, 146 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/e1a6a836/jena-maven-tools/src/it/schemagen-integration-4/pom.xml
----------------------------------------------------------------------
diff --git a/jena-maven-tools/src/it/schemagen-integration-4/pom.xml b/jena-maven-tools/src/it/schemagen-integration-4/pom.xml
new file mode 100644
index 0000000..32f2bd1
--- /dev/null
+++ b/jena-maven-tools/src/it/schemagen-integration-4/pom.xml
@@ -0,0 +1,66 @@
+<!--
+ 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.
+ -->
+<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">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.jena.tools</groupId>
+ <artifactId>schemagen-test</artifactId>
+ <version>@project.version@</version>
+ <packaging>jar</packaging>
+ <name>schemagen-test</name>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.jena</groupId>
+ <artifactId>jena-maven-tools</artifactId>
+ <version>@project.version@</version>
+ <configuration>
+ <includes>
+ <include>src/main/vocabs/*.ttl</include>
+ </includes>
+ <fileOptions>
+ <source>
+ <input>default</input>
+ <package-name>org.example.test</package-name>
+ </source>
+ <source>
+ <!-- Test1.java will contain have a different namespace url. -->
+ <input>src/main/vocabs/test1.ttl</input>
+ <namespace>urn:test#</namespace>
+ </source>
+ </fileOptions>
+ </configuration>
+ <executions>
+ <execution>
+ <id>schemagen</id>
+ <goals>
+ <goal>translate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.jena</groupId>
+ <artifactId>jena-core</artifactId>
+ <version>@jenaCoreVersion@</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jena/blob/e1a6a836/jena-maven-tools/src/it/schemagen-integration-4/src/main/vocabs/test1.ttl
----------------------------------------------------------------------
diff --git a/jena-maven-tools/src/it/schemagen-integration-4/src/main/vocabs/test1.ttl b/jena-maven-tools/src/it/schemagen-integration-4/src/main/vocabs/test1.ttl
new file mode 100644
index 0000000..0c06b60
--- /dev/null
+++ b/jena-maven-tools/src/it/schemagen-integration-4/src/main/vocabs/test1.ttl
@@ -0,0 +1,33 @@
+#
+# 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.
+#
+
+@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
+@prefix owl: <http://www.w3.org/2002/07/owl#> .
+@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
+@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
+@prefix ex: <http://example.org/test#>.
+@prefix test: <urn:test#>.
+
+<http://example.org/test>
+ a owl:Ontology.
+
+test:Cls a owl:Class.
+
+
+
http://git-wip-us.apache.org/repos/asf/jena/blob/e1a6a836/jena-maven-tools/src/it/schemagen-integration-4/verify.bsh
----------------------------------------------------------------------
diff --git a/jena-maven-tools/src/it/schemagen-integration-4/verify.bsh b/jena-maven-tools/src/it/schemagen-integration-4/verify.bsh
new file mode 100644
index 0000000..221ca6e
--- /dev/null
+++ b/jena-maven-tools/src/it/schemagen-integration-4/verify.bsh
@@ -0,0 +1,29 @@
+/*
+ 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.
+*/
+
+import org.apache.maven.it.Verifier;
+
+File testDir = new File("target/it/schemagen-integration-4");
+if (!testDir.exists()) {
+ testDir = new File( "jena-maven-tools/" + testDir.getPath() );
+}
+Verifier verifier = new Verifier( testDir.getAbsolutePath() );
+
+// Test2.java should use the Ont API, Test1.java should not
+String test1 = verifier.getBasedir() + "/target/generated-sources/org/example/test/Test1.java";
+verifier.assertFileMatches( test1, "(?s).* NS = \\\"urn\\:test#\\\";.*" );
http://git-wip-us.apache.org/repos/asf/jena/blob/e1a6a836/jena-maven-tools/src/main/java/org/apache/jena/tools/schemagen/SchemagenOptions.java
----------------------------------------------------------------------
diff --git a/jena-maven-tools/src/main/java/org/apache/jena/tools/schemagen/SchemagenOptions.java b/jena-maven-tools/src/main/java/org/apache/jena/tools/schemagen/SchemagenOptions.java
index 5e35fdb..b4bcbad 100644
--- a/jena-maven-tools/src/main/java/org/apache/jena/tools/schemagen/SchemagenOptions.java
+++ b/jena-maven-tools/src/main/java/org/apache/jena/tools/schemagen/SchemagenOptions.java
@@ -204,6 +204,8 @@ public class SchemagenOptions
setOption(option, (String) optionValue);
} else if (optionValue instanceof Boolean) {
setOption(option, (Boolean) optionValue);
+ } else if (optionValue instanceof Resource) {
+ setOption(option, (Resource) optionValue);
} else {
throw new IllegalArgumentException("Schemagen options of type "
+ optionValue.getClass().getCanonicalName()
http://git-wip-us.apache.org/repos/asf/jena/blob/e1a6a836/jena-maven-tools/src/main/java/org/apache/jena/tools/schemagen/Source.java
----------------------------------------------------------------------
diff --git a/jena-maven-tools/src/main/java/org/apache/jena/tools/schemagen/Source.java b/jena-maven-tools/src/main/java/org/apache/jena/tools/schemagen/Source.java
index e3672e9..038d84c 100644
--- a/jena-maven-tools/src/main/java/org/apache/jena/tools/schemagen/Source.java
+++ b/jena-maven-tools/src/main/java/org/apache/jena/tools/schemagen/Source.java
@@ -20,6 +20,8 @@ package org.apache.jena.tools.schemagen;
import jena.schemagen.SchemagenOptions.OPT;
+import org.apache.jena.rdf.model.Resource;
+import org.apache.jena.rdf.model.ResourceFactory;
import org.apache.maven.plugins.annotations.Parameter;
/**
@@ -231,8 +233,8 @@ public class Source {
}
@SchemagenOption(opt=OPT.NAMESPACE)
- public String getNamespace() {
- return namespace;
+ public Resource getNamespace() {
+ return (namespace == null || namespace.isEmpty())? null : ResourceFactory.createResource(namespace);
}
@SchemagenOption(opt=OPT.DECLARATIONS)
http://git-wip-us.apache.org/repos/asf/jena/blob/e1a6a836/jena-maven-tools/src/test/java/org/apache/jena/tools/schemagen/SourceParameterTest.java
----------------------------------------------------------------------
diff --git a/jena-maven-tools/src/test/java/org/apache/jena/tools/schemagen/SourceParameterTest.java b/jena-maven-tools/src/test/java/org/apache/jena/tools/schemagen/SourceParameterTest.java
index d28fd42..193b247 100644
--- a/jena-maven-tools/src/test/java/org/apache/jena/tools/schemagen/SourceParameterTest.java
+++ b/jena-maven-tools/src/test/java/org/apache/jena/tools/schemagen/SourceParameterTest.java
@@ -29,6 +29,8 @@ import java.util.Collection;
import jena.schemagen.SchemagenOptions.OPT;
+import org.apache.jena.rdf.model.Resource;
+import org.apache.jena.rdf.model.ResourceFactory;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -105,7 +107,14 @@ public class SourceParameterTest
Source s = new Source();
setParamValue( s );
SchemagenOptions so = new SchemagenOptions(null, s);
- assertEquals( optionName, expected, so.getOption( option ).asLiteral().getValue() );
+ if (expected instanceof Resource)
+ {
+ assertEquals( optionName, expected, so.getOption( option ).asResource() );
+ }
+ else
+ {
+ assertEquals( optionName, expected, so.getOption( option ).asLiteral().getValue() );
+ }
}
@@ -220,7 +229,8 @@ public class SourceParameterTest
case NAMESPACE:
s.setNamespace( optionName );
- expected = optionName;
+ //expected = optionName;
+ expected = ResourceFactory.createResource( optionName );
break;
case OUTPUT: