当前位置: 首页>>代码示例>>Java>>正文


Java MultipleFailureException类代码示例

本文整理汇总了Java中org.junit.internal.runners.model.MultipleFailureException的典型用法代码示例。如果您正苦于以下问题:Java MultipleFailureException类的具体用法?Java MultipleFailureException怎么用?Java MultipleFailureException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MultipleFailureException类属于org.junit.internal.runners.model包,在下文中一共展示了MultipleFailureException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: foundConcurrencyBug

import org.junit.internal.runners.model.MultipleFailureException; //导入依赖的package包/类
protected void foundConcurrencyBug() {
	if (fromNotDeadlockedProperty(error)) {
		exception = new DeadlockError(
				error.getProperty().getErrorMessage());
	} else if (exception instanceof MultipleFailureException) {
		MultipleFailureException mfe
				= (MultipleFailureException) exception;
		List<Throwable> failures = mfe.getFailures();
		for (int i = 0; i < failures.size(); i++) {
			Throwable t = failures.remove(0);
			failures.add(new ConcurrentError(t));
		}
	} else {
		exception = new ConcurrentError(exception);
	}
	terminateSearch();
}
 
开发者ID:tdopires,项目名称:cJUnit-mc626,代码行数:18,代码来源:ResultCollector.java

示例2: createMultipleFailureException

import org.junit.internal.runners.model.MultipleFailureException; //导入依赖的package包/类
public MultipleFailureException createMultipleFailureException(
		MultipleFailureExceptionInfo exceptionInfo)
		throws IllegalArgumentException, ClassNotFoundException,
			InstantiationException, IllegalAccessException,
			InvocationTargetException,
			NoSuchMethodException {
	List<Throwable> exceptions = new ArrayList<Throwable>();

	ExceptionInfo[] failures = exceptionInfo.getFailures();

	for (int i = 0; i < failures.length; i++) {
		exceptions.add(createException(failures[i]));
	}

	return new MultipleFailureException(exceptions);
}
 
开发者ID:tdopires,项目名称:cJUnit-mc626,代码行数:17,代码来源:ExceptionFactory.java

示例3: equals

import org.junit.internal.runners.model.MultipleFailureException; //导入依赖的package包/类
public static boolean equals(Throwable t1, Throwable t2) {
	if (t1 == t2) {
		return true;
	}
	if (t1 == null || t2 == null) {
		return false;
	}

	if (!t1.getClass().equals(t2.getClass())) {
		return false;
	} else if (t1 instanceof MultipleFailureException) {
		return equals(((MultipleFailureException) t1).getFailures(),
				((MultipleFailureException) t2).getFailures());
	} else {
		return eq(t1.getMessage(), t2.getMessage())
			&& Arrays.equals(t1.getStackTrace(),
					t2.getStackTrace())
			&& equals(t1.getCause(), t2.getCause());
	}
}
 
开发者ID:tdopires,项目名称:cJUnit-mc626,代码行数:21,代码来源:ExceptionComparator.java

示例4: testMultipleFailureExceptionInfoCtor

import org.junit.internal.runners.model.MultipleFailureException; //导入依赖的package包/类
@Test
public void testMultipleFailureExceptionInfoCtor() {
	Throwable t1 = new TestException();
	Throwable t2 = new OtherTestException();
	List<Throwable> failures = new ArrayList<Throwable>();
	failures.add(t1);
	failures.add(t2);
	MultipleFailureException mfe = new MultipleFailureException(
			failures);

	MultipleFailureExceptionInfo mfei
			= new MultipleFailureExceptionInfo(mfe);

	assertThat(mfei.failures.length, equalTo(2));
	assertThat(mfei.failures[0].getClassName(),
			equalTo(TestException.class.getName()));
	assertThat(mfei.failures[1].getClassName(),
			equalTo(OtherTestException.class.getName()));
}
 
开发者ID:tdopires,项目名称:cJUnit-mc626,代码行数:20,代码来源:MultipleFailureExceptionInfoTest.java

示例5: testAnnotation

import org.junit.internal.runners.model.MultipleFailureException; //导入依赖的package包/类
@Test
public void testAnnotation() throws Exception {
	JUnitCore core = new JUnitCore();
	Result result = core.run(Request.method(TestClass.class, "testThis"));
	
	if (!result.wasSuccessful()) {
		if (result.getFailures().get(0).getException().getCause() instanceof MultipleFailureException) {
			Assert.fail(((MultipleFailureException)result.getFailures().get(0).getException().getCause()).getFailures().toString());
		} else {
			Assert.fail(result.getFailures().toString());
		}
	}
	
	Assert.assertTrue(result.getFailures().toString(), result.wasSuccessful());
	
	ClassLoader loader = UnfinalizingTestRunner.getLastCreatedClassLoader();
	
	// now check to see that the classes are not final
	Class<?> finalClass = loader.loadClass(FinalClass.class.getName());
	Assert.assertFalse("Class should have been non-final", Modifier.isFinal(finalClass.getModifiers()));
	Class<?> finalClass2 = loader.loadClass(FinalClass2.class.getName());
	Assert.assertFalse("Class 2 should have been non-final", Modifier.isFinal(finalClass2.getModifiers()));
}
 
开发者ID:lithiumtech,项目名称:multiverse-test,代码行数:24,代码来源:UnfinalizingTestRunnerTest.java

示例6: testMockFinal

import org.junit.internal.runners.model.MultipleFailureException; //导入依赖的package包/类
@Test
public void testMockFinal() {
	IMocksControl control = EasyMock.createStrictControl();
	try {
		control.createMock(TestClass.FinalClass.class);
		Assert.fail("FinalClass wasn't actually final or EasyMock has changed to support this case");
	} catch(IllegalArgumentException e) {
		
	}
	
	JUnitCore core = new JUnitCore();
	Result result = core.run(Request.method(TestClass.class, "testMockingFinal"));
	
	if (!result.wasSuccessful()) {
		if (result.getFailures().get(0).getException().getCause() instanceof MultipleFailureException) {
			Assert.fail(((MultipleFailureException)result.getFailures().get(0).getException().getCause()).getFailures().toString());
		} else {
			Assert.fail(result.getFailures().toString());
		}
	}
	
}
 
开发者ID:lithiumtech,项目名称:multiverse-test,代码行数:23,代码来源:UnfinalizingTestRunnerTest.java

示例7: testMockParentFinalMethod

import org.junit.internal.runners.model.MultipleFailureException; //导入依赖的package包/类
@Test
public void testMockParentFinalMethod() {
	IMocksControl control = EasyMock.createStrictControl();
	try {
		control.createMock(TestClass.FinalChild.class);
		Assert.fail("FinalClass wasn't actually final or EasyMock has changed to support this case");
	} catch(IllegalArgumentException e) {
		
	}
	
	JUnitCore core = new JUnitCore();
	Result result = core.run(Request.method(TestClass.class, "testMockingParentFinal"));
	
	if (!result.wasSuccessful()) {
		if (result.getFailures().get(0).getException().getCause() instanceof MultipleFailureException) {
			Assert.fail(((MultipleFailureException)result.getFailures().get(0).getException().getCause()).getFailures().toString());
		} else {
			Assert.fail(result.getFailures().toString());
		}
	}
}
 
开发者ID:lithiumtech,项目名称:multiverse-test,代码行数:22,代码来源:UnfinalizingTestRunnerTest.java

示例8: testPrivateMethodAccess

import org.junit.internal.runners.model.MultipleFailureException; //导入依赖的package包/类
@Test
public void testPrivateMethodAccess() throws Exception{
	try {
		TestClass.FinalClass.class.getDeclaredMethod("hiddenMethod").invoke((new TestClass()).new FinalClass());
		Assert.fail("FinalClass.hiddenMethod doesn't seem to be private");
	} catch(IllegalAccessException e) {
		
	}

	JUnitCore core = new JUnitCore();
	Result result = core.run(Request.method(TestClass.class, "testAllMethodsPublic"));
	
	if (!result.wasSuccessful()) {
		if (result.getFailures().get(0).getException().getCause() instanceof MultipleFailureException) {
			Assert.fail(((MultipleFailureException)result.getFailures().get(0).getException().getCause()).getFailures().toString());
		} else {
			Assert.fail(result.getFailures().toString());
		}
	}
}
 
开发者ID:lithiumtech,项目名称:multiverse-test,代码行数:21,代码来源:UnfinalizingTestRunnerTest.java

示例9: testPrivateClassAccess

import org.junit.internal.runners.model.MultipleFailureException; //导入依赖的package包/类
@Test
public void testPrivateClassAccess() throws Exception{
	Parent parent = Parent.getAHiddenImplementationOfParent();
	Assert.assertEquals(parent.getClass().getSimpleName(), "PrivateParentImpl");
	Assert.assertTrue("PrivateParentImpl should be private to start with", Modifier.isPrivate(parent.getClass().getModifiers()));		

	JUnitCore core = new JUnitCore();
	Result result = core.run(Request.method(TestClassForNonVisibleClasses.class, "testProxyingNonVisibleClass"));
	
	if (!result.wasSuccessful()) {
		if (result.getFailures().get(0).getException().getCause() instanceof MultipleFailureException) {
			Assert.fail(((MultipleFailureException)result.getFailures().get(0).getException().getCause()).getFailures().toString());
		} else {
			Assert.fail(result.getFailures().toString());
		}
	}
}
 
开发者ID:lithiumtech,项目名称:multiverse-test,代码行数:18,代码来源:UnfinalizingTestRunnerTest.java

示例10: run

import org.junit.internal.runners.model.MultipleFailureException; //导入依赖的package包/类
protected void run() {
	try {
		createTest();
		runTest();
		notifyTestSucceeded();
	} catch (MultipleFailureException mfe) {
		notifyTestFailed(new MultipleFailureExceptionInfo(mfe));
	} catch (Throwable t) {
		notifyTestFailed(new ExceptionInfo(t));
	}
}
 
开发者ID:tdopires,项目名称:cJUnit-mc626,代码行数:12,代码来源:TestWrapper.java

示例11: handleErrors

import org.junit.internal.runners.model.MultipleFailureException; //导入依赖的package包/类
protected void handleErrors() throws Throwable, Exception {
	if (errors.size() == 1) {
		throw errors.get(0);
	} else if (errors.size() > 1) {
		throw new MultipleFailureException(errors);
	}
}
 
开发者ID:tdopires,项目名称:cJUnit-mc626,代码行数:8,代码来源:TestWrapper.java

示例12: MultipleFailureExceptionInfo

import org.junit.internal.runners.model.MultipleFailureException; //导入依赖的package包/类
public MultipleFailureExceptionInfo(String message,
		StackTraceElementInfo[] stackTrace,
		ExceptionInfo cause, ExceptionInfo[] failures) {
	super(MultipleFailureException.class.getName(), message,
			stackTrace, cause);
	this.failures = failures;
}
 
开发者ID:tdopires,项目名称:cJUnit-mc626,代码行数:8,代码来源:MultipleFailureExceptionInfo.java

示例13: testFoundConcurrencyBugWithMultipleFailures

import org.junit.internal.runners.model.MultipleFailureException; //导入依赖的package包/类
@Test
public void testFoundConcurrencyBugWithMultipleFailures() {
	ResultCollector rc = new ResultCollector(null, null) {
		@Override
		public void terminateSearch() {}
	};
	Throwable t1 = new TestException();
	Throwable t2 = new OtherTestException();
	List<Throwable> initFailures = new ArrayList<Throwable>();
	initFailures.add(t1);
	initFailures.add(t2);
	MultipleFailureException mfe = new MultipleFailureException(
			initFailures);
	rc.exception = mfe;
	rc.error = new Error(0, new PropertyListenerAdapter(), null,
			null);
	rc.foundConcurrencyBug();
	assertThat("MFE unchanged", rc.exception,
			equalTo((Throwable) mfe));
	assertThat("number of failures", mfe.getFailures().size(),
			equalTo(2));
	assertThat("first type", mfe.getFailures().get(0),
			instanceOf(ConcurrentError.class));
	assertThat("first cause", mfe.getFailures().get(0).getCause(),
			equalTo(t1));
	assertThat("second type", mfe.getFailures().get(1),
			instanceOf(ConcurrentError.class));
	assertThat("second cause", mfe.getFailures().get(1).getCause(),
			equalTo(t2));
}
 
开发者ID:tdopires,项目名称:cJUnit-mc626,代码行数:31,代码来源:ResultCollectorTest.java

示例14: testRunWhenFailedMultiple

import org.junit.internal.runners.model.MultipleFailureException; //导入依赖的package包/类
@Test
public void testRunWhenFailedMultiple() {
	final Counter succeededCounter = new Counter();
	final Counter failedCounter = new Counter();
	TestWrapper tw = new TestWrapper() {
		@Override
		protected void createTest() {}
		@Override
		protected void runTest() throws Throwable {
			throw new MultipleFailureException(null);
		}
		@Override
		protected void notifyTestSucceeded() {
			succeededCounter.increment();
		}
		@Override
		protected void notifyTestFailed(ExceptionInfo ei) {
			failedCounter.increment();
			// if this is not invoked, one of the asserts
			// below will fail anyway
			assertThat("type", ei, instanceOf(
				MultipleFailureExceptionInfo.class));
		}
	};

	tw.run();

	assertThat("succeeded", succeededCounter.getValue(),
			equalTo(0));
	assertThat("failed", failedCounter.getValue(), equalTo(1));
}
 
开发者ID:tdopires,项目名称:cJUnit-mc626,代码行数:32,代码来源:TestWrapperTest.java

示例15: testExceptionOnMultipleError

import org.junit.internal.runners.model.MultipleFailureException; //导入依赖的package包/类
@Test(expected=MultipleFailureException.class)
public void testExceptionOnMultipleError() throws Throwable {
	TestWrapper tw = new TestWrapper();
	tw.errors.add(new TestException());
	tw.errors.add(new OtherTestException());

	tw.handleErrors();
}
 
开发者ID:tdopires,项目名称:cJUnit-mc626,代码行数:9,代码来源:TestWrapperTest.java


注:本文中的org.junit.internal.runners.model.MultipleFailureException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。