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, ReificationStyle s )
{
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 );
}