Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-server
Commits
a28ddb9d
Verified
Commit
a28ddb9d
authored
4 years ago
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
TST: add unit testt for etag
parent
4958e1d6
Branches
Branches containing commit
Tags
Tags containing commit
4 merge requests
!21
Release v0.4.0
,
!7
F fsm
,
!6
Draft: F acm permissions2
,
!1
F etag
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/org/caosdb/server/query/Query.java
+12
-0
12 additions, 0 deletions
src/main/java/org/caosdb/server/query/Query.java
src/test/java/org/caosdb/server/query/QueryTest.java
+37
-0
37 additions, 0 deletions
src/test/java/org/caosdb/server/query/QueryTest.java
with
49 additions
and
0 deletions
src/main/java/org/caosdb/server/query/Query.java
+
12
−
0
View file @
a28ddb9d
...
...
@@ -985,4 +985,16 @@ public class Query implements QueryInterface, ToElementable, TransactionInterfac
public
Role
getRole
()
{
return
this
.
role
;
}
/**
* Return the ETag.
*
* <p>The ETag tags the query cache and is renewed each time the cache is being cleared, i.e. each
* time the database is being updated.
*
* @return The ETag
*/
public
static
String
getETag
()
{
return
cacheETag
;
}
}
This diff is collapsed.
Click to expand it.
src/test/java/org/caosdb/server/query/QueryTest.java
+
37
−
0
View file @
a28ddb9d
package
org.caosdb.server.query
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNotEquals
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
static
org
.
junit
.
Assert
.
fail
;
import
java.io.IOException
;
import
org.caosdb.server.CaosDBServer
;
import
org.caosdb.server.database.access.InitAccess
;
import
org.caosdb.server.transaction.WriteTransaction
;
import
org.junit.BeforeClass
;
import
org.junit.Test
;
...
...
@@ -61,4 +66,36 @@ public class QueryTest {
assertNull
(
q
.
getEntity
());
assertEquals
(
Query
.
Role
.
ENTITY
,
q
.
getRole
());
}
/** Assure that {@link WriteTransaction#commit()} calls {@link Query#clearCache()}. */
@Test
public
void
testEtagChangesAfterWrite
()
{
String
old
=
Query
.
getETag
();
assertNotNull
(
old
);
WriteTransaction
w
=
new
WriteTransaction
(
null
)
{
@Override
public
boolean
useCache
()
{
// this function is being overriden purely for the purpose of calling
// commit() (which is protected)
try
{
// otherwise the test fails because getAccess() return null;
setAccess
(
new
InitAccess
(
null
));
commit
();
}
catch
(
Exception
e
)
{
fail
(
"this should not happen"
);
}
return
false
;
}
};
// trigger commit();
w
.
useCache
();
String
neu
=
Query
.
getETag
();
assertNotEquals
(
old
,
neu
,
"old and new tag should not be equal"
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment