*/
public class ViewRegistryTest {
@Test
public void testReadViewArchives() throws Exception {
Configuration configuration = createNiceMock(Configuration.class);
File viewDir = createNiceMock(File.class);
File extractedArchiveDir = createNiceMock(File.class);
File viewArchive = createNiceMock(File.class);
File archiveDir = createNiceMock(File.class);
File entryFile = createNiceMock(File.class);
File classesDir = createNiceMock(File.class);
File libDir = createNiceMock(File.class);
File fileEntry = createNiceMock(File.class);
JarFile viewJarFile = createNiceMock(JarFile.class);
Enumeration<JarEntry> enumeration = createMock(Enumeration.class);
JarEntry jarEntry = createNiceMock(JarEntry.class);
InputStream is = createMock(InputStream.class);
FileOutputStream fos = createMock(FileOutputStream.class);
ViewDAO vDAO = createMock(ViewDAO.class);
ViewRegistry.setViewDAO(vDAO);
ViewEntity viewDefinition = ViewEntityTest.getViewEntity();
Map<File, ViewConfig> viewConfigs =
Collections.singletonMap(viewArchive, viewDefinition.getConfiguration());
Map<String, File> files = new HashMap<String, File>();
files.put("/var/lib/ambari-server/resources/views/work", extractedArchiveDir);
files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}", archiveDir);
files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}/view.xml", entryFile);
files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}/WEB-INF/classes", classesDir);
files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}/WEB-INF/lib", libDir);
Map<File, FileOutputStream> outputStreams = new HashMap<File, FileOutputStream>();
outputStreams.put(entryFile, fos);
Map<File, JarFile> jarFiles = new HashMap<File, JarFile>();
jarFiles.put(viewArchive, viewJarFile);
// set expectations
expect(configuration.getViewsDir()).andReturn(viewDir);
expect(viewDir.getAbsolutePath()).andReturn("/var/lib/ambari-server/resources/views");
expect(viewDir.listFiles()).andReturn(new File[]{viewArchive});
expect(viewArchive.isDirectory()).andReturn(false);