forked from cloudfoundry/uaa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CFID-195: attempt to improve coverage
Change-Id: I8d756116778aa6984642eedb1bbcf77ae8303746
- Loading branch information
Showing
11 changed files
with
204 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
uaa/src/test/java/org/cloudfoundry/identity/uaa/authentication/login/PromptEditorTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* Cloud Foundry 2012.02.03 Beta | ||
* Copyright (c) [2009-2012] VMware, Inc. All Rights Reserved. | ||
* | ||
* This product is licensed to you under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this product except in compliance with the License. | ||
* | ||
* This product includes a number of subcomponents with | ||
* separate copyright notices and license terms. Your use of these | ||
* subcomponents is subject to the terms and conditions of the | ||
* subcomponent's license, as noted in the LICENSE file. | ||
*/ | ||
package org.cloudfoundry.identity.uaa.authentication.login; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.cloudfoundry.identity.uaa.authentication.login.Prompt; | ||
import org.junit.Test; | ||
|
||
/** | ||
* @author Dave Syer | ||
* | ||
*/ | ||
public class PromptEditorTests { | ||
|
||
private PromptEditor editor = new PromptEditor(); | ||
|
||
@Test | ||
public void testDeserialization() throws Exception { | ||
editor.setAsText("username:[text,Username]"); | ||
Prompt prompt = (Prompt) editor.getValue(); | ||
String[] values = prompt.getDetails(); | ||
assertEquals("text", values[0]); | ||
assertEquals("Username", values[1]); | ||
} | ||
|
||
@Test | ||
public void testSerialization() throws Exception { | ||
Prompt prompt = new Prompt("username", "text", "Username"); | ||
editor.setValue(prompt); | ||
assertEquals("\"username\":[\"text\",\"Username\"]", editor.getAsText()); | ||
} | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
uaa/src/test/java/org/cloudfoundry/identity/uaa/config/HandlerAdapterFactoryBeanTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* Cloud Foundry 2012.02.03 Beta Copyright (c) [2009-2012] VMware, Inc. All Rights Reserved. | ||
* | ||
* This product is licensed to you under the Apache License, Version 2.0 (the "License"). You may not use this product | ||
* except in compliance with the License. | ||
* | ||
* This product includes a number of subcomponents with separate copyright notices and license terms. Your use of these | ||
* subcomponents is subject to the terms and conditions of the subcomponent's license, as noted in the LICENSE file. | ||
*/ | ||
|
||
package org.cloudfoundry.identity.uaa.config; | ||
|
||
import static org.junit.Assert.assertNotNull; | ||
|
||
import org.junit.Test; | ||
import org.springframework.context.support.GenericApplicationContext; | ||
|
||
/** | ||
* @author Dave Syer | ||
* | ||
*/ | ||
public class HandlerAdapterFactoryBeanTests { | ||
|
||
private HandlerAdapterFactoryBean factory = new HandlerAdapterFactoryBean(); | ||
|
||
@Test | ||
public void testGetObject() throws Exception { | ||
factory.setApplicationContext(new GenericApplicationContext()); | ||
assertNotNull(factory.getObject()); | ||
} | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
uaa/src/test/java/org/cloudfoundry/identity/uaa/config/YamlMapFactoryBeanTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* Cloud Foundry 2012.02.03 Beta | ||
* Copyright (c) [2009-2012] VMware, Inc. All Rights Reserved. | ||
* | ||
* This product is licensed to you under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this product except in compliance with the License. | ||
* | ||
* This product includes a number of subcomponents with | ||
* separate copyright notices and license terms. Your use of these | ||
* subcomponents is subject to the terms and conditions of the | ||
* subcomponent's license, as noted in the LICENSE file. | ||
*/ | ||
|
||
package org.cloudfoundry.identity.uaa.config; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.io.FileNotFoundException; | ||
|
||
import org.junit.Test; | ||
import org.springframework.core.io.ByteArrayResource; | ||
import org.springframework.core.io.FileSystemResource; | ||
|
||
/** | ||
* @author Dave Syer | ||
* | ||
*/ | ||
public class YamlMapFactoryBeanTests { | ||
|
||
private YamlMapFactoryBean factory = new YamlMapFactoryBean(); | ||
|
||
@Test | ||
public void testSetIgnoreResourceNotFound() throws Exception { | ||
factory.setIgnoreResourceNotFound(true); | ||
factory.setResources(new FileSystemResource[] {new FileSystemResource("non-exsitent-file.yml")}); | ||
assertEquals(0, factory.getObject().size()); | ||
} | ||
|
||
@Test(expected=FileNotFoundException.class) | ||
public void testSetBarfOnResourceNotFound() throws Exception { | ||
factory.setResources(new FileSystemResource[] {new FileSystemResource("non-exsitent-file.yml")}); | ||
assertEquals(0, factory.getObject().size()); | ||
} | ||
|
||
@Test | ||
public void testGetObject() throws Exception { | ||
factory.setResources(new ByteArrayResource[] {new ByteArrayResource("foo: bar".getBytes())}); | ||
assertEquals(1, factory.getObject().size()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
uaa/src/test/java/org/cloudfoundry/identity/uaa/error/ConvertingExceptionViewTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/** | ||
* Cloud Foundry 2012.02.03 Beta | ||
* Copyright (c) [2009-2012] VMware, Inc. All Rights Reserved. | ||
* | ||
* This product is licensed to you under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this product except in compliance with the License. | ||
* | ||
* This product includes a number of subcomponents with | ||
* separate copyright notices and license terms. Your use of these | ||
* subcomponents is subject to the terms and conditions of the | ||
* subcomponent's license, as noted in the LICENSE file. | ||
*/ | ||
|
||
package org.cloudfoundry.identity.uaa.error; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotNull; | ||
|
||
import java.util.HashMap; | ||
|
||
import org.cloudfoundry.identity.uaa.scim.ScimException; | ||
import org.junit.Test; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.http.converter.HttpMessageConverter; | ||
import org.springframework.http.converter.StringHttpMessageConverter; | ||
import org.springframework.mock.web.MockHttpServletRequest; | ||
import org.springframework.mock.web.MockHttpServletResponse; | ||
|
||
/** | ||
* @author Dave Syer | ||
* | ||
*/ | ||
public class ConvertingExceptionViewTests { | ||
|
||
private ConvertingExceptionView view; | ||
private HttpMessageConverter<?>[] messageConverters = new HttpMessageConverter<?>[] { new StringHttpMessageConverter() }; | ||
private MockHttpServletRequest request = new MockHttpServletRequest(); | ||
private MockHttpServletResponse response = new MockHttpServletResponse(); | ||
|
||
@Test | ||
public void testGetContentType() throws Exception { | ||
ScimException e = new ScimException("Unexpected error", new RuntimeException("foo"), HttpStatus.INTERNAL_SERVER_ERROR); | ||
view = new ConvertingExceptionView(new ResponseEntity<Exception>(e, e.getStatus()), messageConverters ); | ||
assertEquals("*/*", view.getContentType()); | ||
} | ||
|
||
@Test | ||
public void testRender() throws Exception { | ||
ScimException e = new ScimException("Unexpected error", new RuntimeException("foo"), HttpStatus.INTERNAL_SERVER_ERROR); | ||
view = new ConvertingExceptionView(new ResponseEntity<Exception>(e, e.getStatus()), messageConverters ); | ||
view.render(new HashMap<String, Object>(), request , response); | ||
assertNotNull(response.getContentAsString()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters