#539 - Polishing.

Add author tags. Simplify dependency setup. Replace logger declarations with Lombok's CommonsLog. Simplify test annotations.

Disable WAN module as the WAN server does not stop after running tests. Reformat code.
This commit is contained in:
Mark Paluch
2020-02-27 10:21:46 +01:00
parent fa0021cffb
commit 54f7146e0f
121 changed files with 1160 additions and 1092 deletions

View File

@@ -13,42 +13,43 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package example.springdata.geode.client.security.client;
import static org.assertj.core.api.Assertions.*;
import example.springdata.geode.client.security.Customer;
import example.springdata.geode.client.security.EmailAddress;
import example.springdata.geode.client.security.server.SecurityEnabledServer;
import lombok.extern.apachecommons.CommonsLog;
import java.io.IOException;
import java.util.List;
import javax.annotation.Resource;
import org.apache.geode.cache.Region;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Patrick Johnson
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = SecurityEnabledClientConfiguration.class)
@SpringBootTest(classes = SecurityEnabledClientConfiguration.class)
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
@CommonsLog
public class SecurityEnabledClientShiroTests extends ForkingClientServerIntegrationTestsSupport {
@Autowired
private CustomerRepository customerRepository;
@Autowired private CustomerRepository customerRepository;
@Resource(name = "Customers")
private Region<Long, Customer> customers;
private Logger logger = LoggerFactory.getLogger(this.getClass());
@Resource(name = "Customers") private Region<Long, Customer> customers;
@BeforeClass
public static void setup() throws IOException {
@@ -57,20 +58,27 @@ public class SecurityEnabledClientShiroTests extends ForkingClientServerIntegrat
@Test
public void securityWasConfiguredCorrectly() {
logger.info("Inserting 3 entries for keys: 1, 2, 3");
log.info("Inserting 3 entries for keys: 1, 2, 3");
Customer john = new Customer(1L, new EmailAddress("2@2.com"), "John", "Smith");
Customer frank = new Customer(2L, new EmailAddress("3@3.com"), "Frank", "Lamport");
Customer jude = new Customer(3L, new EmailAddress("5@5.com"), "Jude", "Simmons");
customerRepository.save(john);
customerRepository.save(frank);
customerRepository.save(jude);
assertThat(customers.keySetOnServer().size()).isEqualTo(3);
logger.info("Customers saved on server:");
log.info("Customers saved on server:");
List<Customer> customerList = customerRepository.findAll();
assertThat(customerList.size()).isEqualTo(3);
assertThat(customerList.contains(john)).isTrue();
assertThat(customerList.contains(frank)).isTrue();
assertThat(customerList.contains(jude)).isTrue();
customerList.forEach(customer -> logger.info("\t Entry: \n \t\t " + customer));
customerList.forEach(customer -> log.info("\t Entry: \n \t\t " + customer));
}
}
}

View File

@@ -13,42 +13,43 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package example.springdata.geode.client.security.client;
import static org.assertj.core.api.Assertions.*;
import example.springdata.geode.client.security.Customer;
import example.springdata.geode.client.security.EmailAddress;
import example.springdata.geode.client.security.server.SecurityEnabledServer;
import lombok.extern.apachecommons.CommonsLog;
import java.io.IOException;
import java.util.List;
import javax.annotation.Resource;
import org.apache.geode.cache.Region;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Patrick Johnson
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = SecurityEnabledClientConfiguration.class)
@SpringBootTest(classes = SecurityEnabledClientConfiguration.class)
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
@CommonsLog
public class SecurityEnabledClientTests extends ForkingClientServerIntegrationTestsSupport {
@Autowired
private CustomerRepository customerRepository;
@Autowired private CustomerRepository customerRepository;
@Resource(name = "Customers")
private Region<Long, Customer> customers;
private Logger logger = LoggerFactory.getLogger(this.getClass());
@Resource(name = "Customers") private Region<Long, Customer> customers;
@BeforeClass
public static void setup() throws IOException {
@@ -57,20 +58,28 @@ public class SecurityEnabledClientTests extends ForkingClientServerIntegrationTe
@Test
public void SecurityWasConfiguredCorrectly() {
logger.info("Inserting 3 entries for keys: 1, 2, 3");
log.info("Inserting 3 entries for keys: 1, 2, 3");
Customer john = new Customer(1L, new EmailAddress("2@2.com"), "John", "Smith");
Customer frank = new Customer(2L, new EmailAddress("3@3.com"), "Frank", "Lamport");
Customer jude = new Customer(3L, new EmailAddress("5@5.com"), "Jude", "Simmons");
customerRepository.save(john);
customerRepository.save(frank);
customerRepository.save(jude);
assertThat(customers.keySetOnServer().size()).isEqualTo(3);
logger.info("Customers saved on server:");
assertThat(customers.keySetOnServer()).hasSize(3);
log.info("Customers saved on server:");
List<Customer> customerList = customerRepository.findAll();
assertThat(customerList.size()).isEqualTo(3);
assertThat(customerList.contains(john)).isTrue();
assertThat(customerList.contains(frank)).isTrue();
assertThat(customerList.contains(jude)).isTrue();
customerList.forEach(customer -> logger.info("\t Entry: \n \t\t " + customer));
customerList.forEach(customer -> log.info("\t Entry: \n \t\t " + customer));
}
}
}