我正在使用arquillian为Tomcat 8上部署的JAX-RS/Jersey Webservice创建集成测试.
我正在尝试这样的POST请求:
E dummy = dummyFactory.manufacturePojo(getSubClassType());
dummy.setId(null);
Client client = ClientBuilder.newClient();
WebTarget target = client.target(BASE_URI).path("bandeira");
Response response = target.request(MediaType.APPLICATION_JSON)
.header(HttpHeaders.AUTHORIZATION, CHAVE_TESTE)
.header(HttpHeaders.CONTENT_TYPE, "application/json")
.post(Entity.entity(dummy, MediaType.APPLICATION_JSON));
Run Code Online (Sandbox Code Playgroud)
当我这样做时,我得到这个例外:
Caused by: java.lang.IllegalStateException: Already connected
at sun.net.www.protocol.http.HttpURLConnection.setRequestProperty(HttpURLConnection.java:3000)
at org.glassfish.jersey.client.HttpUrlConnector.setOutboundHeaders(HttpUrlConnector.java:364)
at org.glassfish.jersey.client.HttpUrlConnector.access$100(HttpUrlConnector.java:91)
at org.glassfish.jersey.client.HttpUrlConnector$4.getOutputStream(HttpUrlConnector.java:327)
at org.glassfish.jersey.message.internal.CommittingOutputStream.commitStream(CommittingOutputStream.java:201)
at org.glassfish.jersey.message.internal.CommittingOutputStream.commitStream(CommittingOutputStream.java:195)
at org.glassfish.jersey.message.internal.CommittingOutputStream.commit(CommittingOutputStream.java:263)
at org.glassfish.jersey.message.internal.OutboundMessageContext.commitStream(OutboundMessageContext.java:816)
at org.glassfish.jersey.client.ClientRequest.writeEntity(ClientRequest.java:546)
at org.glassfish.jersey.client.HttpUrlConnector._apply(HttpUrlConnector.java:331)
at org.glassfish.jersey.client.HttpUrlConnector.apply(HttpUrlConnector.java:243)
at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:246)
... 149 more
Run Code Online (Sandbox Code Playgroud)
我可以使用一些启发式,因为我还在学习arquillian和Jersey客户端API :)谢谢
假设我们有一个名为Comp的Component 和两个名为P1和P2的 @Injectable提供者.
P1需要P2的实例.
P1注入Comp
如果我在Comp上声明两个提供程序,那就完美了,就像这样:
@Component ({
providers: [P1, P2]
})
export class Comp { ... }
Run Code Online (Sandbox Code Playgroud)
现在我想做的是声明P1直接在P1内部需要P2:
@Component ({
providers: [P1]
})
export class Comp { ... }
@Injectable(/** Inject P2 here **/)
export class P1 { ... }
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助.
我有以下结构:
@Decorator
public abstract class MyDecorator<T extends BaseEntity, Q extends QueryParams> implements EntityService<T, Q> {
@Any
@Inject
@Delegate
EntityService<T, Q> delegate;
@Override
public T save(T entity) { ... }
}
Run Code Online (Sandbox Code Playgroud)
这是EntityService接口声明:
public interface EntityService<T extends BaseEntity, Q extends QueryParams> {
T save(T entity);
void deleteById(Integer id);
void deleteAllById(List<Integer> ids);
void delete(T entity);
void deleteAll(List<T> entities);
T findById(Integer id);
QueryResultWrapper<T> query(Q parameters);
Long count(Q parameters);
}
Run Code Online (Sandbox Code Playgroud)
不幸的是,装饰器保存方法永远不会被调用,虽然没有显示错误...我得到它的唯一方法是这样:
@Decorator
public abstract class MyDecorator<T extends BaseEntity> implements EntityService<T> { ... } …Run Code Online (Sandbox Code Playgroud) 我想创建一个具有初始行为的AbstractComponent,同时能够在需要时覆盖它,可能吗?这是一个好习惯吗?
应该看起来或多或少那样:
export abstract class AbstractComponent implements OnInit {
constructor(authService: AuthService, router: Router) {}
ngOnInit() {
if (authService.userNotLoggedInAnymore()) {
router.navigate(['Login']);
}
}
...
}
Run Code Online (Sandbox Code Playgroud) 我已经创建AbstractActivity并AbstractFormActivity删除了一些样板代码,它们的内容可能与问题无关,但无论如何我都会发布它,也许我误解了一些东西,它们是:
public abstract class AbstractActivity extends ActionBarActivity {
protected ObjectGraph graph;
@Inject
public Bus bus;
@Inject
public App app;
@Override
public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
super.onCreate(savedInstanceState, persistentState);
setContentView(getLayout());
setupInjection();
}
public void setupInjection() {
graph = ((App) getApplication()).createScopedGraph(getModule());
graph.inject(this);
bus.register(this);
ButterKnife.inject(this);
}
protected abstract Object getModule();
protected abstract int getLayout();
}
Run Code Online (Sandbox Code Playgroud)
和
public abstract class AbstractFormActivity<T extends EntidadeBase> extends AbstractActivity implements Form<T> {
protected T entity;
protected Map<View, Boolean> formValidations;
protected AbstractFormActivity() {
formValidations …Run Code Online (Sandbox Code Playgroud) 我有一些字段需要在发送到服务器端之前进行格式化.
所以,我想使用自定义序列化程序序列化我的打字稿类的一些字段,这样的理想选择:
export class Person {
@serializeWith(MyDateSerializer)
private date: Date;
}
post(url, value) {
this.http.post(url, JSON.stringfy(value, (key, val) => {
if (//value has serializeWith annotation) {
return //serialize with custom serializer
}
}));
}
Run Code Online (Sandbox Code Playgroud)
任何接近这一点都是可以接受的,欢迎任何帮助.谢谢
我有这个docker-compose.yml文件
version: '3'
volumes:
jenkins_home:
services:
registry:
image: registry:2
ports:
- "5000:5000"
jenkins:
image: jenkins/jenkins
ports:
- "9090:8080"
volumes:
- jenkins_home:/var/jenkins_home
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,有一个名为 的命名卷jenkins_home,现在我想知道数据真正保存在哪里?
运行docker inspect infra_jenkins我得到这个:
...
"Mounts": [
{
"Type": "volume",
"Source": "infra_jenkins_home",
"Target": "/var/jenkins_home",
"VolumeOptions": {
"Labels": {
"com.docker.stack.namespace": "infra"
}
}
}
],
...
Run Code Online (Sandbox Code Playgroud)
我使用命令在本地 docker swarm 集群上运行这些服务docker stack deploy,该集群由三个 VirtualBox 实例组成。
使用新安装的ionic2处理新项目,安装angular2-jwt后我收到此错误:
ParseError: 'import' and 'export' may appear only with 'sourceType: module'
D:\desenv\arquivos\workspace_inbit\medipop-parent\medipop-app\node_modules\angular2-jwt\angular2-jwt.ts:1
import {Injectable, Injector} from 'angular2/core';
Run Code Online (Sandbox Code Playgroud)
重现:
ionic start testapp --v2 --ts
cd testapp
npm i --save angular2-jwt
Run Code Online (Sandbox Code Playgroud)
和应用页面:
@App({
templateUrl: 'build/app.html',
providers: [
provide(AuthHttp, {
useFactory: (http) => {
return new AuthHttp(new AuthConfig({
headerPrefix: '',
noJwtError: true
}), http);
},
deps: [Http]
})
]
})
class MyApp {}
Run Code Online (Sandbox Code Playgroud)
有没有人知道如何解决这个小谜题?
我希望我的工具栏使用材料设计径向反应编排指南来改变颜色
我想将它实现为一个有角度的2转换,但我不知道如何做到这一点:
它看起来像这样..
@Component({
...
animations: [
trigger('heroState', [
state('inactive', style({
backgroundColor: '#eee',
transform: 'scale(1)'
})),
state('active', style({
backgroundColor: '#cfd8dc',
transform: 'scale(1.1)'
})),
transition('inactive => active', animate('100ms ease-in')),
transition('active => inactive', animate('100ms ease-out'))
])
]
})
Run Code Online (Sandbox Code Playgroud) angular ×6
typescript ×3
decorator ×2
java ×2
abstraction ×1
android ×1
animation ×1
architecture ×1
cdi ×1
client ×1
cordova ×1
css ×1
css3 ×1
docker ×1
dockerfile ×1
generics ×1
jersey ×1
json ×1
jwt ×1
oncreate ×1