java.lang.RuntimeException: iwap 环境还没有初始化,请先调用IWapContext.init()。
at com.nantian.ofpiwap.IWapContext.checkInit(IWapContext.java:402)
at com.nantian.ofpiwap.IWapContext.getContext(IWapContext.java:348)
at demo.TestHelloWorld.testGreeting(TestHelloWorld.java:14)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

解决方法:

package demo;

import org.springframework.context.ApplicationContext;
import com.nantian.ofpiwap.IWapContext;
import junit.framework.TestCase;
/**
* 测试greeting函数
*/
public class TestHelloWorld extends TestCase {
/**
* 测试greeting函数
*/
public void testGreeting() {
IWapContext.init();
ApplicationContext context = IWapContext.getContext();
HelloWorld helloWorld = (HelloWorld) context.getBean("HelloWorld");
String accountName = helloWorld.greeting("admin");
assertEquals("管理员", accountName);
}
}

junit报错的更多相关文章

  1. 【Junit 报错】No appenders could be found for logger (org.springframework.core.env.StandardEnvironment).

    Junit报错 log4j:WARN No appenders could be found for logger (org.springframework.core.env.StandardEnvi ...

  2. 【JUnit 报错】java.lang.IncompatibleClassChangeError

    使用Junit 测试spring时候报错: java.lang.IncompatibleClassChangeError: class org.springframework.core.LocalVa ...

  3. 【JUnit 报错】java.lang.NoClassDefFoundError: org/apache/logging/log4j/message/Message

    使用JUnit的时候,报错:java.lang.NoClassDefFoundError: org/apache/logging/log4j/message/Message 原因是因为项目中导入的架包 ...

  4. 【JUnit 报错】 method initializationerror not found:JUnit4单元测试报错问题

    今天是用JUnit测试一段代码,报错method initializationerror not found::出现如下问题: 双击这个就显示出现如下的错误: 查询网上,说是junit版本的问题: 那 ...

  5. spring整合junit报错

    1.Could not autowire field: private javax.servlet.http.HttpServletRequest 参考:https://www.cnblogs.com ...

  6. MyEclipse下Junit报错"The input type of the launch configuration"

    MyEclipse下Junit运行测试用例的时候报错: "The input type of the launch configuration does not exist" 原因 ...

  7. Spring+Hibernate4 Junit 报错No Session found for current thread

    论坛上有另外一篇更全面的帖子,jinnianshilongnian写的:http://www.iteye.com/topic/1120924 本文的环境是:  spring-framework-3.1 ...

  8. Junit 报错: Failed to load ApplicationContext

    今天在使用Junit测试时候,报了个错误: Failed to load ApplicationContext, aspect not found;挺奇怪的 我又没有调用你,之前还好好的,现在不能使用 ...

  9. JUnit报错:java.lang.ClassNotFoundException: com.mogodb.test.test

    最近在使用JUnit做单元测试时,发现新写好的测试类运行总是出错,报找不到类异常. Class not found com.mogodb.test.test java.lang.ClassNotFou ...

  10. 【Junit 报错】Test class should have exactly one public zero-argument constructor和Test class can only have one constructor

    错误1: java.lang.Exception: Test class should have exactly one public zero-argument constructor at org ...

随机推荐

  1. 二维码制作分享-Python

    分享一个简单快捷的二维码制作,Python实现. 1.安装准备 已安装的Python+Pycharm的计算机.本人win7+Python3.6+Pycharm 2.库包下载安装 Python二维码制作 ...

  2. X64驱动:内核操作进线程/模块

    注意:下面的所有案例必须使用.C结尾的文件,且必须在链接选项中加入 /INTEGRITYCHECK 选项,否则编译根本无法通过(整合修正,Win10可编译,须在测试模式下进行),内核代码相对固定,如果 ...

  3. SpringBoot学习(五)—— springboot快速整合Druid

    Druid连接池 简介 由阿里巴巴开源的druid连接池是目前综合实力最突出的数据库连接池,而且还提供了监控日志功能,能够分析SQL执行情况. 引入druid连接池 pom.xml中加入 <de ...

  4. vue npm run build 失败

    之前删除过 node-moudel 文件夹,然后 npm install 重新安装,一切OK.打包的时候,报错,找不到caniuse什么的.再删除node-moudel,重新cnpm install ...

  5. ES与关系型数据库的通俗比较

    1.在Elasticsearch中,文档归属于一种类型(type),而这些类型存在于索引(index)中,我们可以画一些简单的对比图来类比传统关系型数据库: Relational DB -> D ...

  6. 今天还是python游戏

    话不多说,上源码: import random, pygame, sys from pygame.locals import * FPS = 30 # frames per second, the g ...

  7. [转发]C++中new和malloc的区别

    原文地址:https://blog.csdn.net/linux_ever/article/details/50533149 new与malloc的10点区别 1. 申请的内存所在位置 new操作符从 ...

  8. 可以在一个.java文件中写两个类吗?

    一个java文件中可以有任意多个类,接口或是注解..但是只能有一个类是public的,而且这个类的名字要和文件同名,比如public类名为A则文件名就应当为A.java

  9. IntelliJ IDEA.2017.3.4(win7 64位)的安装使用

    下载 1.Idea与Webstorm同为JetBrains公司的产品,因此安装使用方式也极为相似,首先我们打开IDEA的官方下载网站:https://www.jetbrains.com/idea/,点 ...

  10. shell 三剑客之 sed pattern 详解

    sed 基础介绍 语法格式 sed 处理过程 sed 选项 cat sed.txt '-p' 打印输出 ,默认输出两次,流输出一次,源文件输出一次 sed 'p' sed.txt -n  只显示处理的 ...