These are chat archives for spring-cloud/spring-cloud

1st
Aug 2016
bitsofinfo
@bitsofinfo
Aug 01 2016 13:43
is spring cloud brixton.SR4 good to go w/ spring-boot 1.4?
Marcin Grzejszczak
@marcingrzejszczak
Aug 01 2016 17:43
@bitsofinfo - yes it is
Ilya Karpov
@_pls__twitter
Aug 01 2016 20:41
Does anybody know is it possible to create spring ouath2 client without stating a web-app?
Marcos Barbero
@marcosbarbero
Aug 01 2016 20:56
@_pls__twitter yes it is, would be helpful if you provide some more info
Ilya Karpov
@_pls__twitter
Aug 01 2016 21:07
@marcosbarbero the original use case is to call protected by oauth2 resource from spark driver
and it looks like an overhead to start a web server for this
Marcos Barbero
@marcosbarbero
Aug 01 2016 21:08
I see
Ilya Karpov
@_pls__twitter
Aug 01 2016 21:08
but @ EnableOAuth2Client assumes that you have to
Marcos Barbero
@marcosbarbero
Aug 01 2016 21:09
I got it. You want to write just a client to consume the oauth2 resources as a batch process or something that doesn’t need an webserver running at all
Ilya Karpov
@_pls__twitter
Aug 01 2016 21:12
yep, not web server just a client that consumes oauth2 resource. I want this client to hide oauth2 complexity - just as its done in springs oauth2 client - but without overhead of starting web server
Marcos Barbero
@marcosbarbero
Aug 01 2016 21:13
if you remove the starter-web from classpath it just stops to work?
Ilya Karpov
@_pls__twitter
Aug 01 2016 21:16
didn't tried, but I'm afraid that it won't, because here (http://projects.spring.io/spring-security-oauth/docs/oauth2.html) it's said that @ EnableOAuth2Client creates OAuth2ClientContextFilter, and this filter is servlet apis filter (
Marcos Barbero
@marcosbarbero
Aug 01 2016 21:18
you’re right, it may not work
bitsofinfo
@bitsofinfo
Aug 01 2016 22:37
Hi all - I have a spring-data-mongo based microservice app based on spring-cloud, it normally retrieves all of its config info via a config server, but for a simple unit test this is not necessary. How can i get my unit test to NOT hit the config server to avoid this below? Any simple examples out there?
2016-08-01 18:33:15,097 local 21974 spring.application.name_IS_UNDEFINED [t=,s=,se=] INFO [ConfigServicePropertySourceLocator] Fetching config from server at: http://localhost:8888 
2016-08-01 18:33:15,210 local 21974 spring.application.name_IS_UNDEFINED [t=,s=,se=] WARN [ConfigServicePropertySourceLocator] Could not locate PropertySource: I/O error on GET request for "http://localhost:8888/application/default": Unexpected end of file from server; nested exception is java.net.SocketException: Unexpected end of file from server 
2016-08-01 18:33:15,212 local 21974 spring.application.name_IS_UNDEFINED [t=,s=,se=] INFO [DogRepositoryTest] No active profile set, falling back to default profiles: default
Marcos Barbero
@marcosbarbero
Aug 01 2016 22:42
Create a bootstrap.yml in src/test/resources pointing the configserver uri to file:///
something like this:
spring:
  cloud:
    config:
      server.git.uri: file:///
bitsofinfo
@bitsofinfo
Aug 01 2016 22:49
@marcosbarbero thanks, but can't seem to get that to work either. No matter what, none of the properties I specify in @IntegrationTest take, it always attempts a config server then appears to revert to whatever the defaults are in spring-boot etc, so my data targeted for a specific mongo db, always end up in the test db.
Marcos Barbero
@marcosbarbero
Aug 01 2016 22:51
There’s some oddities here, I do use this approach to avoid my app to reach configserver on test phase. Do you have a sample of this behaviour?
bitsofinfo
@bitsofinfo
Aug 01 2016 22:58
Under src/test/java I have a package w/ a simple test class like this
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(MyMongoRepositoryTestApp.class)
public class MyMongoRepositoryTest {

    @Autowired
    private MyMongoRepository myMongoRepository;
        .....
        .....

MyMongoRepositoryTestApp.java:

@SpringBootApplication
@EnableMongoRepositories(basePackages={"my.package.mongodb"})
@IntegrationTest({
                  "spring.data.mongodb.uri=mongodb://localhost:27017/my-db",
                  "spring.data.mongodb.username=myuser",
                  "spring.data.mongodb.password=123"})
public class MyMongoRepositoryTestApp { }

The MyMongoRepository.java is plain simple: (myMongoPojo just a simple entity w/ 3 fields)

public interface MyMongoRepository extends MongoRepository<MyMongoPojo, String> {}

src/test/resources/bootstrap.yml contains what you suggested above

Marcos Barbero
@marcosbarbero
Aug 01 2016 23:04
what the version of spring-boot you’re using?
bitsofinfo
@bitsofinfo
Aug 01 2016 23:04
1.3.7
brixton SR4
Marcos Barbero
@marcosbarbero
Aug 01 2016 23:05
are you using embedded mongo config for unit tests?
bitsofinfo
@bitsofinfo
Aug 01 2016 23:06
what do you mean by embedded mongo config?
are you using this approach? or reaching a real mongodb?
bitsofinfo
@bitsofinfo
Aug 01 2016 23:07
hmm, no, I have nothing defined anywhere that resembles what listed in # EMBEDDED MONGODB (EmbeddedMongoProperties)
its hitting a real mongodb daemon on my laptop (at least that is my intent right now)
Marcos Barbero
@marcosbarbero
Aug 01 2016 23:08
I see
I think it’s good to change your approach on unit tests, because it’s unit and should not have external dependencies
bitsofinfo
@bitsofinfo
Aug 01 2016 23:09
This app, when run for real, will be getting its config from cloud config. But I'm just trying to do the most basic of verification of a mongo repository against a local mongo (i.e. i just created this first class), but can't get it to honor my variables
Yes I agree, but I'm just trying something simple to start.
Marcos Barbero
@marcosbarbero
Aug 01 2016 23:09
I got your point
how your src/test/resources/bootstrap.yml looks like?
bitsofinfo
@bitsofinfo
Aug 01 2016 23:10
spring.cloud.config.server.git.uri: file:///
Marcos Barbero
@marcosbarbero
Aug 01 2016 23:12
And the values keeps coming from the remote configserver?
bitsofinfo
@bitsofinfo
Aug 01 2016 23:18
no, it appears to be attempting some default profile, see this log snippet
2016-08-01 18:47:57,108 local2 22274 spring.application.name_IS_UNDEFINED [t=,s=,se=] INFO [ConfigServicePropertySourceLocator] Fetching config from server at: http://localhost:8888 
2016-08-01 18:47:57,184 local2 22274 spring.application.name_IS_UNDEFINED [t=,s=,se=] WARN [ConfigServicePropertySourceLocator] Could not locate PropertySource: I/O error on GET request for "http://localhost:8888/application/default": Unexpected end of file from server; nested exception is java.net.SocketException: Unexpected end of file from server 
2016-08-01 18:47:57,185 local2 22274 spring.application.name_IS_UNDEFINED [t=,s=,se=] INFO [MyMongoRepositoryTest] No active profile set, falling back to default profiles: default 
2016-08-01 18:47:57,206 local2 22274 spring.application.name_IS_UNDEFINED [t=,s=,se=] INFO [AnnotationConfigApplicationContext] Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@3b956878: startup date [Mon Aug 01 18:47:57 EDT 2016]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@24569dba 
2016-08-01 18:47:57,967 local2 22274 spring.application.name_IS_UNDEFINED [t=,s=,se=] WARN [ConfigurationClassPostProcessor] Cannot enhance @Configuration bean definition 'refreshScope' since its singleton instance has been created too early. The typical cause is a non-static @Bean method with a BeanDefinitionRegistryPostProcessor return type: Consider declaring such methods as 'static'.
Marcos Barbero
@marcosbarbero
Aug 01 2016 23:21
I’m sorry
i gave you the wrong configuration
change your bootstrap config to this property spring.cloud.config.enabled: false
bitsofinfo
@bitsofinfo
Aug 01 2016 23:24
k, that now got rid of the log snippet I pasted above. But its still going to the test mongo db and not obeying my spring.data.mongodb.uri in my @IntegrationTest so that is likely some other issue
Marcos Barbero
@marcosbarbero
Aug 01 2016 23:24
Why don’t you just set those configuration in a application.yml under src/test/resources?
bitsofinfo
@bitsofinfo
Aug 01 2016 23:28
that works yes, thanks. Still no idea why @IntegrationTest does not work, but who knows. This at least gets me rolling. Thank you for your help!
Marcos Barbero
@marcosbarbero
Aug 01 2016 23:28
:clap:
:D
bitsofinfo
@bitsofinfo
Aug 01 2016 23:35
hmm, well, I just figured it out, ultimately the issue was that I was putting @IntegrationTest on my config java class, rather than the actual junit test class... !
thanks again though!