我想用蚂蚁创建一个像"胖"的罐子,不仅包括通常的类,清单文件等,还包括我的'libs'文件夹.
我尝试过:
<jar destfile="myjar.jar" update="yes" basedir="${libs.dir}"/>
Run Code Online (Sandbox Code Playgroud)
但这会将'libs'中的文件添加到jar文件的根目录中,我希望在jar中拥有libs文件夹(当然包含它包含的所有内容)
我可以自己在jar中创建lib文件夹,然后将文件添加到jar中的特定位置吗?
我是JUnit和Android的新手,很难找到与Android合作的好测试文档.
我有一个测试项目,其中包含扩展ActivityInstrumentationTestCase2的类.检查GUI状态(启用了什么,相对位置等)的简单测试按预期工作.但是,当我尝试执行按钮单击操作时,会抛出错误的线程异常.任何人都知道如何解决这个问题?
作为后续,有没有人对Android的测试或TDD免费资源有什么好的建议?我正在使用Eclipse/MotoDev.
谢谢
根据我调用每个按钮的方式,我可以得到不同的故障痕迹,但在此处包含一个以供参考:
android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
at android.view.ViewRoot.checkThread(ViewRoot.java:2683)
at android.view.ViewRoot.playSoundEffect(ViewRoot.java:2472)
at android.view.View.playSoundEffect(View.java:8307)
at android.view.View.performClick(View.java:2363)
at com.android.tigerslair.demo1.test.GoTest.setUp(GoTest.java:49)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:430)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447)
Run Code Online (Sandbox Code Playgroud)
这是简单的setup()例程:
@Override
protected void setUp() throws Exception {
super.setUp();
TigersLair activity=getActivity();
mGoBtn = (Button) activity.findViewById(R.id.go);
mGoBtn.performClick();
}
Run Code Online (Sandbox Code Playgroud)
如果我在setUp()或实际测试中执行单击并不重要.
我想要一个有效的方法,可以像这样工作
编辑:对不起,我没有把我以前尝试过的东西.我现在更新了这个例子.
// Method signature, Only replaces first instance or how many are specified in max
public int MyReplace(ref string source,string org, string replace, int start, int max)
{
int ret = 0;
int len = replace.Length;
int olen = org.Length;
for(int i = 0; i < max; i++)
{
// Find the next instance of the search string
int x = source.IndexOf(org, ret + olen);
if(x > ret)
ret = x;
else
break;
// Insert the replacement
source = …
Run Code Online (Sandbox Code Playgroud) 如果参数通过GET传递,则可以进行Sql注入.但是也可以通过POST.如果是,https可以阻止吗?
http://bash.cyberciti.biz/file-management/shell-script-to-simulate-unix-more-command/
#!/bin/bash
# Write a shell script like a more command. It asks the user name, the
# name of the file on command prompt and displays only the 15 lines of
# the file at a time.
# -------------------------------------------------------------------------
# Copyright (c) 2007 nixCraft project <http://cyberciti.biz/fb/>
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# ------------------------------------------------------------------------- …
Run Code Online (Sandbox Code Playgroud) 我正在使用jama来计算 SVD。效果非常好。如果我通过方阵。例如 2x2 或 3x3 等矩阵。但是当我传递像 2x3 或 4x8 这样的东西时,它会给出错误。我使用了他们所有的例子。他们有不同的构造函数来执行这项工作。我的第二个问题是,我使用 3x3 矩阵,它给出了
double[][] vals = {{1.,1.,0},{1.,0.,1.},{1.,3.,4.},{6.,4.,8.}};
Matrix A = new Matrix(vals);
Run Code Online (Sandbox Code Playgroud)
它产生了以下错误:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3
Run Code Online (Sandbox Code Playgroud)
之后我想使用另一个构造函数,如下所示
double[][] vals = {{1.,1.,0,4},{1.,0.,1.,2},{1.,3.,4.,8},{1.,3.,4.,8}};
Matrix A = new Matrix(vals,4,3);
Run Code Online (Sandbox Code Playgroud)
它产生以下输出:
A =
1.0 1.0 0.0
1.0 0.0 1.0
1.0 3.0 4.0
6.0 4.0 8.0
A = U S V^T
U =
0.078 -0.115 -0.963
0.107 -0.281 0.260
0.402 0.886 -0.018
0.906 -0.351 0.060
Sigma =
11.861881 0.000000 0.000000
0.000000 …
Run Code Online (Sandbox Code Playgroud) 我最近开始使用git,并开始进行单元测试(使用Python的unittest
模块).我想在每次提交时运行我的测试,并且只有在它们通过时才提交.
我猜我需要用pre-commit
的/hooks
,我已经成功地使它运行测试,但我似乎无法找到一种方法来阻止,如果他们失败测试的承诺.我正在运行测试make test
,而后者正在运行python3.1 foo.py --test
.似乎我没有得到不同的退出条件,无论测试通过还是失败,但我可能在错误的地方寻找.
编辑:我想在这里做一些不寻常的事吗?我原以为这是一个常见的要求......
编辑2:万一人们无法阅读评论,问题是unittest.TextTestRunner
不会以非零状态退出,测试套件是否成功.要抓住它,我做了:
result = runner.run(allTests)
if not result.wasSuccessful():
sys.exit(1)
Run Code Online (Sandbox Code Playgroud) Emacs维基说:
公司确实干扰了Yasnippet的本土行为.这是一个快速修复:http: //gist.github.com/265010
代码如下:
(define-key company-active-map "\t" 'company-yasnippet-or-completion)
(defun company-yasnippet-or-completion ()
(interactive)
(if (yas/expansion-at-point)
(progn (company-abort)
(yas/expand))
(company-complete-common)))
(defun yas/expansion-at-point ()
"Tested with v0.6.1. Extracted from `yas/expand-1'"
(first (yas/current-key)))
Run Code Online (Sandbox Code Playgroud)
我将该代码放在我的.emacs中,并显示以下消息:
Warning (initialization): An error occurred while loading `c:/Documents and Settings/Alex.AUTOINSTALL.001/Application Data/.emacs.elc':
Symbol's value as variable is void: company-active-map
To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file. Start Emacs with
the `--debug-init' option to view a complete error …
Run Code Online (Sandbox Code Playgroud) 我有一个流式传输jpeg的aspx页面.它设置内容类型,然后写入响应流.如果我直接查看图像,他们会有一种享受,但如果我使用fancybox 1.2.6,我会得到以下内容. alt text http://img686.imageshack.us/img686/3348/fancybox.png
使用fancybox 1.2.1,图像确实显示.
这是推出图像的代码.
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
using (Stream responseStream = response.GetResponseStream())
{
using (Image outImg = Image.FromStream(responseStream))
{
Response.Clear();
Response.ContentType = "image/jpeg";
outImg.Save(Response.OutputStream, ImageFormat.Jpeg);
}
}
}
Run Code Online (Sandbox Code Playgroud)
有帮助吗?