Created
July 27, 2012 23:28
-
-
Save ahonor/3191022 to your computer and use it in GitHub Desktop.
ImportServiceTests
This file contains hidden or 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
package com.dtolabs | |
import grails.test.mixin.* | |
import grails.test.GrailsUnitTestCase | |
import org.springframework.core.io.Resource | |
import org.springframework.core.io.ClassPathResource | |
/** | |
* See the API for {@link grails.test.mixin.services.ServiceUnitTestMixin} for usage instructions | |
*/ | |
@TestFor(ImportService) | |
@Mock(Project) | |
class ImportServiceTests extends GroovyTestCase { | |
void testValidate() { | |
service.validate( | |
asInputStream("/import/example2.xml"), | |
asInputStream("/import/yana.xsd")) | |
} | |
void testParse() { | |
Project project = new Project(name:'test1',description:'desc') | |
assertNotNull("Could not instantiate Project", project) | |
project.save() | |
service.parse(asInputStream("/import/example2.xml"), project) | |
} | |
def InputStream asInputStream(String filename) { | |
Resource resource = new ClassPathResource(filename, getClass().classLoader) | |
File f = resource.getFile() | |
return new FileInputStream(f) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment