Skip to content

Commit a54c9e0

Browse files
amit2103pivovarit
authored andcommitted
Bael 4461 2 (eugenp#4444)
* [BAEL-4462] - Fixed integration tests * [BAEL-4462] - Fixed integration tests * [BAEL-4462] - Fixed integration tests * [BAEL-4462] - Fixed integration tests * [BAEL-4462] - Fixed integration tests * [BAEL-4462] - Fixed integration tests * [BAEL-4462] - Fixed integration tests * [BAEL-4462] - Fixed integration tests * [BAEL-4462] - Fixed integration tests * [BAEL-4462] - Fixed integration tests * [BAEL-4462] - Fixed integration tests * [BAEL-4462] - Fixed integration tests * [BAEL-4462] - Fixed integration tests * [BAEL-4462] - Fixed integration tests * Fix verification times
1 parent 096826c commit a54c9e0

40 files changed

Lines changed: 201 additions & 101 deletions

File tree

apache-poi/src/test/java/com/baeldung/poi/powerpoint/PowerPointIntegrationTest.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,30 @@
11
package com.baeldung.poi.powerpoint;
22

3+
import java.io.File;
4+
import java.util.List;
5+
36
import org.apache.poi.xslf.usermodel.XMLSlideShow;
47
import org.apache.poi.xslf.usermodel.XSLFShape;
58
import org.apache.poi.xslf.usermodel.XSLFSlide;
69
import org.junit.After;
710
import org.junit.Assert;
811
import org.junit.Before;
12+
import org.junit.Rule;
913
import org.junit.Test;
10-
11-
import java.io.File;
12-
import java.util.List;
14+
import org.junit.rules.TemporaryFolder;
1315

1416
public class PowerPointIntegrationTest {
1517

1618
private PowerPointHelper pph;
1719
private String fileLocation;
1820
private static final String FILE_NAME = "presentation.pptx";
21+
22+
@Rule
23+
public TemporaryFolder tempFolder = new TemporaryFolder();
1924

2025
@Before
2126
public void setUp() throws Exception {
22-
File currDir = new File(".");
27+
File currDir = tempFolder.newFolder();
2328
String path = currDir.getAbsolutePath();
2429
fileLocation = path.substring(0, path.length() - 1) + FILE_NAME;
2530

core-java/src/test/java/com/baeldung/array/JaggedArrayUnitTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void givenJaggedArray_whenUsingArraysAPI_thenVerifyPrintedElements() {
4646
ByteArrayOutputStream outContent = new ByteArrayOutputStream();
4747
System.setOut(new PrintStream(outContent));
4848
obj.printElements(jaggedArr);
49-
assertEquals("[1, 2]\n[3, 4, 5]\n[6, 7, 8, 9]\n", outContent.toString());
49+
assertEquals("[1, 2][3, 4, 5][6, 7, 8, 9]", outContent.toString().replace("\r", "").replace("\n", ""));
5050
System.setOut(System.out);
5151
}
5252

core-java/src/test/java/com/baeldung/money/JavaMoneyUnitManualTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public void givenAmount_whenCustomFormat_thanEquals() {
179179
MonetaryAmountFormat customFormat = MonetaryFormats.getAmountFormat(AmountFormatQueryBuilder
180180
.of(Locale.US)
181181
.set(CurrencyStyle.NAME)
182-
.set("pattern", "00000.00 ")
182+
.set("pattern", "00000.00 US Dollar")
183183
.build());
184184
String customFormatted = customFormat.format(oneDollar);
185185

core-java/src/test/java/com/baeldung/scripting/NashornUnitTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public void jvmBoundaryExamples() throws ScriptException, NoSuchMethodException
104104
public void loadExamples() throws ScriptException {
105105
Object loadResult = engine.eval("load('classpath:js/script.js');" + "increment(5)");
106106

107-
Assert.assertEquals(6.0, loadResult);
107+
Assert.assertEquals(6, ((Double) loadResult).intValue());
108108

109109
Object math = engine.eval("var math = loadWithNewGlobal('classpath:js/math_module.js');" + "math.increment(5);");
110110

couchbase/src/main/java/com/baeldung/couchbase/async/service/ClusterServiceImpl.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import javax.annotation.PostConstruct;
77

8+
import org.springframework.beans.factory.annotation.Autowired;
89
import org.springframework.stereotype.Service;
910

1011
import com.couchbase.client.java.Bucket;
@@ -18,6 +19,11 @@ public class ClusterServiceImpl implements ClusterService {
1819

1920
private Cluster cluster;
2021
private Map<String, Bucket> buckets = new ConcurrentHashMap<>();
22+
23+
@Autowired
24+
public ClusterServiceImpl(Cluster cluster) {
25+
this.cluster = cluster;
26+
}
2127

2228
@PostConstruct
2329
private void init() {

couchbase/src/main/java/com/baeldung/couchbase/async/service/TutorialBucketService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ void init() {
1818
@Autowired
1919
public TutorialBucketService(ClusterService clusterService) {
2020
super(clusterService);
21+
openBucket();
2122
}
2223

2324
@Override
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.baeldung.couchbase.async.person;
2+
3+
import org.springframework.context.annotation.Bean;
4+
import org.springframework.context.annotation.ComponentScan;
5+
import org.springframework.context.annotation.Configuration;
6+
7+
import com.couchbase.client.java.Cluster;
8+
import com.couchbase.client.java.CouchbaseCluster;
9+
import com.couchbase.client.java.env.CouchbaseEnvironment;
10+
import com.couchbase.client.java.env.DefaultCouchbaseEnvironment;
11+
12+
@Configuration
13+
@ComponentScan(basePackages = {"com.baeldung.couchbase.async.service", "com.baeldung.couchbase.n1ql"})
14+
public class PersonCrudServiceIntegrationTestConfig {
15+
16+
@Bean
17+
public Cluster cluster() {
18+
CouchbaseEnvironment env = DefaultCouchbaseEnvironment.builder()
19+
.connectTimeout(60000)
20+
.build();
21+
return CouchbaseCluster.create(env, "127.0.0.1");
22+
}
23+
24+
}

couchbase/src/test/java/com/baeldung/couchbase/async/person/PersonCrudServiceIntegrationTest.java renamed to couchbase/src/test/java/com/baeldung/couchbase/async/person/PersonCrudServiceLiveTest.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,31 @@
11
package com.baeldung.couchbase.async.person;
22

3-
import static org.junit.Assert.*;
3+
import static org.junit.Assert.assertEquals;
4+
import static org.junit.Assert.assertNotNull;
5+
import static org.junit.Assert.assertNull;
6+
import static org.junit.Assert.assertTrue;
47

58
import java.util.ArrayList;
69
import java.util.List;
710
import java.util.UUID;
811

9-
import javax.annotation.PostConstruct;
10-
1112
import org.apache.commons.lang3.RandomStringUtils;
13+
import org.junit.Before;
1214
import org.junit.Test;
15+
import org.junit.runner.RunWith;
1316
import org.springframework.beans.factory.annotation.Autowired;
1417
import org.springframework.beans.factory.annotation.Qualifier;
18+
import org.springframework.test.context.ContextConfiguration;
19+
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
1520

1621
import com.baeldung.couchbase.async.AsyncIntegrationTest;
17-
import com.baeldung.couchbase.async.person.Person;
18-
import com.baeldung.couchbase.async.person.PersonCrudService;
19-
import com.baeldung.couchbase.async.person.PersonDocumentConverter;
2022
import com.baeldung.couchbase.async.service.BucketService;
2123
import com.couchbase.client.java.Bucket;
2224
import com.couchbase.client.java.document.JsonDocument;
2325

24-
public class PersonCrudServiceIntegrationTest extends AsyncIntegrationTest {
26+
@RunWith(SpringJUnit4ClassRunner.class)
27+
@ContextConfiguration(classes = {PersonCrudServiceIntegrationTestConfig.class})
28+
public class PersonCrudServiceLiveTest extends AsyncIntegrationTest {
2529

2630
@Autowired
2731
private PersonCrudService personService;
@@ -35,8 +39,8 @@ public class PersonCrudServiceIntegrationTest extends AsyncIntegrationTest {
3539

3640
private Bucket bucket;
3741

38-
@PostConstruct
39-
private void init() {
42+
@Before
43+
public void init() {
4044
bucket = bucketService.getBucket();
4145
}
4246

couchbase/src/test/java/com/baeldung/couchbase/async/service/ClusterServiceIntegrationTest.java renamed to couchbase/src/test/java/com/baeldung/couchbase/async/service/ClusterServiceLiveTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
@RunWith(SpringJUnit4ClassRunner.class)
1919
@ContextConfiguration(classes = { AsyncIntegrationTestConfig.class })
2020
@TestExecutionListeners(listeners = { DependencyInjectionTestExecutionListener.class })
21-
public class ClusterServiceIntegrationTest extends AsyncIntegrationTest {
21+
public class ClusterServiceLiveTest extends AsyncIntegrationTest {
2222

2323
@Autowired
2424
private ClusterService couchbaseService;

couchbase/src/test/java/com/baeldung/couchbase/mapreduce/StudentGradeServiceIntegrationTest.java renamed to couchbase/src/test/java/com/baeldung/couchbase/mapreduce/StudentGradeServiceLiveTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
import com.couchbase.client.java.view.ViewResult;
1515
import com.couchbase.client.java.view.ViewRow;
1616

17-
public class StudentGradeServiceIntegrationTest {
18-
private static final Logger logger = LoggerFactory.getLogger(StudentGradeServiceIntegrationTest.class);
17+
public class StudentGradeServiceLiveTest {
18+
private static final Logger logger = LoggerFactory.getLogger(StudentGradeServiceLiveTest.class);
1919

2020
static StudentGradeService studentGradeService;
2121
static Set<String> gradeIds = new HashSet<>();

0 commit comments

Comments
 (0)