Skip to content

Commit

Permalink
Build optimization 10.06.2017 (#2037)
Browse files Browse the repository at this point in the history
* Refactor

* Refactor
  • Loading branch information
pivovarit committed Jun 11, 2017
1 parent 25c476a commit dc43aec
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 133 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.baeuldung.serialization;
package com.baeldung.serialization;

public class Address {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.baeuldung.serialization;
package com.baeldung.serialization;

import java.io.IOException;
import java.io.ObjectInputStream;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.baeuldung.serialization;
package com.baeldung.serialization;
import java.io.Serializable;

public class Person implements Serializable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

public class CompletableFutureUnitTest {
public class CompletableFutureLongRunningUnitTest {

private static final Logger LOG = LoggerFactory.getLogger(CompletableFutureUnitTest.class);
private static final Logger LOG = LoggerFactory.getLogger(CompletableFutureLongRunningUnitTest.class);


@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@

import com.baeldung.filesystem.jndi.LookupFSJNDI;

public class LookupFSJNDITest {
public class LookupFSJNDIIntegrationTest {
LookupFSJNDI fsjndi;
File file;
InitialContext ctx = null;
final String FILENAME = "test.find";

public LookupFSJNDITest() {
public LookupFSJNDIIntegrationTest() {
try {
fsjndi = new LookupFSJNDI();
} catch (NamingException e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.baeuldung.serialization;
package com.baeldung.serialization;

import static org.junit.Assert.assertTrue;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
import static junit.framework.TestCase.assertEquals;

@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class SynchronousQueueUnitTest {
public class SynchronousQueueIntegrationTest {

private static final Logger LOG = LoggerFactory.getLogger(SynchronousQueueUnitTest.class);
private static final Logger LOG = LoggerFactory.getLogger(SynchronousQueueIntegrationTest.class);


@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package com.baeldung.test;
package com.baeldung;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import com.baeldung.Spring5Application;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = Spring5Application.class)
public class Spring5ApplicationIntegrationTest {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,54 +1,52 @@
package com.baeldung.test;

import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
import static org.junit.Assert.assertEquals;

import org.junit.Test;
import org.springframework.http.MediaType;

import com.jayway.restassured.RestAssured;
import com.jayway.restassured.response.Response;
import com.jayway.restassured.specification.RequestSpecification;

public class LiveTest {

private static String APP_ROOT = "http://localhost:8081";


@Test
public void givenUser_whenResourceCreatedWithNullName_then400BadRequest() {
final Response response = givenAuth("user", "pass").contentType(MediaType.APPLICATION_JSON.toString()).body(resourceWithNullName()).post(APP_ROOT + "/foos");
assertEquals(400, response.getStatusCode());
}

@Test
public void givenUser_whenResourceCreated_then201Created() {
final Response response = givenAuth("user", "pass").contentType(MediaType.APPLICATION_JSON.toString()).body(resourceString()).post(APP_ROOT + "/foos");
assertEquals(201, response.getStatusCode());
}

/*@Test
public void givenUser_whenGetAllFoos_thenOK() {
final Response response = givenAuth("user", "pass").get(APP_ROOT + "/foos");
assertEquals(200, response.getStatusCode());
}*/



//

private final String resourceWithNullName() {
final String roleData = "{\"name\":null}";
return roleData;
}

private final String resourceString() {
final String roleData = "{\"name\":\"" + randomAlphabetic(8) + "\"}";
return roleData;
}

private final RequestSpecification givenAuth(String username, String password) {
return RestAssured.given().auth().preemptive().basic(username, password);
}

package com.baeldung;

import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
import static org.junit.Assert.assertEquals;

import org.junit.Test;
import org.springframework.http.MediaType;

import com.jayway.restassured.RestAssured;
import com.jayway.restassured.response.Response;
import com.jayway.restassured.specification.RequestSpecification;

public class LiveTest {

private static String APP_ROOT = "http://localhost:8081";


@Test
public void givenUser_whenResourceCreatedWithNullName_then400BadRequest() {
final Response response = givenAuth("user", "pass").contentType(MediaType.APPLICATION_JSON.toString()).body(resourceWithNullName()).post(APP_ROOT + "/foos");
assertEquals(400, response.getStatusCode());
}

@Test
public void givenUser_whenResourceCreated_then201Created() {
final Response response = givenAuth("user", "pass").contentType(MediaType.APPLICATION_JSON.toString()).body(resourceString()).post(APP_ROOT + "/foos");
assertEquals(201, response.getStatusCode());
}

/*@Test
public void givenUser_whenGetAllFoos_thenOK() {
final Response response = givenAuth("user", "pass").get(APP_ROOT + "/foos");
assertEquals(200, response.getStatusCode());
}*/



//

private final String resourceWithNullName() {
return "{\"name\":null}";
}

private final String resourceString() {
return "{\"name\":\"" + randomAlphabetic(8) + "\"}";
}

private final RequestSpecification givenAuth(String username, String password) {
return RestAssured.given().auth().preemptive().basic(username, password);
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package springbootkotlin
package com.baeldung.springbootkotlin

import com.baeldung.springbootkotlin.HelloDto
import com.baeldung.springbootkotlin.KotlinDemoApplication
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Test
Expand All @@ -14,8 +12,8 @@ import org.springframework.test.context.junit4.SpringRunner

@RunWith(SpringRunner::class)
@SpringBootTest(
classes = arrayOf(KotlinDemoApplication::class),
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
classes = arrayOf(KotlinDemoApplication::class),
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class KotlinDemoApplicationIntegrationTest {

@Autowired
Expand Down

This file was deleted.

0 comments on commit dc43aec

Please sign in to comment.