• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java MultipleFailureException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: testMultipleFailureExceptionInfoCtorWithNullFailures

import org.junit.internal.runners.model.MultipleFailureException; //导入依赖的package包/类
@Test
public void testMultipleFailureExceptionInfoCtorWithNullFailures() {
	MultipleFailureException mfe = new MultipleFailureException(
			null);

	MultipleFailureExceptionInfo mfei
			= new MultipleFailureExceptionInfo(mfe);

	assertThat(mfei.failures.length, equalTo(0));
}
 
开发者ID:tdopires,项目名称:cJUnit-mc626,代码行数:11,代码来源:MultipleFailureExceptionInfoTest.java


示例17: falseWhenMFEsWithDifferentLists

import org.junit.internal.runners.model.MultipleFailureException; //导入依赖的package包/类
@Test
public void falseWhenMFEsWithDifferentLists() {
	List<Throwable> l = new ArrayList<Throwable>();
	l.add(t);
	MultipleFailureException mfe1
			= new MultipleFailureException(l);
	MultipleFailureException mfe2
			= new MultipleFailureException(null);
	assertThat(ExceptionComparator.equals(mfe1, mfe2), is(false));
}
 
开发者ID:tdopires,项目名称:cJUnit-mc626,代码行数:11,代码来源:ExceptionComparatorTest.java


示例18: trueWhenMFEsWithEqualLists

import org.junit.internal.runners.model.MultipleFailureException; //导入依赖的package包/类
@Test
public void trueWhenMFEsWithEqualLists() {
	List<Throwable> l1 = new ArrayList<Throwable>();
	l1.add(t);
	MultipleFailureException mfe1
			= new MultipleFailureException(l1);
	List<Throwable> l2 = new ArrayList<Throwable>();
	Throwable t2 = new TestException(t.getMessage());
	t2.setStackTrace(t.getStackTrace());
	l2.add(t2);
	MultipleFailureException mfe2
			= new MultipleFailureException(l2);
	assertThat(ExceptionComparator.equals(mfe1, mfe2), is(true));

}
 
开发者ID:tdopires,项目名称:cJUnit-mc626,代码行数:16,代码来源:ExceptionComparatorTest.java


示例19: evaluate

import org.junit.internal.runners.model.MultipleFailureException; //导入依赖的package包/类
@Override
public void evaluate() throws Throwable {
	try {
		statement.evaluate();
	} catch (Throwable t) {
		if (t instanceof MultipleFailureException) {
			t = ((MultipleFailureException) t).getFailures().get(0);
		}
		if (t instanceof InvocationTargetException) {
			t = ((InvocationTargetException) t).getTargetException();
		}
		String assertMsg;
		if (t instanceof AssertionError) {
			throw t;
		} else if ((!isConnectionExpected) && t.getMessage() != null
				&& t.getMessage().contains(DATASOURCE_ERROR)) {
			// if we throw because of missing data-source and the db server isn't available, ignore it
			return;
		} else if (tClass == null) {
			assertMsg = "Test threw unexpected exception: " + t;
		} else if (tClass == t.getClass()) {
			// we matched our expected exception
			return;
		} else {
			assertMsg = "Expected test to throw " + tClass + " but it threw: " + t;
		}
		Error error = new AssertionError(assertMsg);
		error.initCause(t);
		throw error;
	}
	// can't be in the throw block
	if (tClass != null) {
		throw new AssertionError("Expected test to throw " + tClass);
	}
}
 
开发者ID:j256,项目名称:ormlite-jdbc,代码行数:36,代码来源:BaseJdbcTest.java


示例20: isMissingCredsException

import org.junit.internal.runners.model.MultipleFailureException; //导入依赖的package包/类
private boolean isMissingCredsException( final Throwable t ) {

        if ( t instanceof AmazonClientException ) {

            final AmazonClientException ace = ( AmazonClientException ) t;

            if ( ace.getMessage().contains( "could not get aws access key" ) || ace.getMessage().contains(
                "could not get aws secret key from system properties" ) ) {
                //swallow
                return true;
            }
        }

        if( t instanceof AwsPropertiesNotFoundException ){
            return true;
        }

        /**
         * Handle the multiple failure junit trace
         */
        if( t instanceof MultipleFailureException ){
            for(final Throwable failure : ((MultipleFailureException)t).getFailures()){
                final boolean isMissingCreds = isMissingCredsException( failure );

                if(isMissingCreds){
                    return true;
                }
            }
        }
        final Throwable cause = t.getCause();

        if ( cause == null ) {
            return false;
        }


        return isMissingCredsException( cause );
    }
 
开发者ID:apache,项目名称:usergrid,代码行数:39,代码来源:NoAWSCredsRule.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CDT类代码示例发布时间:2022-05-22
下一篇:
Java ContentSource类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap