You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by dm...@apache.org on 2017/04/12 00:55:11 UTC
ignite git commit: IGNITE-1192: added more tests
Repository: ignite
Updated Branches:
refs/heads/ignite-1192 2fded40c5 -> f4c90c08b
IGNITE-1192: added more tests
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f4c90c08
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f4c90c08
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f4c90c08
Branch: refs/heads/ignite-1192
Commit: f4c90c08bb01ac8bb852ebc73177cafa6b1eb9dd
Parents: 2fded40
Author: Denis Magda <dm...@gridgain.com>
Authored: Tue Apr 11 17:55:07 2017 -0700
Committer: Denis Magda <dm...@gridgain.com>
Committed: Tue Apr 11 17:55:07 2017 -0700
----------------------------------------------------------------------
.../IgniteSpringDataCrudSelfTest.java | 233 +++++++++++++++
.../IgniteSpringDataQueriesSelfTest.java | 291 +++++++++++++++++++
.../springdata/IgniteSpringDataSelfTest.java | 286 ------------------
.../misc/ApplicationConfiguration.java | 2 +-
.../ignite/springdata/misc/FirstRepository.java | 92 ------
.../apache/ignite/springdata/misc/Person.java | 22 ++
.../springdata/misc/PersonRepository.java | 92 ++++++
.../springdata/misc/PersonSecondRepository.java | 40 +++
.../springdata/misc/SecondRepository.java | 40 ---
.../testsuites/IgniteSpringDataTestSuite.java | 6 +-
10 files changed, 683 insertions(+), 421 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/f4c90c08/modules/spring-data/src/test/java/org/apache/ignite/springdata/IgniteSpringDataCrudSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/spring-data/src/test/java/org/apache/ignite/springdata/IgniteSpringDataCrudSelfTest.java b/modules/spring-data/src/test/java/org/apache/ignite/springdata/IgniteSpringDataCrudSelfTest.java
new file mode 100644
index 0000000..14d6844
--- /dev/null
+++ b/modules/spring-data/src/test/java/org/apache/ignite/springdata/IgniteSpringDataCrudSelfTest.java
@@ -0,0 +1,233 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.ignite.springdata;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.TreeMap;
+import java.util.TreeSet;
+import org.apache.ignite.springdata.misc.ApplicationConfiguration;
+import org.apache.ignite.springdata.misc.Person;
+import org.apache.ignite.springdata.misc.PersonRepository;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ *
+ */
+public class IgniteSpringDataCrudSelfTest extends GridCommonAbstractTest {
+ /** Repository. */
+ private static PersonRepository repo;
+
+ /** Context. */
+ private static AnnotationConfigApplicationContext ctx;
+
+ /** Number of entries to store */
+ private static int CACHE_SIZE = 1000;
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ super.beforeTestsStarted();
+
+ ctx = new AnnotationConfigApplicationContext();
+
+ ctx.register(ApplicationConfiguration.class);
+
+ ctx.refresh();
+
+ repo = ctx.getBean(PersonRepository.class);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTest() throws Exception {
+ super.beforeTest();
+
+ fillInRepository();
+
+ assertEquals(CACHE_SIZE, repo.count());
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ repo.deleteAll();
+
+ assertEquals(0, repo.count());
+
+ super.afterTest();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ super.afterTestsStopped();
+
+ ctx.destroy();
+ }
+
+ /**
+ *
+ */
+ public void testPutGet() {
+ Person person = new Person("some_name", "some_surname");
+
+ int id = CACHE_SIZE + 1;
+
+ assertEquals(person, repo.save(id, person));
+
+ assertTrue(repo.exists(id));
+
+ assertEquals(person, repo.findOne(id));
+
+ try {
+ repo.save(person);
+
+ fail("Managed to save a Person without ID");
+ }
+ catch (UnsupportedOperationException e) {
+ //excepted
+ }
+ }
+
+ /**
+ *
+ */
+ public void testPutAllGetAll() {
+ LinkedHashMap<Integer, Person> map = new LinkedHashMap<>();
+
+ for (int i = CACHE_SIZE; i < CACHE_SIZE + 50; i++)
+ map.put(i, new Person("some_name" + i, "some_surname" + i));
+
+ Iterator<Person> persons = repo.save(map).iterator();
+
+ assertEquals(CACHE_SIZE + 50, repo.count());
+
+ Iterator<Person> origPersons = map.values().iterator();
+
+ while (persons.hasNext())
+ assertEquals(origPersons.next(), persons.next());
+
+ try {
+ repo.save(map.values());
+
+ fail("Managed to save a list of Persons with ids");
+ }
+ catch (UnsupportedOperationException e) {
+ //expected
+ }
+
+ persons = repo.findAll(map.keySet()).iterator();
+
+ int counter = 0;
+
+ while (persons.hasNext()) {
+ persons.next();
+ counter++;
+ }
+
+ assertEquals(map.size(), counter);
+ }
+
+ /**
+ *
+ */
+ public void testGetAll() {
+ assertEquals(CACHE_SIZE, repo.count());
+
+ Iterator<Person> persons = repo.findAll().iterator();
+
+ int counter = 0;
+
+ while (persons.hasNext()) {
+ persons.next();
+ counter++;
+ }
+
+ assertEquals(repo.count(), counter);
+ }
+
+ /**
+ *
+ */
+ public void testDelete() {
+ assertEquals(CACHE_SIZE, repo.count());
+
+ repo.delete(0);
+
+ assertEquals(CACHE_SIZE - 1, repo.count());
+ assertNull(repo.findOne(0));
+
+ try {
+ repo.delete(new Person("", ""));
+
+ fail("Managed to delete a Person without id");
+ }
+ catch (UnsupportedOperationException e) {
+ //expected
+ }
+ }
+
+ /**
+ *
+ */
+ public void testDeleteSet() {
+ assertEquals(CACHE_SIZE, repo.count());
+
+ TreeSet<Integer> ids = new TreeSet<>();
+
+ for (int i = 0; i < CACHE_SIZE / 2; i++)
+ ids.add(i);
+
+ repo.deleteAll(ids);
+
+ assertEquals(CACHE_SIZE / 2, repo.count());
+
+ try {
+ ArrayList<Person> persons = new ArrayList<>();
+
+ for (int i = 0; i < 3; i++)
+ persons.add(new Person(String.valueOf(i), String.valueOf(i)));
+
+ repo.delete(persons);
+
+ fail("Managed to delete Persons without ids");
+ }
+ catch (UnsupportedOperationException e) {
+ //expected
+ }
+ }
+
+ /**
+ *
+ */
+ public void testDeleteAll() {
+ assertEquals(CACHE_SIZE, repo.count());
+
+ repo.deleteAll();
+
+ assertEquals(0, repo.count());
+ }
+
+ /**
+ *
+ */
+ private void fillInRepository() {
+ for (int i = 0; i < CACHE_SIZE; i++)
+ repo.save(i, new Person("person" + Integer.toHexString(i),
+ "lastName" + Integer.toHexString((i + 16) % 256)));
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f4c90c08/modules/spring-data/src/test/java/org/apache/ignite/springdata/IgniteSpringDataQueriesSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/spring-data/src/test/java/org/apache/ignite/springdata/IgniteSpringDataQueriesSelfTest.java b/modules/spring-data/src/test/java/org/apache/ignite/springdata/IgniteSpringDataQueriesSelfTest.java
new file mode 100644
index 0000000..40b7df2
--- /dev/null
+++ b/modules/spring-data/src/test/java/org/apache/ignite/springdata/IgniteSpringDataQueriesSelfTest.java
@@ -0,0 +1,291 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.ignite.springdata;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import javax.cache.Cache;
+import org.apache.ignite.springdata.misc.ApplicationConfiguration;
+import org.apache.ignite.springdata.misc.PersonRepository;
+import org.apache.ignite.springdata.misc.Person;
+import org.apache.ignite.springdata.misc.PersonSecondRepository;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Slice;
+import org.springframework.data.domain.Sort;
+
+/**
+ *
+ */
+public class IgniteSpringDataQueriesSelfTest extends GridCommonAbstractTest {
+ /** Repository. */
+ private static PersonRepository repo;
+
+ /** Repository 2. */
+ private static PersonSecondRepository repo2;
+
+ /** Context. */
+ private static AnnotationConfigApplicationContext ctx;
+
+ /** Number of entries to store */
+ private static int CACHE_SIZE = 1000;
+
+ @Override protected void beforeTestsStarted() throws Exception {
+ super.beforeTestsStarted();
+
+ ctx = new AnnotationConfigApplicationContext();
+
+ ctx.register(ApplicationConfiguration.class);
+
+ ctx.refresh();
+
+ repo = ctx.getBean(PersonRepository.class);
+ repo2 = ctx.getBean(PersonSecondRepository.class);
+
+ for (int i = 0; i < CACHE_SIZE; i++)
+ repo.save(i, new Person("person" + Integer.toHexString(i),
+ "lastName" + Integer.toHexString((i + 16) % 256)));
+ }
+
+ @Override protected void afterTestsStopped() throws Exception {
+ ctx.destroy();
+
+ super.afterTestsStopped();
+ }
+
+ /** */
+ public void testExplicitQuery() {
+ List<Person> persons = repo.simpleQuery("person4a");
+
+ assertFalse(persons.isEmpty());
+
+ for (Person person : persons)
+ assertEquals("person4a", person.getFirstName());
+ }
+
+ /** */
+ public void testEqualsPart() {
+ List<Person> persons = repo.findByFirstName("person4e");
+
+ assertFalse(persons.isEmpty());
+
+ for (Person person : persons)
+ assertEquals("person4e", person.getFirstName());
+ }
+
+ /** */
+ public void testContainingPart() {
+ List<Person> persons = repo.findByFirstNameContaining("person4");
+
+ assertFalse(persons.isEmpty());
+
+ for (Person person : persons)
+ assertTrue(person.getFirstName().startsWith("person4"));
+ }
+
+ /** */
+ public void testTopPart() {
+ Iterable<Person> top = repo.findTopByFirstNameContaining("person4");
+
+ Iterator<Person> iter = top.iterator();
+
+ Person person = iter.next();
+
+ assertFalse(iter.hasNext());
+
+ assertTrue(person.getFirstName().startsWith("person4"));
+ }
+
+ /** */
+ public void testLikeAndLimit() {
+ Iterable<Person> like = repo.findFirst10ByFirstNameLike("person");
+
+ int cnt = 0;
+
+ for (Person next : like) {
+ assertTrue(next.getFirstName().contains("person"));
+
+ cnt++;
+ }
+
+ assertEquals(10, cnt);
+ }
+
+ /** */
+ public void testCount() {
+ int cnt = repo.countByFirstNameLike("person");
+
+ assertEquals(1000, cnt);
+ }
+
+ /** */
+ public void testCount2() {
+ int cnt = repo.countByFirstNameLike("person4");
+
+ assertTrue(cnt < 1000);
+ }
+
+ /** */
+ public void testPageable() {
+ PageRequest pageable = new PageRequest(1, 5, Sort.Direction.DESC, "firstName");
+
+ HashSet<String> firstNames = new HashSet<>();
+
+ List<Person> pageable1 = repo.findByFirstNameRegex("^[a-z]+$", pageable);
+
+ assertEquals(5, pageable1.size());
+
+ for (Person person : pageable1) {
+ firstNames.add(person.getFirstName());
+ assertTrue(person.getFirstName().matches("^[a-z]+$"));
+ }
+
+ List<Person> pageable2 = repo.findByFirstNameRegex("^[a-z]+$", pageable.next());
+
+ assertEquals(5, pageable2.size());
+
+ for (Person person : pageable2) {
+ firstNames.add(person.getFirstName());
+ assertTrue(person.getFirstName().matches("^[a-z]+$"));
+ }
+
+ assertEquals(10, firstNames.size());
+ }
+
+ /** */
+ public void testAndAndOr() {
+ int cntAnd = repo.countByFirstNameLikeAndSecondNameLike("person1", "lastName1");
+
+ int cntOr = repo.countByFirstNameStartingWithOrSecondNameStartingWith("person1", "lastName1");
+
+ assertTrue(cntAnd <= cntOr);
+ }
+
+ /** */
+ public void testQueryWithSort() {
+ List<Person> persons = repo.queryWithSort("^[a-z]+$", new Sort(Sort.Direction.DESC, "secondName"));
+
+ Person previous = persons.get(0);
+
+ for (Person person : persons) {
+ assertTrue(person.getSecondName().compareTo(previous.getSecondName()) <= 0);
+
+ assertTrue(person.getFirstName().matches("^[a-z]+$"));
+
+ previous = person;
+ }
+ }
+
+ /** */
+ public void testQueryWithPaging() {
+ List<Person> persons = repo.queryWithPageable("^[a-z]+$", new PageRequest(1, 7, Sort.Direction.DESC, "secondName"));
+
+ assertEquals(7, persons.size());
+
+ Person previous = persons.get(0);
+
+ for (Person person : persons) {
+ assertTrue(person.getSecondName().compareTo(previous.getSecondName()) <= 0);
+
+ assertTrue(person.getFirstName().matches("^[a-z]+$"));
+
+ previous = person;
+ }
+ }
+
+ /** */
+ public void testQueryFields() {
+ List<String> persons = repo.selectField("^[a-z]+$", new PageRequest(1, 7, Sort.Direction.DESC, "secondName"));
+
+ assertEquals(7, persons.size());
+ }
+
+ /** */
+ public void testFindCacheEntries() {
+ List<Cache.Entry<Integer, Person>> cacheEntries = repo.findBySecondNameLike("stName1");
+
+ assertFalse(cacheEntries.isEmpty());
+
+ for (Cache.Entry<Integer, Person> entry : cacheEntries)
+ assertTrue(entry.getValue().getSecondName().contains("stName1"));
+ }
+
+ /** */
+ public void testFindOneCacheEntry() {
+ Cache.Entry<Integer, Person> cacheEntry = repo.findTopBySecondNameLike("tName18");
+
+ assertNotNull(cacheEntry);
+
+ assertTrue(cacheEntry.getValue().getSecondName().contains("tName18"));
+ }
+
+ /** */
+ public void testFindOneValue() {
+ Person person = repo.findTopBySecondNameStartingWith("lastName18");
+
+ assertNotNull(person);
+
+ assertTrue(person.getSecondName().startsWith("lastName18"));
+ }
+
+ /** */
+ public void testSelectSeveralFields() {
+ List<List> lists = repo.selectSeveralField("^[a-z]+$", new PageRequest(2, 6));
+
+ assertEquals(6, lists.size());
+
+ for (List list : lists) {
+ assertEquals(2, list.size());
+
+ assertTrue(list.get(0) instanceof Integer);
+ }
+ }
+
+ /** */
+ public void testCountQuery() {
+ int cnt = repo.countQuery(".*");
+
+ assertEquals(256, cnt);
+ }
+
+ /** */
+ public void testSliceOfCacheEntries() {
+ Slice<Cache.Entry<Integer, Person>> slice = repo2.findBySecondNameIsNot("lastName18", new PageRequest(3, 4));
+
+ assertEquals(4, slice.getSize());
+
+ for (Cache.Entry<Integer, Person> entry : slice)
+ assertFalse("lastName18".equals(entry.getValue().getSecondName()));
+ }
+
+ /** */
+ public void testSliceOfLists() {
+ Slice<List> lists = repo2.querySliceOfList("^[a-z]+$", new PageRequest(0, 3));
+
+ assertEquals(3, lists.getSize());
+
+ for (List list : lists) {
+ assertEquals(2, list.size());
+
+ assertTrue(list.get(0) instanceof Integer);
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/ignite/blob/f4c90c08/modules/spring-data/src/test/java/org/apache/ignite/springdata/IgniteSpringDataSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/spring-data/src/test/java/org/apache/ignite/springdata/IgniteSpringDataSelfTest.java b/modules/spring-data/src/test/java/org/apache/ignite/springdata/IgniteSpringDataSelfTest.java
deleted file mode 100644
index a097c29..0000000
--- a/modules/spring-data/src/test/java/org/apache/ignite/springdata/IgniteSpringDataSelfTest.java
+++ /dev/null
@@ -1,286 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.apache.ignite.springdata;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import javax.cache.Cache;
-import org.apache.ignite.springdata.misc.FirstRepository;
-import org.apache.ignite.springdata.misc.Person;
-import org.apache.ignite.springdata.misc.SecondRepository;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import org.springframework.context.annotation.AnnotationConfigApplicationContext;
-import org.springframework.data.domain.PageRequest;
-import org.springframework.data.domain.Slice;
-import org.springframework.data.domain.Sort;
-
-/**
- *
- */
-public class IgniteSpringDataSelfTest extends GridCommonAbstractTest {
- /** Repository. */
- private static FirstRepository repo;
-
- /** Repository 2. */
- private static SecondRepository repo2;
-
- /** Context. */
- private static AnnotationConfigApplicationContext ctx;
-
- @Override protected void beforeTestsStarted() throws Exception {
- super.beforeTestsStarted();
-
- ctx = new AnnotationConfigApplicationContext();
-
- ctx.scan("org.apache.ignite.springdata");
- ctx.refresh();
-
- repo = ctx.getBean(FirstRepository.class);
- repo2 = ctx.getBean(SecondRepository.class);
-
- for (int i = 0; i < 1000; i++)
- repo.save(i, new Person("person" + Integer.toHexString(i),
- "lastName" + Integer.toHexString((i + 16) % 256)));
- }
-
- @Override protected void afterTestsStopped() throws Exception {
- ctx.destroy();
-
- super.afterTestsStopped();
- }
-
- /** */
- public void testExplicitQuery() {
- List<Person> persons = repo.simpleQuery("person4a");
-
- assertFalse(persons.isEmpty());
-
- for (Person person : persons)
- assertEquals("person4a", person.getFirstName());
- }
-
- /** */
- public void testEqualsPart() {
- List<Person> persons = repo.findByFirstName("person4e");
-
- assertFalse(persons.isEmpty());
-
- for (Person person : persons)
- assertEquals("person4e", person.getFirstName());
- }
-
- /** */
- public void testContainingPart() {
- List<Person> persons = repo.findByFirstNameContaining("person4");
-
- assertFalse(persons.isEmpty());
-
- for (Person person : persons)
- assertTrue(person.getFirstName().startsWith("person4"));
- }
-
- /** */
- public void testTopPart() {
- Iterable<Person> top = repo.findTopByFirstNameContaining("person4");
-
- Iterator<Person> iter = top.iterator();
-
- Person person = iter.next();
-
- assertFalse(iter.hasNext());
-
- assertTrue(person.getFirstName().startsWith("person4"));
- }
-
- /** */
- public void testLikeAndLimit() {
- Iterable<Person> like = repo.findFirst10ByFirstNameLike("person");
-
- int cnt = 0;
-
- for (Person next : like) {
- assertTrue(next.getFirstName().contains("person"));
-
- cnt++;
- }
-
- assertEquals(10, cnt);
- }
-
- /** */
- public void testCount() {
- int cnt = repo.countByFirstNameLike("person");
-
- assertEquals(1000, cnt);
- }
-
- /** */
- public void testCount2() {
- int cnt = repo.countByFirstNameLike("person4");
-
- assertTrue(cnt < 1000);
- }
-
- /** */
- public void testPageable() {
- PageRequest pageable = new PageRequest(1, 5, Sort.Direction.DESC, "firstName");
-
- HashSet<String> firstNames = new HashSet<>();
-
- List<Person> pageable1 = repo.findByFirstNameRegex("^[a-z]+$", pageable);
-
- assertEquals(5, pageable1.size());
-
- for (Person person : pageable1) {
- firstNames.add(person.getFirstName());
- assertTrue(person.getFirstName().matches("^[a-z]+$"));
- }
-
- List<Person> pageable2 = repo.findByFirstNameRegex("^[a-z]+$", pageable.next());
-
- assertEquals(5, pageable2.size());
-
- for (Person person : pageable2) {
- firstNames.add(person.getFirstName());
- assertTrue(person.getFirstName().matches("^[a-z]+$"));
- }
-
- assertEquals(10, firstNames.size());
- }
-
- /** */
- public void testAndAndOr() {
- int cntAnd = repo.countByFirstNameLikeAndSecondNameLike("person1", "lastName1");
-
- int cntOr = repo.countByFirstNameStartingWithOrSecondNameStartingWith("person1", "lastName1");
-
- assertTrue(cntAnd <= cntOr);
- }
-
- /** */
- public void testQueryWithSort() {
- List<Person> persons = repo.queryWithSort("^[a-z]+$", new Sort(Sort.Direction.DESC, "secondName"));
-
- Person previous = persons.get(0);
-
- for (Person person : persons) {
- assertTrue(person.getSecondName().compareTo(previous.getSecondName()) <= 0);
-
- assertTrue(person.getFirstName().matches("^[a-z]+$"));
-
- previous = person;
- }
- }
-
- /** */
- public void testQueryWithPaging() {
- List<Person> persons = repo.queryWithPageable("^[a-z]+$", new PageRequest(1, 7, Sort.Direction.DESC, "secondName"));
-
- assertEquals(7, persons.size());
-
- Person previous = persons.get(0);
-
- for (Person person : persons) {
- assertTrue(person.getSecondName().compareTo(previous.getSecondName()) <= 0);
-
- assertTrue(person.getFirstName().matches("^[a-z]+$"));
-
- previous = person;
- }
- }
-
- /** */
- public void testQueryFields() {
- List<String> persons = repo.selectField("^[a-z]+$", new PageRequest(1, 7, Sort.Direction.DESC, "secondName"));
-
- assertEquals(7, persons.size());
- }
-
- /** */
- public void testFindCacheEntries() {
- List<Cache.Entry<Integer, Person>> cacheEntries = repo.findBySecondNameLike("stName1");
-
- assertFalse(cacheEntries.isEmpty());
-
- for (Cache.Entry<Integer, Person> entry : cacheEntries)
- assertTrue(entry.getValue().getSecondName().contains("stName1"));
- }
-
- /** */
- public void testFindOneCacheEntry() {
- Cache.Entry<Integer, Person> cacheEntry = repo.findTopBySecondNameLike("tName18");
-
- assertNotNull(cacheEntry);
-
- assertTrue(cacheEntry.getValue().getSecondName().contains("tName18"));
- }
-
- /** */
- public void testFindOneValue() {
- Person person = repo.findTopBySecondNameStartingWith("lastName18");
-
- assertNotNull(person);
-
- assertTrue(person.getSecondName().startsWith("lastName18"));
- }
-
- /** */
- public void testSelectSeveralFields() {
- List<List> lists = repo.selectSeveralField("^[a-z]+$", new PageRequest(2, 6));
-
- assertEquals(6, lists.size());
-
- for (List list : lists) {
- assertEquals(2, list.size());
-
- assertTrue(list.get(0) instanceof Integer);
- }
- }
-
- /** */
- public void testCountQuery() {
- int cnt = repo.countQuery(".*");
-
- assertEquals(256, cnt);
- }
-
- /** */
- public void testSliceOfCacheEntries() {
- Slice<Cache.Entry<Integer, Person>> slice = repo2.findBySecondNameIsNot("lastName18", new PageRequest(3, 4));
-
- assertEquals(4, slice.getSize());
-
- for (Cache.Entry<Integer, Person> entry : slice)
- assertFalse("lastName18".equals(entry.getValue().getSecondName()));
- }
-
- /** */
- public void testSliceOfLists() {
- Slice<List> lists = repo2.querySliceOfList("^[a-z]+$", new PageRequest(0, 3));
-
- assertEquals(3, lists.getSize());
-
- for (List list : lists) {
- assertEquals(2, list.size());
-
- assertTrue(list.get(0) instanceof Integer);
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/ignite/blob/f4c90c08/modules/spring-data/src/test/java/org/apache/ignite/springdata/misc/ApplicationConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/spring-data/src/test/java/org/apache/ignite/springdata/misc/ApplicationConfiguration.java b/modules/spring-data/src/test/java/org/apache/ignite/springdata/misc/ApplicationConfiguration.java
index fb614ae..731e6d9 100644
--- a/modules/spring-data/src/test/java/org/apache/ignite/springdata/misc/ApplicationConfiguration.java
+++ b/modules/spring-data/src/test/java/org/apache/ignite/springdata/misc/ApplicationConfiguration.java
@@ -35,7 +35,7 @@ public class ApplicationConfiguration {
public Ignite igniteInstance() {
IgniteConfiguration cfg = new IgniteConfiguration();
- CacheConfiguration ccfg = new CacheConfiguration("cache");
+ CacheConfiguration ccfg = new CacheConfiguration("PersonCache");
ccfg.setIndexedTypes(Integer.class, Person.class);
http://git-wip-us.apache.org/repos/asf/ignite/blob/f4c90c08/modules/spring-data/src/test/java/org/apache/ignite/springdata/misc/FirstRepository.java
----------------------------------------------------------------------
diff --git a/modules/spring-data/src/test/java/org/apache/ignite/springdata/misc/FirstRepository.java b/modules/spring-data/src/test/java/org/apache/ignite/springdata/misc/FirstRepository.java
deleted file mode 100644
index 315162d..0000000
--- a/modules/spring-data/src/test/java/org/apache/ignite/springdata/misc/FirstRepository.java
+++ /dev/null
@@ -1,92 +0,0 @@
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.apache.ignite.springdata.misc;
-
-import java.util.Collection;
-import java.util.List;
-import javax.cache.Cache;
-import org.apache.ignite.springdata.repository.Query;
-import org.apache.ignite.springdata.repository.config.RepositoryConfig;
-import org.springframework.data.domain.Pageable;
-import org.springframework.data.domain.Sort;
-import org.apache.ignite.springdata.repository.IgniteRepository;
-
-/**
- *
- */
-@RepositoryConfig(cacheName = "cache")
-public interface FirstRepository extends IgniteRepository<Person, Integer> {
- /** */
- public List<Person> findByFirstName(String val);
-
- /** */
- public List<Person> findByFirstNameContaining(String val);
-
- /** */
- public List<Person> findByFirstNameRegex(String val, Pageable pageable);
-
- /** */
- public Collection<Person> findTopByFirstNameContaining(String val);
-
- /** */
- public Iterable<Person> findFirst10ByFirstNameLike(String val);
-
- /** */
- public int countByFirstNameLike(String val);
-
- /** */
- public int countByFirstNameLikeAndSecondNameLike(String like1, String like2);
-
- /** */
- public int countByFirstNameStartingWithOrSecondNameStartingWith(String like1, String like2);
-
- /** */
- public List<Cache.Entry<Integer, Person>> findBySecondNameLike(String val);
-
- /** */
- public Cache.Entry<Integer, Person> findTopBySecondNameLike(String val);
-
- /** */
- public Person findTopBySecondNameStartingWith(String val);
-
- /** */
- @Query("firstName = ?")
- public List<Person> simpleQuery(String val);
-
- /** */
- @Query("firstName REGEXP ?")
- public List<Person> queryWithSort(String val, Sort sort);
-
- /** */
- @Query("SELECT * FROM Person WHERE firstName REGEXP ?")
- public List<Person> queryWithPageable(String val, Pageable pageable);
-
- /** */
- @Query("SELECT secondName FROM Person WHERE firstName REGEXP ?")
- public List<String> selectField(String val, Pageable pageable);
-
- /** */
- @Query("SELECT _key, secondName FROM Person WHERE firstName REGEXP ?")
- public List<List> selectSeveralField(String val, Pageable pageable);
-
- /** */
- @Query("SELECT count(1) FROM (SELECT DISTINCT secondName FROM Person WHERE firstName REGEXP ?)")
- public int countQuery(String val);
-}
-
http://git-wip-us.apache.org/repos/asf/ignite/blob/f4c90c08/modules/spring-data/src/test/java/org/apache/ignite/springdata/misc/Person.java
----------------------------------------------------------------------
diff --git a/modules/spring-data/src/test/java/org/apache/ignite/springdata/misc/Person.java b/modules/spring-data/src/test/java/org/apache/ignite/springdata/misc/Person.java
index 502d86d..a0adde5 100644
--- a/modules/spring-data/src/test/java/org/apache/ignite/springdata/misc/Person.java
+++ b/modules/spring-data/src/test/java/org/apache/ignite/springdata/misc/Person.java
@@ -72,4 +72,26 @@ public class Person {
", secondName='" + secondName + '\'' +
'}';
}
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ Person person = (Person)o;
+
+ if (firstName != null ? !firstName.equals(person.firstName) : person.firstName != null)
+ return false;
+ return secondName != null ? secondName.equals(person.secondName) : person.secondName == null;
+
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ int result = firstName != null ? firstName.hashCode() : 0;
+ result = 31 * result + (secondName != null ? secondName.hashCode() : 0);
+ return result;
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/f4c90c08/modules/spring-data/src/test/java/org/apache/ignite/springdata/misc/PersonRepository.java
----------------------------------------------------------------------
diff --git a/modules/spring-data/src/test/java/org/apache/ignite/springdata/misc/PersonRepository.java b/modules/spring-data/src/test/java/org/apache/ignite/springdata/misc/PersonRepository.java
new file mode 100644
index 0000000..dc164e6
--- /dev/null
+++ b/modules/spring-data/src/test/java/org/apache/ignite/springdata/misc/PersonRepository.java
@@ -0,0 +1,92 @@
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.ignite.springdata.misc;
+
+import java.util.Collection;
+import java.util.List;
+import javax.cache.Cache;
+import org.apache.ignite.springdata.repository.Query;
+import org.apache.ignite.springdata.repository.config.RepositoryConfig;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.domain.Sort;
+import org.apache.ignite.springdata.repository.IgniteRepository;
+
+/**
+ *
+ */
+@RepositoryConfig(cacheName = "PersonCache")
+public interface PersonRepository extends IgniteRepository<Person, Integer> {
+ /** */
+ public List<Person> findByFirstName(String val);
+
+ /** */
+ public List<Person> findByFirstNameContaining(String val);
+
+ /** */
+ public List<Person> findByFirstNameRegex(String val, Pageable pageable);
+
+ /** */
+ public Collection<Person> findTopByFirstNameContaining(String val);
+
+ /** */
+ public Iterable<Person> findFirst10ByFirstNameLike(String val);
+
+ /** */
+ public int countByFirstNameLike(String val);
+
+ /** */
+ public int countByFirstNameLikeAndSecondNameLike(String like1, String like2);
+
+ /** */
+ public int countByFirstNameStartingWithOrSecondNameStartingWith(String like1, String like2);
+
+ /** */
+ public List<Cache.Entry<Integer, Person>> findBySecondNameLike(String val);
+
+ /** */
+ public Cache.Entry<Integer, Person> findTopBySecondNameLike(String val);
+
+ /** */
+ public Person findTopBySecondNameStartingWith(String val);
+
+ /** */
+ @Query("firstName = ?")
+ public List<Person> simpleQuery(String val);
+
+ /** */
+ @Query("firstName REGEXP ?")
+ public List<Person> queryWithSort(String val, Sort sort);
+
+ /** */
+ @Query("SELECT * FROM Person WHERE firstName REGEXP ?")
+ public List<Person> queryWithPageable(String val, Pageable pageable);
+
+ /** */
+ @Query("SELECT secondName FROM Person WHERE firstName REGEXP ?")
+ public List<String> selectField(String val, Pageable pageable);
+
+ /** */
+ @Query("SELECT _key, secondName FROM Person WHERE firstName REGEXP ?")
+ public List<List> selectSeveralField(String val, Pageable pageable);
+
+ /** */
+ @Query("SELECT count(1) FROM (SELECT DISTINCT secondName FROM Person WHERE firstName REGEXP ?)")
+ public int countQuery(String val);
+}
+
http://git-wip-us.apache.org/repos/asf/ignite/blob/f4c90c08/modules/spring-data/src/test/java/org/apache/ignite/springdata/misc/PersonSecondRepository.java
----------------------------------------------------------------------
diff --git a/modules/spring-data/src/test/java/org/apache/ignite/springdata/misc/PersonSecondRepository.java b/modules/spring-data/src/test/java/org/apache/ignite/springdata/misc/PersonSecondRepository.java
new file mode 100644
index 0000000..defbb01
--- /dev/null
+++ b/modules/spring-data/src/test/java/org/apache/ignite/springdata/misc/PersonSecondRepository.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.ignite.springdata.misc;
+
+import java.util.List;
+import javax.cache.Cache;
+import org.apache.ignite.springdata.repository.IgniteRepository;
+import org.apache.ignite.springdata.repository.Query;
+import org.apache.ignite.springdata.repository.config.RepositoryConfig;
+import org.springframework.data.domain.AbstractPageRequest;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Slice;
+
+/**
+ *
+ */
+@RepositoryConfig(cacheName = "PersonCache")
+public interface PersonSecondRepository extends IgniteRepository<Person, Integer> {
+ /** */
+ public Slice<Cache.Entry<Integer, Person>> findBySecondNameIsNot(String val, PageRequest pageReq);
+
+ /** */
+ @Query("SELECT _key, secondName FROM Person WHERE firstName REGEXP ?")
+ public Slice<List> querySliceOfList(String val, AbstractPageRequest pageReq);
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f4c90c08/modules/spring-data/src/test/java/org/apache/ignite/springdata/misc/SecondRepository.java
----------------------------------------------------------------------
diff --git a/modules/spring-data/src/test/java/org/apache/ignite/springdata/misc/SecondRepository.java b/modules/spring-data/src/test/java/org/apache/ignite/springdata/misc/SecondRepository.java
deleted file mode 100644
index 63b0b8f..0000000
--- a/modules/spring-data/src/test/java/org/apache/ignite/springdata/misc/SecondRepository.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.apache.ignite.springdata.misc;
-
-import java.util.List;
-import javax.cache.Cache;
-import org.apache.ignite.springdata.repository.IgniteRepository;
-import org.apache.ignite.springdata.repository.Query;
-import org.apache.ignite.springdata.repository.config.RepositoryConfig;
-import org.springframework.data.domain.AbstractPageRequest;
-import org.springframework.data.domain.PageRequest;
-import org.springframework.data.domain.Slice;
-
-/**
- *
- */
-@RepositoryConfig(cacheName = "cache")
-public interface SecondRepository extends IgniteRepository<Person, Integer> {
- /** */
- public Slice<Cache.Entry<Integer, Person>> findBySecondNameIsNot(String val, PageRequest pageReq);
-
- /** */
- @Query("SELECT _key, secondName FROM Person WHERE firstName REGEXP ?")
- public Slice<List> querySliceOfList(String val, AbstractPageRequest pageReq);
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f4c90c08/modules/spring-data/src/test/java/org/apache/ignite/testsuites/IgniteSpringDataTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/spring-data/src/test/java/org/apache/ignite/testsuites/IgniteSpringDataTestSuite.java b/modules/spring-data/src/test/java/org/apache/ignite/testsuites/IgniteSpringDataTestSuite.java
index 36fb267..d44628c 100644
--- a/modules/spring-data/src/test/java/org/apache/ignite/testsuites/IgniteSpringDataTestSuite.java
+++ b/modules/spring-data/src/test/java/org/apache/ignite/testsuites/IgniteSpringDataTestSuite.java
@@ -18,7 +18,8 @@
package org.apache.ignite.testsuites;
import junit.framework.TestSuite;
-import org.apache.ignite.springdata.IgniteSpringDataSelfTest;
+import org.apache.ignite.springdata.IgniteSpringDataCrudSelfTest;
+import org.apache.ignite.springdata.IgniteSpringDataQueriesSelfTest;
/**
*
@@ -31,7 +32,8 @@ public class IgniteSpringDataTestSuite extends TestSuite {
public static TestSuite suite() throws Exception {
TestSuite suite = new TestSuite("Spring Data Test Suite");
- suite.addTestSuite(IgniteSpringDataSelfTest.class);
+ suite.addTestSuite(IgniteSpringDataCrudSelfTest.class);
+ suite.addTestSuite(IgniteSpringDataQueriesSelfTest.class);
return suite;
}