Skip to content

Commit

Permalink
Bael 4461 2 (eugenp#4444)
Browse files Browse the repository at this point in the history
* [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
  • Loading branch information
amit2103 authored and pivovarit committed Jun 11, 2018
1 parent 096826c commit a54c9e0
Show file tree
Hide file tree
Showing 40 changed files with 201 additions and 101 deletions.
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
package com.baeldung.poi.powerpoint;

import java.io.File;
import java.util.List;

import org.apache.poi.xslf.usermodel.XMLSlideShow;
import org.apache.poi.xslf.usermodel.XSLFShape;
import org.apache.poi.xslf.usermodel.XSLFSlide;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;

import java.io.File;
import java.util.List;
import org.junit.rules.TemporaryFolder;

public class PowerPointIntegrationTest {

private PowerPointHelper pph;
private String fileLocation;
private static final String FILE_NAME = "presentation.pptx";

@Rule
public TemporaryFolder tempFolder = new TemporaryFolder();

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void givenJaggedArray_whenUsingArraysAPI_thenVerifyPrintedElements() {
ByteArrayOutputStream outContent = new ByteArrayOutputStream();
System.setOut(new PrintStream(outContent));
obj.printElements(jaggedArr);
assertEquals("[1, 2]\n[3, 4, 5]\n[6, 7, 8, 9]\n", outContent.toString());
assertEquals("[1, 2][3, 4, 5][6, 7, 8, 9]", outContent.toString().replace("\r", "").replace("\n", ""));
System.setOut(System.out);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public void givenAmount_whenCustomFormat_thanEquals() {
MonetaryAmountFormat customFormat = MonetaryFormats.getAmountFormat(AmountFormatQueryBuilder
.of(Locale.US)
.set(CurrencyStyle.NAME)
.set("pattern", "00000.00 ")
.set("pattern", "00000.00 US Dollar")
.build());
String customFormatted = customFormat.format(oneDollar);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void jvmBoundaryExamples() throws ScriptException, NoSuchMethodException
public void loadExamples() throws ScriptException {
Object loadResult = engine.eval("load('classpath:js/script.js');" + "increment(5)");

Assert.assertEquals(6.0, loadResult);
Assert.assertEquals(6, ((Double) loadResult).intValue());

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

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

private Cluster cluster;
private Map<String, Bucket> buckets = new ConcurrentHashMap<>();

@Autowired
public ClusterServiceImpl(Cluster cluster) {
this.cluster = cluster;
}

@PostConstruct
private void init() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ void init() {
@Autowired
public TutorialBucketService(ClusterService clusterService) {
super(clusterService);
openBucket();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.baeldung.couchbase.async.person;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

import com.couchbase.client.java.Cluster;
import com.couchbase.client.java.CouchbaseCluster;
import com.couchbase.client.java.env.CouchbaseEnvironment;
import com.couchbase.client.java.env.DefaultCouchbaseEnvironment;

@Configuration
@ComponentScan(basePackages = {"com.baeldung.couchbase.async.service", "com.baeldung.couchbase.n1ql"})
public class PersonCrudServiceIntegrationTestConfig {

@Bean
public Cluster cluster() {
CouchbaseEnvironment env = DefaultCouchbaseEnvironment.builder()
.connectTimeout(60000)
.build();
return CouchbaseCluster.create(env, "127.0.0.1");
}

}
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
package com.baeldung.couchbase.async.person;

import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

import javax.annotation.PostConstruct;

import org.apache.commons.lang3.RandomStringUtils;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.baeldung.couchbase.async.AsyncIntegrationTest;
import com.baeldung.couchbase.async.person.Person;
import com.baeldung.couchbase.async.person.PersonCrudService;
import com.baeldung.couchbase.async.person.PersonDocumentConverter;
import com.baeldung.couchbase.async.service.BucketService;
import com.couchbase.client.java.Bucket;
import com.couchbase.client.java.document.JsonDocument;

public class PersonCrudServiceIntegrationTest extends AsyncIntegrationTest {
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {PersonCrudServiceIntegrationTestConfig.class})
public class PersonCrudServiceLiveTest extends AsyncIntegrationTest {

@Autowired
private PersonCrudService personService;
Expand All @@ -35,8 +39,8 @@ public class PersonCrudServiceIntegrationTest extends AsyncIntegrationTest {

private Bucket bucket;

@PostConstruct
private void init() {
@Before
public void init() {
bucket = bucketService.getBucket();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = { AsyncIntegrationTestConfig.class })
@TestExecutionListeners(listeners = { DependencyInjectionTestExecutionListener.class })
public class ClusterServiceIntegrationTest extends AsyncIntegrationTest {
public class ClusterServiceLiveTest extends AsyncIntegrationTest {

@Autowired
private ClusterService couchbaseService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import com.couchbase.client.java.view.ViewResult;
import com.couchbase.client.java.view.ViewRow;

public class StudentGradeServiceIntegrationTest {
private static final Logger logger = LoggerFactory.getLogger(StudentGradeServiceIntegrationTest.class);
public class StudentGradeServiceLiveTest {
private static final Logger logger = LoggerFactory.getLogger(StudentGradeServiceLiveTest.class);

static StudentGradeService studentGradeService;
static Set<String> gradeIds = new HashSet<>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
package com.baeldung.couchbase.n1ql;

import static com.baeldung.couchbase.n1ql.CodeSnippets.extractJsonResult;
import static com.couchbase.client.java.query.Select.select;
import static com.couchbase.client.java.query.dsl.Expression.i;
import static com.couchbase.client.java.query.dsl.Expression.s;
import static com.couchbase.client.java.query.dsl.Expression.x;
import static org.junit.Assert.assertNotNull;

import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.couchbase.client.java.Bucket;
import com.couchbase.client.java.Cluster;
import com.couchbase.client.java.document.JsonDocument;
Expand All @@ -10,28 +28,13 @@
import com.couchbase.client.java.query.N1qlQueryRow;
import com.couchbase.client.java.query.Statement;
import com.fasterxml.jackson.databind.JsonNode;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import rx.Observable;

import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;

import static com.baeldung.couchbase.n1ql.CodeSnippets.extractJsonResult;
import static com.couchbase.client.java.query.Select.select;
import static com.couchbase.client.java.query.dsl.Expression.*;
import static org.junit.Assert.assertNotNull;
import rx.Observable;


@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = { IntegrationTestConfig.class })
public class N1QLIntegrationTest {
public class N1QLLiveTest {


@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import com.baeldung.couchbase.spring.IntegrationTest;

public class PersonCrudServiceIntegrationTest extends IntegrationTest {
public class PersonCrudServiceLiveTest extends IntegrationTest {

private static final String CLARK_KENT = "Clark Kent";
private static final String SMALLVILLE = "Smallville";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = { IntegrationTestConfig.class })
@TestExecutionListeners(listeners = { DependencyInjectionTestExecutionListener.class })
public class ClusterServiceIntegrationTest extends IntegrationTest {
public class ClusterServiceLiveTest extends IntegrationTest {

@Autowired
private ClusterService couchbaseService;
Expand Down
5 changes: 5 additions & 0 deletions jaxb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1</version>
</dependency>
</dependencies>

<build>
Expand Down
9 changes: 9 additions & 0 deletions jaxb/src/main/resources/log4jstructuraldp.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

# Root logger
log4j.rootLogger=INFO, file, stdout

# Write to console
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void marshal() throws JAXBException, IOException {
File bookFile = new File(this.getClass().getResource("/book.xml").getFile());
String sampleBookXML = FileUtils.readFileToString(sampleBookFile, "UTF-8");
String marshallerBookXML = FileUtils.readFileToString(bookFile, "UTF-8");
Assert.assertEquals(sampleBookXML, marshallerBookXML);
Assert.assertEquals(sampleBookXML.replace("\r", "").replace("\n", ""), marshallerBookXML.replace("\r", "").replace("\n", ""));
}

@Test
Expand Down
5 changes: 5 additions & 0 deletions jaxb/src/test/resources/book.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<book id="1">
<title>Book1</title>
<date>2016-12-16T17:28:49.718Z</date>
</book>
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.openqa.selenium.support.FindBy;

@RunWith(Arquillian.class)
public class ConvListValIntegrationTest {
public class ConvListValLiveTest {

@ArquillianResource
private URL deploymentUrl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@


@RunWith(Arquillian.class)
public class AutomaticTimerBeanIntegrationTest {
public class AutomaticTimerBeanLiveTest {

//the @AutomaticTimerBean has a method called every 10 seconds
//testing the difference ==> 100000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@


@RunWith(Arquillian.class)
public class ProgrammaticAtFixedRateTimerBeanIntegrationTest {
public class ProgrammaticAtFixedRateTimerBeanLiveTest {

final static long TIMEOUT = 1000;
final static long TOLERANCE = 500l;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


@RunWith(Arquillian.class)
public class ProgrammaticTimerBeanIntegrationTest {
public class ProgrammaticTimerBeanLiveTest {

final static long TIMEOUT = 5000l;
final static long TOLERANCE = 1000l;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@


@RunWith(Arquillian.class)
public class ProgrammaticWithFixedDelayTimerBeanIntegrationTest {
public class ProgrammaticWithFixedDelayTimerBeanLiveTest {

final static long TIMEOUT = 15000l;
final static long TOLERANCE = 1000l;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import static org.hamcrest.Matchers.equalTo;

@RunWith(Arquillian.class)
public class ScheduleTimerBeanIntegrationTest {
public class ScheduleTimerBeanLiveTest {

private final static long TIMEOUT = 5000l;
private final static long TOLERANCE = 1000l;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import com.baeldung.jpa.model.Car;

public class StoredProcedureIntegrationTest {
public class StoredProcedureLiveTest {

private static EntityManagerFactory factory = null;
private static EntityManager entityManager = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
public class EntryProcessorIntegrationTest {

private static final String CACHE_NAME = "MyCache";
private static final String CACHE_PROVIDER_NAME = "com.hazelcast.cache.HazelcastCachingProvider";

private Cache<String, String> cache;

@Before
public void instantiateCache() {
CachingProvider cachingProvider = Caching.getCachingProvider();
CachingProvider cachingProvider = Caching.getCachingProvider(CACHE_PROVIDER_NAME);
CacheManager cacheManager = cachingProvider.getCacheManager();
MutableConfiguration<String, String> config = new MutableConfiguration<>();
this.cache = cacheManager.createCache(CACHE_NAME, config);
Expand All @@ -29,7 +30,7 @@ public void instantiateCache() {

@After
public void tearDown() {
Caching.getCachingProvider().getCacheManager().destroyCache(CACHE_NAME);
Caching.getCachingProvider(CACHE_PROVIDER_NAME).getCacheManager().destroyCache(CACHE_NAME);
}

@Test
Expand Down
Loading

0 comments on commit a54c9e0

Please sign in to comment.