Skip to content

Commit

Permalink
small test improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Jun 8, 2018
1 parent 0b9ff73 commit 7e5adbd
Showing 1 changed file with 38 additions and 1 deletion.
Expand Up @@ -19,6 +19,9 @@
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.prism.query.SubstringFilter;
import com.evolveum.midpoint.prism.schema.SchemaRegistry;
import com.evolveum.midpoint.repo.api.RepoAddOptions;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.util.logging.Trace;
Expand Down Expand Up @@ -67,7 +70,10 @@ public void testSerializationExceptions() throws Exception {
workers[i] = new Worker(this, UserType.class, oid, "testAttribute");
}

ExecutorService executors = Executors.newFixedThreadPool(workers.length);
ExecutorService executors = Executors.newFixedThreadPool(workers.length * 2);
// for (int i = 0; i < WORKER_COUNT; i++) {
// executors.execute(new SelectWorker(this));
// }

for (int i = 1; i <= 1000; i++) {
List<Future> futures = new ArrayList<>();
Expand All @@ -85,6 +91,36 @@ public void testSerializationExceptions() throws Exception {

Thread.sleep(100);
}

executors.shutdownNow();
}

private static class SelectWorker<T extends ObjectType> implements Runnable {

private ExtDictionaryConcurrencyTest test;

public SelectWorker(ExtDictionaryConcurrencyTest test) {
this.test = test;
}

@Override
public void run() {
try {
OperationResult result = new OperationResult("search");

SchemaRegistry registry = test.prismContext.getSchemaRegistry();

ObjectQuery query = ObjectQuery.createObjectQuery(
SubstringFilter.createSubstring(
new ItemPath(UserType.F_NAME),
registry.findComplexTypeDefinitionByCompileTimeClass(UserType.class).findPropertyDefinition(UserType.F_NAME),
test.prismContext, null, "worker", false, false));
List<PrismObject<UserType>> res = test.repositoryService.searchObjects(UserType.class, query, new ArrayList<>(), result);
LOGGER.info("Found {} users", res.size());
} catch (Exception ex) {
LOGGER.error("Search exception", ex);
}
}
}

private static class Worker<T extends ObjectType> implements Runnable {
Expand Down Expand Up @@ -115,6 +151,7 @@ public void run() {
OperationResult result = new OperationResult("Test: " + attribute + index);
try {
ItemPath path = new ItemPath(UserType.F_EXTENSION, new QName(NAMESPACE, attribute + index));
// ItemPath path = new ItemPath(UserType.F_DESCRIPTION);
ObjectDelta delta = ObjectDelta.createModificationAddProperty(type, oid, path,
test.prismContext, attribute + index);

Expand Down

0 comments on commit 7e5adbd

Please sign in to comment.