Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moved public inner classes and interfaces in OrientDB Test Commons to…
… appropriate places
- Loading branch information
Karl-Philipp Richter
committed
Mar 6, 2015
1 parent
5e964ae
commit 5d01bce
Showing
7 changed files
with
153 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
test-commons/src/main/java/com/orientechnologies/orient/test/CompositeException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright 2015 Orient Technologies. | ||
* | ||
* Licensed 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 com.orientechnologies.orient.test; | ||
|
||
import java.io.PrintStream; | ||
import java.io.PrintWriter; | ||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
/** | ||
* | ||
* @author richter | ||
*/ | ||
public class CompositeException extends RuntimeException { | ||
private static final long serialVersionUID = 1L; | ||
private final List<Throwable> causes = new ArrayList<Throwable>(); | ||
|
||
public CompositeException(Collection<? extends Throwable> causes) { | ||
this.causes.addAll(causes); | ||
} | ||
|
||
@Override | ||
public void printStackTrace() { | ||
if (causes.isEmpty()) { | ||
super.printStackTrace(); | ||
return; | ||
} | ||
for (Throwable cause : causes) { | ||
cause.printStackTrace(); | ||
} | ||
} | ||
|
||
@Override | ||
public void printStackTrace(PrintStream s) { | ||
if (causes.isEmpty()) { | ||
super.printStackTrace(s); | ||
} else { | ||
for (Throwable cause : causes) { | ||
cause.printStackTrace(s); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void printStackTrace(PrintWriter s) { | ||
if (causes.isEmpty()) { | ||
super.printStackTrace(s); | ||
} else { | ||
for (Throwable cause : causes) { | ||
cause.printStackTrace(s); | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
test-commons/src/main/java/com/orientechnologies/orient/test/TestBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright 2015 Orient Technologies. | ||
* | ||
* Licensed 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 com.orientechnologies.orient.test; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.concurrent.Callable; | ||
|
||
/** | ||
* | ||
* @author richter | ||
* @param <T> see {@link TestFactory} | ||
*/ | ||
public class TestBuilder<T> { | ||
private final List<Callable<T>> workers = new ArrayList<Callable<T>>(); | ||
|
||
public TestBuilder<T> add(int threadCount, TestFactory<T> factory) { | ||
workers.addAll(ConcurrentTestHelper.prepareWorkers(threadCount, factory)); | ||
return this; | ||
} | ||
|
||
public Collection<T> go() { | ||
return ConcurrentTestHelper.go(workers); | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
test-commons/src/main/java/com/orientechnologies/orient/test/TestFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright 2015 Orient Technologies. | ||
* | ||
* Licensed 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 com.orientechnologies.orient.test; | ||
|
||
import java.util.concurrent.Callable; | ||
|
||
/** | ||
* | ||
* @author richter | ||
* @param <T> the type of the {@link Callable} to be created with | ||
* {@link #createWorker() } | ||
*/ | ||
public interface TestFactory<T> { | ||
|
||
Callable<T> createWorker(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters