Skip to content

Commit 3829886

Browse files
authored
Merge pull request eugenp#63 from eugenp/master
update
2 parents f57f769 + 2b9260b commit 3829886

File tree

117 files changed

+17690
-20
lines changed

Some content is hidden

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

117 files changed

+17690
-20
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
### Relevant Articles:
22

33
- [Introduction to Lock Striping](https://www.baeldung.com/java-lock-stripping)
4+
- [Guide to the Java TransferQueue](http://www.baeldung.com/java-transfer-queue)
5+
- [[<-- Prev]](/core-java-modules/core-java-concurrency-collections)

core-java-modules/core-java-concurrency-collections-2/pom.xml

+9-15
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,16 @@
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<modelVersion>4.0.0</modelVersion>
6-
<groupId>com.baeldung.concurrent.lock</groupId>
76
<artifactId>core-java-concurrency-collections-2</artifactId>
8-
<version>0.0.1-SNAPSHOT</version>
7+
<version>0.1.0-SNAPSHOT</version>
8+
<name>core-java-concurrency-collections-2</name>
9+
<packaging>jar</packaging>
10+
<parent>
11+
<groupId>com.baeldung.core-java-modules</groupId>
12+
<artifactId>core-java-modules</artifactId>
13+
<version>0.0.1-SNAPSHOT</version>
14+
<relativePath>../</relativePath>
15+
</parent>
916

1017
<dependencies>
1118
<dependency>
@@ -30,19 +37,6 @@
3037
<scope>test</scope>
3138
</dependency>
3239
</dependencies>
33-
<build>
34-
<sourceDirectory>src</sourceDirectory>
35-
<plugins>
36-
<plugin>
37-
<artifactId>maven-compiler-plugin</artifactId>
38-
<version>3.8.0</version>
39-
<configuration>
40-
<source>1.8</source>
41-
<target>1.8</target>
42-
</configuration>
43-
</plugin>
44-
</plugins>
45-
</build>
4640

4741
<properties>
4842
<jmh.version>1.21</jmh.version>
+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import org.junit.Test;
2020

2121
@FixMethodOrder
22-
public class TestConcurrentLinkedQueue {
22+
public class ConcurrentLinkedQueueUnitTest {
2323

2424
@Test
2525
public void givenThereIsExistingCollection_WhenAddedIntoQueue_ThenShouldContainElements() {
+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import org.junit.Test;
1919

2020
@FixMethodOrder
21-
public class TestLinkedBlockingQueue {
21+
public class LinkedBlockingQueueUnitTest {
2222

2323
@Test
2424
public void givenThereIsExistingCollection_WhenAddedIntoQueue_ThenShouldContainElements() {
+5-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
import org.junit.Test;
55
import org.junit.runners.MethodSorters;
66

7-
import java.util.concurrent.*;
7+
import java.util.concurrent.ExecutorService;
8+
import java.util.concurrent.Executors;
9+
import java.util.concurrent.LinkedTransferQueue;
10+
import java.util.concurrent.TimeUnit;
11+
import java.util.concurrent.TransferQueue;
812

913
import static junit.framework.TestCase.assertEquals;
1014

core-java-modules/core-java-concurrency-collections/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This module contains articles about concurrent Java collections
1010
- [Custom Thread Pools In Java 8 Parallel Streams](http://www.baeldung.com/java-8-parallel-streams-custom-threadpool)
1111
- [Guide to DelayQueue](http://www.baeldung.com/java-delay-queue)
1212
- [A Guide to Java SynchronousQueue](http://www.baeldung.com/java-synchronous-queue)
13-
- [Guide to the Java TransferQueue](http://www.baeldung.com/java-transfer-queue)
1413
- [Guide to the ConcurrentSkipListMap](http://www.baeldung.com/java-concurrent-skip-list-map)
1514
- [Guide to CopyOnWriteArrayList](http://www.baeldung.com/java-copy-on-write-arraylist)
1615
- [LinkedBlockingQueue vs ConcurrentLinkedQueue](https://www.baeldung.com/java-queue-linkedblocking-concurrentlinked)
16+
- [[Next -->]](/core-java-modules/core-java-concurrency-collections-2)

core-java-modules/core-java-io/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ This module contains articles about core Java input and output (IO)
1212
- [Getting a File’s Mime Type in Java](https://www.baeldung.com/java-file-mime-type)
1313
- [How to Avoid the Java FileNotFoundException When Loading Resources](https://www.baeldung.com/java-classpath-resource-cannot-be-opened)
1414
- [Create a Directory in Java](https://www.baeldung.com/java-create-directory)
15+
- [Java – Rename or Move a File](https://www.baeldung.com/java-how-to-rename-or-move-a-file)
1516
- [[More -->]](/core-java-modules/core-java-io-2)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package com.baeldung.rename;
2+
3+
import org.apache.commons.io.FileUtils;
4+
import org.junit.jupiter.api.AfterEach;
5+
import org.junit.jupiter.api.BeforeEach;
6+
import org.junit.jupiter.api.Test;
7+
8+
import java.io.File;
9+
import java.io.IOException;
10+
import java.nio.file.FileSystemException;
11+
import java.nio.file.Files;
12+
import java.nio.file.Path;
13+
import java.nio.file.Paths;
14+
15+
public class RenameFileUnitTest {
16+
17+
private final String FILE_TO_MOVE = "src/test/resources/originalFileToMove.txt";
18+
private final String TARGET_FILE = "src/test/resources/targetFileToMove.txt";
19+
20+
@BeforeEach
21+
public void createFileToMove() throws IOException {
22+
File fileToMove = new File(FILE_TO_MOVE);
23+
fileToMove.createNewFile();
24+
}
25+
26+
@AfterEach
27+
public void cleanUpFiles() {
28+
File targetFile = new File(TARGET_FILE);
29+
targetFile.delete();
30+
}
31+
32+
@Test
33+
public void givenUsingNio_whenMovingFile_thenCorrect() throws IOException {
34+
Path fileToMovePath = Paths.get(FILE_TO_MOVE);
35+
Path targetPath = Paths.get(TARGET_FILE);
36+
Files.move(fileToMovePath, targetPath);
37+
}
38+
39+
@Test
40+
public void givenUsingFileClass_whenMovingFile_thenCorrect() throws IOException {
41+
File fileToMove = new File(FILE_TO_MOVE);
42+
boolean isMoved = fileToMove.renameTo(new File(TARGET_FILE));
43+
if (!isMoved) {
44+
throw new FileSystemException(TARGET_FILE);
45+
}
46+
}
47+
48+
@Test
49+
public void givenUsingGuava_whenMovingFile_thenCorrect()
50+
throws IOException {
51+
File fileToMove = new File(FILE_TO_MOVE);
52+
File targetFile = new File(TARGET_FILE);
53+
54+
com.google.common.io.Files.move(fileToMove, targetFile);
55+
}
56+
57+
@Test
58+
public void givenUsingApache_whenMovingFile_thenCorrect() throws IOException {
59+
FileUtils.moveFile(
60+
FileUtils.getFile(FILE_TO_MOVE),
61+
FileUtils.getFile(TARGET_FILE));
62+
}
63+
64+
}

pom.xml

+2
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,7 @@
558558
<module>rxjava-operators</module>
559559

560560
<module>atomikos</module>
561+
<module>reactive-systems</module>
561562
</modules>
562563

563564
</profile>
@@ -1069,6 +1070,7 @@
10691070
<module>rxjava-operators</module>
10701071

10711072
<module>atomikos</module>
1073+
<module>reactive-systems</module>
10721074
</modules>
10731075

10741076
</profile>

reactive-systems/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## Reactive Systems in Java
2+
3+
This module contains services for article about reactive systems in Java. Please note that these secrives comprise parts of a full stack application to demonstrate the capabilities of a reactive system. Unless there is an article which extends on this concept, this is probably not a suitable module to add other code.
4+
5+
### Relevant Articles
6+
7+
- [Reactive Systems in Java](https://www.baeldung.com/)

reactive-systems/frontend/Dockerfile

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM nginx:alpine
2+
COPY nginx.conf /etc/nginx/nginx.conf
3+
WORKDIR /usr/share/nginx/html
4+
COPY dist/frontend .

reactive-systems/frontend/README.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Frontend
2+
3+
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.6.
4+
5+
## Development server
6+
7+
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
8+
9+
## Code scaffolding
10+
11+
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
12+
13+
## Build
14+
15+
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.
16+
17+
## Running unit tests
18+
19+
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
20+
21+
## Running end-to-end tests
22+
23+
Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
24+
25+
## Further help
26+
27+
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
+125
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
{
2+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3+
"version": 1,
4+
"newProjectRoot": "projects",
5+
"projects": {
6+
"frontend": {
7+
"projectType": "application",
8+
"schematics": {},
9+
"root": "",
10+
"sourceRoot": "src",
11+
"prefix": "app",
12+
"architect": {
13+
"build": {
14+
"builder": "@angular-devkit/build-angular:browser",
15+
"options": {
16+
"outputPath": "dist/frontend",
17+
"index": "src/index.html",
18+
"main": "src/main.ts",
19+
"polyfills": "src/polyfills.ts",
20+
"tsConfig": "tsconfig.app.json",
21+
"aot": true,
22+
"assets": [
23+
"src/favicon.ico",
24+
"src/assets"
25+
],
26+
"styles": [
27+
"node_modules/bootstrap/dist/css/bootstrap.min.css",
28+
"src/styles.css"
29+
],
30+
"scripts": []
31+
},
32+
"configurations": {
33+
"production": {
34+
"fileReplacements": [
35+
{
36+
"replace": "src/environments/environment.ts",
37+
"with": "src/environments/environment.prod.ts"
38+
}
39+
],
40+
"optimization": true,
41+
"outputHashing": "all",
42+
"sourceMap": false,
43+
"extractCss": true,
44+
"namedChunks": false,
45+
"extractLicenses": true,
46+
"vendorChunk": false,
47+
"buildOptimizer": true,
48+
"budgets": [
49+
{
50+
"type": "initial",
51+
"maximumWarning": "2mb",
52+
"maximumError": "5mb"
53+
},
54+
{
55+
"type": "anyComponentStyle",
56+
"maximumWarning": "6kb",
57+
"maximumError": "10kb"
58+
}
59+
]
60+
}
61+
}
62+
},
63+
"serve": {
64+
"builder": "@angular-devkit/build-angular:dev-server",
65+
"options": {
66+
"browserTarget": "frontend:build"
67+
},
68+
"configurations": {
69+
"production": {
70+
"browserTarget": "frontend:build:production"
71+
}
72+
}
73+
},
74+
"extract-i18n": {
75+
"builder": "@angular-devkit/build-angular:extract-i18n",
76+
"options": {
77+
"browserTarget": "frontend:build"
78+
}
79+
},
80+
"test": {
81+
"builder": "@angular-devkit/build-angular:karma",
82+
"options": {
83+
"main": "src/test.ts",
84+
"polyfills": "src/polyfills.ts",
85+
"tsConfig": "tsconfig.spec.json",
86+
"karmaConfig": "karma.conf.js",
87+
"assets": [
88+
"src/favicon.ico",
89+
"src/assets"
90+
],
91+
"styles": [
92+
"src/styles.css"
93+
],
94+
"scripts": []
95+
}
96+
},
97+
"lint": {
98+
"builder": "@angular-devkit/build-angular:tslint",
99+
"options": {
100+
"tsConfig": [
101+
"tsconfig.app.json",
102+
"tsconfig.spec.json",
103+
"e2e/tsconfig.json"
104+
],
105+
"exclude": [
106+
"**/node_modules/**"
107+
]
108+
}
109+
},
110+
"e2e": {
111+
"builder": "@angular-devkit/build-angular:protractor",
112+
"options": {
113+
"protractorConfig": "e2e/protractor.conf.js",
114+
"devServerTarget": "frontend:serve"
115+
},
116+
"configurations": {
117+
"production": {
118+
"devServerTarget": "frontend:serve:production"
119+
}
120+
}
121+
}
122+
}
123+
}},
124+
"defaultProject": "frontend"
125+
}
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
2+
# For additional information regarding the format and rule options, please see:
3+
# https://github.com/browserslist/browserslist#queries
4+
5+
# You can see what browsers were selected by your queries by running:
6+
# npx browserslist
7+
8+
> 0.5%
9+
last 2 versions
10+
Firefox ESR
11+
not dead
12+
not IE 9-11 # For IE 9-11 support, remove 'not'.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// @ts-check
2+
// Protractor configuration file, see link for more information
3+
// https://github.com/angular/protractor/blob/master/lib/config.ts
4+
5+
const { SpecReporter } = require('jasmine-spec-reporter');
6+
7+
/**
8+
* @type { import("protractor").Config }
9+
*/
10+
exports.config = {
11+
allScriptsTimeout: 11000,
12+
specs: [
13+
'./src/**/*.e2e-spec.ts'
14+
],
15+
capabilities: {
16+
browserName: 'chrome'
17+
},
18+
directConnect: true,
19+
baseUrl: 'http://localhost:4200/',
20+
framework: 'jasmine',
21+
jasmineNodeOpts: {
22+
showColors: true,
23+
defaultTimeoutInterval: 30000,
24+
print: function() {}
25+
},
26+
onPrepare() {
27+
require('ts-node').register({
28+
project: require('path').join(__dirname, './tsconfig.json')
29+
});
30+
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
31+
}
32+
};

0 commit comments

Comments
 (0)