我的DOM看起来像这样:
<div id="d1">
<div class="c1">
<a href="#"><img src="img1_on.gif"></a>
<a href="#"><img src="img2_on.gif"></a>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
当有人点击图像上,我希望图像SRC切换到<img src="imgx_off.gif">其中x表示图像编号1或2.
这是可能的还是我必须使用CSS来更改图像?
所以我开始为Java-Spring项目编写测试.
我使用的是JUnit和Mockito.据说,当我使用when()... thenReturn()选项时,我可以模拟服务,而不需要模拟它们.所以我想做的是,设置:
when(classIwantToTest.object.get().methodWhichReturnsAList(input))thenReturn(ListcreatedInsideTheTestClass)
Run Code Online (Sandbox Code Playgroud)
但无论我在哪个when子句中,我总是得到一个NullpointerException,当然这是有意义的,因为输入是null.
当我尝试从对象模拟另一个方法时:
when(object.method()).thenReturn(true)
Run Code Online (Sandbox Code Playgroud)
在那里我也得到一个Nullpointer,因为该方法需要一个未设置的变量.
但我想使用when().. thenReturn()来绕过创建这个变量等等.我只是想确保,如果任何类调用此方法,那么无论如何,只返回true或上面的列表.
这是我身边的一个基本误解,还是有其他错误?
码:
public class classIWantToTest implements classIWantToTestFacade{
@Autowired
private SomeService myService;
@Override
public Optional<OutputData> getInformations(final InputData inputData) {
final Optional<OutputData> data = myService.getListWithData(inputData);
if (data.isPresent()) {
final List<ItemData> allData = data.get().getItemDatas();
//do something with the data and allData
return data;
}
return Optional.absent();
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的测试类:
public class Test {
private InputData inputdata;
private ClassUnderTest classUnderTest;
final List<ItemData> allData = new ArrayList<ItemData>();
@Mock
private DeliveryItemData item1;
@Mock
private DeliveryItemData item2; …Run Code Online (Sandbox Code Playgroud) 我注意到,当Get-Content path/to/logfile -Wait文档解释它应该时,输出实际上不会每秒刷新一次.如果我将Windows资源管理器转到日志文件所在的文件夹并刷新文件夹,则会Get-Content将最新更改输出到日志文件.
如果我tail -f在同一个日志文件上尝试使用cygwin(不是在尝试的同时get-content),那么它会像人们期望的那样尾巴,在没有我必须做任何事情的情况下刷新实时.
有谁知道为什么会这样?
我正在使用Intellij IDEA 12.1.6.一些顶级或功能文件名称是砖红色文本.例如,清单文件和.iml文件.我关心iml文件,因为那是项目文件.
IDEA文档说如果文件中存在合并冲突,它会"突出显示"红色文本,但是,当我打开iml文件时,它没有合并冲突.此外,文本为红色,未突出显示,但"突出显示"可能意味着文本的颜色.
为什么文件名的文本是红色的?屏幕截图如下:

我扩展了MapKit使用以下代码绘制自定义注释图像的能力:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{
NSLog(@"Drawing a cloud on the map");
MKAnnotationView *view;
if(annotation != mapView.userLocation){
view=[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"parkingloc"];
view.image=[UIImage imageNamed:@"placemarkCloud.png"];
[view setCanShowCallout:YES];
[view setRightCalloutAccessoryView:[UIButton buttonWithType:UIButtonTypeDetailDisclosure]];
}
else{
view=
}
return view;
}
Run Code Online (Sandbox Code Playgroud)
我的问题是我应该如何制作视图=以保留iPhone的内置蓝点.您可以看到我删除了为点绘制的自定义图像,但我不知道如何将其显示为默认值.
我的应用程序最多运行180个AJAX作业,这些作业在服务器端是IO密集型的(长时间运行的SELECT查询).
我想优化我可用的多个CPU内核的负载,从每个AJAX调用顺序执行的设计切换到执行这些请求的设计,最多并行执行4个请求.
一个可能但丑陋的解决方案可能是在客户端上同时发出所有180个请求,并让服务器使用Semaphore存储的Session或者Application级别.我将在稍后讨论应用程序工作负载.
我想找到一个更好的解决方案,其中调用全部按顺序启动(表上的每一行是一个不同的检查查询)但是当任何终止时,下一个启动并且有一些(即4个)并发AJAX请求与各自的装载机指标.
我曾尝试使用Threadpool-js,但我发现自己无法使用工作者的jQuery
我目前的代码如下
function GlobalCheck() { //entry point
if (ValidateDate()) {
//Below are global variables
list = $(".chkClass:checked"); //Only checked rows deal to AJAX request
num = $(".chkClass:checked").length; //Total number of ajax calls
done = 0; //Count of complete calls. When it reaches num we are done!
if (list.length == 0) {
alert('...');
return;
}
$(".pMessage").fadeOut();
$(".tbStatus").html('');
$(".submit").hide();
$(".exportFunctions").fadeOut();
$(".loader").show();
$(":checkbox").attr('disabled', true);
SingleCheck(0); //simplification, I do other …Run Code Online (Sandbox Code Playgroud) 我注意到,对于返回的getter Boolean(不是boolean!),netbeans会生成带有"get"前缀的getter.例如:
private Boolean main;
public Boolean getMain(){
return this.main;
}
Run Code Online (Sandbox Code Playgroud)
这是错的(根据命名惯例)?或者只是原始类型的"是"前缀?
如果我有
Reflections reflections = new Reflections("my.package", classLoader, new SubTypesScanner(false));
Run Code Online (Sandbox Code Playgroud)
然后这会找到我的枚举类
Set<Class<? extends Enum>> enums = reflections.getSubTypesOf(Enum.class);
Run Code Online (Sandbox Code Playgroud)
但事实并非如此
Set<Class<?>> classes = reflections.getSubTypesOf(Object.class);
Run Code Online (Sandbox Code Playgroud)
是否有一个原因?
可重复的例子:
package cupawntae;
import org.reflections.Reflections;
import org.reflections.scanners.SubTypesScanner;
public class Reflector {
public static void main(String[] args) {
Reflections reflections = new Reflections("cupawntae", Reflector.class.getClassLoader(), new SubTypesScanner(false));
System.out.println("Objects: " + reflections.getSubTypesOf(Object.class));
System.out.println("Enums: " + reflections.getSubTypesOf(Enum.class));
System.out.println("Enum's superclass: " + Enum.class.getSuperclass());
}
}
Run Code Online (Sandbox Code Playgroud)
枚举类:
package cupawntae;
public enum MyEnum {
}
Run Code Online (Sandbox Code Playgroud)
输出:
Objects: [class cupawntae.Reflector]
Enums: [class cupawntae.MyEnum]
Enum's superclass: class …Run Code Online (Sandbox Code Playgroud) 我有一个要求,即不应将值缓存在服务器中,也不应将浏览器缓存为域和会话上的cookie.
所以我选择永久重定向到价值
Servlet的:
@Override
protected void service(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
String key = request.getParameter("key");
String val = request.getContentType();
if (val != null && val.length() == 0) {
val = null;
}
String repeatText = request.getParameter("repeatText");
if (val != null && repeatText == null) {
response.setStatus(301); // moved permanent
response.addHeader("Location", "?repeatText=" + val);
System.out.println("Write");
} else {
if (repeatText != null) {
response.setContentLength(repeatText.length());
response.addHeader("pragma", "no-cache");
response.addIntHeader("expires", BROWSER_CACHE_DAYS);
response.getWriter().write(repeatText);
System.out.println("Read and cache!");
} else {
response.sendError(304); // use …Run Code Online (Sandbox Code Playgroud) 我有一个子类UIView,并添加了touchesBegan和touchesEnd方法......
在touchesBegan,我backgroundColor通过使用self.backgroundColor = [UIColor greenColor]... 将白色设置为绿色,touchesEnd我将颜色重置为白色.
它工作但很慢.通过点击视图,它需要0.5 - 1.0秒,直到我看到绿色.
选择一个单元格UITableView的速度要快得多.
java ×4
jquery ×3
javascript ×2
ajax ×1
enums ×1
gesture ×1
http ×1
ide ×1
image ×1
ios ×1
junit ×1
mapkit ×1
mockito ×1
netbeans ×1
objective-c ×1
powershell ×1
reflection ×1
reflections ×1
servlets ×1
stubbing ×1
testing ×1