BAEL-1171 java.lang.String API (#2693)

* Evaluation article: Different Types of Bean Injection in Spring

* added tests & changed configuration to Java-based config

* removed xml config files

* rename unit tests

* BAEL-972 - Apache Commons Text

* remove code from evaluation article

* remove code from evaluation article

* BAEL-972 - Apache Commons Text - added another example

* BAEL-972 - Apache Commons Text - just indentation

* BAEL-994 - TemporalAdjuster in Java

* BAEL-994 - TemporalAdjuster in Java

* BAEL-994 - TemporalAdjuster in Java

* BAEL-994 - TemporalAdjuster in Java

* BAEL-994 - TemporalAdjuster in Java - fix problems

* BAEL-1033 Introduction to StreamUtils

* BAEL-1033 Introduction to StreamUtils

* BAEL-1033 Introduction to StreamUtils

* fix formatting

* BAEL-1033 minor refactor

* BAEL-1035 Introduction to Eclipse Collections

* format

* BAEL-1035 Introduction to Eclipse Collections

* BAEL-1035 Introduction to Eclipse Collections

* BAEL-1035 Introduction to Eclipse Collections

* cleanup

* cleanup

* BAEL-1109 Introduction to JCache

* BAEL-1109 Introduction to JCache

* remove unneeded property in pom.xml

* fix formatting

* close cache instances properly

* remove latest commit

* BAEL-1057 Introduction to rxjava-jdbc

* refactor rxjava-jdbc

* Refactor rxjava-jdbc

* Refactoring rxjava-jdbc

* BAEL-1171 java.lang.String API

* refactor rxjava-jdbc

* refactor String

* String API - move multiple classes into a single class

* move class into test package
This commit is contained in:
Ahmed Tawila 2017-10-08 11:55:55 +02:00 committed by Grzegorz Piwowarek
parent 4653e0ad3e
commit 9e273b1474
8 changed files with 110 additions and 57 deletions

View File

@ -0,0 +1,26 @@
package com.baeldung.string;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class StringTest {
@Test
public void whenCallCodePointAt_thenDecimalUnicodeReturned() {
assertEquals(97, "abcd".codePointAt(0));
}
@Test
public void whenCallConcat_thenCorrect() {
assertEquals("elephant", "elep".concat("hant"));
}
@Test
public void whenGetBytes_thenCorrect() {
byte[] byteArray = "abcd".getBytes();
byte[] expected = new byte[] { 97, 98, 99, 100 };
assertArrayEquals(expected, byteArray);
}
}

View File

@ -8,13 +8,15 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.github.davidmoten.rx.jdbc.ConnectionProvider;
import com.github.davidmoten.rx.jdbc.Database;
import rx.Observable;
public class AutomapClassIntegrationTest {
private Database db = Database.from(Connector.connectionProvider);
private ConnectionProvider connectionProvider = Connector.connectionProvider;
private Database db = Database.from(connectionProvider);
private Observable<Integer> create = null;
private Observable<Integer> insert1, insert2 = null;
@ -56,6 +58,6 @@ public class AutomapClassIntegrationTest {
public void close() {
db.update("DROP TABLE MANAGER")
.dependsOn(create);
Connector.connectionProvider.close();
connectionProvider.close();
}
}

View File

@ -8,13 +8,15 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.github.davidmoten.rx.jdbc.ConnectionProvider;
import com.github.davidmoten.rx.jdbc.Database;
import rx.Observable;
public class AutomapInterfaceIntegrationTest {
private Database db = Database.from(Connector.connectionProvider);
private ConnectionProvider connectionProvider = Connector.connectionProvider;
private Database db = Database.from(connectionProvider);
private Observable<Integer> create = null;
private Observable<Integer> insert1, insert2 = null;
@ -55,8 +57,7 @@ public class AutomapInterfaceIntegrationTest {
@After
public void close() {
db.update("DROP TABLE EMPLOYEE")
.dependsOn(create);
Connector.connectionProvider.close();
.dependsOn(create);
connectionProvider.close();
}
}

View File

@ -1,38 +1,42 @@
package com.baeldung.rxjava.jdbc;
import com.github.davidmoten.rx.jdbc.Database;
import org.junit.After;
import org.junit.Test;
import rx.Observable;
import static org.junit.Assert.assertEquals;
import java.util.Arrays;
import java.util.List;
import static org.junit.Assert.assertEquals;
import org.junit.After;
import org.junit.Test;
import com.github.davidmoten.rx.jdbc.ConnectionProvider;
import com.github.davidmoten.rx.jdbc.Database;
import rx.Observable;
public class BasicQueryTypesIntegrationTest {
private Database db = Database.from(Connector.connectionProvider);
private ConnectionProvider connectionProvider = Connector.connectionProvider;
private Database db = Database.from(connectionProvider);
private Observable<Integer> create;
private Observable<Integer> create, insert1, insert2, insert3, update, delete = null;
@Test
public void whenCreateTableAndInsertRecords_thenCorrect() {
create = db.update("CREATE TABLE IF NOT EXISTS EMPLOYEE(id int primary key, name varchar(255))")
.count();
Observable<Integer> insert1 = db.update("INSERT INTO EMPLOYEE(id, name) VALUES(1, 'John')")
insert1 = db.update("INSERT INTO EMPLOYEE(id, name) VALUES(1, 'John')")
.dependsOn(create)
.count();
Observable<Integer> update = db.update("UPDATE EMPLOYEE SET name = 'Alan' WHERE id = 1")
update = db.update("UPDATE EMPLOYEE SET name = 'Alan' WHERE id = 1")
.dependsOn(create)
.count();
Observable<Integer> insert2 = db.update("INSERT INTO EMPLOYEE(id, name) VALUES(2, 'Sarah')")
insert2 = db.update("INSERT INTO EMPLOYEE(id, name) VALUES(2, 'Sarah')")
.dependsOn(create)
.count();
Observable<Integer> insert3 = db.update("INSERT INTO EMPLOYEE(id, name) VALUES(3, 'Mike')")
insert3 = db.update("INSERT INTO EMPLOYEE(id, name) VALUES(3, 'Mike')")
.dependsOn(create)
.count();
Observable<Integer> delete = db.update("DELETE FROM EMPLOYEE WHERE id = 2")
delete = db.update("DELETE FROM EMPLOYEE WHERE id = 2")
.dependsOn(create)
.count();
List<String> names = db.select("select name from EMPLOYEE where id < ?")
@ -55,6 +59,6 @@ public class BasicQueryTypesIntegrationTest {
public void close() {
db.update("DROP TABLE EMPLOYEE")
.dependsOn(create);
Connector.connectionProvider.close();
connectionProvider.close();
}
}

View File

@ -1,21 +1,25 @@
package com.baeldung.rxjava.jdbc;
import com.github.davidmoten.rx.jdbc.Database;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import rx.Observable;
import static org.junit.Assert.assertEquals;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import static org.junit.Assert.assertEquals;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.github.davidmoten.rx.jdbc.ConnectionProvider;
import com.github.davidmoten.rx.jdbc.Database;
import rx.Observable;
public class InsertBlobIntegrationTest {
private Database db = Database.from(Connector.connectionProvider);
private ConnectionProvider connectionProvider = Connector.connectionProvider;
private Database db = Database.from(connectionProvider);
private String expectedDocument = null;
private String actualDocument = null;
@ -56,6 +60,6 @@ public class InsertBlobIntegrationTest {
public void close() {
db.update("DROP TABLE SERVERLOG")
.dependsOn(create);
Connector.connectionProvider.close();
connectionProvider.close();
}
}
}

View File

@ -1,20 +1,24 @@
package com.baeldung.rxjava.jdbc;
import com.github.davidmoten.rx.jdbc.Database;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import rx.Observable;
import static org.junit.Assert.assertEquals;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import static org.junit.Assert.assertEquals;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.github.davidmoten.rx.jdbc.ConnectionProvider;
import com.github.davidmoten.rx.jdbc.Database;
import rx.Observable;
public class InsertClobIntegrationTest {
private Database db = Database.from(Connector.connectionProvider);
private ConnectionProvider connectionProvider = Connector.connectionProvider;
private Database db = Database.from(connectionProvider);
private String expectedDocument = null;
private String actualDocument = null;
@ -54,6 +58,6 @@ public class InsertClobIntegrationTest {
public void close() {
db.update("DROP TABLE SERVERLOG")
.dependsOn(create);
Connector.connectionProvider.close();
connectionProvider.close();
}
}

View File

@ -1,24 +1,28 @@
package com.baeldung.rxjava.jdbc;
import com.github.davidmoten.rx.jdbc.Database;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import rx.Observable;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.github.davidmoten.rx.jdbc.ConnectionProvider;
import com.github.davidmoten.rx.jdbc.Database;
import rx.Observable;
public class ReturnKeysIntegrationTest {
private Observable<Integer> createStatement;
private Observable<Boolean> begin = null;
private Observable<Integer> createStatement = null;
private Database db = Database.from(Connector.connectionProvider);
private ConnectionProvider connectionProvider = Connector.connectionProvider;
private Database db = Database.from(connectionProvider);
@Before
public void setup() {
Observable<Boolean> begin = db.beginTransaction();
createStatement = db
.update("CREATE TABLE IF NOT EXISTS EMPLOYEE(id int auto_increment primary key, name varchar(255))")
begin = db.beginTransaction();
createStatement = db.update("CREATE TABLE IF NOT EXISTS EMPLOYEE(id int auto_increment primary key, name varchar(255))")
.dependsOn(begin)
.count();
}
@ -37,7 +41,8 @@ public class ReturnKeysIntegrationTest {
@After
public void close() {
db.update("DROP TABLE EMPLOYEE");
Connector.connectionProvider.close();
db.update("DROP TABLE EMPLOYEE")
.dependsOn(createStatement);
connectionProvider.close();
}
}

View File

@ -1,15 +1,21 @@
package com.baeldung.rxjava.jdbc;
import com.github.davidmoten.rx.jdbc.Database;
import org.junit.After;
import org.junit.Test;
import rx.Observable;
import static org.junit.Assert.assertEquals;
import org.junit.After;
import org.junit.Test;
import com.github.davidmoten.rx.jdbc.ConnectionProvider;
import com.github.davidmoten.rx.jdbc.Database;
import rx.Observable;
public class TransactionIntegrationTest {
private Database db = Database.from(Connector.connectionProvider);
private Observable<Integer> createStatement = null;
private ConnectionProvider connectionProvider = Connector.connectionProvider;
private Database db = Database.from(connectionProvider);
@Test
public void whenCommitTransaction_thenRecordUpdated() {
@ -36,7 +42,8 @@ public class TransactionIntegrationTest {
@After
public void close() {
db.update("DROP TABLE EMPLOYEE");
Connector.connectionProvider.close();
db.update("DROP TABLE EMPLOYEE")
.dependsOn(createStatement);
connectionProvider.close();
}
}