Skip to content

Commit 4930415

Browse files
committed
DATAES-211 - Fix tests for CDI (jar hell)
1 parent 42fc41b commit 4930415

File tree

4 files changed

+113
-136
lines changed

4 files changed

+113
-136
lines changed

pom.xml

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,22 @@
108108
<version>${spring}</version>
109109
<scope>test</scope>
110110
</dependency>
111-
<!--<dependency>-->
112-
<!--<groupId>org.apache.openwebbeans.test</groupId>-->
113-
<!--<artifactId>cditest-owb</artifactId>-->
114-
<!--<version>${webbeans}</version>-->
115-
<!--<scope>test</scope>-->
116-
<!--</dependency>-->
111+
<dependency>
112+
<groupId>org.apache.openwebbeans.test</groupId>
113+
<artifactId>cditest-owb</artifactId>
114+
<version>${webbeans}</version>
115+
<scope>test</scope>
116+
<exclusions>
117+
<exclusion>
118+
<groupId>org.apache.geronimo.specs</groupId>
119+
<artifactId>geronimo-jcdi_1.0_spec</artifactId>
120+
</exclusion>
121+
<exclusion>
122+
<groupId>org.apache.geronimo.specs</groupId>
123+
<artifactId>geronimo-atinject_1.0_spec</artifactId>
124+
</exclusion>
125+
</exclusions>
126+
</dependency>
117127
<dependency>
118128
<groupId>javax.servlet</groupId>
119129
<artifactId>servlet-api</artifactId>
@@ -128,20 +138,6 @@
128138
<scope>test</scope>
129139
</dependency>
130140

131-
<!--<dependency>-->
132-
<!--<groupId>org.codehaus.groovy</groupId>-->
133-
<!--<artifactId>groovy-all</artifactId>-->
134-
<!--<version>2.4.4</version>-->
135-
<!--<scope>test</scope>-->
136-
<!--</dependency>-->
137-
138-
<!--<dependency>-->
139-
<!--<groupId>org.elasticsearch.module</groupId>-->
140-
<!--<artifactId>lang-groovy</artifactId>-->
141-
<!--<version>${elasticsearch}</version>-->
142-
<!--&lt;!&ndash;<scope>test</scope>&ndash;&gt;-->
143-
<!--</dependency>-->
144-
145141
</dependencies>
146142

147143
<build>

src/main/java/org/springframework/data/elasticsearch/client/NodeClientFactoryBean.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@ public void afterPropertiesSet() throws Exception {
7676
nodeClient = (NodeClient) nodeBuilder().settings(Settings.builder().put(loadConfig())
7777
.put("http.enabled", String.valueOf(this.enableHttp))
7878
.put("path.home", this.pathHome)
79-
.put("path.data", this.pathData)
80-
.put("script.inline", "on")
81-
)
79+
.put("path.data", this.pathData))
8280
.clusterName(this.clusterName).local(this.local).node()
8381
.client();
8482
}
Lines changed: 95 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,95 @@
1-
///*
2-
// * Copyright 2014 the original author or authors.
3-
// *
4-
// * Licensed under the Apache License, Version 2.0 (the "License");
5-
// * you may not use this file except in compliance with the License.
6-
// * You may obtain a copy of the License at
7-
// *
8-
// * http://www.apache.org/licenses/LICENSE-2.0
9-
// *
10-
// * Unless required by applicable law or agreed to in writing, software
11-
// * distributed under the License is distributed on an "AS IS" BASIS,
12-
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
// * See the License for the specific language governing permissions and
14-
// * limitations under the License.
15-
// */
16-
//package org.springframework.data.elasticsearch.repositories.cdi;
17-
//
18-
//import static org.hamcrest.CoreMatchers.is;
19-
//import static org.junit.Assert.*;
20-
//
21-
//import org.apache.webbeans.cditest.CdiTestContainer;
22-
//import org.apache.webbeans.cditest.CdiTestContainerLoader;
23-
//import org.junit.AfterClass;
24-
//import org.junit.Before;
25-
//import org.junit.BeforeClass;
26-
//import org.junit.Test;
27-
//import org.springframework.data.elasticsearch.entities.Product;
28-
//
29-
///**
30-
// * @author Mohsin Husen
31-
// */
32-
//TODO: ako cdi - jar hell
33-
//public class CdiRepositoryTests {
34-
//
35-
// private static CdiTestContainer cdiContainer;
36-
// private CdiProductRepository repository;
37-
// private SamplePersonRepository personRepository;
38-
//
39-
// @BeforeClass
40-
// public static void init() throws Exception {
41-
// cdiContainer = CdiTestContainerLoader.getCdiContainer();
42-
// cdiContainer.startApplicationScope();
43-
// cdiContainer.bootContainer();
44-
// }
45-
//
46-
// @AfterClass
47-
// public static void shutdown() throws Exception {
48-
// cdiContainer.stopContexts();
49-
// cdiContainer.shutdownContainer();
50-
// }
51-
//
52-
// @Before
53-
// public void setUp() {
54-
// CdiRepositoryClient client = cdiContainer.getInstance(CdiRepositoryClient.class);
55-
// repository = client.getRepository();
56-
// personRepository = client.getSamplePersonRepository();
57-
// }
58-
//
59-
// @Test
60-
// public void testCdiRepository() {
61-
// assertNotNull(repository);
62-
//
63-
// Product bean = new Product();
64-
// bean.setId("id-1");
65-
// bean.setName("cidContainerTest-1");
66-
//
67-
// repository.save(bean);
68-
//
69-
// assertTrue(repository.exists(bean.getId()));
70-
//
71-
// Product retrieved = repository.findOne(bean.getId());
72-
// assertNotNull(retrieved);
73-
// assertEquals(bean.getId(), retrieved.getId());
74-
// assertEquals(bean.getName(), retrieved.getName());
75-
//
76-
// assertEquals(1, repository.count());
77-
//
78-
// assertTrue(repository.exists(bean.getId()));
79-
//
80-
// repository.delete(bean);
81-
//
82-
// assertEquals(0, repository.count());
83-
// retrieved = repository.findOne(bean.getId());
84-
// assertNull(retrieved);
85-
// }
86-
//
87-
// /**
88-
// * @see DATAES-113
89-
// */
90-
// @Test
91-
// public void returnOneFromCustomImpl() {
92-
//
93-
// assertThat(personRepository.returnOne(), is(1));
94-
// }
95-
//}
1+
/*
2+
* Copyright 2014 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.data.elasticsearch.repositories.cdi;
17+
18+
import static org.hamcrest.CoreMatchers.is;
19+
import static org.junit.Assert.*;
20+
21+
import org.apache.webbeans.cditest.CdiTestContainer;
22+
import org.apache.webbeans.cditest.CdiTestContainerLoader;
23+
import org.junit.AfterClass;
24+
import org.junit.Before;
25+
import org.junit.BeforeClass;
26+
import org.junit.Test;
27+
import org.springframework.data.elasticsearch.entities.Product;
28+
29+
/**
30+
* @author Mohsin Husen
31+
*/
32+
33+
public class CdiRepositoryTests {
34+
35+
private static CdiTestContainer cdiContainer;
36+
private CdiProductRepository repository;
37+
private SamplePersonRepository personRepository;
38+
39+
@BeforeClass
40+
public static void init() throws Exception {
41+
cdiContainer = CdiTestContainerLoader.getCdiContainer();
42+
cdiContainer.startApplicationScope();
43+
cdiContainer.bootContainer();
44+
}
45+
46+
@AfterClass
47+
public static void shutdown() throws Exception {
48+
cdiContainer.stopContexts();
49+
cdiContainer.shutdownContainer();
50+
}
51+
52+
@Before
53+
public void setUp() {
54+
CdiRepositoryClient client = cdiContainer.getInstance(CdiRepositoryClient.class);
55+
repository = client.getRepository();
56+
personRepository = client.getSamplePersonRepository();
57+
}
58+
59+
@Test
60+
public void testCdiRepository() {
61+
assertNotNull(repository);
62+
63+
Product bean = new Product();
64+
bean.setId("id-1");
65+
bean.setName("cidContainerTest-1");
66+
67+
repository.save(bean);
68+
69+
assertTrue(repository.exists(bean.getId()));
70+
71+
Product retrieved = repository.findOne(bean.getId());
72+
assertNotNull(retrieved);
73+
assertEquals(bean.getId(), retrieved.getId());
74+
assertEquals(bean.getName(), retrieved.getName());
75+
76+
assertEquals(1, repository.count());
77+
78+
assertTrue(repository.exists(bean.getId()));
79+
80+
repository.delete(bean);
81+
82+
assertEquals(0, repository.count());
83+
retrieved = repository.findOne(bean.getId());
84+
assertNull(retrieved);
85+
}
86+
87+
/**
88+
* @see DATAES-113
89+
*/
90+
@Test
91+
public void returnOneFromCustomImpl() {
92+
93+
assertThat(personRepository.returnOne(), is(1));
94+
}
95+
}
Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,3 @@
11
#enabled scripts - this require groovy
22
script.inline: true
3-
script.indexed: true
4-
#script.groovy.sandbox.enabled: true
5-
#script.groovy.sandbox.enabled: true
6-
#script.engine.groovy.file.aggs: true
7-
#script.engine.groovy.file.mapping: true
8-
#script.engine.groovy.file.search: true
9-
#script.engine.groovy.file.update: true
10-
#script.engine.groovy.file.plugin: true
11-
#script.engine.groovy.indexed.aggs: true
12-
#script.engine.groovy.indexed.mapping: true
13-
#script.engine.groovy.indexed.search: true
14-
#script.engine.groovy.indexed.update: true
15-
#script.engine.groovy.indexed.plugin: true
16-
#script.engine.groovy.inline.aggs: true
17-
#script.engine.groovy.inline.mapping: true
18-
#script.engine.groovy.inline.search: true
19-
#script.engine.groovy.inline.update: true
20-
#script.engine.groovy.inline.plugin: true
3+
script.indexed: true

0 commit comments

Comments
 (0)