Skip to content

Commit 2163d9b

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 878b1f5 + 6e114b6 commit 2163d9b

53 files changed

Lines changed: 878 additions & 155 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎core-java/0.004102810554955205‎

Whitespace-only changes.

‎core-java/0.04832801936270381‎

Whitespace-only changes.

‎core-java/0.5633433244738808‎

Whitespace-only changes.

‎core-java/0.6256429734439612‎

Whitespace-only changes.

‎core-java/0.9799201796740292‎

Whitespace-only changes.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.baeldung.streamApi;
2+
3+
import java.util.Arrays;
4+
import java.util.List;
5+
import java.util.stream.Collectors;
6+
import java.util.stream.Stream;
7+
8+
public class JoinerSplitter {
9+
10+
public static String join ( String[] arrayOfString ) {
11+
return Arrays.asList(arrayOfString)
12+
.stream()
13+
.map(x -> x)
14+
.collect(Collectors.joining(","));
15+
}
16+
17+
public static List<String> split ( String str ) {
18+
return Stream.of(str.split(","))
19+
.map (elem -> new String(elem))
20+
.collect(Collectors.toList());
21+
}
22+
23+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.baeldung.stream;
2+
3+
import static org.junit.Assert.*;
4+
5+
import java.util.ArrayList;
6+
import java.util.List;
7+
8+
import org.junit.Test;
9+
10+
import com.baeldung.streamApi.JoinerSplitter;
11+
12+
public class JoinerSplitterTest {
13+
14+
@Test
15+
public void provided_array_convert_to_stream_and_convert_to_string() {
16+
String[] programming_languages = {"java", "python", "nodejs", "ruby"};
17+
String expectation = "java,python,nodejs,ruby";
18+
19+
String result = JoinerSplitter.join(programming_languages);
20+
assertEquals(result, expectation);
21+
}
22+
23+
@Test
24+
public void provided_list_convert_to_stream_and_convert_to_list() {
25+
String programming_languages = "java,python,nodejs,ruby";
26+
27+
List<String> expectation = new ArrayList<String>();
28+
expectation.add("java");
29+
expectation.add("python");
30+
expectation.add("nodejs");
31+
expectation.add("ruby");
32+
33+
List<String> result = JoinerSplitter.split(programming_languages);
34+
35+
assertEquals(result, expectation);
36+
}
37+
38+
}

‎spring-boot/pom.xml‎

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.baeldung</groupId>
55
<artifactId>spring-boot</artifactId>
@@ -12,8 +12,8 @@
1212
<parent>
1313
<groupId>org.springframework.boot</groupId>
1414
<artifactId>spring-boot-starter-parent</artifactId>
15-
<version>1.4.2.RELEASE</version>
16-
<relativePath /> <!-- lookup parent from repository -->
15+
<version>1.5.1.RELEASE</version>
16+
<relativePath/> <!-- lookup parent from repository -->
1717
</parent>
1818

1919
<dependencies>
@@ -24,6 +24,26 @@
2424
<dependency>
2525
<groupId>org.springframework.boot</groupId>
2626
<artifactId>spring-boot-starter-web</artifactId>
27+
<exclusions>
28+
<exclusion>
29+
<groupId>org.springframework.boot</groupId>
30+
<artifactId>spring-boot-starter-tomcat</artifactId>
31+
</exclusion>
32+
</exclusions>
33+
</dependency>
34+
35+
<dependency>
36+
<groupId>org.apache.geronimo.specs</groupId>
37+
<artifactId>geronimo-osgi-locator</artifactId>
38+
<version>1.1</version>
39+
<scope>test</scope>
40+
</dependency>
41+
42+
<dependency>
43+
<groupId>org.apache.geronimo.components</groupId>
44+
<artifactId>geronimo-jaspi</artifactId>
45+
<version>2.0.0</version>
46+
<scope>test</scope>
2747
</dependency>
2848

2949
<dependency>
@@ -87,6 +107,20 @@
87107
<artifactId>jquery</artifactId>
88108
<version>${jquery.version}</version>
89109
</dependency>
110+
111+
<dependency>
112+
<groupId>org.apache.tomee</groupId>
113+
<artifactId>arquillian-tomee-embedded</artifactId>
114+
<version>${arquillian-tomee-embedded.version}</version>
115+
<scope>test</scope>
116+
</dependency>
117+
118+
<dependency>
119+
<groupId>org.apache.tomee</groupId>
120+
<artifactId>javaee-api</artifactId>
121+
<version>${tomee-javaee-api.version}</version>
122+
<scope>provided</scope>
123+
</dependency>
90124
</dependencies>
91125

92126
<build>
@@ -166,7 +200,7 @@
166200
</executions>
167201
<configuration>
168202
<systemPropertyVariables>
169-
<test.mime>json</test.mime>
203+
<test.mime>json</test.mime>
170204
</systemPropertyVariables>
171205
</configuration>
172206
</plugin>
@@ -186,6 +220,8 @@
186220
<jquery.version>3.1.1</jquery.version>
187221
<bootstrap.version>3.3.7-1</bootstrap.version>
188222
<subethasmtp.version>3.1.7</subethasmtp.version>
223+
<arquillian-tomee-embedded.version>7.0.2</arquillian-tomee-embedded.version>
224+
<tomee-javaee-api.version>7.0-1</tomee-javaee-api.version>
189225
</properties>
190226

191227
</project>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.baeldung.annotation.servletcomponentscan;
2+
3+
import javax.enterprise.context.ApplicationScoped;
4+
import javax.enterprise.context.Initialized;
5+
import javax.enterprise.event.Observes;
6+
import javax.servlet.ServletContext;
7+
8+
@ApplicationScoped
9+
public class JavaEEApp {
10+
11+
private ServletContext context;
12+
13+
/**
14+
* act as a servletContext provider
15+
*/
16+
private void setContext(@Observes @Initialized(ApplicationScoped.class) final ServletContext context) {
17+
if (this.context != null) {
18+
throw new IllegalStateException("app context started twice");
19+
}
20+
21+
this.context = context;
22+
}
23+
24+
public ServletContext getContext() {
25+
return context;
26+
}
27+
28+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.baeldung.annotation.servletcomponentscan;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.boot.web.servlet.ServletComponentScan;
6+
7+
/**
8+
* using the following annotations are equivalent:
9+
* <ul><li>
10+
* <code>@ServletComponentScan</code>
11+
* </li><li>
12+
* <code>@ServletComponentScan(basePackages = "com.baeldung.annotation.servletcomponentscan.javaee")</code>
13+
* </li><li>
14+
* <code>@ServletComponentScan(basePackageClasses = {AttrListener.class, HelloFilter.class, HelloServlet.class, EchoServlet.class})</code>
15+
* </li></ul>
16+
*/
17+
@SpringBootApplication
18+
@ServletComponentScan("com.baeldung.annotation.servletcomponentscan.javaee")
19+
public class SpringBootAnnotatedApp {
20+
21+
public static void main(String[] args) {
22+
SpringApplication.run(SpringBootAnnotatedApp.class, args);
23+
}
24+
25+
}

0 commit comments

Comments
 (0)