Jetty itself has no temporary directories, but each web application can be assigned a directory into which the war is unpacked, JSPs compiled on-the-fly etc.
The algorithm for determining a webapp's temporary directory location is as follows:
Try to use an explicit directory specifically for this webapp: Iff webapp.getTempDirectory() is set, use it. Do NOT delete it on jvm exit. Iff javax.servlet.context.tempdir context attribute is set for this webapp && exists && writeable, then use it. Do NOT delete on jvm exit. Create a directory based on global settings. The new directory will be called "Jetty_"host""port""context""+virtualhost : Iff $(jetty.home)/work exists create the directory there. Do NOT delete on jvm exit. Do NOT delete contents if dir already exists. Iff WEB-INF/work exists create the directory there. Do NOT delete on jvm exit. Do NOT delete contents if dir already exists. Else create dir in $(java.io.tmpdir). Set delete on jvm exit. Delete contents if dir already exists.
It is important to note that a temporary directory will have its contents deleted when the webapp is stopped unless either:
it is called "work" it pre-existed the deployment of the webapp
Once a tempory directory has been allocated, a File instance for it is set and retrievable as the javax.servlet.context.tempdir attribute of the web application.
@Test public void testQueryApi() throws Exception { // Context of the app under test. new QueryModelImpl().queryIp("8.8.8.8", new BasePresenterImpl.SubscriberEx<IpBean>() { @Override public void onSubscribeing(Subscription subscription) { subscription.request(Long.MAX_VALUE); }
@Override public void onNext(IpBean bean) { assertTrue(null != bean); }
@Override public void onError(Throwable e, boolean global) { super.onError(e, global); assertTrue(false); } }); }
然而...并没有什么卵用!断言根本不被执行...呵呵
仔细一想,嗯! testQueryApi() 应该是运行在主线程的,而我的 new QueryModelImpl().queryIp() 是异步的,也就是说 queryIp() 这个方法还没执行完(呵呵,可能初始化都还没走完),我们的主线程就已经死了,单元测试进程就 Game Over 了...自然是没法返回断言的数据了.
@Test public void testQueryApi() throws Exception { // Context of the app under test. final Object[] object = new Object[1]; new QueryModelImpl().queryIp("8.8.8.8", new BasePresenterImpl.SubscriberEx<IpBean>() { @Override public void onSubscribeing(Subscription subscription) { subscription.request(Long.MAX_VALUE); }
@Override public void onNext(IpBean bean) { object[0] = bean; }
@Override public void onError(Throwable e, boolean global) { super.onError(e, global); } }); Thread.sleep(10 * 1000); assertTrue(object[0] instanceof IpBean); }
@Test public void testQueryApi() throws Exception { // Context of the app under test. final Object[] object = new Object[1]; final CountDownLatch latch = new CountDownLatch(1); new QueryModelImpl().queryIp("8.8.8.8", new BasePresenterImpl.SubscriberEx<IpBean>() { @Override public void onSubscribeing(Subscription subscription) { subscription.request(Long.MAX_VALUE); }
cd /etc/pki/tls openssl genrsa -out server.key 1024
注意:server.key是私钥。
3、用私钥server.key文件生成证书请求文件csr
1
openssl req -new -key server.key -out server.csr
注:server.csr是证书请求文件。
此步骤需要输入一些证书信息:
1 2 3 4 5 6 7
Country Name (2 letter code) [XX]:CN State or Province Name (full name) []:shanghai Locality Name (eg, city) [Default City]:shanghai Organization Name (eg, company) [Default Company Ltd]:ccc Organizational Unit Name (eg, section) []:bbb Common Name (eg, your name or your server’s hostname) []:www.test.com Email Address []:a@a.com