You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2015/04/29 22:55:13 UTC
[2/2] jena git commit: JENA-924: Remove FileGraph
JENA-924: Remove FileGraph
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/f65249be
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/f65249be
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/f65249be
Branch: refs/heads/master
Commit: f65249be0ef454700bdb9ce1a86a8c825b613eda
Parents: f2f539d
Author: Andy Seaborne <an...@apache.org>
Authored: Wed Apr 29 21:54:52 2015 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Wed Apr 29 21:54:52 2015 +0100
----------------------------------------------------------------------
.../org/apache/jena/assembler/Assembler.java | 3 -
.../assemblers/FileModelAssembler.java | 109 -------
.../org/apache/jena/graph/impl/FileGraph.java | 207 --------------
.../apache/jena/graph/impl/FileGraphMaker.java | 224 ---------------
.../graph/impl/FileGraphTransactionHandler.java | 81 ------
.../org/apache/jena/rdf/model/ModelFactory.java | 12 -
.../jena/assembler/test/TestAssemblers.java | 1 -
.../test/TestBuiltinAssemblerGroup.java | 2 -
.../assembler/test/TestFileModelAssembler.java | 282 -------------------
.../apache/jena/graph/test/TestFileGraph.java | 194 -------------
.../jena/graph/test/TestFileGraphMaker.java | 111 --------
.../org/apache/jena/graph/test/TestPackage.java | 2 -
12 files changed, 1228 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/f65249be/jena-core/src/main/java/org/apache/jena/assembler/Assembler.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/assembler/Assembler.java b/jena-core/src/main/java/org/apache/jena/assembler/Assembler.java
index e7ba2ec..78e4810 100644
--- a/jena-core/src/main/java/org/apache/jena/assembler/Assembler.java
+++ b/jena-core/src/main/java/org/apache/jena/assembler/Assembler.java
@@ -73,8 +73,6 @@ public interface Assembler
public static final Assembler prefixMapping = new PrefixMappingAssembler();
- public static final Assembler fileModel = new FileModelAssembler();
-
public static final Assembler unionModel = new UnionModelAssembler();
public static final Assembler ontModelSpec = new OntModelSpecAssembler();
@@ -100,7 +98,6 @@ public interface Assembler
.implementWith( JA.UnionModel, unionModel )
.implementWith( JA.PrefixMapping, prefixMapping )
.implementWith( JA.SinglePrefixMapping, prefixMapping )
- .implementWith( JA.FileModel, fileModel )
.implementWith( JA.OntModel, ontModel )
.implementWith( JA.OntModelSpec, ontModelSpec )
.implementWith( JA.RuleSet, ruleSet )
http://git-wip-us.apache.org/repos/asf/jena/blob/f65249be/jena-core/src/main/java/org/apache/jena/assembler/assemblers/FileModelAssembler.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/assembler/assemblers/FileModelAssembler.java b/jena-core/src/main/java/org/apache/jena/assembler/assemblers/FileModelAssembler.java
deleted file mode 100644
index 936a0b5..0000000
--- a/jena-core/src/main/java/org/apache/jena/assembler/assemblers/FileModelAssembler.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.jena.assembler.assemblers;
-
-import java.io.File ;
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-import java.nio.charset.StandardCharsets;
-
-import org.apache.jena.assembler.Assembler ;
-import org.apache.jena.assembler.JA ;
-import org.apache.jena.assembler.Mode ;
-import org.apache.jena.graph.Graph ;
-import org.apache.jena.graph.impl.FileGraph ;
-import org.apache.jena.graph.impl.FileGraphMaker ;
-import org.apache.jena.graph.impl.FileGraph.NotifyOnClose ;
-import org.apache.jena.rdf.model.* ;
-import org.apache.jena.util.FileUtils ;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class FileModelAssembler extends NamedModelAssembler implements Assembler
- {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(FileModelAssembler.class);
-
- @Override
- protected Model openEmptyModel( Assembler a, Resource root, Mode mode )
- {
- checkType( root, JA.FileModel );
- File fullName = getFileName( root );
- boolean mayCreate = mode.permitCreateNew( root, fullName.toString() );
- boolean mayReuse = mode.permitUseExisting( root, fullName.toString() );
- boolean create = getBoolean( root, JA.create, mayCreate );
- boolean strict = getBoolean( root, JA.strict, mayCreate != mayReuse );
- String lang = getLanguage( root, fullName );
- return createFileModel( fullName, lang, create, strict );
- }
-
- public Model createFileModel( File fullName, String lang, boolean create, boolean strict )
- {
- NotifyOnClose notify = NotifyOnClose.ignore;
- Graph fileGraph = new FileGraph( notify, fullName, lang, create, strict );
- return ModelFactory.createModelForGraph( fileGraph );
- }
-
- protected String getLanguage( Resource root, File fullName )
- {
- Statement s = getUniqueStatement( root, JA.fileEncoding );
- return s == null ? FileUtils.guessLang( fullName.toString() ) : getString( s );
- }
-
- protected File getFileName( Resource root )
- {
- String name = getModelName( root );
- boolean mapName = getBoolean( root, JA.mapName, false );
- String dir = getDirectoryName( root );
- return new File( dir, (mapName ? FileGraphMaker.toFilename( name ): name) );
- }
-
- private boolean getBoolean( Resource root, Property p, boolean ifAbsent )
- {
- RDFNode r = getUnique( root, p );
- return
- r == null ? ifAbsent
- : r.isLiteral() ? booleanSpelling( r.asNode().getLiteralLexicalForm() )
- : r.isURIResource() ? booleanSpelling( r.asNode().getLocalName() )
- : false
- ;
- }
-
- private boolean booleanSpelling( String spelling )
- {
- if (spelling.equalsIgnoreCase( "true" )) return true;
- if (spelling.equalsIgnoreCase( "t" )) return true;
- if (spelling.equalsIgnoreCase( "1" )) return true;
- if (spelling.equalsIgnoreCase( "false" )) return false;
- if (spelling.equalsIgnoreCase( "f" )) return false;
- if (spelling.equalsIgnoreCase( "0" )) return false;
- throw new IllegalArgumentException( "boolean requires spelling true/false/t/f/0/1" );
- }
-
- private String getDirectoryName( Resource root )
- {
- String dir = getRequiredResource( root, JA.directory ).getURI().replaceFirst( "file:", "" );
- try {
- dir = URLDecoder.decode(dir, StandardCharsets.UTF_8.name());
- } catch (UnsupportedEncodingException e) {
- LOGGER.warn(String.format("Failed to decode dir %s: %s", dir, e.getMessage()), e);
- }
- return dir;
- }
- }
http://git-wip-us.apache.org/repos/asf/jena/blob/f65249be/jena-core/src/main/java/org/apache/jena/graph/impl/FileGraph.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/graph/impl/FileGraph.java b/jena-core/src/main/java/org/apache/jena/graph/impl/FileGraph.java
deleted file mode 100644
index df4199f..0000000
--- a/jena-core/src/main/java/org/apache/jena/graph/impl/FileGraph.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.jena.graph.impl;
-
-import java.io.*;
-
-import org.apache.jena.graph.TransactionHandler ;
-import org.apache.jena.mem.GraphMem ;
-import org.apache.jena.rdf.model.Model ;
-import org.apache.jena.rdf.model.impl.ModelCom ;
-import org.apache.jena.shared.* ;
-import org.apache.jena.util.FileUtils ;
-
-/**
- A FileGraph is a memory-based graph that is optionally read in from a file
- when it is created, and is written back when it is closed. It supports
- (weak) transactions by using checkpoint files.
-*/
-public class FileGraph extends GraphMem
- {
- public interface NotifyOnClose
- {
- void notifyClosed( File f );
-
- static final NotifyOnClose ignore = new NotifyOnClose()
- { @Override
- public void notifyClosed( File f ) {} };
- }
-
- public FileGraph( File f, boolean create, boolean strict )
- { this( NotifyOnClose.ignore, f, create, strict ); }
-
- /**
- The File-name of this graph, used to name it in the filing system
- */
- public final File name;
-
- /**
- A model used to wrap the graph for the IO operations (since these are not
- yet available at the graph level).
- */
- protected final Model model;
-
- /**
- The language used to read and write the graph, guessed from the filename's
- suffix.
- */
- public final String lang;
-
- protected final NotifyOnClose notify;
-
- /**
- Construct a new FileGraph who's name is given by the specified File,
- If create is true, this is a new file, and any existing file will be destroyed;
- if create is false, this is an existing file, and its current contents will
- be loaded. The language code for the file is guessed from its suffix.
-
- @param f the File naming the associated file-system file
- @param create true to create a new one, false to read an existing one
- @param strict true to throw exceptions for create: existing, open: not found
- */
- public FileGraph( NotifyOnClose notify, File f, boolean create, boolean strict )
- { this( notify, f, FileUtils.guessLang( f.toString() ), create, strict ); }
-
- /**
- Construct a new FileGraph who's name is given by the specified File,
- If create is true, this is a new file, and any existing file will be destroyed;
- if create is false, this is an existing file, and its current contents will
- be loaded. The language code for the file is supplied.
-
- @param f the File naming the associated file-system file
- @param lang the language string for the file
- @param create true to create a new one, false to read an existing one
- @param strict true to throw exceptions for create: existing, open: not found
- */
- public FileGraph( NotifyOnClose notify, File f, String lang, boolean create, boolean strict )
- {
- this.name = f;
- this.notify = notify;
- this.model = new ModelCom( this );
- this.lang = lang;
- if (create)
- { if (f.exists() && strict) throw new AlreadyExistsException( f.toString() ); }
- else
- readModel( this.model, strict );
- }
-
- protected void readModel( Model m, boolean strict )
- { readModelFrom( m, strict, name ); }
-
- protected void readModelFrom( Model m, boolean strict, File name )
- {
- try(FileInputStream in = new FileInputStream( name ) ) {
- model.read( in, "", this.lang );
- }
- catch (FileNotFoundException f)
- { if (strict) throw new DoesNotExistException( name.toString() ); }
- catch (IOException ignore) {}
- }
-
- /**
- As for FileGraph(File,boolean), except the name is given as a String.
- */
- public FileGraph( String s, boolean create )
- { this( new File( s ), create, true ); }
-
- public static FileGraph create()
- { return new FileGraph( FileUtils.tempFileName( "anonymousFileGraph", ".rdf" ), true, true ); }
-
- /**
- Answer true iff the filename string given is plausibly the name of a
- graph, ie, may have RDF content. We appeal to FileUtils - if it can
- guess an RDF language name, we deliver true, otherwise false.
-
- @param name the leaf component of a filename
- @return true if it is likely to be an RDF file
- */
- public static boolean isPlausibleGraphName( String name )
- { return FileUtils.guessLang( name, null ) != null; }
-
- /**
- Write out and then close this FileGraph.
- */
- @Override
- public void close()
- {
- saveContents( name );
- super.close();
- if (count == 0) notify.notifyClosed( name );
- }
-
- /**
- Delete the backing file. Primarily intended for test cleanup.
- */
- public void delete()
- { name.delete(); }
-
- /**
- The graph is written out to the
- named file in the language guessed from the suffix, and then the
- parent close is invoked. The write-out goes to an intermediate file
- first, which is then renamed to the correct name, to try and ensure
- that the output is either done completely or not at all.
- */
- protected void saveContents( File targetName )
- {
- try
- {
- File intermediate = new File( targetName.getPath() + ".new" );
- try( FileOutputStream out = new FileOutputStream( intermediate ) ) {
- model.write( out, lang );
- }
- updateFrom( targetName, intermediate );
- }
- catch (Exception e)
- { throw new JenaException( e ); }
- }
-
- /**
- The file intermediate has the new file contents. We want to move
- them to the current file. renameTo doesn't have a powerful enough
- semantics, so we anticipate failure and attempt to bypass it ...
- <p>
- If the rename works, that's fine. If it fails, we delete the old file if it
- exists, and try again.
- */
- protected void updateFrom( File targetName, File intermediate )
- {
- if (intermediate.renameTo( targetName ) == false)
- {
- if (targetName.exists()) mustDelete( targetName );
- mustRename( intermediate, targetName );
- }
- }
-
- protected void mustDelete( File f )
- { if (f.delete() == false) throw new JenaException( "could not delete " + f ); }
-
- protected void mustRename( File from, File to )
- {
- if (from.renameTo( to ) == false)
- throw new JenaException( "could not rename " + from + " to " + to );
- }
-
- @Override
- public TransactionHandler getTransactionHandler()
- { if (th == null) th = new FileGraphTransactionHandler( this );
- return th; }
-
- protected TransactionHandler th;
- }
http://git-wip-us.apache.org/repos/asf/jena/blob/f65249be/jena-core/src/main/java/org/apache/jena/graph/impl/FileGraphMaker.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/graph/impl/FileGraphMaker.java b/jena-core/src/main/java/org/apache/jena/graph/impl/FileGraphMaker.java
deleted file mode 100644
index 518335f..0000000
--- a/jena-core/src/main/java/org/apache/jena/graph/impl/FileGraphMaker.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.jena.graph.impl;
-
-import java.io.*;
-import java.util.*;
-
-import org.apache.jena.graph.* ;
-import org.apache.jena.shared.* ;
-import org.apache.jena.util.CollectionFactory ;
-import org.apache.jena.util.iterator.* ;
-
-/**
- A FileGraph factory, making FileGraphs based round some supplied
- directory. We have to keep track of created files ourselves, because a
- FileGraph that has been created but not closed is not visible in the
- filing system. (This might count as a bug at some point.)
-*/
-public class FileGraphMaker
- extends BaseGraphMaker
- implements FileGraph.NotifyOnClose
- {
- protected String fileBase;
- protected boolean deleteOnClose;
- protected Map<File, FileGraph> created = CollectionFactory.createHashedMap();
- protected Set<File> toDelete = CollectionFactory.createHashedSet();
-
- /**
- Construct a file graph factory whose files will appear in root. The reifier
- style is Minimal and the files will be retained when the maker is closed.
-
- @param root the directory to keep the files in.
- */
- public FileGraphMaker( String root )
- { this ( root, false ) ; }
- /**
- Construct a file graph factory whose files will appear in root.
- If deleteOnClose is true, the files created by this factory will be deleted
- when the factory is closed.
-
- @param root the directory to keep the files in
- @param deleteOnClose iff true, delete created files on close
- */
- public FileGraphMaker( String root, boolean deleteOnClose )
- {
- super( );
- this.fileBase = root;
- this.deleteOnClose = deleteOnClose;
- }
-
- /**
- Answer the fileBase of all the graphs created by this FileGraphMaker.
- @return the fileBase of this Maker
- */
- public String getFileBase()
- { return fileBase; }
-
- /**
- Answer a new, anonynous FileGraph. See FileGraph.create().
- @return a new anonymous FileGraph
- */
- @Override
- public Graph createGraph()
- { return FileGraph.create(); }
-
- @Override
- public Graph createGraph( String name, boolean strict )
- {
- File f = withRoot( name );
- FileGraph already = created.get( f );
- if (already == null)
- return remember( f, new FileGraph( this, f, true, strict ) );
- else
- {
- if (strict) throw new AlreadyExistsException( name );
- else return already.openAgain();
- }
- }
-
- @Override
- public Graph openGraph( String name, boolean strict )
- {
- File f = withRoot( name );
- return created.containsKey( f )
- ? created.get( f ).openAgain()
- : remember( f, new FileGraph( this, f, false, strict ) )
- ;
- }
-
- @Override
- public void notifyClosed( File f )
- {
- toDelete.add( f );
- created.remove( f );
- }
-
- private File withRoot( String name )
- { return new File( fileBase, toFilename( name ) ); }
-
- /**
- Make <code>name</name> into a "safe" filename. "safe" is a bit weak
- here; we want to allow URIs as graph names and assume that our filing
- systems will be reasonably liberal. We'll see ...
-
- @param name
- @return name with underbar, slash, and colon escaped as _U, _S, _C
- */
- public static String toFilename( String name )
- {
- return name
- .replaceAll( "_", "_U" )
- .replaceAll( "/", "_S" )
- .replaceAll( ":", "_C" )
- ;
- }
-
- /**
- Answer the graphname corresponding to the given filename, undoing the
- conversion done by toFilename.
-
- @param fileName a filename, possible containing _U, _C, and _S escapes
- @return the unescaped name
- */
- public static String toGraphname( String fileName )
- {
- return fileName
- .replaceAll( "_C", ":" )
- .replaceAll( "_S", "/" )
- .replaceAll( "_U", "_" );
- }
-
- @Override
- public void removeGraph( String name )
- { forget( withRoot( name ) ).delete(); }
-
- private FileGraph remember( File f, FileGraph g )
- {
- created.put( f, g );
- return g;
- }
-
- private File forget( File f )
- {
- created.remove( f );
- return f;
- }
-
- @Override
- public boolean hasGraph( String name )
- {
- File f = withRoot( name );
- return created.containsKey( f ) || f.exists();
- }
-
- @Override
- public void close()
- {
- if (deleteOnClose)
- {
- deleteFiles( created.keySet().iterator() );
- deleteFiles( toDelete.iterator() );
- }
- }
-
- protected void deleteFiles( Iterator<File> it )
- { while (it.hasNext()) it.next().delete(); }
-
- /**
- A Map1 that will convert filename strings to the corresponding graphname strings.
- */
- private static Map1<String, String> unconvert = new Map1<String, String>()
- { @Override
- public String map1( String x )
- { return toGraphname( x ); }
- };
-
- /**
- Answer a FilenameFilter which recognises plausibly RDF filenames; they're not
- directories, and FileGraph likes them. Pass the buck, pass the buck ...
-
- @return a FilenameFilter that accepts plausible graph names
- */
- public static FilenameFilter graphName()
- { return new FilenameFilter()
- {
- @Override
- public boolean accept( File file, String name )
- { return !new File( file, name ).isDirectory()
- && FileGraph.isPlausibleGraphName( name ); }
- }; }
-
- /**
- Answer an iterator over the names of graphs in the FileGraphMaker. This is all the
- names of freshly-created graphs, plus the names of any files in the fileBase that
- might be RDF files. "Might" is weaker than we'd like for now.
-
- @see org.apache.jena.graph.GraphMaker#listGraphs()
- */
- @Override
- public ExtendedIterator<String> listGraphs()
- { String [] fileNames = new File( fileBase ).list( graphName() );
- Set<String> allNames = CollectionFactory.createHashedSet( Arrays.asList( fileNames ) );
- for ( File file : created.keySet() )
- {
- allNames.add( file.getName() );
- }
- return WrappedIterator.create( allNames.iterator() ) .mapWith( unconvert ); }
- }
http://git-wip-us.apache.org/repos/asf/jena/blob/f65249be/jena-core/src/main/java/org/apache/jena/graph/impl/FileGraphTransactionHandler.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/graph/impl/FileGraphTransactionHandler.java b/jena-core/src/main/java/org/apache/jena/graph/impl/FileGraphTransactionHandler.java
deleted file mode 100644
index e142d88..0000000
--- a/jena-core/src/main/java/org/apache/jena/graph/impl/FileGraphTransactionHandler.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.jena.graph.impl;
-
-import java.io.File;
-
-import org.apache.jena.graph.TransactionHandler ;
-import org.apache.jena.shared.JenaException ;
-
-/**
- A TransactionHandler for FileGraphs. When a FileGraph begin()s a
- transaction, its current contents are checkpointed into a sibling file
- (whose name starts "checkPoint-"). On an abort(), the current contents
- are discarded, and the checkpointed contents restored; on a commit(),
- the current contents are written back to the backing file, and the
- checkpoint file is deleted. Nested transactions are Not Allowed.
-
-*/
-public class FileGraphTransactionHandler
- extends TransactionHandlerBase implements TransactionHandler
- {
- protected boolean inTransaction;
- protected FileGraph fileGraph;
- protected File checkPointFile;
-
- public FileGraphTransactionHandler( FileGraph fileGraph )
- { this.fileGraph = fileGraph; }
-
- @Override
- public boolean transactionsSupported()
- { return true; }
-
- @Override
- public void begin()
- { if (inTransaction)
- throw new JenaException( "nested transactions not supported" );
- else
- { checkPointFile = new File( checkPointName( fileGraph.name ) );
- checkPointFile.deleteOnExit();
- fileGraph.saveContents( checkPointFile );
- inTransaction = true; } }
-
- protected String checkPointName( File name )
- {
- String path = name.getPath();
- int pos = path.lastIndexOf( File.separatorChar );
- String start = path.substring( 0, pos + 1 );
- String finish = path.substring( pos + 1 );
- return start + "checkPoint-" + finish;
- }
-
- @Override
- public void abort()
- { fileGraph.clear();
- fileGraph.readModelFrom( fileGraph.model, true, checkPointFile );
- checkPointFile.delete();
- inTransaction = false; }
-
- @Override
- public void commit()
- { fileGraph.saveContents( fileGraph.name );
- checkPointFile.delete();
- inTransaction = false; }
-
- }
http://git-wip-us.apache.org/repos/asf/jena/blob/f65249be/jena-core/src/main/java/org/apache/jena/rdf/model/ModelFactory.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/rdf/model/ModelFactory.java b/jena-core/src/main/java/org/apache/jena/rdf/model/ModelFactory.java
index fff5904..55bbda8 100644
--- a/jena-core/src/main/java/org/apache/jena/rdf/model/ModelFactory.java
+++ b/jena-core/src/main/java/org/apache/jena/rdf/model/ModelFactory.java
@@ -25,7 +25,6 @@ import org.apache.jena.assembler.AssemblerHelp ;
import org.apache.jena.graph.Factory ;
import org.apache.jena.graph.Graph ;
import org.apache.jena.graph.compose.Union ;
-import org.apache.jena.graph.impl.FileGraphMaker ;
import org.apache.jena.graph.impl.SimpleGraphMaker ;
import org.apache.jena.ontology.OntModel ;
import org.apache.jena.ontology.OntModelSpec ;
@@ -124,17 +123,6 @@ public class ModelFactory extends ModelFactoryBase
}
/**
- Answer a ModelMaker that constructs memory-based Models that
- are backed by files in the root directory. The Model is loaded from the
- file when it is opened, and when the Model is closed it is written back.
-
- @param root the name of the directory in which the backing files are held
- @return a ModelMaker linked to the files in the root
- */
- public static ModelMaker createFileModelMaker( String root )
- { return new ModelMakerImpl( new FileGraphMaker( root ) ); }
-
- /**
Answer a ModelMaker that constructs memory-based Models that do
not persist past JVM termination.
http://git-wip-us.apache.org/repos/asf/jena/blob/f65249be/jena-core/src/test/java/org/apache/jena/assembler/test/TestAssemblers.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/assembler/test/TestAssemblers.java b/jena-core/src/test/java/org/apache/jena/assembler/test/TestAssemblers.java
index 344eb87..c62fff1 100644
--- a/jena-core/src/test/java/org/apache/jena/assembler/test/TestAssemblers.java
+++ b/jena-core/src/test/java/org/apache/jena/assembler/test/TestAssemblers.java
@@ -42,7 +42,6 @@ public class TestAssemblers extends AssemblerTestBase
result.addTestSuite( TestReasonerFactoryAssembler.class );
result.addTestSuite( TestContentAssembler.class );
result.addTestSuite( TestModelContent.class );
- result.addTestSuite( TestFileModelAssembler.class );
result.addTestSuite( TestUnionModelAssembler.class );
result.addTestSuite( TestPrefixMappingAssembler.class );
result.addTestSuite( TestBuiltinAssemblerGroup.class );
http://git-wip-us.apache.org/repos/asf/jena/blob/f65249be/jena-core/src/test/java/org/apache/jena/assembler/test/TestBuiltinAssemblerGroup.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/assembler/test/TestBuiltinAssemblerGroup.java b/jena-core/src/test/java/org/apache/jena/assembler/test/TestBuiltinAssemblerGroup.java
index b09d6f1..a85a8cb 100644
--- a/jena-core/src/test/java/org/apache/jena/assembler/test/TestBuiltinAssemblerGroup.java
+++ b/jena-core/src/test/java/org/apache/jena/assembler/test/TestBuiltinAssemblerGroup.java
@@ -36,7 +36,6 @@ public class TestBuiltinAssemblerGroup extends AssemblerTestBase
assertAssemblerClass( JA.DefaultModel, DefaultModelAssembler.class );
assertAssemblerClass( JA.PrefixMapping, PrefixMappingAssembler.class );
assertAssemblerClass( JA.SinglePrefixMapping, PrefixMappingAssembler.class );
- assertAssemblerClass( JA.FileModel, FileModelAssembler.class );
assertAssemblerClass( JA.OntModel, OntModelAssembler.class );
assertAssemblerClass( JA.OntModelSpec, OntModelSpecAssembler.class );
assertAssemblerClass( JA.Content, ContentAssembler.class );
@@ -56,7 +55,6 @@ public class TestBuiltinAssemblerGroup extends AssemblerTestBase
{
assertInstanceOf( DefaultModelAssembler.class, Assembler.defaultModel );
assertInstanceOf( PrefixMappingAssembler.class, Assembler.prefixMapping );
- assertInstanceOf( FileModelAssembler.class, Assembler.fileModel );
assertInstanceOf( OntModelAssembler.class, Assembler.ontModel );
assertInstanceOf( OntModelSpecAssembler.class, Assembler.ontModelSpec );
assertInstanceOf( ContentAssembler.class, Assembler.content );
http://git-wip-us.apache.org/repos/asf/jena/blob/f65249be/jena-core/src/test/java/org/apache/jena/assembler/test/TestFileModelAssembler.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/assembler/test/TestFileModelAssembler.java b/jena-core/src/test/java/org/apache/jena/assembler/test/TestFileModelAssembler.java
deleted file mode 100644
index ecf3697..0000000
--- a/jena-core/src/test/java/org/apache/jena/assembler/test/TestFileModelAssembler.java
+++ /dev/null
@@ -1,282 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.jena.assembler.test;
-
-import java.io.ByteArrayInputStream ;
-import java.io.File ;
-import java.io.IOException ;
-import java.io.InputStream ;
-
-import org.apache.jena.assembler.Assembler ;
-import org.apache.jena.assembler.BadObjectException ;
-import org.apache.jena.assembler.JA ;
-import org.apache.jena.assembler.Mode ;
-import org.apache.jena.assembler.assemblers.FileModelAssembler ;
-import org.apache.jena.graph.impl.FileGraph ;
-import org.apache.jena.rdf.model.Model ;
-import org.apache.jena.rdf.model.ModelFactory ;
-import org.apache.jena.rdf.model.Resource ;
-import org.apache.jena.shared.JenaException ;
-import org.apache.jena.util.FileUtils ;
-import org.junit.Test ;
-import org.junit.rules.TemporaryFolder ;
-
-public class TestFileModelAssembler extends AssemblerTestBase
- {
-
- public TestFileModelAssembler( String name )
- { super( name ); }
-
- @Override protected Class<? extends Assembler> getAssemblerClass()
- { return FileModelAssembler.class; }
-
- public void testFileModelAssemblerType()
- { testDemandsMinimalType( new FileModelAssembler(), JA.FileModel ); }
-
- public void testFileAssemblerExists()
- {
- assertInstanceOf( Assembler.class, Assembler.fileModel );
- assertInstanceOf( FileModelAssembler.class, Assembler.fileModel );
- }
-
- public void testFileAssemblerVocabulary()
- {
- assertSubclassOf( JA.FileModel, JA.NamedModel );
- assertDomain( JA.FileModel, JA.fileEncoding );
- assertDomain( JA.FileModel, JA.directory );
- assertDomain( JA.FileModel, JA.mapName );
- }
-
- public void testFileModelAssemblerCreatesFileModels()
- {
- FileModelAssembler a = new FileModelAssembler();
- File x = FileUtils.tempFileName( "fileModelAssembler", ".n3" );
- Model m = a.createFileModel( x, "N3", true, false);
- assertInstanceOf( FileGraph.class, m.getGraph() );
- FileGraph fg = (FileGraph) m.getGraph();
- assertEquals( x, fg.name );
- }
-
- public void testFileModelAssemblerUsesSpecialisedMethod()
- {
- final Model model = ModelFactory.createDefaultModel();
- FileModelAssembler a = new FileModelAssembler()
- {
- @Override
- public Model createFileModel( File fullName, String lang, boolean create, boolean strict)
- { return model; }
- };
- Resource root = resourceInModel( "x rdf:type ja:FileModel; x ja:modelName 'junk'; x ja:directory file:" );
- Model m = a.openModel( root );
- assertSame( model, m );
- }
-
- public void testFileModelAssemblerUsesLanguage()
- {
- final Model model = ModelFactory.createDefaultModel();
- Resource root = resourceInModel( "x rdf:type ja:FileModel; x ja:modelName 'junk'; x ja:directory file:; x ja:fileEncoding 'LANG'" );
- FileModelAssembler a = new FileModelAssembler()
- {
- @Override
- public Model createFileModel( File fullName, String lang, boolean create, boolean strict)
- {
- assertEquals( "LANG", lang );
- return model;
- }
- };
- Model m = a.openModel( root );
- assertSame( model, m );
- }
-
- public void testFileModelAssemblerTrapsBadLanguage()
- {
- testTrapsBadLanguage( "badLanguage" );
- testTrapsBadLanguage( "17" );
- testTrapsBadLanguage( "'invalid'xsd:rhubarb" );
- }
-
- private void testTrapsBadLanguage( String lang )
- {
- final Model model = ModelFactory.createDefaultModel();
- Resource root = resourceInModel( "x rdf:type ja:FileModel; x ja:modelName 'junk'; x ja:directory file:; x ja:fileEncoding <lang>".replaceAll( "<lang>", lang ) );
- FileModelAssembler a = new FileModelAssembler()
- {
- @Override
- public Model createFileModel( File fullName, String lang, boolean create, boolean strict)
- { return model; }
- };
- try
- { a.openModel( root );
- fail( "should trap bad fileEncoding object" ); }
- catch (BadObjectException e)
- { Model m = e.getRoot().getModel();
- assertEquals( resource( "x" ), e.getRoot() );
- assertEquals( rdfNode( m, lang ), e.getObject() ); }
- }
-
- public void testStrictAndCreateCanBeSetFromProperties()
- {
- NoteAssemblerBooleans a = new NoteAssemblerBooleans();
- a.openModel( assemble( "x ja:create 'true'" ) ); assertEquals( true, a.create );
- a.openModel( assemble( "x ja:create 'false'" ) ); assertEquals( false, a.create );
- a.openModel( assemble( "x ja:strict 'true'" ) ); assertEquals( true, a.strict );
- a.openModel( assemble( "x ja:strict 'false'" ) ); assertEquals( false, a.strict );
- }
-
- private Resource assemble( String details )
- {
- return resourceInModel( "x rdf:type ja:FileModel; x ja:modelName 'junk'; <D>; x ja:directory file:spoo".replaceAll( "<D>", details ) );
- }
-
- private final class NoteAssemblerBooleans extends FileModelAssembler
- {
- private final Model model;
- public boolean create;
- public boolean strict;
-
- private NoteAssemblerBooleans()
- { this.model = model(); }
-
- @Override
- public Model createFileModel( File fullName, String lang, boolean create, boolean strict )
- {
- this.create = create;
- this.strict = strict;
- return model;
- }
- }
-
-
- public void testFileModelAssemblerUsesMode()
- {
- testMode( true, true );
- testMode( false, true );
- testMode( true, false );
- try { testMode( false, false ); fail( "should trap, can nver create" ); }
- catch (JenaException e ) { pass(); }
- }
-
- private void testMode( final boolean mayCreate, final boolean mayReuse )
- {
- final Model model = ModelFactory.createDefaultModel();
- Mode mode = new Mode( mayCreate, mayReuse );
- FileModelAssembler a = new FileModelAssembler()
- {
- @Override
- public Model createFileModel( File fullName, String lang, boolean create, boolean strict)
- {
- if (mayCreate && mayReuse)
- {
- assertEquals( "mayCreate && mayReuse implies non-strict", false, strict );
- }
- if (mayCreate && !mayReuse)
- {
- assertEquals( true, create );
- assertEquals( true, strict );
- }
- if (!mayCreate && mayReuse)
- {
- assertEquals( false, create );
- assertEquals( true, strict );
- }
- if (!mayCreate && !mayReuse)
- throw new JenaException( "cannot create" );
- return model;
- }
- };
- Resource root = resourceInModel( "x rdf:type ja:FileModel; x ja:modelName 'junk'; x ja:directory file:" );
- Model m = a.openModel( root, mode );
- assertSame( model, m );
- }
-
- public void testCorrectSimpleModelName()
- {
- testCorrectModelName( "root/spoo", "root", "spoo", empty );
- testCorrectModelName( "root/branch/spoo", "root/branch", "spoo", empty );
- testCorrectModelName( "/root/spoo", "/root", "spoo", empty );
- testCorrectModelName( "root/spoo", "root", "spoo", empty );
- }
-
- public void testCorrectURIModelName()
- {
- testCorrectModelName( "root/name/subname", "root", "name/subname", empty );
- testCorrectModelName( "root/name_Ssubname", "root", "name/subname", model( "x ja:mapName ja:true" ) );
- testCorrectModelName( "root/name_Usubname", "root", "name_subname", model( "x ja:mapName ja:true" ) );
- testCorrectModelName( "root/name_Csubname", "root", "name:subname", model( "x ja:mapName ja:true" ) );
- testCorrectModelName( "root/http_C_S_Sdomain_Sdir_Sname", "root", "http://domain/dir/name", model( "x ja:mapName ja:true" ) );
- }
-
- private void testCorrectModelName( String expectedName, String directoryName, String modelName, Model extras )
- {
- final Model model = ModelFactory.createDefaultModel();
- final File wantedFullName = new File( expectedName );
- final boolean wantedCreate = Mode.DEFAULT.permitCreateNew( null, null );
- final boolean wantedStrict = Mode.DEFAULT.permitUseExisting( null, null );
- Resource root = resourceInModel( "x rdf:type ja:FileModel; x ja:modelName '" + modelName + "'; x ja:directory file:" + directoryName );
- root.getModel().add( extras );
- FileModelAssembler a = new FileModelAssembler()
- {
- @Override
- public Model createFileModel( File fullName, String lang, boolean create, boolean strict)
- {
- assertEquals( wantedFullName, fullName );
- assertEquals( wantedCreate, create );
- assertEquals( wantedStrict, strict );
- return model;
- }
- };
- Model m = a.openModel( root );
- assertSame( model, m );
- }
-
- @Test
- public void testDecodeDirectoryName() throws IOException
- {
- // TODO: JenaTestBase is mixing JUnit3 and JUnit4 classes.
- // A @Rule doesn't get called correctly.
-
- //@Rule private final
- TemporaryFolder tempFolder = new TemporaryFolder();
- tempFolder.create();
- assertTrue(tempFolder.getRoot().isDirectory());
- File folderWithSpace = tempFolder.newFolder("folder with space");
- folderWithSpace.mkdir();
- File modelFile = new File(folderWithSpace, "file with space.ttl");
- modelFile.createNewFile();
- String graphs = "";
- graphs += "@prefix ja: <http://jena.hpl.hp.com/2005/11/Assembler#> . ";
- graphs += "<http://example.org/file> a ja:FileModel ; ";
-
- // Sanitize for Windows
- String dirName = tempFolder.getRoot().getAbsolutePath() ;
- dirName = dirName.replace("\\", "/") ;
- dirName = dirName.replace(" ", "%20") ;
- graphs += "ja:directory <file:///" + dirName + "/folder%20with%20space/> ; ";
- graphs += "ja:modelName \"" + modelFile.getName() + "\" . ";
-
- InputStream is = new ByteArrayInputStream(graphs.getBytes());
-
- Model model = ModelFactory.createDefaultModel();
- model.read(is, "http://example.org/", "TURTLE");
- Resource r = model.createResource("http://example.org/file");
- Model assemblerModel = (Model) Assembler.general.open(r);
- assertNotNull(assemblerModel);
- tempFolder.delete();
- }
- }
http://git-wip-us.apache.org/repos/asf/jena/blob/f65249be/jena-core/src/test/java/org/apache/jena/graph/test/TestFileGraph.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/test/TestFileGraph.java b/jena-core/src/test/java/org/apache/jena/graph/test/TestFileGraph.java
deleted file mode 100644
index af34a8a..0000000
--- a/jena-core/src/test/java/org/apache/jena/graph/test/TestFileGraph.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.jena.graph.test;
-
-import java.io.File ;
-import java.util.ArrayList ;
-import java.util.List ;
-
-import junit.framework.TestSuite ;
-import org.apache.jena.graph.Graph ;
-import org.apache.jena.graph.GraphUtil ;
-import org.apache.jena.graph.impl.FileGraph ;
-import org.apache.jena.rdf.model.Model ;
-import org.apache.jena.rdf.model.ModelFactory ;
-import org.apache.jena.util.FileUtils ;
-
-/**
- Test FileGraph by seeing if we can make some file graphs and then read
- them back.
-*/
-
-public class TestFileGraph extends GraphTestBase
- {
- public TestFileGraph( String name )
- { super( name ); }
-
- // TODO want a wider variety of cases, now we've discovered how to abstract.
- public static TestSuite suite()
- {
- TestSuite result = new TestSuite( TestFileGraph.class );
- result.addTest( new Case( "x /R y", "xxxA", ".rdf" ) );
- result.addTest( new Case( "x /R y", "xxxB", ".n3" ) );
- result.addTest( new Case( "x /R y", "xxxC", ".nt" ) );
- result.addTest( new Case( "x /R y; p /R q", "xxxD", ".rdf" ) );
- result.addTest( new Case( "x /R y; p /R q", "xxxE", ".n3" ) );
- result.addTest( new Case( "x /R y; p /R q", "xxxF", ".nt" ) );
- result.addTest( new Case( "http://domain/S ftp:ftp/P O", "xxxG", ".rdf" ) );
- result.addTest( new Case( "http://domain/S ftp:ftp/P O", "xxxH", ".nt" ) );
- result.addTest( new Case( "http://domain/S ftp:ftp/P O", "xxxI", ".n3" ) );
- return result;
- }
-
- public void testPlausibleGraphname()
- {
- assertTrue( FileGraph.isPlausibleGraphName( "agnessi.rdf" ) );
- assertTrue( FileGraph.isPlausibleGraphName( "parabola.nt" ) );
- assertTrue( FileGraph.isPlausibleGraphName( "hyperbola.n3" ) );
- assertTrue( FileGraph.isPlausibleGraphName( "chris.dollin.n3" ) );
- assertTrue( FileGraph.isPlausibleGraphName( "hedgehog.spine.end.rdf" ) );
- }
-
- public void testisPlausibleUppercaseGraphname()
- {
- assertTrue( FileGraph.isPlausibleGraphName( "LOUDER.RDF" ) );
- assertTrue( FileGraph.isPlausibleGraphName( "BRIDGE.NT" ) );
- assertTrue( FileGraph.isPlausibleGraphName( "NOTN2.N3" ) );
- assertTrue( FileGraph.isPlausibleGraphName( "chris.dollin.N3" ) );
- assertTrue( FileGraph.isPlausibleGraphName( "hedgehog.spine.end.RDF" ) );
- }
-
- public void testImPlausibleGraphName()
- {
- assertFalse( FileGraph.isPlausibleGraphName( "undecorated" ) );
- assertFalse( FileGraph.isPlausibleGraphName( "danger.exe" ) );
- assertFalse( FileGraph.isPlausibleGraphName( "pretty.jpg" ) );
- assertFalse( FileGraph.isPlausibleGraphName( "FileGraph.java" ) );
- assertFalse( FileGraph.isPlausibleGraphName( "infix.rdf.c" ) );
- }
-
- public void testTransactionCommit()
- {
- Graph initial = graphWith( "initial hasValue 42; also hasURI hello" );
- Graph extra = graphWith( "extra hasValue 17; also hasURI world" );
- File foo = FileUtils.tempFileName( "fileGraph", ".nt" );
-
- Graph g = new FileGraph( foo, true, true );
- GraphUtil.addInto( g, initial );
- g.getTransactionHandler().begin();
- GraphUtil.addInto( g, extra );
- g.getTransactionHandler().commit();
- Graph union = graphWith( "" );
- GraphUtil.addInto(union, initial );
- GraphUtil.addInto(union, extra );
- assertIsomorphic( union, g );
- Model inFile = ModelFactory.createDefaultModel();
- inFile.read( "file:///" + foo, "N-TRIPLES" );
- assertIsomorphic( union, inFile.getGraph() );
- }
-
- public void testTransactionAbort()
- {
- Graph initial = graphWith( "initial hasValue 42; also hasURI hello" );
- Graph extra = graphWith( "extra hasValue 17; also hasURI world" );
- File foo = FileUtils.tempFileName( "fileGraph", ".n3" );
- Graph g = new FileGraph( foo, true, true );
- GraphUtil.addInto( g, initial );
- g.getTransactionHandler().begin();
- GraphUtil.addInto( g, extra );
- g.getTransactionHandler().abort();
- assertIsomorphic( initial, g );
- }
-
- public void testTransactionCommitThenAbort()
- {
- Graph initial = graphWith( "A pings B; B pings C" );
- Graph extra = graphWith( "C pingedBy B; fileGraph rdf:type Graph" );
- File foo = FileUtils.tempFileName( "fileGraph", ".nt" );
- Graph g = new FileGraph( foo, true, true );
- g.getTransactionHandler().begin();
- GraphUtil.addInto( g, initial );
- g.getTransactionHandler().commit();
- g.getTransactionHandler().begin();
- GraphUtil.addInto( g, extra );
- g.getTransactionHandler().abort();
- assertIsomorphic( initial, g );
- Model inFile = ModelFactory.createDefaultModel();
- inFile.read( "file:///" + foo, "N-TRIPLES" );
- assertIsomorphic( initial, inFile.getGraph() );
- }
-
- public void testClosingNotifys()
- {
- final List<File> history = new ArrayList<>();
- FileGraph.NotifyOnClose n = new FileGraph.NotifyOnClose()
- {
- @Override
- public void notifyClosed( File f )
- { history.add( f ); }
- };
- File file = FileUtils.tempFileName( "fileGraph", ".nt" );
- Graph g = new FileGraph( n, file, true, true );
- assertEquals( new ArrayList<File>(), history );
- g.close();
- assertEquals( oneElementList( file ), history );
- }
-
- protected List<Object> oneElementList( Object x )
- {
- List<Object> result = new ArrayList<>();
- result.add( x );
- return result;
- }
-
- /**
- Test that the graph encoded as the test-string content can be
- written out to a temporary file generated from the prefix and suffix,
- and then read back correctly. The temporary files are marked as
- delete-on-exit to try and avoid cluttering the user's filespace ...
- */
- private static class Case extends TestFileGraph
- {
- String content;
- String prefix;
- String suffix;
-
- Case( String content, String prefix, String suffix )
- {
- super( "Case: " + content + " in " + prefix + "*" + suffix );
- this.content = content;
- this.prefix = prefix;
- this.suffix = suffix;
- }
-
- @Override
- public void runTest()
- {
- File foo = FileUtils.tempFileName( prefix, suffix );
- Graph original = graphWith( content );
- Graph g = new FileGraph( foo, true, true );
- GraphUtil.addInto( g, original );
- g.close();
- Graph g2 = new FileGraph( foo, false, true );
- assertIsomorphic( original, g2 );
- g2.close();
- }
- }
-
- }
http://git-wip-us.apache.org/repos/asf/jena/blob/f65249be/jena-core/src/test/java/org/apache/jena/graph/test/TestFileGraphMaker.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/test/TestFileGraphMaker.java b/jena-core/src/test/java/org/apache/jena/graph/test/TestFileGraphMaker.java
deleted file mode 100644
index 40f9bd2..0000000
--- a/jena-core/src/test/java/org/apache/jena/graph/test/TestFileGraphMaker.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.jena.graph.test;
-
-import java.io.File ;
-import java.util.HashSet ;
-
-import junit.framework.TestSuite ;
-import org.apache.jena.graph.Graph ;
-import org.apache.jena.graph.GraphMaker ;
-import org.apache.jena.graph.GraphUtil ;
-import org.apache.jena.graph.impl.FileGraph ;
-import org.apache.jena.graph.impl.FileGraphMaker ;
-import org.apache.jena.util.FileUtils ;
-
-/**
- Test a FileGraphMaker; use the abstract tests, plus specialised ones for the name
- conversion routines.
-*/
-public class TestFileGraphMaker extends AbstractTestGraphMaker
- {
- public TestFileGraphMaker( String name )
- { super( name ); }
-
- public static TestSuite suite()
- { return new TestSuite( TestFileGraphMaker.class ); }
-
- @Override
- public GraphMaker getGraphMaker()
- { String scratch = FileUtils.getScratchDirectory( "jena-test-FileGraphMaker" ).getPath();
- return new FileGraphMaker( scratch, true ); }
-
- public void testToFilename()
- { assertEquals( "plain", FileGraphMaker.toFilename( "plain" ) );
- assertEquals( "with_Sslash", FileGraphMaker.toFilename( "with/slash" ) );
- assertEquals( "with_Ccolon", FileGraphMaker.toFilename( "with:colon" ) );
- assertEquals( "with_Uunderbar", FileGraphMaker.toFilename( "with_underbar" ) );
- assertEquals( "with_Stwo_Sslashes", FileGraphMaker.toFilename( "with/two/slashes" ) );
- assertEquals( "with_Sa_Cmixture_U...", FileGraphMaker.toFilename( "with/a:mixture_..." ) ); }
-
- public void testToGraphname()
- { assertEquals( "plain", FileGraphMaker.toGraphname( "plain" ) );
- assertEquals( "with/slash", FileGraphMaker.toGraphname( "with_Sslash" ) );
- assertEquals( "with:colon", FileGraphMaker.toGraphname( "with_Ccolon" ) );
- assertEquals( "with_underbar", FileGraphMaker.toGraphname( "with_Uunderbar" ) );
- assertEquals( "a/mixture_of:things", FileGraphMaker.toGraphname( "a_Smixture_Uof_Cthings" ) );
- assertEquals( "with/two/slashes", FileGraphMaker.toGraphname( "with_Stwo_Sslashes" ) ); }
-
- public void testDetectsExistingFiles()
- {
- File scratch = FileUtils.getScratchDirectory( "jena-test-FileGraphMaker-already" );
- Graph content = graphWith( "something hasProperty someValue" );
- FileGraphMaker A = new FileGraphMaker( scratch.getPath(), true );
- FileGraphMaker B = new FileGraphMaker( scratch.getPath(), true );
- FileGraph gA = (FileGraph) A.createGraph( "already", true );
- GraphUtil.addInto( gA, content );
- gA.close();
- FileGraph gB = (FileGraph) B.openGraph( "already", false );
- assertIsomorphic( content, gB );
- gB.close();
- gB.delete();
- gA.delete();
- }
-
- public void testDeletesFilesOfClosedMaker()
- {
- File scratch = FileUtils.getScratchDirectory( "jena-test-FileGraphMaker-forgets" );
- FileGraphMaker A = new FileGraphMaker( scratch.getPath(), true );
- A.createGraph( "empty" ).close();
- assertTrue( "file 'empty' should exist in '" + scratch + "'", new File( scratch, "empty" ) .exists() );
- A.close();
- assertFalse( "file 'empty' should no longer exist in '" + scratch + "'", new File( scratch, "empty" ) .exists() );
- }
-
- public void testForgetsClosedGraphs()
- {
- File scratch = FileUtils.getScratchDirectory( "jena-test-FileGraphMaker-forgets" );
- FileGraphMaker m = new FileGraphMaker( scratch.getPath(), true );
- m.createGraph( "example" ).close();
- assertEquals( new HashSet<String>(), m.listGraphs().toSet() );
- m.close();
- }
-
- public void testDoesntReusedClosedGraphs()
- {
- File scratch = FileUtils.getScratchDirectory( "jena-test-FileGraphMaker-noReuse" );
- FileGraphMaker m = new FileGraphMaker( scratch.getPath(), true );
- Graph m1 = m.createGraph( "hello" );
- m1.close();
- Graph m2 = m.createGraph( "hello" );
- assertNotSame( m1, m2 );
- m2.add( triple( "this graph isOpen" ) );
- m.close();
- }
- }
http://git-wip-us.apache.org/repos/asf/jena/blob/f65249be/jena-core/src/test/java/org/apache/jena/graph/test/TestPackage.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/test/TestPackage.java b/jena-core/src/test/java/org/apache/jena/graph/test/TestPackage.java
index 85e960f..c070ca6 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/test/TestPackage.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/test/TestPackage.java
@@ -46,8 +46,6 @@ public class TestPackage extends TestSuite {
addTest( TestFactory.suite() );
addTest( TestGraph.suite() );
addTest( TestSimpleGraphMaker.suite() );
- addTest( TestFileGraph.suite() );
- addTest( TestFileGraphMaker.suite() );
addTest( TestGraphExtract.suite() );
addTest( TestCapabilities.suite() );
addTest( TestGraphUtils.suite() );