DATAREDIS-759 - Fix line endings to LF.

This commit is contained in:
Mark Paluch
2018-01-24 13:04:01 +01:00
parent 29bcdb55d4
commit f8f422f948
6 changed files with 284 additions and 284 deletions

View File

@@ -1,102 +1,102 @@
/*
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.redis.repository.cdi;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import java.util.List;
import java.util.Set;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.spi.Bean;
import org.apache.webbeans.cditest.CdiTestContainer;
import org.apache.webbeans.cditest.CdiTestContainerLoader;
import org.junit.BeforeClass;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Integration tests for Spring Data Redis CDI extension.
*
* @author Mark Paluch
*/
public class CdiExtensionIntegrationTests {
private static Logger LOGGER = LoggerFactory.getLogger(CdiExtensionIntegrationTests.class);
static CdiTestContainer container;
@BeforeClass
public static void setUp() throws Exception {
container = CdiTestContainerLoader.getCdiContainer();
container.bootContainer();
LOGGER.debug("CDI container bootstrapped!");
}
@Test // DATAREDIS-425
@SuppressWarnings("rawtypes")
public void beanShouldBeRegistered() {
Set<Bean<?>> beans = container.getBeanManager().getBeans(PersonRepository.class);
assertThat(beans, hasSize(1));
assertThat(beans.iterator().next().getScope(), is(equalTo((Class) ApplicationScoped.class)));
}
@Test // DATAREDIS-425
public void saveAndFindUnqualified() {
RepositoryConsumer repositoryConsumer = container.getInstance(RepositoryConsumer.class);
repositoryConsumer.deleteAll();
Person person = new Person();
person.setName("foo");
repositoryConsumer.getUnqualifiedRepo().save(person);
List<Person> result = repositoryConsumer.getUnqualifiedRepo().findByName("foo");
assertThat(result, contains(person));
}
@Test // DATAREDIS-425
public void saveAndFindQualified() {
RepositoryConsumer repositoryConsumer = container.getInstance(RepositoryConsumer.class);
repositoryConsumer.deleteAll();
Person person = new Person();
person.setName("foo");
repositoryConsumer.getUnqualifiedRepo().save(person);
List<Person> result = repositoryConsumer.getQualifiedRepo().findByName("foo");
assertThat(result, contains(person));
}
@Test // DATAREDIS-425
public void callMethodOnCustomRepositoryShouldSuceed() {
RepositoryConsumer repositoryConsumer = container.getInstance(RepositoryConsumer.class);
int result = repositoryConsumer.getUnqualifiedRepo().returnOne();
assertThat(result, is(1));
}
}
/*
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.redis.repository.cdi;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import java.util.List;
import java.util.Set;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.spi.Bean;
import org.apache.webbeans.cditest.CdiTestContainer;
import org.apache.webbeans.cditest.CdiTestContainerLoader;
import org.junit.BeforeClass;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Integration tests for Spring Data Redis CDI extension.
*
* @author Mark Paluch
*/
public class CdiExtensionIntegrationTests {
private static Logger LOGGER = LoggerFactory.getLogger(CdiExtensionIntegrationTests.class);
static CdiTestContainer container;
@BeforeClass
public static void setUp() throws Exception {
container = CdiTestContainerLoader.getCdiContainer();
container.bootContainer();
LOGGER.debug("CDI container bootstrapped!");
}
@Test // DATAREDIS-425
@SuppressWarnings("rawtypes")
public void beanShouldBeRegistered() {
Set<Bean<?>> beans = container.getBeanManager().getBeans(PersonRepository.class);
assertThat(beans, hasSize(1));
assertThat(beans.iterator().next().getScope(), is(equalTo((Class) ApplicationScoped.class)));
}
@Test // DATAREDIS-425
public void saveAndFindUnqualified() {
RepositoryConsumer repositoryConsumer = container.getInstance(RepositoryConsumer.class);
repositoryConsumer.deleteAll();
Person person = new Person();
person.setName("foo");
repositoryConsumer.getUnqualifiedRepo().save(person);
List<Person> result = repositoryConsumer.getUnqualifiedRepo().findByName("foo");
assertThat(result, contains(person));
}
@Test // DATAREDIS-425
public void saveAndFindQualified() {
RepositoryConsumer repositoryConsumer = container.getInstance(RepositoryConsumer.class);
repositoryConsumer.deleteAll();
Person person = new Person();
person.setName("foo");
repositoryConsumer.getUnqualifiedRepo().save(person);
List<Person> result = repositoryConsumer.getQualifiedRepo().findByName("foo");
assertThat(result, contains(person));
}
@Test // DATAREDIS-425
public void callMethodOnCustomRepositoryShouldSuceed() {
RepositoryConsumer repositoryConsumer = container.getInstance(RepositoryConsumer.class);
int result = repositoryConsumer.getUnqualifiedRepo().returnOne();
assertThat(result, is(1));
}
}

View File

@@ -1,68 +1,68 @@
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.redis.repository.cdi;
import org.springframework.data.annotation.Id;
import org.springframework.data.redis.core.RedisHash;
import org.springframework.data.redis.core.index.Indexed;
/**
* @author Mark Paluch
*/
@RedisHash
class Person {
@Id private String id;
@Indexed private String name;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (!(o instanceof Person))
return false;
Person person = (Person) o;
if (id != null ? !id.equals(person.id) : person.id != null)
return false;
return name != null ? name.equals(person.name) : person.name == null;
}
@Override
public int hashCode() {
int result = id != null ? id.hashCode() : 0;
result = 31 * result + (name != null ? name.hashCode() : 0);
return result;
}
}
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.redis.repository.cdi;
import org.springframework.data.annotation.Id;
import org.springframework.data.redis.core.RedisHash;
import org.springframework.data.redis.core.index.Indexed;
/**
* @author Mark Paluch
*/
@RedisHash
class Person {
@Id private String id;
@Indexed private String name;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (!(o instanceof Person))
return false;
Person person = (Person) o;
if (id != null ? !id.equals(person.id) : person.id != null)
return false;
return name != null ? name.equals(person.name) : person.name == null;
}
@Override
public int hashCode() {
int result = id != null ? id.hashCode() : 0;
result = 31 * result + (name != null ? name.hashCode() : 0);
return result;
}
}

View File

@@ -1,33 +1,33 @@
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.redis.repository.cdi;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import javax.inject.Qualifier;
/**
* @author Mark Paluch
*/
@Qualifier
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER })
@interface PersonDB {
}
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.redis.repository.cdi;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import javax.inject.Qualifier;
/**
* @author Mark Paluch
*/
@Qualifier
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER })
@interface PersonDB {
}

View File

@@ -1,33 +1,33 @@
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.redis.repository.cdi;
import java.util.List;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.cdi.Eager;
/**
* @author Mark Paluch
*/
@Eager
public interface PersonRepository extends CrudRepository<Person, String>, PersonRepositoryCustom {
List<Person> findAll();
List<Person> findByName(String name);
}
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.redis.repository.cdi;
import java.util.List;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.cdi.Eager;
/**
* @author Mark Paluch
*/
@Eager
public interface PersonRepository extends CrudRepository<Person, String>, PersonRepositoryCustom {
List<Person> findAll();
List<Person> findByName(String name);
}

View File

@@ -1,42 +1,42 @@
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.redis.repository.cdi;
import javax.inject.Inject;
/**
* @author Mark Paluch
*/
class RepositoryConsumer {
@Inject PersonRepository unqualifiedRepo;
@Inject @PersonDB PersonRepository qualifiedRepo;
public PersonRepository getUnqualifiedRepo() {
return unqualifiedRepo;
}
public PersonRepository getQualifiedRepo() {
return qualifiedRepo;
}
public void deleteAll() {
unqualifiedRepo.deleteAll();
qualifiedRepo.deleteAll();
}
}
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.redis.repository.cdi;
import javax.inject.Inject;
/**
* @author Mark Paluch
*/
class RepositoryConsumer {
@Inject PersonRepository unqualifiedRepo;
@Inject @PersonDB PersonRepository qualifiedRepo;
public PersonRepository getUnqualifiedRepo() {
return unqualifiedRepo;
}
public PersonRepository getQualifiedRepo() {
return qualifiedRepo;
}
public void deleteAll() {
unqualifiedRepo.deleteAll();
qualifiedRepo.deleteAll();
}
}