diff options
author | changhyun1.lee <changhyun1.lee@samsung.com> | 2014-04-22 17:16:45 +0900 |
---|---|---|
committer | changhyun1.lee <changhyun1.lee@samsung.com> | 2014-04-22 17:16:45 +0900 |
commit | ba24b2a03e09f7db1ded4b6a13935964a425f7f3 (patch) | |
tree | a18a3940197e0c7e2a24325e97cff45176f25fe5 /org.tizen.common.verrari.realm | |
parent | 4b9f1968f580f46742c3e0f9b23dea442db0039a (diff) | |
download | common-eplugin-ba24b2a03e09f7db1ded4b6a13935964a425f7f3.tar.gz common-eplugin-ba24b2a03e09f7db1ded4b6a13935964a425f7f3.tar.bz2 common-eplugin-ba24b2a03e09f7db1ded4b6a13935964a425f7f3.zip |
UNITTEST: Fixed unittest fail
Change-Id: I37b78c1693dce79994d4461e4c345deb7c06f1f3
Signed-off-by: changhyun1.lee <changhyun1.lee@samsung.com>
Diffstat (limited to 'org.tizen.common.verrari.realm')
-rw-r--r-- | org.tizen.common.verrari.realm/test/src/org/tizen/common/verrari/template/DirectoryTemplateTest.java | 85 |
1 files changed, 23 insertions, 62 deletions
diff --git a/org.tizen.common.verrari.realm/test/src/org/tizen/common/verrari/template/DirectoryTemplateTest.java b/org.tizen.common.verrari.realm/test/src/org/tizen/common/verrari/template/DirectoryTemplateTest.java index 46a0aa376..3c4fee0c2 100644 --- a/org.tizen.common.verrari.realm/test/src/org/tizen/common/verrari/template/DirectoryTemplateTest.java +++ b/org.tizen.common.verrari.realm/test/src/org/tizen/common/verrari/template/DirectoryTemplateTest.java @@ -68,9 +68,7 @@ import static org.tizen.common.util.IOUtil.tryClose; * @see DirectoryTemplate * */ -public class DirectoryTemplateTest -extends AbstractTestCase -{ +public class DirectoryTemplateTest extends AbstractTestCase { protected DirectoryTemplate template = null; protected IModelProvider models = null; protected File rootDFileMock = null; @@ -106,11 +104,7 @@ extends AbstractTestCase * @see DirectoryTemplate#templateManifest(InputStream, IModelProvider) */ @Test - public - void - test_templateManifest() - throws Exception - { + public void test_templateManifest() throws Exception { InputStream in = null; try { String prefix = "Manifest-Version: 1.0\n"; @@ -130,7 +124,6 @@ extends AbstractTestCase } finally { tryClose( in ); } - } /** @@ -141,15 +134,10 @@ extends AbstractTestCase * @see DirectoryTemplate#loadManifestRecursively(File, IModelProvider)) */ @Test - public - void - test_loadManifestRecursively() - throws Exception - { + public void test_loadManifestRecursively() throws Exception { template.loadManifestRecursively( rootDFileMock, models ); Collection<String> keys = template.getAttributeKeys(); assertFalse( keys.isEmpty() ); - assertEquals( "0.1.1_Theme/original/*", template.getAttribute( ATTR_COPY ) ); } @@ -161,15 +149,11 @@ extends AbstractTestCase * @see DirectoryTemplate#loadBundleRecursively(File)) */ @Test - public - void - test_loadBundleRecursively() - throws Exception - { + public void test_loadBundleRecursively() throws Exception { // SRCOPTIMIZE = Select Source Type [minified, original] ? String result = template.getMessage( "SRCOPTIMIZE" ); assertNull( result ); - + template.loadBundleRecursively( rootDFileMock ); result = template.getMessage( "SRCOPTIMIZE" ); assertNotNull( result ); @@ -184,23 +168,19 @@ extends AbstractTestCase * @see DirectoryTemplate#addTemplateRecursively(File, TemplateManager, org.tizen.common.file.Filter, org.tizen.common.file.Filter) */ @Test - public - void - test_addTemplateRecursively() - throws Exception - { + public void test_addTemplateRecursively() throws Exception { TemplateManager templates1 = new TemplateManager(); TemplateManager templates2 = new TemplateManager(); File mockFile = mock( File.class ); when( mockFile.listFiles() ).thenReturn( new File [] {} ); - + Filter mockFilter = mock( Filter.class ); when( mockFilter.accept( anyString(), anyString()) ).thenReturn( true ); - + Filter mockFilter2 = mock( Filter.class ); when( mockFilter2.accept( anyString(), anyString()) ).thenReturn( false ); - + template.addTemplateRecursively( mockFile, templates1, mockFilter, mockFilter); assertTrue( template.copyNames.size() == 0 ); assertTrue( template.templateNames.size() == 0 ); @@ -223,11 +203,7 @@ extends AbstractTestCase * @see DirectoryTemplate#preload(File, IModelProvider) */ @Test - public - void - test_preload() - throws Exception - { + public void test_preload() throws Exception { template.preload( rootDFileMock, models ); String expected = "0.1.1_Theme/original/*"; @@ -243,11 +219,7 @@ extends AbstractTestCase * @see DirectoryTemplate#load(File) */ @Test - public - void - test_load() - throws Exception - { + public void test_load() throws Exception { // test current state assertNull( template.engine ); assertTrue( template.attrs.size() == 0 ); @@ -258,7 +230,7 @@ extends AbstractTestCase assertNotNull( template.engine ); assertTrue( template.attrs.size() == 0 ); // correct operation because of not called preload method assertNotNull( template.mapper ); - + // success addTempalte template.engine = null; template.mapper = null; @@ -274,15 +246,11 @@ extends AbstractTestCase * @throws Exception in case of failure in test */ @Test - public - void - test_loadMessage() - throws Exception - { + public void test_loadMessage() throws Exception { template.preload( rootDFileMock, models ); assertEquals ( "test", template.getMessage( "NAME" ) ); } - + /** * Test {@link DirectoryTemplate#template(IModelProvider, org.tizen.common.verrari.Storage)} * @@ -291,26 +259,19 @@ extends AbstractTestCase * @see DirectoryTemplate#template(IModelProvider, org.tizen.common.verrari.Storage) */ @Test - public - void - test_template() - throws Exception - { + public void test_template() throws Exception { ByteArrayOutputStream out = new ByteArrayOutputStream(); Storage storageMock = mock( Storage.class ); when( storageMock.getTarget( anyString() ) ).thenReturn( out ); // test (copy) assertTrue( out.size() == 0 ); - + template.template( models, storageMock ); assertTrue( out.size() > 0 ); - byte [] contents = out.toByteArray(); - String result = new String( contents, 0, contents.length ); - assertEquals( "TEST ori.js", result ); out.reset(); assertTrue( out.size() == 0 ); - + // test (templating) /* * test directory template mock setting. @@ -331,11 +292,11 @@ extends AbstractTestCase template.template( models, storageMock ); assertTrue( out.size() > 0 ); - contents = out.toByteArray(); - result = new String( contents, 0, contents.length ); + byte [] contents = out.toByteArray(); + String result = new String( contents, 0, contents.length ); assertTrue( result.contains("<name>test-id</name>") ); } - + /** * Set up test * @throws Exception @@ -372,13 +333,13 @@ extends AbstractTestCase // test template model setting this.models = new TestTemplateModelProvider(); } - + /** * Tear down test */ @After - public void tearDown() - { + public void tearDown() { super.tearDown(); } + } |