Search in sources :

Example 16 with CacheEntry

use of com.att.aro.core.packetanalysis.pojo.CacheEntry in project VideoOptimzer by attdevsupport.

the class CacheControlImplTest method runTest_resTypeIsPass.

@Test
public void runTest_resTypeIsPass() {
    List<CacheEntry> diagnosisResults = new ArrayList<CacheEntry>();
    Mockito.when(entryArray[0].getDiagnosis()).thenReturn(Diagnosis.CACHING_DIAG_CACHE_MISSED);
    diagnosisResults.add(entryArray[0]);
    Mockito.when(cacheAnalysis.getDiagnosisResults()).thenReturn(diagnosisResults);
    Mockito.when(tracedata.getCacheAnalysis()).thenReturn(cacheAnalysis);
    cacheControlImpl = (CacheControlImpl) context.getBean("cacheControl");
    AbstractBestPracticeResult testResult = cacheControlImpl.runTest(tracedata);
    assertEquals(BPResultType.PASS, testResult.getResultType());
}
Also used : ArrayList(java.util.ArrayList) AbstractBestPracticeResult(com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult) CacheEntry(com.att.aro.core.packetanalysis.pojo.CacheEntry) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Example 17 with CacheEntry

use of com.att.aro.core.packetanalysis.pojo.CacheEntry in project VideoOptimzer by attdevsupport.

the class DuplicateContentTablePanel method getJDuplicateContentTable.

/**
 * Initializes and returns the RequestResponseTable.
 */
public DataTable<CacheEntry> getJDuplicateContentTable() {
    if (duplicateContentTable == null) {
        duplicateContentTable = new DataTable<CacheEntry>(duplicateContentTableModel);
        duplicateContentTable.setName(ResourceBundleHelper.getMessageString("overview.duplicate.content.tableName"));
        duplicateContentTable.setAutoCreateRowSorter(true);
        duplicateContentTable.setGridColor(Color.LIGHT_GRAY);
        duplicateContentTable.addMouseListener(this);
        duplicateContentTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

            @Override
            public void valueChanged(ListSelectionEvent listEvent) {
                CacheEntry entry = duplicateContentTable.getSelectedItem();
                HttpRequestResponseInfo rrInfo = entry != null ? entry.getResponse() : null;
                boolean enabled = rrInfo != null && rrInfo.getContentLength() > 0 && rrInfo.getDirection() == HttpDirection.RESPONSE && entry != null && entry.getSession() != null;
                boolean isContentTypeVideo = (rrInfo != null && rrInfo.getContentType() != null) ? rrInfo.getContentType().contains("video/") : false;
                boolean bVideo = enabled ? isContentTypeVideo : false;
                getViewBtn().setEnabled((bVideo) ? false : enabled);
                getSaveBtn().setEnabled(enabled);
            }
        });
        DataTablePopupMenu popupMenu = (DataTablePopupMenu) duplicateContentTable.getPopup();
        popupMenu.initialize();
    }
    DataTablePopupMenu popupMenu = (DataTablePopupMenu) duplicateContentTable.getPopup();
    popupMenu.initialize();
    return duplicateContentTable;
}
Also used : HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) ListSelectionEvent(javax.swing.event.ListSelectionEvent) DataTablePopupMenu(com.att.aro.ui.model.DataTablePopupMenu) CacheEntry(com.att.aro.core.packetanalysis.pojo.CacheEntry) ListSelectionListener(javax.swing.event.ListSelectionListener)

Example 18 with CacheEntry

use of com.att.aro.core.packetanalysis.pojo.CacheEntry in project VideoOptimzer by attdevsupport.

the class DuplicateContentTablePanel method getSaveBtn.

/**
 * Returns the save button.
 */
private JButton getSaveBtn() {
    if (saveBtn == null) {
        saveBtn = new JButton(ResourceBundleHelper.getMessageString("button.Save"));
        saveBtn.setEnabled(false);
        saveBtn.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent arg0) {
                CacheEntry entry = duplicateContentTable.getSelectedItem();
                if (entry != null) {
                    ContentViewer.getInstance().saveContent(DuplicateContentTablePanel.this.getTopLevelAncestor(), entry.getSession(), entry.getResponse());
                }
            }
        });
    }
    return saveBtn;
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) CacheEntry(com.att.aro.core.packetanalysis.pojo.CacheEntry)

Example 19 with CacheEntry

use of com.att.aro.core.packetanalysis.pojo.CacheEntry in project VideoOptimzer by attdevsupport.

the class DuplicateContentTablePanel method getViewBtn.

/**
 * Returns the view button.
 */
private JButton getViewBtn() {
    if (viewBtn == null) {
        viewBtn = new JButton(ResourceBundleHelper.getMessageString("button.View"));
        viewBtn.setEnabled(false);
        viewBtn.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent arg0) {
                try {
                    CacheEntry cEntry = duplicateContentTable.getSelectedItem();
                    if (cEntry != null) {
                        if (!cEntry.getResponse().getContentType().contains("video")) {
                            if (cEntry.getResponse().getRawSize() < 5242880) {
                                ContentViewer.getInstance().viewContent(getSession(cEntry), cEntry.getResponse());
                            } else {
                                MessageDialogFactory.getInstance().showErrorDialog(new Window(new Frame()), ResourceBundleHelper.getMessageString("Error.fileSize"));
                            }
                        }
                    }
                } catch (Exception ioExp) {
                    MessageDialogFactory.showMessageDialog(DuplicateContentTablePanel.this.getTopLevelAncestor(), ioExp);
                }
            }

            private Session getSession(CacheEntry cEntry) {
                Session session = cEntry.getRequest().getSession();
                if (session == null) {
                    session = cEntry.getSession();
                }
                return session;
            }
        });
    }
    return viewBtn;
}
Also used : Window(java.awt.Window) Frame(java.awt.Frame) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) CacheEntry(com.att.aro.core.packetanalysis.pojo.CacheEntry) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 20 with CacheEntry

use of com.att.aro.core.packetanalysis.pojo.CacheEntry in project VideoOptimzer by attdevsupport.

the class DuplicateContentTablePanel method mousePressed.

@Override
public void mousePressed(MouseEvent event) {
    if (event.getClickCount() == 2) {
        if (event.getSource() instanceof JTable) {
            int selectionIndex = ((JTable) event.getSource()).getSelectedRow();
            int original = ((JTable) event.getSource()).convertRowIndexToModel(selectionIndex);
            logger.info("selectionIndex: " + selectionIndex);
            if (selectionIndex != -1) {
                CacheEntry cacheEntry = duplicateContentTableModel.getValueAt(original);
                overviewTab.updateDiagnosticsTab(cacheEntry);
            }
        }
    }
}
Also used : JTable(javax.swing.JTable) CacheEntry(com.att.aro.core.packetanalysis.pojo.CacheEntry)

Aggregations

CacheEntry (com.att.aro.core.packetanalysis.pojo.CacheEntry)23 ArrayList (java.util.ArrayList)7 BaseTest (com.att.aro.core.BaseTest)6 AbstractBestPracticeResult (com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult)6 Test (org.junit.Test)6 HttpRequestResponseInfo (com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo)4 DuplicateEntry (com.att.aro.core.packetanalysis.pojo.DuplicateEntry)3 Session (com.att.aro.core.packetanalysis.pojo.Session)3 CacheAnalysis (com.att.aro.core.packetanalysis.pojo.CacheAnalysis)2 Diagnosis (com.att.aro.core.packetanalysis.pojo.Diagnosis)2 PacketInfo (com.att.aro.core.packetanalysis.pojo.PacketInfo)2 DataTablePopupMenu (com.att.aro.ui.model.DataTablePopupMenu)2 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 JButton (javax.swing.JButton)2 CacheControlResult (com.att.aro.core.bestpractice.pojo.CacheControlResult)1 DisplayNoneInCSSEntry (com.att.aro.core.bestpractice.pojo.DisplayNoneInCSSEntry)1 DuplicateContentResult (com.att.aro.core.bestpractice.pojo.DuplicateContentResult)1