以下是 aws 网站的片段:
WITH dataset AS (
SELECT ARRAY[
CAST(
ROW('aws.amazon.com', ROW(true)) AS ROW(hostname VARCHAR, flaggedActivity ROW(isNew BOOLEAN))
),
CAST(
ROW('news.cnn.com', ROW(false)) AS ROW(hostname VARCHAR, flaggedActivity ROW(isNew BOOLEAN))
),
CAST(
ROW('netflix.com', ROW(false)) AS ROW(hostname VARCHAR, flaggedActivity ROW(isNew BOOLEAN))
)
] as items
)
SELECT sites.hostname, sites.flaggedActivity.isNew
FROM dataset, UNNEST(items) t(sites)
WHERE sites.flaggedActivity.isNew = true;
Run Code Online (Sandbox Code Playgroud)
它有效!但什么t(sites)意思呢?当我尝试使用真实表而不是dataset我收到错误时Table 'site' not found。
它看起来很奇怪 - 就像用关键字调用的函数一样UNNEST。有人能解释一下这是什么吗?
arrays amazon-web-services presto amazon-athena lateral-join
这是 JUnit 5 数据驱动测试的经典示例。
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@Slf4j
@ExtendWith(SpringExtension.class)
@SpringBootTest
class ScrathTest {
@Autowired
private MyBean myBean;
@ParameterizedTest
@ValueSource(ints = {1, 3, 5, -3, 15, Integer.MAX_VALUE}) // six numbers
void isOdd_ShouldReturnTrueForOddNumbers(int number) {
myBean.doSomeThing(number)
}
}
Run Code Online (Sandbox Code Playgroud)
但是,如果我需要运行的不是整数数组,而是配置文件数组呢?我的意思是我创建了一个测试,然后创建了 3 个测试配置文件,然后在每个创新中使用不同的配置文件重复该测试 3 次。是否可以?
笔记
@ActiveProfile 注释不是一个解决方案,因为它只是激活列出的配置文件,而不需要重复测试和重新创建上下文。
我已在默认 vpc (java) 中部署了 rivate 子网:
var stack = new Stack(app, "system-resource", StackProps.builder().env(env).build());
final IVpc vpc = Vpc.fromLookup(stack, "default-vpc", VpcLookupOptions.builder().isDefault(true).build());
final AtomicInteger index = new AtomicInteger();
var zones = stack.getAvailabilityZones();
var subnets = zones.stream().map(z -> {
var subnet = new PrivateSubnet(stack, "priavte-subnet-" + index.getAndIncrement(), PrivateSubnetProps.builder()
.vpcId(vpc.getVpcId())
.cidrBlock(String.format(cidrTemplate, start.get()))
.availabilityZone(z)
.build());
start.addAndGet(increment);
return subnet;
}).collect(Collectors.toList());
Run Code Online (Sandbox Code Playgroud)
然后我尝试使用 SubnetSelection:
final IVpc vpc = Vpc.fromLookup(this, "default-vpc", VpcLookupOptions.builder().isDefault(true).build());
final SubnetSelection vpcSubnets = SubnetSelection.builder().subnetType(SubnetType.PRIVATE).build();
Run Code Online (Sandbox Code Playgroud)
并得到异常:
An exception occured while executing the Java class. There are no …Run Code Online (Sandbox Code Playgroud) 我用一个无状态的Ejb编写了非常简单的Web应用程序,当我实现接口时,有趣的时刻来了 - ejb依赖注入不起作用:
web.xml中
<?xml version="1.0" ?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>Archetype Created Web Application</display-name>
<servlet>
<servlet-name>simpleController</servlet-name>
<servlet-class>com.SimpleController</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>simpleController</servlet-name>
<url-pattern>*.job</url-pattern>
</servlet-mapping>
</web-app>
Run Code Online (Sandbox Code Playgroud)
Servlet类
package com;
import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
public class SimpleController extends HttpServlet {
@EJB
private SimpleBean bean;
@Override
protected void doPost (HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.getWriter().println(bean.getSomeString());
}
@Override
protected void doGet (HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
doPost(req, resp);
} …Run Code Online (Sandbox Code Playgroud) 我尝试在 Intellij Idea 中的 web.xml 中执行 xpath 表达式
Xpath 表达式
//param-value[email]
Run Code Online (Sandbox Code Playgroud)
网页.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Archetype Created Web Application</display-name>
<servlet>
<servlet-name>ServletName</servlet-name>
<servlet-class>com.ServletDemo</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ServletName</servlet-name>
<url-pattern>/Demo1</url-pattern>
</servlet-mapping>
<context-param>
<param-name>email</param-name>
<param-value>admin@email.com</param-value>
</context-param>
</web-app>
Run Code Online (Sandbox Code Playgroud)
我没有结果。此外,Idea 突出显示参数值,因为它不存在,当我点击 ctrl+space 时,我看不到任何标签!我尝试在另一个项目和另一个 xml 中使用这个插件 - 它有效,但在这种情况下它不是。
有任何想法吗?可能是我错过了一些配置?
更新
我从 web-app 标签中删除了属性,表达式开始工作。但为什么?
我已经开始学习Backbone.js了.目前我的JavaScript技能不太好.我已经开始检查该backbone.js文件,并遇到了一个奇怪的代码行,其目的我无法弄清楚.代码示例(如果您需要更多上下文,请为开发人员手动下载backbone.js并查看第80行):
var Events = Backbone.Events = {
// Bind an event to a `callback` function. Passing `"all"` will bind
// the callback to all events fired.
on: function(name, callback, context) {
if (!eventsApi(this, 'on', name, [callback, context]) || !callback) return this;
this._events || (this._events = {});
var events = this._events[name] || (this._events[name] = []);
events.push({callback: callback, context: context, ctx: context || this});
return this;
},
Run Code Online (Sandbox Code Playgroud)
这条线this._events || (this._events = {});是什么意思?对我来说,_events看起来像一个内部变量,但(this._events = …
scala是否支持JSR-303验证?
如果是的话 - 你能写一个例子吗?
如果没有 - 是否有在scala类上运行JSR-303验证的变通方法?
这里链接到maven Scala插件的用法.但是没有提到它使用的Scala版本究竟是什么.我已经使用以下配置创建了maven Scala项目:
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
然后我构建了有效的pom,maven Scala插件的插件部分是:
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
并且配置标签中也没有Scala版本.那么Scala版本默认使用maven Scala插件的是什么?
这是一个原始响应:
HTTP/1.1 200 OK
Date: Tue, 21 Oct 2014 08:46:31 GMT
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked
Server: Jetty(9.2.2.v20140723)
{"id":"myId"}
Run Code Online (Sandbox Code Playgroud)
我试图设置属性(源是来自另一个测试步骤的响应,属性可以是请求、响应等)响应和 ResponseAsXML,对于两者我都无法提取值。并尝试 xPath 选择,但它不起作用。是否可以id使用 json 从 HTTP 响应中提取?
更新
如果我选择 ResponseAsXml,我会得到以下字符串:
[<Response xmlns="http://localhost/path">
<id>882fe993-d150-b67c-4b0f-014931e2dd21</id>
</Response>]
Run Code Online (Sandbox Code Playgroud)
我试过 xPath:
declare namespace sam="http://localhost/path";
//sam:response
Run Code Online (Sandbox Code Playgroud)
我也写//sam:Response或//response结果是[null]字符串。
-Dconfig.resource和-Dconfig.file参数有什么区别?
java ×4
scala ×3
akka ×1
amazon-vpc ×1
arrays ×1
aws-cdk ×1
backbone.js ×1
config ×1
ejb ×1
javascript ×1
json ×1
junit5 ×1
lateral-join ×1
maven ×1
presto ×1
properties ×1
rest ×1
servlets ×1
soapui ×1
spring ×1
spring-boot ×1
transfer ×1
web.xml ×1
xml ×1
xpath ×1