我有一个A类,它有一个由B类代表的内部Cache.这个内部类是私有的,因为缓存不需要对外部消费者可见,只是为了帮助外部类A.我使用的是Jmock和Java
public class A {
...
private class B {
...
public void testMethod() {
//The method I want to unit test
...
}
}
}
Run Code Online (Sandbox Code Playgroud)
如上所示.我不确定如何对来自私有内部类B的testMethod()进行单元测试(因为B类对于外部世界是不可见的).
请指教!
谢谢!
我无法让伊斯坦布尔与茉莉花合作:
这是我的目录结构
ttm-jira
- package.json
- spec
- jira-spec.js
Run Code Online (Sandbox Code Playgroud)
我的package.json看起来像这样:
{
"name": "ttm-jira",
"version": "1.0.0",
"description": "nodeJS module to provide access to the JIRA REST API",
"author": {
"name": "...",
"url" : "...."
},
"main": "jira.js",
"private": true,
"repository": {
"type": "git",
"url" : "https://........git"
},
"bugs": {
"url" : "https://jira2........."
},
"scripts": {
"test" : "npm run code-coverage && npm run unit-test",
"unit-test" : "jasmine-node . --autotest --captureExceptions --watch",
"code-coverage": "istanbul cover --include-all-sources"
},
"devDependencies": {
"istanbul" : "^0.4.0", …Run Code Online (Sandbox Code Playgroud) 我正在尝试从数据 url 中提取 base64 字符串。字符串看起来像这样,所以我试图提取单词 base64 之后的所有内容
test = 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQAB'
Run Code Online (Sandbox Code Playgroud)
所以我想从上面的字符串中提取以下内容
,/9j/4AAQSkZJRgABAQAAAQAB
Run Code Online (Sandbox Code Playgroud)
这是我的正则表达式
const base64rgx = new RegExp('(?<=base64)(?s)(.*$)');
console.log(test.match(base64rgx))
Run Code Online (Sandbox Code Playgroud)
但这失败并出现错误:
VM3616:1 Uncaught SyntaxError: Invalid regular expression: /(?<=base64)(?s)(.*$)/: Invalid group
Run Code Online (Sandbox Code Playgroud) 我正在开发一个html页面的node.js应用程序。此html页面显示根据传递到此页面的数据构建的关联公司列表。建立一个清单,如下所示:
<ul class="notification-body" style="">
//loop for all assocaite id's passed to this page
<li class="testClass" data-associateid="<%= assocID %>">
<span>
<span class="subject">
<label class="btnClass label label-info">ClickMe!</label>
</span>
</span>
</li>
Run Code Online (Sandbox Code Playgroud)
生成的html src看起来像这样:
<ul class="notification-body" style="">
<li class="testClass" data-associateid="AA01">
<li class="testClass" data-associateid="AA02">
<li class="testClass" data-associateid="AA03">
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用Jquery获取数据属性的值,并且尝试了以下操作:
$(".btnClass").click(function(){
console.log($".testClass").attr("data-associateid"));
});
Run Code Online (Sandbox Code Playgroud)
但是每次我在btn上单击时都会输出'AA01',但我在控制台中没有得到预期的输出:AA01 AA02 AA03
我也尝试了以下方法,但它给了我不确定的含义:
$(".btnClass").click(function(){
console.log($(this).find(".testClass").attr("data-associateid"));
});
Run Code Online (Sandbox Code Playgroud) 我有一些关于 HDFS 的数据,我正在尝试设置这些数据以通过 hive 进行查询。数据采用逗号分隔的文本文件的形式。文件中的一列是日期/时间列,如下所示:
Wed Aug 29 16:16:58 CDT 2018
Run Code Online (Sandbox Code Playgroud)
当我尝试读取使用以下脚本创建的 Hive 表时,我得到 NULL 作为为此列读取的值。
use test_db;
drop table ORDERS;
create external table ORDERS(
SAMPLE_DT_TM TIMESTAMP
...
)
row format delimited
fields terminated by ','
stored as textfile
location '/user/data';
Run Code Online (Sandbox Code Playgroud)
当我用 STRING 替换 TIMESTAMP 时,我能够读取列值。但不确定如何将其作为 Hive 支持的适当日期格式读取...
我想将${1}传递给我的脚本的参数(${1}是一个文件路径)保存到同一个 shell 脚本中的一个字符串变量中,然后echo使用echo variable和 not echo ${1}.
从以下3种不同的实现中,哪一个看起来像一个基于可读性,性能等的好候选者?
实施例#1:
@Override
public String toString() {
return "GuiTemplateCriteriaImpl [appTitle=" + appTitle
+ ", button1Text=" + button1Text + ", button2Text="
+ button2Text + ", defaultMessageText=" + defaultMessageText
+ ", rootFolder=" + rootFolder + ", supportedFileExt="
+ supportedFileExt + ", list1ToolTipText=" + list1ToolTipText
+ ", list2ToolTipText=" + list2ToolTipText + "]";
}
Run Code Online (Sandbox Code Playgroud)
实施例#2:
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("GuiTemplateCriteriaImpl")
.append("[")
.append(" appTitle=" + appTitle)
.append(", button1Text=" + button1Text)
.append(", button2Text=" + button2Text)
.append(", defaultMessageText=" + defaultMessageText)
.append(", …Run Code Online (Sandbox Code Playgroud)