1
1
package com .tinkerpop .blueprints .impls .orient ;
2
2
3
- import com .orientechnologies .orient .core .config .OGlobalConfiguration ;
4
- import com .orientechnologies .orient .core .id .ORID ;
5
- import com .orientechnologies .orient .core .metadata .schema .OClass ;
6
- import com .orientechnologies .orient .core .metadata .schema .OType ;
7
- import com .tinkerpop .blueprints .Vertex ;
8
- import org .junit .*;
9
-
10
3
import java .io .File ;
11
4
import java .io .FileNotFoundException ;
5
+ import java .io .IOException ;
12
6
import java .io .PrintStream ;
13
- import java .util .*;
7
+ import java .util .ArrayList ;
8
+ import java .util .List ;
9
+ import java .util .Random ;
14
10
import java .util .concurrent .CountDownLatch ;
15
11
import java .util .concurrent .atomic .AtomicInteger ;
16
12
13
+ import org .junit .AfterClass ;
14
+ import org .junit .Assert ;
15
+ import org .junit .Before ;
16
+ import org .junit .Ignore ;
17
+ import org .junit .Test ;
18
+
19
+ import com .orientechnologies .orient .client .db .ODatabaseHelper ;
20
+ import com .orientechnologies .orient .client .remote .OServerAdmin ;
21
+ import com .orientechnologies .orient .core .config .OGlobalConfiguration ;
22
+ import com .orientechnologies .orient .core .id .ORID ;
23
+ import com .orientechnologies .orient .core .metadata .schema .OClass ;
24
+ import com .orientechnologies .orient .core .metadata .schema .OType ;
25
+ import com .tinkerpop .blueprints .Vertex ;
26
+
17
27
public class OrientCommitMT {
18
28
public static final String DB_URL = "remote:localhost/avltreetest" ;
19
29
public static final String DB_USER = "admin" ;
@@ -33,25 +43,41 @@ public class OrientCommitMT {
33
43
final AtomicInteger idGenerator = new AtomicInteger (1 );
34
44
35
45
private static Random random = new Random ();
36
- private static final OrientGraphFactory factory = new OrientGraphFactory (DB_URL );
37
-
38
- @ BeforeClass
39
- public static void beforeClass () {
40
- factory .setupPool (5 , 10 );
41
- // OrientGraph graph = new OrientGraph(DB_URL, DB_USER, DB_PASSWORD);
42
- // graph.drop();
43
- }
46
+ private static OrientGraphFactory factory ;
44
47
45
48
@ Before
46
- public void setUp () {
49
+ public void setUp () throws IOException {
50
+ if (DB_URL .startsWith ("remote:" )) {
51
+ OServerAdmin serverAdmin = new OServerAdmin (DB_URL );
52
+ serverAdmin .connect ("root" , ODatabaseHelper .getServerRootPassword ());
53
+
54
+ if (serverAdmin .existsDatabase ("plocal" )) {
55
+ serverAdmin .dropDatabase ("plocal" );
56
+ }
57
+ serverAdmin .createDatabase (DB_URL , "graph" , "plocal" );
58
+ } else {
59
+ OrientGraph graph = new OrientGraph (DB_URL , DB_USER , DB_PASSWORD );
60
+ graph .drop ();
61
+ }
62
+ factory = new OrientGraphFactory (DB_URL ).setupPool (5 , 10 );
63
+
47
64
buildSchemaAndSeed ();
48
65
this .isValidData = true ;
49
66
}
50
67
51
68
@ AfterClass
52
- public static void afterClass () {
53
- // OrientGraph graph = new OrientGraph(DB_URL, DB_USER, DB_PASSWORD);
54
- // graph.drop();
69
+ public static void afterClass () throws IOException {
70
+ if (DB_URL .startsWith ("remote:" )) {
71
+ OServerAdmin serverAdmin = new OServerAdmin (DB_URL );
72
+ serverAdmin .connect ("root" , ODatabaseHelper .getServerRootPassword ());
73
+
74
+ if (serverAdmin .existsDatabase ("plocal" )) {
75
+ serverAdmin .dropDatabase ("plocal" );
76
+ }
77
+ } else {
78
+ OrientGraph graph = new OrientGraph (DB_URL , DB_USER , DB_PASSWORD );
79
+ graph .drop ();
80
+ }
55
81
}
56
82
57
83
@ Test
@@ -127,14 +153,6 @@ public String getFailureMessage() {
127
153
return this .failureMessage ;
128
154
}
129
155
130
- /**
131
- * @param threadCount
132
- * - number of thread to run
133
- * @param maxSleepTime
134
- * @param maxOpCount
135
- * @param initialCacheSize
136
- * @param runtimeInMin
137
- */
138
156
private void executeTest (final int threadCount , final int maxSleepTime , final int maxOpCount , final int initialCacheSize ,
139
157
final int runtimeInMin ) {
140
158
CountDownLatch endLatch = new CountDownLatch (threadCount );
@@ -342,8 +360,9 @@ private boolean isInDatabase(final ORID id, OrientGraph orientGraph) throws Exce
342
360
* operation in the temp cache.
343
361
*
344
362
* @param tempCache
363
+ * cached objects
345
364
*/
346
- private void updateCache (final List <TempCacheObject > tempCache ) {
365
+ private void updateCache (final List <TempCacheObject > tempCache ) {
347
366
for (TempCacheObject tempCacheObject : tempCache ) {
348
367
ORID id = tempCacheObject .getOrientId ();
349
368
Operation operation = tempCacheObject .getOperation ();
@@ -463,13 +482,10 @@ public Integer getCustomId() {
463
482
}
464
483
465
484
public String toString () {
466
- StringBuilder stringObject = new StringBuilder ();
467
- stringObject .append ("Operation:" ).append (this .operation ).append (", ORID:" ).append (this .orientId ).append (", CustomId:" )
468
- .append (this .customId );
469
- return stringObject .toString ();
485
+ return "Operation:" + this .operation + ", ORID:" + this .orientId + ", CustomId:" + this .customId ;
470
486
}
471
487
472
- }
488
+ }
473
489
}
474
490
475
491
/**
0 commit comments