我有一个A
需要经过测试的课程.以下是定义A
:
public class A {
public void methodOne(int argument) {
//some operations
methodTwo(int argument);
//some operations
}
private void methodTwo(int argument) {
DateTime dateTime = new DateTime();
//use dateTime to perform some operations
}
}
Run Code Online (Sandbox Code Playgroud)
并且基于该dateTime
值,一些数据将被操纵,从数据库中检索.对于此数据库,值通过JSON文件保留.
这使事情复杂化.我需要的dateTime
是在测试时将其设置为某个特定日期.有没有办法可以使用mockito模拟局部变量的值?
如果进程超过几秒钟,我试图杀死它。
当我在终端中运行它时,以下工作正常。
timeout 2 sleep 5
Run Code Online (Sandbox Code Playgroud)
但是当我有剧本时——
#!/bin/bash
timeout 2 sleep 5
Run Code Online (Sandbox Code Playgroud)
它说
超时:找不到命令
为什么这样?解决方法是什么?
- 编辑 -
在执行类型超时时,它说 -
timeout 是一个 shell 函数
当我在编译沙箱c程序后尝试运行.out文件时,它会出现以下错误:
./sandbox: error while loading shared libraries: libsandbox.so: cannot open shared object file: No such file or directory
Run Code Online (Sandbox Code Playgroud)
我该怎么办?
我有一个方法接受一个InputStream作为参数.如何找到传递的处理程序正在处理的文件?
例如:
public performSomething(InputStream inputStream) {
System.out.println(FILENAME);
}
Run Code Online (Sandbox Code Playgroud)
应该替换FILENAME,以便显示处理程序打开的文件的名称.
如果我的代码如下.请告诉我我做错了什么?
package version.nitt;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import version.nitt.R;
import android.util.Log;
import android.content.Intent;
public class versionActivity extends Activity {
private Runnable runnable;
private static final String TAG="WElcome!";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.startscreen);
runnable= new Runnable(){
public void run()
{
try
{
Log.v(TAG,"Going to sleep...");
Thread.sleep(1000);
Log.v(TAG,"Waking up from sleep...");
}
catch(Exception e1)
{
}
}
};
try
{
Thread t=new …
Run Code Online (Sandbox Code Playgroud) 我试图使用以下命令执行插入:
insert into table2(COL1, COL2, COL3, COL4) values((select COL1 FROM table1 WHERE COL1 = 121212),120,10,"Y");
Run Code Online (Sandbox Code Playgroud)
但是我收到以下错误:
第1行的错误:ORA-00984:此处不允许列
有帮助吗?