Skip to content

Commit

Permalink
Additional tests for StoreResolver
Browse files Browse the repository at this point in the history
  • Loading branch information
paulcwarren committed May 25, 2020
1 parent fb6a06c commit e77cd4a
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,6 @@ private Class<?> getDomainObjectClass(Class<?> contentStoreInterface) {
return null;
}

// public Set<ContentStoreInfo> getContentStoreInfos() {
// return storeInfos;
// }
//
// public void setContentStoreInfos(Set<ContentStoreInfo> contentStoreInfos) {
// this.storeInfos = contentStoreInfos;
// }

// public ContentStoreInfo[] getContentStores() {
// return (ContentStoreInfo[]) getStores(ContentStore.class);
// }

@Override
public void addStoreResolver(String name, StoreResolver resolver) {
resolvers.put(name, resolver);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package org.springframework.content.commons.repository.factory.testsupport;

import org.springframework.content.commons.repository.ContentStore;
import org.springframework.content.commons.repository.factory.AbstractStoreFactoryBean;
import org.springframework.core.io.Resource;

import java.io.InputStream;
import java.io.Serializable;

public class TestStoreFactoryBean extends AbstractStoreFactoryBean {

Expand All @@ -9,6 +14,40 @@ protected Object getContentStoreImpl() {
return new TestConfigStoreImpl();
}

public static class TestConfigStoreImpl {
public static class TestConfigStoreImpl implements ContentStore {
@Override
public Object setContent(Object property, InputStream content) {
throw new UnsupportedOperationException();
}

@Override
public Object unsetContent(Object property) {
throw new UnsupportedOperationException();
}

@Override
public InputStream getContent(Object property) {
throw new UnsupportedOperationException();
}

@Override
public Resource getResource(Object entity) {
throw new UnsupportedOperationException();
}

@Override
public void associate(Object entity, Serializable id) {
throw new UnsupportedOperationException();
}

@Override
public void unassociate(Object entity) {
throw new UnsupportedOperationException();
}

@Override
public Resource getResource(Serializable id) {
throw new UnsupportedOperationException();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package internal.org.springframework.content.rest.multistore;
package internal.org.springframework.content.rest.storeresolver;

import internal.org.springframework.content.rest.it.SecurityConfiguration;
import lombok.Data;
Expand Down Expand Up @@ -30,18 +30,15 @@
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.Database;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.stereotype.Component;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.sql.DataSource;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.UUID;


@SpringBootApplication
Expand All @@ -59,10 +56,10 @@ public static void main(String[] args) {

@Configuration
@Import({RestConfiguration.class, SecurityConfiguration.class})
@EnableJpaRepositories(basePackages="internal.org.springframework.content.rest.multistore", considerNestedRepositories = true)
@EnableJpaRepositories(basePackages= "internal.org.springframework.content.rest.storeresolver", considerNestedRepositories = true)
@EnableTransactionManagement
@EnableJpaStores(basePackages="internal.org.springframework.content.rest.multistore")
@EnableFilesystemStores(basePackages="internal.org.springframework.content.rest.multistore")
@EnableJpaStores(basePackages="internal.org.springframework.content.rest.storeresolver")
@EnableFilesystemStores(basePackages="internal.org.springframework.content.rest.storeresolver")
public static class AppConfig {

@Value("/org/springframework/content/jpa/schema-drop-h2.sql")
Expand Down Expand Up @@ -100,7 +97,7 @@ public LocalContainerEntityManagerFactoryBean entityManagerFactory() {

LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
factory.setJpaVendorAdapter(vendorAdapter);
factory.setPackagesToScan("internal.org.springframework.content.rest.multistore");
factory.setPackagesToScan("internal.org.springframework.content.rest.storeresolver");
factory.setDataSource(dataSource());

return factory;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package internal.org.springframework.content.rest.multistore;
package internal.org.springframework.content.rest.storeresolver;

import com.github.paulcwarren.ginkgo4j.Ginkgo4jConfiguration;
import com.github.paulcwarren.ginkgo4j.Ginkgo4jSpringRunner;
import com.jayway.restassured.RestAssured;
import internal.org.springframework.content.rest.it.AbstractRestIT;
import internal.org.springframework.content.rest.support.TestEntity2;
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpStatus;
Expand All @@ -24,7 +23,7 @@
@RunWith(Ginkgo4jSpringRunner.class)
@Ginkgo4jConfiguration(threads=1)
@SpringBootTest(classes = Application.class, webEnvironment=WebEnvironment.RANDOM_PORT)
public class MultiStoreRestIT {
public class StoreResolverRestConfigurationIT {

@Autowired
private Application.TEntityRepository repo;
Expand Down

0 comments on commit e77cd4a

Please sign in to comment.