我是jQuery的新手,想要解析一个xml文档.
我能够使用默认名称空间解析常规XML,但使用xml,例如:
<xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema">
<s:Schema id="RowsetSchema">
<s:ElementType name="row" content="eltOnly" rs:CommandTimeout="30">
<s:AttributeType name="ows_ID" rs:name="ID" rs:number="1">
<s:datatype dt:type="i4" dt:maxLength="4" />
</s:AttributeType>
<s:AttributeType name="ows_DocIcon" rs:name="Type" rs:number="2">
<s:datatype dt:type="string" dt:maxLength="512" />
</s:AttributeType>
<s:AttributeType name="ows_LinkTitle" rs:name="Title" rs:number="3">
<s:datatype dt:type="string" dt:maxLength="512" />
</s:AttributeType>
<s:AttributeType name="ows_ServiceCategory" rs:name="Service Category" rs:number="4">
<s:datatype dt:type="string" dt:maxLength="512" />
</s:AttributeType>
</s:ElementType>
</s:Schema>
<rs:data>
<z:row ows_ID="2" ows_LinkTitle="Sample Data 1" />
<z:row ows_ID="3" ows_LinkTitle="Sample Data 2" />
<z:row ows_ID="4" ows_LinkTitle="Sample Data 3" />
</rs:data>
</xml>
Run Code Online (Sandbox Code Playgroud)
我真正想要的只是他们<z:row>
的.
到目前为止,我一直在做:
$.get(xmlPath, {}, function(xml) …
Run Code Online (Sandbox Code Playgroud) 我应该如何测试获取EntityManager实例的EJB 3.1?
一个可能的EJB:
@Stateless
@LocalBean
public class CommentService {
@PersistenceContext
private EntityManager em;
public List<Comment> findAll() {
TypedQuery<Comment> query = em.createNamedQuery(
Comment.FIND_ALL, Comment.class
);
return query.getResultList();
}
}
Run Code Online (Sandbox Code Playgroud)
可能的测试:
@Test
public void testFindAll() {
List<Comment> all = service.findAll();
Assert.assertEquals(8, all.size());
}
Run Code Online (Sandbox Code Playgroud)
我只使用GlassFish 3.1和Eclipse Indigo for Java EE Developers.我已经尝试过这样的事情:
@Before
public void setUp() throws Exception {
ejbContainer = EJBContainer.createEJBContainer();
service = (CommentService) ejbContainer.getContext()
.lookup("java:global/classes/CommentService");
}
Run Code Online (Sandbox Code Playgroud)
但我得到的只是:
javax.ejb.EJBException:
No EJBContainer provider available: no provider names had been found.
Run Code Online (Sandbox Code Playgroud) 我已经梳理了StackOverflow和许多其他网站,发现了许多其他相关的帖子,并且已经遵循了所有的建议,但最终,故障安全正在跳过我的测试.
我的JUnit测试位于:
myModule/src/main/test/java/ClientAccessIT.java
我正在跳过surefire,因为这个模块中没有单元测试:
<!-- POM snippet -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用failsafe运行集成测试:
<!-- POM snippet -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<id>run-tests</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
但是,当我跑步时,mvn verify
我看到了这个:
[INFO] --- maven-failsafe-plugin:2.14.1:integration-test (run-tests) @ rest-services-test ---
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
Run Code Online (Sandbox Code Playgroud)
我花了最后4个半小时的冲刷,任何帮助将不胜感激.唯一可能值得一提的是我有Cargo设置并拆除Tomcat容器.有没有人看到明显的问题?
我想用我的语法忽略空格和新行,因此它们在PEG.js输出中缺失.此外,括号内的文字应该在新数组中返回.
语法
start
= 'a'? sep+ ('cat'/'dog') sep* '(' sep* stmt_list sep* ')'
stmt_list
= exp: [a-zA-Z]+ { return new Array(exp.join('')) }
sep
= [' '\t\r\n]
Run Code Online (Sandbox Code Playgroud)
测试用例
a dog( Harry )
Run Code Online (Sandbox Code Playgroud)
产量
[
"a",
[
" "
],
"dog",
[],
"(",
[
" "
],
[
"Harry"
],
[
" "
],
")"
]
Run Code Online (Sandbox Code Playgroud)
我想要的输出
[
"a",
"dog",
[
"Harry"
]
]
Run Code Online (Sandbox Code Playgroud) 我想通过Three.js中的IdMapping进行选择
由于性能问题,我只有一个巨大的几何体,计算如下:
for (var i = 0; i < numberOfVertices; i += 9) {
p1 = new THREE.Vector3(graphData.triangles.vertices[i+0], graphData.triangles.vertices[i+1], graphData.triangles.vertices[i+2]);
p2 = new THREE.Vector3(graphData.triangles.vertices[i+3], graphData.triangles.vertices[i+4], graphData.triangles.vertices[i+5]);
p3 = new THREE.Vector3(graphData.triangles.vertices[i+6], graphData.triangles.vertices[i+7], graphData.triangles.vertices[i+8]);
geometry.vertices.push(new THREE.Vertex( p1.clone() ));
geometry.vertices.push(new THREE.Vertex( p2.clone() ));
geometry.vertices.push(new THREE.Vertex( p3.clone() ));
geometry.faces.push( new THREE.Face3( i/3, i/3+1, i/3+2 ) );
// i want to do something like this:
geometry.colors.push(new THREE.Color(0xFF0000));
geometry.colors.push(new THREE.Color(0xFF0000));
geometry.colors.push(new THREE.Color(0xFF0000));
}
geometry.computeFaceNormals();
var material = new THREE.MeshBasicMaterial({});
var triangles = new THREE.Mesh( geometry, material …
Run Code Online (Sandbox Code Playgroud) 我试图改变网格的单个面上的颜色.这是在WebGL上下文中.我可以改变整个网格颜色,而不是单个面.相关代码如下:
// Updated Per Lee!
var camera = _this.camera;
var projector = new THREE.Projector();
var vector = new THREE.Vector3( ( event.clientX / window.innerWidth ) * 2 - 1, - ( event.clientY / window.innerHeight ) * 2 + 1, 0.5 );
projector.unprojectVector( vector, camera );
var ray = new THREE.Ray( camera.position, vector.subSelf( camera.position ).normalize() );
var intersects = ray.intersectObjects( kage.scene.children );
if ( intersects.length > 0 ) {
face = intersects[0].face;
var faceIndices = ['a', 'b', 'c', 'd'];
var numberOfSides = …
Run Code Online (Sandbox Code Playgroud) 我做了Apache Kafka 0.10.1.0的全新安装.
我能够在命令提示符下发送/接收消息.
使用Producer/Consumer Java示例时,我无法知道Consumer Example上的group.id参数.
让我知道如何解决这个问题.
以下是我用过的消费者示例:
public static void main(String[] args) {
Properties props = new Properties();
props.put("bootstrap.servers", "localhost:9092");
props.put("group.id", "my-topic");
props.put("enable.auto.commit", "true");
props.put("auto.commit.interval.ms", "1000");
props.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
props.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
KafkaConsumer<String, String> consumer = new KafkaConsumer<>(props);
try {
consumer.subscribe(Arrays.asList("my-topic"));
ConsumerRecords<String, String> records = consumer.poll(100);
System.err.println("records size=>"+records.count());
for (ConsumerRecord<String, String> record : records)
System.out.printf("offset = %d, key = %s, value = %s%n", record.offset(), record.key(), record.value());
}
catch (Exception ex){
ex.printStackTrace();
}
finally {
consumer.close();
}
}
Run Code Online (Sandbox Code Playgroud)
在为消费者运行命令之后,我可以看到生产者发布的消息(在控制台上).但无法从java程序中看到消息 …
我无法从cygwin控制台访问我的虚拟机.(Windows 7,UAC已禁用)
Matthias@laptop0x4d53 /cygdrive/c/Program Files/Oracle/VirtualBox
$ ./VBoxManage list vms
Run Code Online (Sandbox Code Playgroud)
但是,Windows控制台可以访问我的虚拟机.
C:\Program Files\Oracle\VirtualBox>VBoxManage.exe list vms
"GlassFish" {68874e4d-817a-4315-9ea2-38726964ac32}
"Tomcat" {2e22a7c0-9950-4593-8eda-778d404476c7}
"LAMP" {36aa6968-df52-49b5-be52-1f59c50f1527}
Run Code Online (Sandbox Code Playgroud)
也许这是用户权利的问题.如何从cygwin访问我的虚拟机?
我不想写冗余的javadoc注释.正如您所看到的,@param x
在某种程度上是多余的.是否有一个javadoc标记来设置从@param x
类中B
到@param x
类中的引用,A
或者我可以将它留下来?
/**
* Class A constructor
*
* @param x position on x-axis
*/
public A(final int x) {
this.x = x;
}
/**
* Class B constructor
*
* @param x position on x-axis
* @param y position on y-axis
*/
public B(final int x, final int y) {
super(x);
this.y = y
}
Run Code Online (Sandbox Code Playgroud)