我正在使用Java Mail API来读取和解析电子邮件.它与Servlet代码一起工作正常.
现在我正在尝试为同一目的编写一个JUnit测试用例.但在线 Session session = Session.getDefaultInstance(properties);我得到以下异常:
java.lang.NoClassDefFoundError: com/sun/mail/util/MailLogger
at javax.mail.Session.initLogger(Session.java:227)
at javax.mail.Session.<init>(Session.java:212)
at javax.mail.Session.getDefaultInstance(Session.java:315)
at javax.mail.Session.getDefaultInstance(Session.java:355)
at com.vxl.appanalytix.dataload.fromEmail.EmailParser.parseEmailSubject(EmailParser.java:44)
at com.vxl.appanalytix.controllers.controllerClasses.GenericEmailServiceClass.readEmailAttachments(GenericEmailServiceClass.java:33)
at com.vxl.appanalytix.dataload.GenericEmailTestCase.test(GenericEmailTestCase.java:42)
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 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) …Run Code Online (Sandbox Code Playgroud) 我有以下if语句:
String newStr4 = strr.split("2012")[0];
if (newStr4.startsWith("Mon")) {
str4.add(newStr4);
}
Run Code Online (Sandbox Code Playgroud)
我希望它包含startsWith Mon Tues Weds Thurs Friday等.使用字符串时有一个简单的方法吗?我试过||但它没用.
我想在confirmExit()单击JFrame标题栏的红色关闭按钮时调用方法.
我该如何捕获该事件?
如果用户选择不继续,我还想阻止窗口关闭.
为什么我不能@Autowired在这种情况下使用?
@SpringBootApplication
public class Application {
@Autowired
BookingService bookingService;
public static void main(String[] args) {
bookingService.book("Alice", "Bob", "Carol");
}
}
Run Code Online (Sandbox Code Playgroud)
但可以使用 @Bean
@SpringBootApplication
public class Application {
@Bean
BookingService bookingService() {
return new BookingService();
}
public static void main(String[] args) {
ApplicationContext ctx = SpringApplication.run(Application.class, args);
BookingService bookingService = ctx.getBean(BookingService.class);
bookingService.book("Alice", "Bob", "Carol");
}
}
Run Code Online (Sandbox Code Playgroud)
是不是两种方式生成BookingService相同的东西?
我指的是这里的基本关系代数运算符.
在我看来,可以通过选择完成项目所能完成的一切.
我不知道我错过了是否存在差异或某种细微差别.
在我的应用程序中,我想应用一些过滤器,但我不希望所有的请求都必须转到该过滤器.这将是一个性能问题,因为我们已经有了一些其他的过滤器.
我希望我的过滤器仅适用于HTTP POST方法..有什么办法吗?
请帮我解决这个问题.
谢谢Kiran
如何找到Oracle数据库的URL和端口?
例:
"jdbc:oracle:thin:@host:port:dbName","userName","password");
我可以看一下SQL命令或日志/配置文件吗?
我有一个包含非ASCII字符的URI,如:
http://www.abc.de/qq/qq.ww?MIval=typo3_bsl_int_Smtliste&p_smtbez=Schmalbl ttrigeSomerzischeruchtanb
如何从此URI中删除" "
我敢肯定这必须存在,但我找不到任何能做到这一点的事情.我想要的是一些在线服务,它提供了一个我可以发送电子邮件的电子邮件地址,并保证它会一直反弹.
我想要的原因是测试一个软件的弹跳处理功能.显然我可以使用某种我知道不存在的有效地址,但这似乎不是一种好的做法,即使这只是一次性测试,也不是自动化的(至少还没有) ).
理想情况下,我正在寻找像Mailinator这样的东西,但我可以发送消息,看待它们等待,并选择是否反弹它们,以及反弹的类型.
谷歌确实把这个地址发给了bounce-test@service.socketlabs.com,但就我所知,它已经不再弹出消息了,因为当我尝试它时,我没有得到任何回报.
有什么建议?
编辑 根据约翰的帖子,该服务似乎再次运行 - 于2016年9月30日从Gmail测试,并在5分钟内得到反弹.
我试图将相当于asm{int 3}(或类似)的东西放入我的iPhone程序中.我的目标是让Xcode完全停在有问题的线上,而不必调整调用堆栈(所以_Debugger听起来不像它会做的那样,而不是我无论如何都能找到它的框架......)然后离开我能够恢复执行(这就是我不满意的原因assert).
(我已经习惯了其他系统上的这些行为,我想在iOS上重现它们.)
到目前为止,我最好的尝试是:
asm volatile("bkpt 1");
Run Code Online (Sandbox Code Playgroud)
这会阻止相关行上的Xcode,但是当我尝试继续使用Cmd + Alt + P时,Xcode似乎BKPT再次运行.如果我使用Shift + Cmd + O,我只是得到这个:
Watchdog has expired. Remote device was disconnected? Debugging session terminated.
Run Code Online (Sandbox Code Playgroud)
(不用说,远程设备IS仍然连接.)
我没有大量的iOS,Mac,ARM,gdb或gcc的经验asm.所以我已经难过了.有没有办法让iOS和Xcode做我想做的事情?
(我不知道它是否有所作为,但根据指令大小判断我的程序是ARM代码.)