--- /dev/null
+/*
+ * Verrari - Realm
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GyeongSeok Seo <gyeongseok.seo@samsung.com>
+ * BonYong Lee <bonyong.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+package org.tizen.common.verrari.realm;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.tizen.common.verrari.AttributeConfiguable;
+import org.tizen.common.verrari.Realm;
+import org.tizen.common.verrari.util.QueryFactory;
+
+/**
+ * <p>
+ * CommonRealm
+ *
+ * Built-in {@link Realm} to provide RI
+ *
+ * </p>
+ *
+ * @author GyeongSeok Seo{@literal <gyeongseok.seo@samsung.com>} (S-Core)
+ * @author BonYong Lee{@literal <bonyong.lee@samsung.com>} (S-Core)
+ *
+ * @see Realm
+ * @see AttributeConfiguable
+ */
+public abstract class
+CommonRealm
+implements Realm, AttributeConfiguable
+{
+ /**
+ * logger for this object
+ */
+ protected final Logger logger = LoggerFactory.getLogger( getClass() );
+
+ /**
+ * attribute( ,metadata ) for realm
+ */
+ protected HashMap<String, String> attributes;
+
+ /**
+ * Separate arguemnt with semicolon
+ *
+ * @param value value to separate
+ *
+ * @return string array to be separated
+ */
+ public static
+ String[]
+ separate(
+ final String value
+ )
+ {
+ if ( null == value )
+ {
+ return null;
+ }
+ Pattern p =Pattern.compile("[,;]+");
+ return p.split( value );
+ }
+
+ /* (non-Javadoc)
+ * @see org.tizen.common.verrari.AttributeContainer#getAttributeKeys()
+ */
+ @Override
+ public Collection<String> getAttributeKeys()
+ {
+ return attributes.keySet();
+ }
+
+ /* (non-Javadoc)
+ * @see org.tizen.common.verrari.realm.CompositeRealm#getAttribute(java.lang.String)
+ */
+ @Override
+ public String getAttribute(String key) {
+ final String value = attributes.get( key );
+ logger.debug( "Key :{}, Value :{}", key, value );
+ if ( null == value )
+ {
+ return null;
+ }
+ return QueryFactory.getInstance().query( value, new HashMap<String, Object>() );
+ }
+
+ /* (non-Javadoc)
+ * @see org.tizen.common.verrari.AttributeConfiguable#setAttributes(java.util.Map)
+ */
+ @Override
+ public void setAttributes(Map<String, String> attrs) {
+ if ( null == this.attributes )
+ {
+ this.attributes = new HashMap<String, String>( attrs );
+ }
+ else
+ {
+ throw new IllegalStateException( "Setting attributes is duplicated" );
+ }
+ }
+
+ /**
+ * make template query
+ *
+ * @return template query
+ *
+ * @see QueryFactory
+ */
+ protected
+ Query
+ getTemplateQuery(Realm realm)
+ {
+ final QueryFactory factory = QueryFactory.getInstance();
+ return factory.createTemplateQuery( realm );
+ }
+}
* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
*\r
* Contact: \r
+ * GyeongSeok Seo <gyeongseok.seo@samsung.com>\r
* BonYong Lee <bonyong.lee@samsung.com>\r
* \r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* \r
* </p>\r
* \r
+ * @author GyeongSeok Seo{@literal <gyeongseok.seo@samsung.com>} (S-Core)\r
* @author BonYong Lee{@literal <bonyong.lee@samsung.com>} (S-Core)\r
* \r
* @see Realm\r
{\r
chain.add( realm );\r
}\r
+\r
+ /**\r
+ * get realm into realm chain\r
+ * \r
+ * @return all realm in realm chain\r
+ */\r
+ public\r
+ Realm []\r
+ getRealm()\r
+ {\r
+ if ( chain.isEmpty() ) {\r
+ return null;\r
+ }\r
+ return chain.toArray( new Realm [] {} );\r
+ }\r
\r
/* (non-Javadoc)\r
* @see org.tizen.common.verrari.AttributeContainer#getAttributeKeys()\r
--- /dev/null
+/*
+ * Verrari - Realm
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GyeongSeok Seo <gyeongseok.seo@samsung.com>
+ * BonYong Lee <bonyong.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+package org.tizen.common.verrari.realm;
+
+import static org.tizen.common.util.IOUtil.tryClose;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Map;
+
+import org.tizen.common.util.MapUtil;
+import org.tizen.common.verrari.AttributeConfiguable;
+import org.tizen.common.verrari.Realm;
+import org.tizen.common.verrari.Template;
+import org.tizen.common.verrari.TemplateException;
+import org.tizen.common.verrari.template.DirectoryTemplate;
+
+/**
+ * <p>
+ * DirectoryRealm
+ *
+ * Built-in {@link Realm} to provide RI
+ *
+ * </p>
+ *
+ * @author GyeongSeok Seo{@literal <gyeongseok.seo@samsung.com>} (S-Core)
+ * @author BonYong Lee{@literal <bonyong.lee@samsung.com>} (S-Core)
+ *
+ * @see Realm
+ * @see AttributeConfiguable
+ */
+public class
+DirectoryRealm
+extends CommonRealm
+{
+ @SuppressWarnings("unchecked")
+ @Override
+ public Template getTemplate(String id) throws IOException {
+ final Query templateQuery = getTemplateQuery( this );
+ final Map<?, ?> modelMap = MapUtil.asMap( new Object[][] { new Object[] { "id", id } } );
+ logger.trace( "Map :{}", modelMap );
+ final String query = templateQuery.query( (Map<String, Object>) modelMap );
+
+ logger.trace( "Query :{}", query );
+ final URL url = new URL( query );
+
+ File file = null;
+
+ try
+ {
+ file = getURItoFile( url.toURI() );
+ return getTemplate( file );
+ }
+ catch (URISyntaxException e)
+ {
+ throw new IOException( "Template[" + id + "] not found" );
+ }
+ finally
+ {
+ tryClose( file );
+ }
+ }
+
+ /**
+ * extract template from {@link InputStream}
+ *
+ * @param in {@link InputStream} to read
+ *
+ * @return template to be extracted
+ *
+ * @throws IOException If <code>in</code> throw {@link IOException}
+ */
+ public
+ Template
+ getTemplate(
+ final File file
+ )
+ throws IOException
+ {
+ try
+ {
+ final DirectoryTemplate template = new DirectoryTemplate( file );
+
+ return template;
+ }
+ catch ( final TemplateException e )
+ {
+ throw new IOException( e );
+ }
+ }
+
+ protected
+ File
+ getURItoFile( URI uri ) {
+ return new File( uri );
+ }
+}
--- /dev/null
+/*\r
+ * Verrari - Realm\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: \r
+ * BonYong Lee <bonyong.lee@samsung.com>\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ *\r
+ */\r
+package org.tizen.common.verrari.realm;\r
+\r
+import static org.tizen.common.util.IOUtil.getBytes;\r
+import static org.tizen.common.util.IOUtil.tryClose;\r
+\r
+import java.io.IOException;\r
+import java.io.InputStream;\r
+import java.net.URL;\r
+import java.util.Map;\r
+\r
+import org.tizen.common.core.command.UntrackedException;\r
+import org.tizen.common.util.MapUtil;\r
+import org.tizen.common.verrari.AttributeConfiguable;\r
+import org.tizen.common.verrari.Realm;\r
+import org.tizen.common.verrari.Template;\r
+import org.tizen.common.verrari.TemplateException;\r
+import org.tizen.common.verrari.template.StandardTemplate;\r
+\r
+/**\r
+ * <p>\r
+ * JarRealm\r
+ * \r
+ * Built-in {@link Realm} to provide RI\r
+ * \r
+ * </p>\r
+ * \r
+ * @author BonYong Lee{@literal <bonyong.lee@samsung.com>} (S-Core)\r
+ * \r
+ * @see Realm\r
+ * @see AttributeConfiguable\r
+ */\r
+public class\r
+JarRealm\r
+extends CommonRealm\r
+{\r
+ /* (non-Javadoc)\r
+ * @see org.tizen.common.verrari.Realm#getTemplate(java.lang.String)\r
+ */\r
+ @SuppressWarnings("unchecked")\r
+ @Override\r
+ public\r
+ Template\r
+ getTemplate(\r
+ final String id\r
+ ) throws IOException\r
+ {\r
+ final Query templateQuery = getTemplateQuery( this );\r
+ final Map<?, ?> modelMap = MapUtil.asMap( new Object[][] { new Object[] { "id", id } } );\r
+ logger.trace( "Map :{}", modelMap );\r
+ final String query = templateQuery.query( (Map<String, Object>) modelMap );\r
+ \r
+ logger.trace( "Query :{}", query );\r
+ final URL url = new URL( query );\r
+ \r
+ InputStream in = null;\r
+ \r
+ try\r
+ {\r
+ in = url.openStream();\r
+ if ( null == in )\r
+ {\r
+ throw new IOException( "Template[" + id + "] not found" );\r
+ }\r
+ \r
+ return getTemplate( in );\r
+ }\r
+ catch ( final IOException e )\r
+ {\r
+ throw new UntrackedException( "Template[" + id + "] not found", e );\r
+ }\r
+ finally\r
+ {\r
+ tryClose( in );\r
+ }\r
+ }\r
+ \r
+ /**\r
+ * extract template from {@link InputStream}\r
+ * \r
+ * @param in {@link InputStream} to read\r
+ * \r
+ * @return template to be extracted\r
+ * \r
+ * @throws IOException If <code>in</code> throw {@link IOException}\r
+ */\r
+ public\r
+ Template\r
+ getTemplate(\r
+ final InputStream in\r
+ )\r
+ throws IOException\r
+ {\r
+ \r
+ final byte[] bytes = getBytes( in );\r
+ \r
+ try\r
+ {\r
+ final StandardTemplate template = new StandardTemplate( bytes );\r
+ \r
+ return template;\r
+ }\r
+ catch ( final TemplateException e )\r
+ {\r
+ throw new IOException( e );\r
+ }\r
+ \r
+ }\r
+\r
+ \r
+ /* (non-Javadoc)\r
+ * @see java.lang.Object#toString()\r
+ */\r
+ @Override\r
+ public String toString()\r
+ {\r
+ return attributes.get( RealmConstants.ATTR_ID ) + "@" + Realm.class.getSimpleName();\r
+ }\r
+ \r
+\r
+}\r
\r
/**\r
* <p>\r
- * StandardSearchableRealm\r
+ * JarSearchableRealm\r
* \r
* Built-in {@link SearchableRealm} to provide RI\r
* \r
* @see SearchableRealm\r
*/\r
public class\r
-StandardSearchableRealm\r
-extends StandardRealm\r
+JarSearchableRealm\r
+extends JarRealm\r
implements SearchableRealm\r
{\r
\r
-/*\r
- * Verrari - Realm\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: \r
- * BonYong Lee <bonyong.lee@samsung.com>\r
- * \r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- * Contributors:\r
- * - S-Core Co., Ltd\r
- *\r
- */\r
-package org.tizen.common.verrari.realm;\r
-\r
-import static org.tizen.common.util.IOUtil.getBytes;\r
-import static org.tizen.common.util.IOUtil.tryClose;\r
-\r
-import java.io.IOException;\r
-import java.io.InputStream;\r
-import java.net.URL;\r
-import java.util.Collection;\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-import org.tizen.common.core.command.UntrackedException;\r
-import org.tizen.common.util.MapUtil;\r
-import org.tizen.common.verrari.AttributeConfiguable;\r
-import org.tizen.common.verrari.Realm;\r
-import org.tizen.common.verrari.Template;\r
-import org.tizen.common.verrari.TemplateException;\r
-import org.tizen.common.verrari.template.StandardTemplate;\r
-import org.tizen.common.verrari.util.QueryFactory;\r
-\r
-/**\r
- * <p>\r
- * StandardRealm\r
- * \r
- * Built-in {@link Realm} to provide RI\r
- * \r
- * </p>\r
- * \r
- * @author BonYong Lee{@literal <bonyong.lee@samsung.com>} (S-Core)\r
- * \r
- * @see Realm\r
- * @see AttributeConfiguable\r
- */\r
-public class\r
-StandardRealm\r
-implements Realm, AttributeConfiguable\r
-{\r
- /**\r
- * logger for this object\r
- */\r
- protected final Logger logger = LoggerFactory.getLogger( getClass() );\r
- \r
- /**\r
- * attribute( ,metadata ) for realm\r
- */\r
- protected HashMap<String, String> attributes;\r
- \r
- \r
-\r
- /**\r
- * Separate arguemnt with semicolon\r
- * \r
- * @param value value to separate\r
- * \r
- * @return string array to be separated\r
- */\r
- public static\r
- String[]\r
- separate(\r
- final String value\r
- )\r
- {\r
- if ( null == value )\r
- {\r
- return null;\r
- }\r
- return value.split( ";" );\r
- }\r
-\r
-\r
- /* (non-Javadoc)\r
- * @see org.tizen.common.verrari.AttributeContainer#getAttributeKeys()\r
- */\r
- @Override\r
- public Collection<String> getAttributeKeys()\r
- {\r
- return attributes.keySet();\r
- }\r
-\r
- /* (non-Javadoc)\r
- * @see org.tizen.common.verrari.AttributeContainer#getAttribute(java.lang.String)\r
- */\r
- @Override\r
- public\r
- String\r
- getAttribute(\r
- final String key\r
- )\r
- {\r
- final String value = attributes.get( key );\r
- logger.debug( "Key :{}, Value :{}", key, value );\r
- if ( null == value )\r
- {\r
- return null;\r
- }\r
- return QueryFactory.getInstance().query( value, new HashMap<String, Object>() );\r
- }\r
-\r
- /* (non-Javadoc)\r
- * @see org.tizen.common.verrari.AttributeConfiguable#setAttributes(java.util.Map)\r
- */\r
- @Override\r
- public void setAttributes( final Map<String, String> attrs )\r
- {\r
- if ( null == this.attributes )\r
- {\r
- this.attributes = new HashMap<String, String>( attrs );\r
- }\r
- else\r
- {\r
- throw new IllegalStateException( "Setting attributes is duplicated" );\r
- }\r
- \r
- }\r
-\r
-\r
- /* (non-Javadoc)\r
- * @see org.tizen.common.verrari.Realm#getTemplate(java.lang.String)\r
- */\r
- @SuppressWarnings("unchecked")\r
- @Override\r
- public\r
- Template\r
- getTemplate(\r
- final String id\r
- ) throws IOException\r
- {\r
- final Query templateQuery = getTemplateQuery();\r
- final Map<?, ?> modelMap = MapUtil.asMap( new Object[][] { new Object[] { "id", id } } );\r
- logger.trace( "Map :{}", modelMap );\r
- final String query = templateQuery.query( (Map<String, Object>) modelMap );\r
- \r
- logger.trace( "Query :{}", query );\r
- final URL url = new URL( query );\r
- \r
- InputStream in = null;\r
- \r
- try\r
- {\r
- in = url.openStream();\r
- if ( null == in )\r
- {\r
- throw new IOException( "Template[" + id + "] not found" );\r
- }\r
- \r
- return getTemplate( in );\r
- }\r
- catch ( final IOException e )\r
- {\r
- throw new UntrackedException( "Template[" + id + "] not found", e );\r
- }\r
- finally\r
- {\r
- tryClose( in );\r
- }\r
- }\r
- \r
- /**\r
- * extract template from {@link InputStream}\r
- * \r
- * @param in {@link InputStream} to read\r
- * \r
- * @return template to be extracted\r
- * \r
- * @throws IOException If <code>in</code> throw {@link IOException}\r
- */\r
- public\r
- Template\r
- getTemplate(\r
- final InputStream in\r
- )\r
- throws IOException\r
- {\r
- \r
- final byte[] bytes = getBytes( in );\r
- \r
- try\r
- {\r
- final StandardTemplate template = new StandardTemplate( bytes );\r
- \r
- return template;\r
- }\r
- catch ( final TemplateException e )\r
- {\r
- throw new IOException( e );\r
- }\r
- \r
- }\r
-\r
- /**\r
- * make template query\r
- * \r
- * @return template query\r
- * \r
- * @see QueryFactory\r
- */\r
- protected\r
- Query\r
- getTemplateQuery()\r
- {\r
- final QueryFactory factory = QueryFactory.getInstance();\r
- return factory.createTemplateQuery( this );\r
- }\r
- \r
- /* (non-Javadoc)\r
- * @see java.lang.Object#toString()\r
- */\r
- @Override\r
- public String toString()\r
- {\r
- return attributes.get( RealmConstants.ATTR_ID ) + "@" + Realm.class.getSimpleName();\r
- }\r
- \r
-\r
-}\r
+/*
+ * Verrari - Realm
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GyeongSeok Seo <gyeongseok.seo@samsung.com>
+ * BonYong Lee <bonyong.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+package org.tizen.common.verrari.realm;
+
+import org.tizen.common.verrari.AttributeConfiguable;
+import org.tizen.common.verrari.Realm;
+
+/**
+ * <p>
+ * StandardRealm
+ *
+ * Built-in {@link Realm} to provide RI
+ *
+ * </p>
+ *
+ * @author GyeongSeok Seo{@literal <gyeongseok.seo@samsung.com>} (S-Core)
+ * @author BonYong Lee{@literal <bonyong.lee@samsung.com>} (S-Core)
+ *
+ * @see Realm
+ * @see AttributeConfiguable
+ */
+public class
+StandardRealm
+extends CompositeRealm
+{
+ public StandardRealm() {
+ super();
+ addRealm( new JarSearchableRealm() );
+ addRealm( new DirectoryRealm() );
+ }
+}
import org.tizen.common.verrari.Template;
import org.tizen.common.verrari.TemplateException;
import org.tizen.common.verrari.engine.TemplateEngineFactory;
-import org.tizen.common.verrari.realm.StandardRealm;
+import org.tizen.common.verrari.realm.JarRealm;
import org.tizen.common.verrari.util.BufferFactory;
/**
this( new File( path ) );
}
- /**
- * get file's {@link InputStream},
- * caller must close inputStream
- *
- * @param file
- * @return InputStream
- * @throws FileNotFoundException
- */
- protected InputStream getInputStream(File file) throws IOException {
- return new FileInputStream(file);
- }
/**
* constructor with template contents in file, file is must directory
}
/**
+ * get file's {@link InputStream},
+ * caller must close inputStream
+ *
+ * @param file
+ * @return InputStream
+ * @throws FileNotFoundException
+ */
+ protected InputStream getInputStream(File file) throws IOException {
+ return new FileInputStream(file);
+ }
+
+ /**
* pre-changing MANIFEST.MF file, because of MANIFEST.MF file also marking to template engine
*
* @param in - manifestfile's inputstream
final String mappings = attrs.get( ATTR_MAPPING );
this.mapper = getMapper( attrs.get( ATTR_MAPPER ), mappings );
- final Filter templateFilter = createFilter( StandardRealm.separate( includes ), StandardRealm.separate( excludes ) );
+ final Filter templateFilter = createFilter( JarRealm.separate( includes ), JarRealm.separate( excludes ) );
- final Filter copyFilter = createFilter( StandardRealm.separate( copies ), null );
+ final Filter copyFilter = createFilter( JarRealm.separate( copies ), null );
// Process files
addTemplateRecursively( rootFile, templates, templateFilter, copyFilter );
import org.tizen.common.verrari.engine.TemplateEngineFactory;\r
import org.tizen.common.verrari.exception.InvalidMapperException;\r
import org.tizen.common.verrari.exception.UnsupportedVersionException;\r
-import org.tizen.common.verrari.realm.StandardRealm;\r
+import org.tizen.common.verrari.realm.JarRealm;\r
import org.tizen.common.verrari.util.BufferFactory;\r
\r
/**\r
final String mappings = attrs.get( ATTR_MAPPING );\r
this.mapper = getMapper( attrs.get( ATTR_MAPPER ), mappings );\r
\r
- final Filter filter = createFilter( StandardRealm.separate( includes ), StandardRealm.separate( excludes ) );\r
+ final Filter filter = createFilter( JarRealm.separate( includes ), JarRealm.separate( excludes ) );\r
\r
- final Filter copyFilter = createFilter( StandardRealm.separate( copies ), null );\r
+ final Filter copyFilter = createFilter( JarRealm.separate( copies ), null );\r
\r
// Process files\r
JarEntry iter = null;\r
Manifest-Version: 1.0
-Tizen-Template-Realm: org.tizen.common.verrari.realm.StandardSearchableRealm
+Tizen-Template-Realm: org.tizen.common.verrari.realm.StandardRealm
*/\r
package org.tizen.common.verrari;\r
\r
+import static org.tizen.common.util.ObjectUtil.nvl;\r
+\r
+import java.util.Collection;\r
+\r
import org.junit.After;\r
import org.junit.Before;\r
import org.slf4j.Logger;\r
import org.slf4j.LoggerFactory;\r
+import org.tizen.common.Factory;\r
import org.tizen.common.classloader.CustomClassLoader;\r
import org.tizen.common.classloader.JarClassSource;\r
+import org.tizen.common.config.Preference;\r
+import org.tizen.common.core.command.ExecutionContext;\r
+import org.tizen.common.core.command.Executor;\r
+import org.tizen.common.core.command.policy.PolicyRegistry;\r
+import org.tizen.common.core.command.prompter.NopPrompter;\r
+import org.tizen.common.file.VirtualFileHandler;\r
\r
/**\r
* AbstractTestCase.\r
*\r
* abstract class for test case\r
*\r
+ * @author GyeongSeok Seo{@literal <gyeongseok.seo@samsung.com>} (S-Core)\r
* @author BonYong Lee{@literal <bonyong.lee@samsung.com>} (S-Core)\r
*\r
*/\r
public class\r
AbstractTestCase\r
{\r
+ protected static final Object NULL = new Object();\r
+\r
/**\r
* logger for this object\r
*/\r
* cloassloader to use in test case\r
*/\r
protected CustomClassLoader cl;\r
- \r
+\r
+ /**\r
+ * {@link Executor} to provide test environment\r
+ */\r
+ protected Executor executor;\r
+\r
/**\r
* Initialize test case\r
* \r
System.setProperty( "java.protocol.handler.pkgs", "org.tizen.common.util.url" );\r
final JarClassSource source = new JarClassSource( "cp:///" + getClass().getPackage().getName().replace( '.', '/' ) + "/realm.jar" );\r
cl = new CustomClassLoader( source );\r
+\r
+ executor = new Executor( new Factory<ExecutionContext>() {\r
+ public ExecutionContext create() {\r
+ return new ExecutionContext( new PolicyRegistry(), new NopPrompter(), new VirtualFileHandler() );\r
+ }\r
+ } );\r
+ \r
+ TemplateContext.getInstance().setModelProvider( new TestTemplateModelProvider() );\r
}\r
\r
/**\r
}\r
}\r
\r
+ /**\r
+ * Test Mocking TemplateModelProvider class\r
+ */\r
+ public class\r
+ TestTemplateModelProvider\r
+ implements IModelProvider\r
+ {\r
+ protected final ExecutionContext context;\r
+\r
+ public\r
+ TestTemplateModelProvider()\r
+ {\r
+ context = executor.getContext();\r
+ }\r
+\r
+ public\r
+ TestTemplateModelProvider(\r
+ final ExecutionContext context\r
+ )\r
+ {\r
+ this.context = context;\r
+ }\r
+\r
+ public ExecutionContext getContext()\r
+ {\r
+ return this.context;\r
+ }\r
+ \r
+ @Override\r
+ public boolean isEmpty()\r
+ {\r
+ return false;\r
+ }\r
+\r
+ @Override\r
+ public Collection<String> keys()\r
+ {\r
+ throw new UnsupportedOperationException();\r
+ }\r
+\r
+ @Override\r
+ public\r
+ Object\r
+ getModel(\r
+ final String key\r
+ )\r
+ {\r
+ Object obj = context.getValue( key );\r
+ if ( NULL.equals( obj ) )\r
+ {\r
+ return null;\r
+ } else if ( null != obj )\r
+ {\r
+ return obj;\r
+ }\r
+ \r
+ obj = Preference.getValue( key, null );\r
+ if ( null != obj )\r
+ {\r
+ return obj;\r
+ }\r
+ \r
+ obj = inputFromUser( key );\r
+ \r
+ this.context.setValue( key, nvl( obj, NULL ) );\r
+ \r
+ return obj;\r
+ }\r
+\r
+ protected Object inputFromUser( final String key )\r
+ {\r
+ if ( "WidgetID".equals( key ) ) {\r
+ return "test-id";\r
+ }\r
+ // mocking ( It's like user input key "original" )\r
+ return "original";\r
+ }\r
+ }\r
}\r
import java.util.Map;\r
\r
import org.junit.Test;\r
+import org.tizen.common.verrari.realm.CompositeRealm;\r
import org.tizen.common.verrari.realm.StandardRealm;\r
\r
/**\r
final Realm realm =\r
RealmFactory.getInstance().create( new URL( "cp:///" + getClass().getPackage().getName().replace( '.', '/' ) + "/config.json" ) );\r
\r
- assertEquals( "tizen-standard-realm", realm.getAttribute( "id" ) );\r
+ if ( realm instanceof CompositeRealm ) {\r
+ Realm [] realms = ((CompositeRealm) realm).getRealm();\r
+ \r
+ for( Realm realm_element : realms ) {\r
+ assertEquals( "tizen-standard-realm", realm_element.getAttribute( "id" ) );\r
+ }\r
+ }\r
\r
}\r
}\r
--- /dev/null
+/*
+ * Verrari - Realm
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GyeongSeok Seo <gyeongseok.seo@samsung.com>
+ * BonYong Lee <bonyong.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+package org.tizen.common.verrari.realm;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import org.junit.Test;
+import org.tizen.common.verrari.AbstractTestCase;
+
+/**
+ * <p>
+ * CommonRealmTest
+ *
+ * Built-in {@link CommonRealm} to provide RI
+ *
+ * </p>
+ *
+ * @author GyeongSeok Seo{@literal <gyeongseok.seo@samsung.com>} (S-Core)
+ * @author BonYong Lee{@literal <bonyong.lee@samsung.com>} (S-Core)
+ */
+public class
+CommonRealmTest
+extends AbstractTestCase
+{
+ /**
+ * Test {@link CommonRealm#separate(String)}
+ *
+ * @throws Exception in case of failure in test
+ *
+ * @see CommonRealm#separate(String)
+ */
+ @Test
+ public void
+ test_separate()
+ throws Exception
+ {
+ String expected1 = "cp:///org/tizen/common/verrari/template/${id}.jar";
+ String expected2 = "file:///org/tizen/common/verrari/template/${id}.jar";
+ String expected3 = "http:///org/tizen/common/verrari/template/${id}.jar";
+
+ // separate to comma, colon
+ String src = expected1 + "," + expected2 + ";" + expected3;
+ String results[] = CommonRealm.separate(src);
+ assertEquals( 3, results.length );
+
+ ArrayList<String> array = new ArrayList<String>();
+ array.addAll( Arrays.asList( results ) );
+
+ assertTrue( array.contains( expected1 ) );
+ assertTrue( array.contains( expected2 ) );
+ assertTrue( array.contains( expected3 ) );
+ }
+}
--- /dev/null
+/*
+ * Verrari - Realm
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GyeongSeok Seo <gyeongseok.seo@samsung.com>
+ * BonYong Lee <bonyong.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+package org.tizen.common.verrari.realm;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.File;
+import java.net.URI;
+import java.util.Map;
+
+import org.junit.Test;
+import org.tizen.common.util.MapUtil;
+import org.tizen.common.verrari.AbstractTestCase;
+import org.tizen.common.verrari.Template;
+import org.tizen.common.verrari.TemplateContext;
+import org.tizen.common.verrari.template.FileMock;
+
+/**
+ * <p>
+ * DirectoryRealmTest
+ *
+ * Built-in {@link DirectoryRealm} to provide RI
+ *
+ * </p>
+ *
+ * @author GyeongSeok Seo{@literal <gyeongseok.seo@samsung.com>} (S-Core)
+ * @author BonYong Lee{@literal <bonyong.lee@samsung.com>} (S-Core)
+ */
+public class
+DirectoryRealmTest
+extends AbstractTestCase
+{
+ /**
+ * Test {@link DirectoryRealm#getTemplate(String)}
+ *
+ * @throws Exception in case of failure in test
+ *
+ * @see DirectoryRealm#getTemplate(String)
+ */
+ @SuppressWarnings("unchecked")
+ @Test
+ public void
+ test_getTemplate()
+ throws Exception
+ {
+ TestTemplateModelProvider modelProvider = new TestTemplateModelProvider();
+ TemplateContext.getInstance().setModelProvider( modelProvider );
+ modelProvider.getContext().setValue("id", "web-ui-fw"); // it's mock to "CreateTemplate.java - ExecutionContext.getCurrentContext().setValue( "id", name );
+
+ final DirectoryRealm realm = new DirectoryRealm() {
+ @Override
+ protected File getURItoFile(URI uri) {
+ if ( "cp:/org/tizen/common/verrari/template/web-ui-fw".equals( uri.toString() ) ){
+ return FileMock.getFileMock();
+ }
+ return super.getURItoFile(uri);
+ }
+ };
+ final Map<?, ?> attrs = MapUtil.asMap( new Object[][] {
+ new Object[] { "id", "tizen-standard-realm" },
+ new Object[] { "loader", "cp:///org/tizen/common/verrari/realm.jar" },
+ new Object[] { "template-query-url", "cp:///org/tizen/common/verrari/template/${id}" },
+ new Object[] { "search-query-url", "cp:///org/tizen/common/verrari/category" }
+ } );
+ realm.setAttributes( (Map<String, String>) attrs );
+ final Template simple = realm.getTemplate( "web-ui-fw" );
+ assertNotNull( simple );
+ }
+}
import org.tizen.common.util.MapUtil;\r
import org.tizen.common.verrari.AbstractTestCase;\r
import org.tizen.common.verrari.Template;\r
+import org.tizen.common.verrari.TemplateContext;\r
\r
/**\r
* StandardRealmTest.\r
*\r
- * Test case for {@link StandardRealm}\r
+ * Test case for {@link JarRealm}\r
*\r
* @author BonYong Lee{@literal <bonyong.lee@samsung.com>} (S-Core)\r
*\r
*\r
*/\r
public class\r
-StandardRealmTest\r
+JarRealmTest\r
extends AbstractTestCase\r
{\r
/**\r
- * Test {@link StandardRealm#getTemplate(String)}\r
+ * Test {@link JarRealm#getTemplate(String)}\r
*\r
* @throws Exception in case of failure in test\r
*\r
- * @see StandardRealm#getTemplate(String)\r
+ * @see JarRealm#getTemplate(String)\r
*/\r
@SuppressWarnings("unchecked")\r
@Test\r
public void test_getTemplate() throws Exception\r
{\r
- final StandardRealm realm = new StandardRealm();\r
+ TestTemplateModelProvider modelProvider = new TestTemplateModelProvider();\r
+ TemplateContext.getInstance().setModelProvider( modelProvider );\r
+ modelProvider.getContext().setValue("id", "simple-template"); // it's mock to "CreateTemplate.java - ExecutionContext.getCurrentContext().setValue( "id", name ); \r
+\r
+ final JarRealm realm = new JarRealm();\r
final Map<?, ?> attrs = MapUtil.asMap( new Object[][] {\r
new Object[] { "id", "tizen-standard-realm" },\r
new Object[] { "loader", "cp:///org/tizen/common/verrari/realm.jar" },\r
realm.setAttributes( (Map<String, String>) attrs );\r
final Template simple = realm.getTemplate( "simple-template" );\r
assertNotNull( simple );\r
- // TODO\r
-// final Template complex = realm.getTemplate( "complex-template" );\r
-// assertNotNull( complex );\r
+\r
+ modelProvider.getContext().setValue("id", "complex-template");\r
+ final Template complex = realm.getTemplate( "complex-template" );\r
+ assertNotNull( complex );\r
}\r
\r
}\r
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.List;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.junit.Before;
import org.junit.Test;
import org.tizen.common.file.Filter;
-import org.tizen.common.Factory;
-import org.tizen.common.config.Preference;
-import org.tizen.common.core.command.ExecutionContext;
-import org.tizen.common.core.command.Executor;
-import org.tizen.common.core.command.policy.PolicyRegistry;
-import org.tizen.common.core.command.prompter.NopPrompter;
-import org.tizen.common.file.VirtualFileHandler;
import org.tizen.common.verrari.AbstractTestCase;
import org.tizen.common.verrari.IModelProvider;
import org.tizen.common.verrari.Storage;
import static org.tizen.common.verrari.template.TemplateConstants.ATTR_EXCLUDE;
import static org.tizen.common.util.IOUtil.tryClose;
-import static org.tizen.common.util.IOUtil.getBytes;
-import static org.tizen.common.util.ObjectUtil.nvl;
/**
* DirectoryTemplateTest.
public class DirectoryTemplateTest
extends AbstractTestCase
{
- protected static final Object NULL = new Object();
protected DirectoryTemplate template = null;
protected IModelProvider models = null;
protected File rootDFileMock = null;
{
super.setUp();
- /*
- * test directory template mock setting.
- * mock directory structure, (d) directory, (f) file
- * - 0.1.1 (d)
- * - 0.1.1_Theme (d)
- * - minified (d)
- * - min.js (f)
- * - original (d)
- * - ori.js (f)
- * - META-INF (d)
- * - MANIFEST.MF (f)
- * - messages.properties (f)
- */
- // Theme mock
- File minJsFMock = mock ( File.class );
- File themeMinDMock = mock ( File.class );
- when( minJsFMock.isDirectory() ).thenReturn( false ); // theme - minified - min.js
- when( minJsFMock.getAbsolutePath() ).thenReturn( "0.1.1/0.1.1_Theme/minified/min.js" );
- when( minJsFMock.getParentFile() ).thenReturn( themeMinDMock );
- when( minJsFMock.getName() ).thenReturn( "min.js" );
- when( themeMinDMock.isDirectory() ).thenReturn( true ); // theme - minified
- when( themeMinDMock.listFiles() ).thenReturn( new File [] { minJsFMock } );
- when( themeMinDMock.getName() ).thenReturn( "minified" );
-
- File oriJsFMock = mock ( File.class );
- File themeOriDMock = mock ( File.class );
- when( oriJsFMock.isDirectory() ).thenReturn( false ); // theme - original - ori.js
- when( oriJsFMock.getAbsolutePath() ).thenReturn( "0.1.1/0.1.1_Theme/original/ori.js" );
- when( oriJsFMock.getParentFile() ).thenReturn( themeOriDMock );
- when( oriJsFMock.getName() ).thenReturn( "ori.js" );
- when( themeOriDMock.isDirectory() ).thenReturn( true ); // theme - original
- when( themeOriDMock.listFiles() ).thenReturn( new File [] { oriJsFMock } );
- when( themeOriDMock.getName() ).thenReturn( "original" );
-
- File themeDMock = mock ( File.class );
- when( themeDMock.isDirectory() ).thenReturn( true );
- when( themeDMock.listFiles() ).thenReturn( new File [] { themeMinDMock, themeOriDMock } );
- when( themeDMock.getName() ).thenReturn( "0.1.1_Theme" );
-
- // META-INF mock
- File metaDMock = mock ( File.class );
- File manifestFMock = mock ( File.class );
- when( manifestFMock.isDirectory() ).thenReturn( false );
- when( manifestFMock.getAbsolutePath() ).thenReturn( "0.1.1/META-INF/MANIFEST.MF" );
- when( manifestFMock.getParentFile() ).thenReturn( metaDMock );
- when( manifestFMock.getName() ).thenReturn( "MANIFEST.MF" );
-
- File messagesFMock = mock ( File.class );
- when( messagesFMock.isDirectory() ).thenReturn( false );
- when( messagesFMock.getAbsolutePath() ).thenReturn( "0.1.1/META-INF/messages.properties" );
- when( messagesFMock.getParentFile() ).thenReturn( metaDMock );
- when( messagesFMock.getName() ).thenReturn( "messages.properties" );
-
- when( metaDMock.isDirectory() ).thenReturn( true );
- when( metaDMock.listFiles() ).thenReturn( new File [] { manifestFMock, messagesFMock } );
- when( metaDMock.getName() ).thenReturn( "META-INF" );
-
- // root mock
- rootDFileMock = mock( File.class );
- when( rootDFileMock.isDirectory() ).thenReturn( true );
- when( rootDFileMock.getAbsolutePath() ).thenReturn( "0.1.1" );
- when( rootDFileMock.listFiles() ).thenReturn( new File [] { themeDMock, metaDMock } );
+ rootDFileMock = FileMock.getFileMock();
// test mock template class setting
this.template = new DirectoryTemplate( rootDFileMock ) {
};
// test template model setting
- final VirtualFileHandler fileHandler = new VirtualFileHandler();
- Executor executor = new Executor( new Factory<ExecutionContext>() {
- public ExecutionContext create() {
- return new ExecutionContext( new PolicyRegistry(), new NopPrompter(), fileHandler );
- }
- } );
- this.models = new TestTemplateModelProvider( executor.getContext() );
+ this.models = new TestTemplateModelProvider();
}
/**
{
super.tearDown();
}
-
- /**
- * Test Mocking TemplateModelProvider class
- */
- public class
- TestTemplateModelProvider
- implements IModelProvider
- {
- protected final ExecutionContext context;
-
- public
- TestTemplateModelProvider(
- final ExecutionContext context
- )
- {
- this.context = context;
- }
-
- @Override
- public boolean isEmpty()
- {
- return false;
- }
-
- @Override
- public Collection<String> keys()
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public
- Object
- getModel(
- final String key
- )
- {
- Object obj = context.getValue( key );
- if ( NULL.equals( obj ) )
- {
- return null;
- } else if ( null != obj )
- {
- return obj;
- }
-
- obj = Preference.getValue( key, null );
- if ( null != obj )
- {
- return obj;
- }
-
- obj = inputFromUser( key );
-
- this.context.setValue( key, nvl( obj, NULL ) );
-
- return obj;
- }
-
- protected Object inputFromUser( final String key )
- {
- if ( "WidgetID".equals( key ) ) {
- return "test-id";
- }
- // mocking ( It's like user input key "original" )
- return "original";
- }
-
- }
-
}
--- /dev/null
+/*
+ * Verrari - Realm
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GyeongSeok Seo <gyeongseok.seo@samsung.com>
+ * BonYong Lee <bonyong.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+package org.tizen.common.verrari.template;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.io.File;
+
+/**
+ * FileMock.
+ *
+ * mocking for real {@link File} class's
+ *
+ *
+ * @author GyeongSeok Seo{@literal <gyeongseok.seo@samsung.com>} (S-Core)
+ * @author BonYong Lee{@literal <bonyong.lee@samsung.com>} (S-Core)
+ *
+ * @see FileMock
+ *
+ */
+public class FileMock {
+ /**
+ * get {@link File} class's mock, It's working on real filesystem's file
+ *
+ * @return mock File
+ */
+ public static
+ File
+ getFileMock() {
+ /*
+ * test directory template mock setting.
+ * mock directory structure, (d) directory, (f) file
+ * - 0.1.1 (d)
+ * - 0.1.1_Theme (d)
+ * - minified (d)
+ * - min.js (f)
+ * - original (d)
+ * - ori.js (f)
+ * - META-INF (d)
+ * - MANIFEST.MF (f)
+ * - messages.properties (f)
+ */
+ // Theme mock
+ File minJsFMock = mock ( File.class );
+ File themeMinDMock = mock ( File.class );
+ when( minJsFMock.isDirectory() ).thenReturn( false ); // theme - minified - min.js
+ when( minJsFMock.getAbsolutePath() ).thenReturn( "0.1.1/0.1.1_Theme/minified/min.js" );
+ when( minJsFMock.getParentFile() ).thenReturn( themeMinDMock );
+ when( minJsFMock.getName() ).thenReturn( "min.js" );
+ when( themeMinDMock.isDirectory() ).thenReturn( true ); // theme - minified
+ when( themeMinDMock.listFiles() ).thenReturn( new File [] { minJsFMock } );
+ when( themeMinDMock.getName() ).thenReturn( "minified" );
+
+ File oriJsFMock = mock ( File.class );
+ File themeOriDMock = mock ( File.class );
+ when( oriJsFMock.isDirectory() ).thenReturn( false ); // theme - original - ori.js
+ when( oriJsFMock.getAbsolutePath() ).thenReturn( "0.1.1/0.1.1_Theme/original/ori.js" );
+ when( oriJsFMock.getParentFile() ).thenReturn( themeOriDMock );
+ when( oriJsFMock.getName() ).thenReturn( "ori.js" );
+ when( themeOriDMock.isDirectory() ).thenReturn( true ); // theme - original
+ when( themeOriDMock.listFiles() ).thenReturn( new File [] { oriJsFMock } );
+ when( themeOriDMock.getName() ).thenReturn( "original" );
+
+ File themeDMock = mock ( File.class );
+ when( themeDMock.isDirectory() ).thenReturn( true );
+ when( themeDMock.listFiles() ).thenReturn( new File [] { themeMinDMock, themeOriDMock } );
+ when( themeDMock.getName() ).thenReturn( "0.1.1_Theme" );
+
+ // META-INF mock
+ File metaDMock = mock ( File.class );
+ File manifestFMock = mock ( File.class );
+ when( manifestFMock.isDirectory() ).thenReturn( false );
+ when( manifestFMock.getAbsolutePath() ).thenReturn( "0.1.1/META-INF/MANIFEST.MF" );
+ when( manifestFMock.getParentFile() ).thenReturn( metaDMock );
+ when( manifestFMock.getName() ).thenReturn( "MANIFEST.MF" );
+
+ File messagesFMock = mock ( File.class );
+ when( messagesFMock.isDirectory() ).thenReturn( false );
+ when( messagesFMock.getAbsolutePath() ).thenReturn( "0.1.1/META-INF/messages.properties" );
+ when( messagesFMock.getParentFile() ).thenReturn( metaDMock );
+ when( messagesFMock.getName() ).thenReturn( "messages.properties" );
+
+ when( metaDMock.isDirectory() ).thenReturn( true );
+ when( metaDMock.listFiles() ).thenReturn( new File [] { manifestFMock, messagesFMock } );
+ when( metaDMock.getName() ).thenReturn( "META-INF" );
+
+ // root mock
+ File rootDFileMock = mock( File.class );
+ when( rootDFileMock.isDirectory() ).thenReturn( true );
+ when( rootDFileMock.getAbsolutePath() ).thenReturn( "0.1.1" );
+ when( rootDFileMock.listFiles() ).thenReturn( new File [] { themeDMock, metaDMock } );
+
+ return rootDFileMock;
+ }
+}