首页 \ 问答 \ 请问下,JUnit单元测试有什么用??

请问下,JUnit单元测试有什么用??

我的编程习惯是写一段代码就测试一下,请问JUnit单元测试对我来说有用吗??或者说它有什么作用,什么情况下有什么效果??
更新时间:2022-03-22 18:03

最满意答案

常见的情况下,Linux下nginx一般的ssl配置文件是这样的: server { listen 443; server_name example.com; root /apps/www; index index.html index.htm index.php; ssl on; ssl_certificate ../SSL/ittest.pem; ssl_certificate_key ../SSL/itt.

其他回答

下载apr依赖: apr 1.2+ development headers (libapr1-dev package)
下载openssl依赖:openssl 0.9.7+ development headers (libssl-dev package)
准备依赖包
解压缩tomcat_home/bin/tomcat-native.tar.gz
进入目录:tomcat-native-1.1.20-src/jni/native 详细安装见此目录下的building文件
执行 export java_home=/prog/java/jdk 设置jdk
执行:./configure --with-apr=/usr/bin --with-ssl=/usr/bin
执行:make
执行:sudo make install -->安装到/usr/local/apr/lib
执行:ln -s /usr/local/apr/lib/libtcnative-1.so $java_home/jre/lib/amd64/
重新启动tomcat看到:
sep 3, 2010 9:56:17 pm org.apache.catalina.core.aprlifecyclelistener init
info: loaded apr based apache tomcat native library 1.1.20.
sep 3, 2010 9:56:18 pm org.apache.catalina.core.aprlifecyclelistener init
info: apr capabilities: ipv6 [true], sendfile [true], accept filters [false], random [true].
sep 3, 2010 9:56:18 pm org.apache.catalina.core.aprlifecyclelistener lifecycleevent
info: failed to initialize the sslengine.
sep 3, 2010 9:56:18 pm org.apache.coyote.http11.http11aprprotocol init
info: initializing coyote http/1.1 on http-8782
sep 3, 2010 9:56:18 pm org.apache.coyote.ajp.ajpaprprotocol init
info: initializing coyote ajp/1.3 on ajp-8711
sep 3, 2010 9:56:18 pm org.apache.catalina.startup.catalina load
info: initialization processed in 840 ms

配置ssl

非apr的ssl配置步骤
创建keystore:
jdk/bin/keytool -genkey -keystore tomcat.keystore -alias tomcat -keyalg rsa

把tomcat.keystore放入${user.home}目录中,就是你的用户目录,当然你可以放入其他目录中
修改tomcat的server.xml,增加connector:

xml代码  
  apr环境的ssl配置(ssl不使用apr):

           
  
如果还是按照上面的#非apr的ssl配置步骤进行ssl配置,那么需要这么做:
在connector中配置protocol=org.apache.coyote.http11.http11nioprotocol
       
           


但启动时会提示错误:failed to initialize the sslengine.
sep 3, 2010 10:49:42 pm org.apache.catalina.core.aprlifecyclelistener init
info: loaded apr based apache tomcat native library 1.1.20.
sep 3, 2010 10:49:43 pm org.apache.catalina.core.aprlifecyclelistener init
info: apr capabilities: ipv6 [true], sendfile [true], accept filters [false], random [true].
sep 3, 2010 10:49:43 pm org.apache.catalina.core.aprlifecyclelistener lifecycleevent
info: failed to initialize the sslengine.
sep 3, 2010 10:49:43 pm org.apache.coyote.http11.http11aprprotocol init
info: initializing coyote http/1.1 on http-8782
sep 3, 2010 10:49:43 pm org.apache.tomcat.util.net.nioselectorpool getsharedselector
info: using a shared selector for servlet write/read
sep 3, 2010 10:49:43 pm org.apache.coyote.http11.http11nioprotocol init
info: initializing coyote http/1.1 on http-9145
sep 3, 2010 10:49:43 pm org.apache.coyote.ajp.ajpaprprotocol init
info: initializing coyote ajp/1.3 on ajp-8711
sep 3, 2010 10:49:43 pm org.apache.catalina.startup.catalina load
info: initialization processed in 1162 ms

虽然提示信息:failed to initialize the sslengine.但ssl依然可以正常运行,要抑制此信息只要修改server.xml配置apr的sslengine=off即可,如
 
           


启动信息
sep 3, 2010 10:51:53 pm org.apache.catalina.core.aprlifecyclelistener init
info: loaded apr based apache tomcat native library 1.1.20.
sep 3, 2010 10:51:53 pm org.apache.catalina.core.aprlifecyclelistener init
info: apr capabilities: ipv6 [true], sendfile [true], accept filters [false], random [true].
sep 3, 2010 10:51:54 pm org.apache.coyote.http11.http11aprprotocol init
info: initializing coyote http/1.1 on http-8782
sep 3, 2010 10:51:54 pm org.apache.tomcat.util.net.nioselectorpool getsharedselector
info: using a shared selector for servlet write/read
sep 3, 2010 10:51:54 pm org.apache.coyote.http11.http11nioprotocol init
info: initializing coyote http/1.1 on http-9145
sep 3, 2010 10:51:54 pm org.apache.coyote.ajp.ajpaprprotocol init
info: initializing coyote ajp/1.3 on ajp-8711
sep 3, 2010 10:51:54 pm org.apache.catalina.startup.catalina load
info: initialization processed in 1081 ms

相关问答

更多
  • 配置之前您需要获得:Nginx格式证书,他是2个文件组成。 Nginx安装SSL证书:网页链接 Nginx 自动跳转到HTTPS:网页链接 注意:安装防火墙需要设置允许443端口或关闭防火墙,如果本地服务器安装安全狗的,请允许443端口。如果无法根据教程完成SSL证书配置工作,建议您请求技术支持:网页链接
  • 常见的情况下,Linux下nginx一般的ssl配置文件是这样的: server { listen 443; server_name example.com; root /apps/www; index index.html index.htm index.php; ssl on; ssl_certificate ../SSL/ittest.pem; ssl_certificate_key ../SSL/itt.
  • 下载APR依赖: APR 1.2+ development headers (libapr1-dev package) 下载OpenSSL依赖:OpenSSL 0.9.7+ development headers (libssl-dev package) 准备依赖包 解压缩tomcat_home/bin/tomcat-native.tar.gz 进入目录:tomcat-native-1.1.20-src/jni/native 详细安装见此目录下的BUILDING文件 执行 export JAVA_HOME= ...
  • 您的SSL证书可能是针对给定域提供的,而不是针对IP地址提供的,并且您使用的是IP而不是域连接: io.connect('https://52.29.55.217') 除非您的证书在其涵盖的主机列表中包含该IP地址(极不可能),否则这将无效。 尝试使用Let's Encrypt创建证书时使用的确切域名(不是子域,不是IP,确切的域名)。 Your SSL certificate is likely provided for a given domain, not for the IP address an ...
  • 看起来像site2服务器声明缺少ssl on; 配置。 在site1中,您可以直接listen它。 Looks like site2 server declaration is missing the ssl on; config. In site1, you have it directly under listen.
  • 在我的情况下,用LibreSSL替换OpenSSL解决了这个问题。 In my case, replacing OpenSSL with LibreSSL solved the problem.
  • 我正在周末的一个很好的部分研究这个不便的解决方案,并设法找到解决方案。 Let's Encrypt和Nginx中都没有错误,所有这些都指的是我的错误配置; 但是,我不能不再认为这是一件奇怪的事情,即使不多说,我的解决方案也可以改进,这是我的Nginx配置文件: server { listen 80; server_name example.com www.example.com; return 301 https://example.com$request_uri; } serve ...
  • 好吧所以这个问题比我想象的要简单。 我正在使用不支持ssl的免费cloudflare dns指向。 我切换到使用namescheap dns,它开始工作。 okay so the problem was simpler than I thought. I was using the free cloudflare dns pointing which didn't support ssl. I switched to using the namescheap dns and it started worki ...
  • server_name _; 是无关紧要的(并且在现代版本的nginx不是必需的)。 如果找不到具有匹配的listen和server_name , nginx将使用默认服务器 。 如果没有listen指令的default_server后缀, nginx将使用匹配listen的第一个server块。 如果您的配置分布在多个文件中,则评估顺序将不明确,因此您需要明确标记默认服务器。 试试这个jelastic服务器块: server { listen 443 ssl default_server; ...
  • 你混淆了你的端口: 这个http://104.236.228.111:1337/parse/files/IpFrZ8h4ZFjv9fKhUq3p7C2ca2WOBuAkbbzmtrxe/50c99849-9e31-4414-9552-f640fb43eb53_iphone_6.png绕过nginx直接进入后端,后端正在1337端口侦听此服务器。 此https://cobbet.com:1337/parse/files/IpFrZ8h4ZFjv9fKhUq3p7C2ca2WOBuAkbbzmtrxe/50c9 ...

相关文章

更多

最新问答

更多
  • h2元素推动其他h2和div。(h2 element pushing other h2 and div down. two divs, two headers, and they're wrapped within a parent div)
  • 创建一个功能(Create a function)
  • 我投了份简历,是电脑编程方面的学徒,面试时说要培训三个月,前面
  • PDO语句不显示获取的结果(PDOstatement not displaying fetched results)
  • Qt冻结循环的原因?(Qt freezing cause of the loop?)
  • TableView重复youtube-api结果(TableView Repeating youtube-api result)
  • 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
  • SQL Server 2014版本支持的最大数据库数(Maximum number of databases supported by SQL Server 2014 editions)
  • 我如何获得DynamicJasper 3.1.2(或更高版本)的Maven仓库?(How do I get the maven repository for DynamicJasper 3.1.2 (or higher)?)
  • 以编程方式创建UITableView(Creating a UITableView Programmatically)
  • 如何打破按钮上的生命周期循环(How to break do-while loop on button)
  • C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
  • 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
  • 如何防止调用冗余函数的postgres视图(how to prevent postgres views calling redundant functions)
  • Sql Server在欧洲获取当前日期时间(Sql Server get current date time in Europe)
  • 设置kotlin扩展名(Setting a kotlin extension)
  • 如何并排放置两个元件?(How to position two elements side by side?)
  • 如何在vim中启用python3?(How to enable python3 in vim?)
  • 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
  • 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
  • Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
  • dedecms如何安装?
  • 在哪儿学计算机最好?
  • 学php哪个的书 最好,本人菜鸟
  • 触摸时不要突出显示表格视图行(Do not highlight table view row when touched)
  • 如何覆盖错误堆栈getter(How to override Error stack getter)
  • 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
  • USSD INTERFACE - > java web应用程序通信(USSD INTERFACE -> java web app communication)
  • 电脑高中毕业学习去哪里培训
  • 正则表达式验证SMTP响应(Regex to validate SMTP Responses)