Example usage for java.lang IllegalStateException getMessage

List of usage examples for java.lang IllegalStateException getMessage

Introduction

In this page you can find the example usage for java.lang IllegalStateException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.jahia.bundles.extender.jahiamodules.Activator.java

@Override
public void stop(BundleContext context) throws Exception {

    logger.info("== Stopping DX Extender ============================================================== ");
    long startTime = System.currentTimeMillis();

    if (fileInstallConfigurer != null) {
        fileInstallConfigurer.stop();//from  w w  w.j  a v a2s .co  m
        fileInstallConfigurer = null;
    }

    context.removeBundleListener(bundleListener);

    bundleListener = null;

    for (Iterator<ServiceRegistration<?>> iterator = serviceRegistrations.iterator(); iterator.hasNext();) {
        try {
            iterator.next().unregister();
        } catch (IllegalStateException e) {
            logger.warn(e.getMessage());
        } finally {
            iterator.remove();
        }
    }

    // Ensure all trackers are correctly closed - should be empty now
    for (Iterator<ServiceTracker<HttpService, HttpService>> iterator = bundleHttpServiceTrackers.values()
            .iterator(); iterator.hasNext();) {
        iterator.next().close();
        iterator.remove();
    }

    long totalTime = System.currentTimeMillis() - startTime;
    logger.info(
            "== DX Extender stopped in {}ms ============================================================== ",
            totalTime);
}

From source file:net.kevxu.purdueassist.course.ScheduleDetail.java

@Override
public void onRequestFinished(HttpResponse httpResponse) {
    try {/*from   www .  j  a v  a2  s . c o  m*/
        InputStream stream = httpResponse.getEntity().getContent();
        Header encoding = httpResponse.getEntity().getContentEncoding();
        Document document;
        if (encoding == null) {
            document = Jsoup.parse(stream, null, URL_HEAD);
        } else {
            document = Jsoup.parse(stream, encoding.getValue(), URL_HEAD);
        }
        stream.close();
        ScheduleDetailEntry entry = parseDocument(document);
        mListener.onScheduleDetailFinished(entry);
    } catch (IllegalStateException e) {
        e.printStackTrace();
    } catch (IOException e) {
        mListener.onScheduleDetailFinished(e);
    } catch (HtmlParseException e) {
        mListener.onScheduleDetailFinished(e);
    } catch (CourseNotFoundException e) {
        mListener.onScheduleDetailFinished(e, term, crn);
    } catch (ResultNotMatchException e) {
        mListener.onScheduleDetailFinished(new HtmlParseException(e.getMessage()));
    } catch (Exception e) {
        mListener.onScheduleDetailFinished(e);
    } finally {
        this.requestFinished = true;
    }
}

From source file:org.opencastproject.index.service.impl.IndexServiceImpl.java

/**
 * Get a single event/* w  ww .ja  v  a 2  s.  c om*/
 *
 * @param id
 *          the mediapackage id
 * @return an event or none if not found wrapped in an option
 * @throws SearchIndexException
 */
@Override
public Opt<Event> getEvent(String id, AbstractSearchIndex index) throws InternalServerErrorException {
    SearchResult<Event> result;
    try {
        result = index.getByQuery(new EventSearchQuery(getSecurityService().getOrganization().getId(),
                getSecurityService().getUser()).withIdentifier(id));
        // If the results list if empty, we return already a response.
        if (result.getPageSize() == 0) {
            logger.debug("Didn't find event with id {}", id);
            return Opt.<Event>none();
        }
        return Opt.some(result.getItems()[0].getSource());
    } catch (IllegalStateException e) {
        logger.error("Unable to get event with id {} because {}", id, ExceptionUtils.getStackTrace(e));
        throw new InternalServerErrorException(e.getMessage(), e);
    } catch (SearchIndexException e) {
        logger.error("Unable to get event with id {} because {}", id, ExceptionUtils.getStackTrace(e));
        throw new InternalServerErrorException(e.getMessage(), e);
    }
}

From source file:zsk.YTDownloadThread.java

boolean downloadone(String sURL) {
    boolean rc = false;
    boolean rc204 = false;
    boolean rc302 = false;

    this.iRecursionCount++;

    // stop recursion
    try {/*  w  ww.  j ava2 s  . c o  m*/
        if (sURL.equals(""))
            return (false);
    } catch (NullPointerException npe) {
        return (false);
    }
    if (JFCMainClient.getbQuitrequested())
        return (false); // try to get information about application shutdown

    debugoutput("start.");

    // TODO GUI option for proxy?
    // http://wiki.squid-cache.org/ConfigExamples/DynamicContent/YouTube
    // using local squid to save download time for tests

    try {
        // determine http_proxy environment variable
        if (!this.getProxy().equals("")) {

            String sproxy = JFCMainClient.sproxy.toLowerCase().replaceFirst("http://", "");
            this.proxy = new HttpHost(sproxy.replaceFirst(":(.*)", ""),
                    Integer.parseInt(sproxy.replaceFirst("(.*):", "")), "http");

            SchemeRegistry supportedSchemes = new SchemeRegistry();
            supportedSchemes.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
            supportedSchemes.register(new Scheme("https", 443, SSLSocketFactory.getSocketFactory()));

            HttpParams params = new BasicHttpParams();
            HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
            HttpProtocolParams.setContentCharset(params, "UTF-8");
            HttpProtocolParams.setUseExpectContinue(params, true);

            ClientConnectionManager ccm = new PoolingClientConnectionManager(supportedSchemes);

            // with proxy
            this.httpclient = new DefaultHttpClient(ccm, params);
            this.httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, this.proxy);
            this.httpclient.getParams().setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.BEST_MATCH);
        } else {
            // without proxy
            this.httpclient = new DefaultHttpClient();
            this.httpclient.getParams().setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.BEST_MATCH);
        }
        this.httpget = new HttpGet(getURI(sURL));
        if (sURL.toLowerCase().startsWith("https"))
            this.target = new HttpHost(getHost(sURL), 443, "https");
        else
            this.target = new HttpHost(getHost(sURL), 80, "http");
    } catch (Exception e) {
        debugoutput(e.getMessage());
    }

    debugoutput("executing request: ".concat(this.httpget.getRequestLine().toString()));
    debugoutput("uri: ".concat(this.httpget.getURI().toString()));
    debugoutput("host: ".concat(this.target.getHostName()));
    debugoutput("using proxy: ".concat(this.getProxy()));

    // we dont need cookies at all because the download runs even without it (like my wget does) - in fact it blocks downloading videos from different webpages, because we do not handle the bcs for every URL (downloading of one video with different resolutions does work)
    /*
    this.localContext = new BasicHttpContext();
    if (this.bcs == null) this.bcs = new BasicCookieStore(); // make cookies persistent, otherwise they would be stored in a HttpContext but get lost after calling org.apache.http.impl.client.AbstractHttpClient.execute(HttpHost target, HttpRequest request, HttpContext context)
    ((DefaultHttpClient) httpclient).setCookieStore(this.bcs); // cast to AbstractHttpclient would be best match because DefaultHttpClass is a subclass of AbstractHttpClient
    */

    // TODO maybe we save the video IDs+res that were downloaded to avoid downloading the same video again?

    try {
        this.response = this.httpclient.execute(this.target, this.httpget, this.localContext);
    } catch (ClientProtocolException cpe) {
        debugoutput(cpe.getMessage());
    } catch (UnknownHostException uhe) {
        output((JFCMainClient.isgerman() ? "Fehler bei der Verbindung zu: " : "error connecting to: ")
                .concat(uhe.getMessage()));
        debugoutput(uhe.getMessage());
    } catch (IOException ioe) {
        debugoutput(ioe.getMessage());
    } catch (IllegalStateException ise) {
        debugoutput(ise.getMessage());
    }

    /*
    CookieOrigin cookieOrigin = (CookieOrigin) localContext.getAttribute( ClientContext.COOKIE_ORIGIN);
    CookieSpec cookieSpec = (CookieSpec) localContext.getAttribute( ClientContext.COOKIE_SPEC);
    CookieStore cookieStore = (CookieStore) localContext.getAttribute( ClientContext.COOKIE_STORE) ;
    try { debugoutput("HTTP Cookie store: ".concat( cookieStore.getCookies().toString( )));
    } catch (NullPointerException npe) {} // useless if we don't set our own CookieStore before calling httpclient.execute
    try {
       debugoutput("HTTP Cookie origin: ".concat(cookieOrigin.toString()));
       debugoutput("HTTP Cookie spec used: ".concat(cookieSpec.toString()));
       debugoutput("HTTP Cookie store (persistent): ".concat(this.bcs.getCookies().toString()));
    } catch (NullPointerException npe) {
    }
    */

    try {
        debugoutput("HTTP response status line:".concat(this.response.getStatusLine().toString()));
        //for (int i = 0; i < response.getAllHeaders().length; i++) {
        //   debugoutput(response.getAllHeaders()[i].getName().concat("=").concat(response.getAllHeaders()[i].getValue()));
        //}

        // abort if HTTP response code is != 200, != 302 and !=204 - wrong URL?
        if (!(rc = this.response.getStatusLine().toString().toLowerCase().matches("^(http)(.*)200(.*)"))
                & !(rc204 = this.response.getStatusLine().toString().toLowerCase()
                        .matches("^(http)(.*)204(.*)"))
                & !(rc302 = this.response.getStatusLine().toString().toLowerCase()
                        .matches("^(http)(.*)302(.*)"))) {
            debugoutput(this.response.getStatusLine().toString().concat(" ").concat(sURL));
            output(this.response.getStatusLine().toString().concat(" \"").concat(this.sTitle).concat("\""));
            return (rc & rc204 & rc302);
        }
        if (rc204) {
            debugoutput("last response code==204 - download: ".concat(this.vNextVideoURL.get(0).getsYTID()));
            rc = downloadone(this.vNextVideoURL.get(0).getsURL());
            return (rc);
        }
        if (rc302)
            debugoutput(
                    "location from HTTP Header: ".concat(this.response.getFirstHeader("Location").toString()));

    } catch (NullPointerException npe) {
        // if an IllegalStateException was catched while calling httpclient.execute(httpget) a NPE is caught here because
        // response.getStatusLine() == null
        this.sVideoURL = null;
    }

    HttpEntity entity = null;
    try {
        entity = this.response.getEntity();
    } catch (NullPointerException npe) {
    }

    // try to read HTTP response body
    if (entity != null) {
        try {
            if (this.response.getFirstHeader("Content-Type").getValue().toLowerCase().matches("^text/html(.*)"))
                this.textreader = new BufferedReader(new InputStreamReader(entity.getContent()));
            else
                this.binaryreader = new BufferedInputStream(entity.getContent());
        } catch (IllegalStateException e1) {
            e1.printStackTrace();
        } catch (IOException e1) {
            e1.printStackTrace();
        }
        try {
            // test if we got a webpage
            this.sContentType = this.response.getFirstHeader("Content-Type").getValue().toLowerCase();
            if (this.sContentType.matches("^text/html(.*)")) {
                rc = savetextdata();
                // test if we got the binary content
            } else if (this.sContentType.matches("video/(.)*")) {
                if (JFCMainClient.getbNODOWNLOAD())
                    reportheaderinfo();
                else
                    savebinarydata();
            } else { // content-type is not video/
                rc = false;
                this.sVideoURL = null;
            }
        } catch (IOException ex) {
            try {
                throw ex;
            } catch (IOException e) {
                e.printStackTrace();
            }
        } catch (RuntimeException ex) {
            try {
                throw ex;
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    } //if (entity != null)

    this.httpclient.getConnectionManager().shutdown();

    debugoutput("done: ".concat(sURL));
    if (this.sVideoURL == null)
        this.sVideoURL = ""; // to prevent NPE

    if (!this.sVideoURL.matches(JFCMainClient.szURLREGEX)) {
        // no more recursion - html source hase been read
        // test !rc than video could not downloaded because of some error (like wrong protocol or restriction)
        if (!rc) {
            debugoutput("cannot download video - URL does not seem to be valid or could not be found: "
                    .concat(this.sURL));
            output(JFCMainClient.isgerman()
                    ? "es gab ein Problem die Video URL zu finden! evt. wegen Landesinschrnkung?!"
                    : "there was a problem getting the video URL! perhaps not allowed in your country?!");
            output((JFCMainClient.isgerman() ? "erwge die URL dem Autor mitzuteilen!"
                    : "consider reporting the URL to author! - ").concat(this.sURL));
            this.sVideoURL = null;
        }
    } else {
        // enter recursion - download video resource
        debugoutput("try to download video from URL: ".concat(this.sVideoURL));
        rc = downloadone(this.sVideoURL);
    }
    this.sVideoURL = null;

    return (rc);

}

From source file:com.chiorichan.http.HttpRequestWrapper.java

HttpRequestWrapper(Channel channel, HttpRequest http, HttpHandler handler, boolean ssl, LogEvent log)
        throws IOException {
    this.channel = channel;
    this.http = http;
    this.handler = handler;
    this.ssl = ssl;
    this.log = log;

    putRequest(this);

    // Set Time of this Request
    requestTime = Timings.epoch();//from w w  w .j av  a  2 s  . co  m

    // Create a matching HttpResponseWrapper
    response = new HttpResponseWrapper(this, log);

    String host = getHostDomain();

    if (host == null || host.length() == 0) {
        parentDomain = "";
        site = SiteManager.instance().getDefaultSite();
    } else if (NetworkFunc.isValidIPv4(host) || NetworkFunc.isValidIPv6(host)) {
        parentDomain = host;
        site = SiteManager.instance().getSiteByIp(host).get(0);
    } else {
        Pair<String, SiteMapping> match = SiteMapping.get(host);

        if (match == null) {
            parentDomain = host;
            site = SiteManager.instance().getDefaultSite();
        } else {
            parentDomain = match.getKey();
            Namespace hostNamespace = new Namespace(host);
            Namespace parentNamespace = new Namespace(parentDomain);
            Namespace childNamespace = hostNamespace.subNamespace(0,
                    hostNamespace.getNodeCount() - parentNamespace.getNodeCount());
            assert hostNamespace.getNodeCount() - parentNamespace.getNodeCount() == childNamespace
                    .getNodeCount();
            childDomain = childNamespace.getNamespace();

            site = match.getValue().getSite();
        }
    }

    if (site == null)
        site = SiteManager.instance().getDefaultSite();

    if (site == SiteManager.instance().getDefaultSite() && getUri().startsWith("/~")) {
        List<String> uris = Splitter.on("/").omitEmptyStrings().splitToList(getUri());
        String siteId = uris.get(0).substring(1);

        Site siteTmp = SiteManager.instance().getSiteById(siteId);
        if (!siteId.equals("wisp") && siteTmp != null) {
            site = siteTmp;
            uri = "/" + Joiner.on("/").join(uris.subList(1, uris.size()));

            // TODO Implement both a virtual and real URI for use in redirects and url_to()
            String[] domains = site.getDomains().keySet().toArray(new String[0]);
            parentDomain = domains.length == 0 ? host : domains[0];
        }
    }

    // log.log( Level.INFO, "SiteId: " + site.getSiteId() + ", ParentDomain: " + parentDomain + ", ChildDomain: " + childDomain );

    try {
        QueryStringDecoder queryStringDecoder = new QueryStringDecoder(http.uri());
        Map<String, List<String>> params = queryStringDecoder.parameters();
        if (!params.isEmpty())
            for (Entry<String, List<String>> p : params.entrySet()) {
                // XXX This is overriding the key, why would their there be multiple values???
                String key = p.getKey();
                List<String> vals = p.getValue();
                for (String val : vals)
                    getMap.put(key, val);
            }
    } catch (IllegalStateException e) {
        log.log(Level.SEVERE, "Failed to decode the GET map because " + e.getMessage());
    }

    // Decode Cookies
    // String var1 = URLDecoder.decode( http.headers().getAndConvert( "Cookie" ), Charsets.UTF_8.displayName() );
    String var1 = http.headers().getAndConvert("Cookie");

    // TODO Find a way to fix missing invalid stuff

    if (var1 != null)
        try {
            Set<Cookie> var2 = CookieDecoder.decode(var1);
            for (Cookie cookie : var2)
                if (cookie.name().startsWith("_ws"))
                    serverCookies.add(new HttpCookie(cookie));
                else
                    cookies.add(new HttpCookie(cookie));
        } catch (IllegalArgumentException | NullPointerException e) {
            //NetworkManager.getLogger().debug( var1 );

            NetworkManager.getLogger().severe("Failed to parse cookie for reason: " + e.getMessage());
            // NetworkManager.getLogger().warning( "There was a problem decoding the request cookie.", e );
            // NetworkManager.getLogger().debug( "Cookie: " + var1 );
            // NetworkManager.getLogger().debug( "Headers: " + Joiner.on( "," ).withKeyValueSeparator( "=" ).join( http.headers() ) );
        }

    initServerVars();
}

From source file:org.nuxeo.ecm.core.storage.dbs.DBSDocument.java

@Override
public Map<String, Serializable> readPrefetch(ComplexType complexType, Set<String> xpaths)
        throws PropertyException {
    DBSDocumentState docState = getStateMaybeProxyTarget(complexType);
    Map<String, Serializable> prefetch = new HashMap<String, Serializable>();
    for (String xpath : xpaths) {
        try {/* www  . ja v a 2  s .c  om*/
            readPrefetch(complexType, docState.getState(), xpath, 0, prefetch);
        } catch (IllegalStateException e) {
            throw new IllegalStateException(e.getMessage() + " xpath=" + xpath + ", data=" + docState, e);
        }
    }
    return prefetch;
}

From source file:org.finra.herd.service.helper.notification.BusinessObjectDataStatusChangeMessageBuilderTest.java

@Test
public void testBuildBusinessObjectDataStatusChangeMessagesJsonPayloadNoMessageType() throws Exception {
    // Create a business object data entity.
    BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataServiceTestHelper
            .createTestValidBusinessObjectData(SUBPARTITION_VALUES, NO_ATTRIBUTE_DEFINITIONS, NO_ATTRIBUTES);

    // Get a business object data key.
    BusinessObjectDataKey businessObjectDataKey = businessObjectDataHelper
            .getBusinessObjectDataKey(businessObjectDataEntity);

    // Override configuration.
    ConfigurationEntity configurationEntity = new ConfigurationEntity();
    configurationEntity/*from   w  ww .j ava 2s  .  c om*/
            .setKey(ConfigurationValue.HERD_NOTIFICATION_BUSINESS_OBJECT_DATA_STATUS_CHANGE_MESSAGE_DEFINITIONS
                    .getKey());
    configurationEntity.setValueClob(xmlHelper.objectToXml(new NotificationMessageDefinitions(
            Collections.singletonList(new NotificationMessageDefinition(NO_MESSAGE_TYPE, MESSAGE_DESTINATION,
                    BUSINESS_OBJECT_DATA_STATUS_CHANGE_NOTIFICATION_MESSAGE_VELOCITY_TEMPLATE_JSON,
                    NO_MESSAGE_HEADER_DEFINITIONS)))));
    configurationDao.saveAndRefresh(configurationEntity);

    // Try to build a notification message.
    try {
        businessObjectDataStatusChangeMessageBuilder.buildNotificationMessages(
                new BusinessObjectDataStatusChangeNotificationEvent(businessObjectDataKey, BDATA_STATUS,
                        BDATA_STATUS_2));
        fail();
    } catch (IllegalStateException e) {
        assertEquals(String.format(
                "Notification message type must be specified. Please update \"%s\" configuration entry.",
                ConfigurationValue.HERD_NOTIFICATION_BUSINESS_OBJECT_DATA_STATUS_CHANGE_MESSAGE_DEFINITIONS
                        .getKey()),
                e.getMessage());
    }
}

From source file:org.finra.herd.service.helper.notification.BusinessObjectDataStatusChangeMessageBuilderTest.java

@Test
public void testBuildBusinessObjectDataStatusChangeMessagesJsonPayloadNoMessageDestination() throws Exception {
    // Create a business object data entity.
    BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataServiceTestHelper
            .createTestValidBusinessObjectData(SUBPARTITION_VALUES, NO_ATTRIBUTE_DEFINITIONS, NO_ATTRIBUTES);

    // Get a business object data key.
    BusinessObjectDataKey businessObjectDataKey = businessObjectDataHelper
            .getBusinessObjectDataKey(businessObjectDataEntity);

    // Override configuration.
    ConfigurationEntity configurationEntity = new ConfigurationEntity();
    configurationEntity/*  w  w  w.j a va 2 s  .  co m*/
            .setKey(ConfigurationValue.HERD_NOTIFICATION_BUSINESS_OBJECT_DATA_STATUS_CHANGE_MESSAGE_DEFINITIONS
                    .getKey());
    configurationEntity.setValueClob(xmlHelper.objectToXml(new NotificationMessageDefinitions(Collections
            .singletonList(new NotificationMessageDefinition(MESSAGE_TYPE_SNS, NO_MESSAGE_DESTINATION,
                    BUSINESS_OBJECT_DATA_STATUS_CHANGE_NOTIFICATION_MESSAGE_VELOCITY_TEMPLATE_JSON,
                    NO_MESSAGE_HEADER_DEFINITIONS)))));
    configurationDao.saveAndRefresh(configurationEntity);

    // Try to build a notification message.
    try {
        businessObjectDataStatusChangeMessageBuilder.buildNotificationMessages(
                new BusinessObjectDataStatusChangeNotificationEvent(businessObjectDataKey, BDATA_STATUS,
                        BDATA_STATUS_2));
        fail();
    } catch (IllegalStateException e) {
        assertEquals(String.format(
                "Notification message destination must be specified. Please update \"%s\" configuration entry.",
                ConfigurationValue.HERD_NOTIFICATION_BUSINESS_OBJECT_DATA_STATUS_CHANGE_MESSAGE_DEFINITIONS
                        .getKey()),
                e.getMessage());
    }
}

From source file:org.opendaylight.vtn.manager.internal.util.vnode.VTNMacMapStatusTest.java

/**
 * Test case for {@link VTNMacMapStatus#VTNMacMapStatus()} and
 * {@link VTNMacMapStatus#VTNMacMapStatus(MacMapStatus)}.
 *//*from   ww w  . jav a 2 s.  c om*/
@Test
public void testConstructor() {
    // Test case for an empty instance.
    VTNMacMapStatus vmst = new VTNMacMapStatus();
    MacMapStatus empty = new MacMapStatusBuilder().build();
    assertEquals(empty, vmst.toMacMapStatus());
    assertFalse(vmst.isDirty());

    vmst = new VTNMacMapStatus(null);
    assertEquals(empty, vmst.toMacMapStatus());
    assertFalse(vmst.isDirty());

    vmst = new VTNMacMapStatus(empty);
    assertEquals(empty, vmst.toMacMapStatus());
    assertFalse(vmst.isDirty());

    HostMap hostMap = new HostMap();
    MacVlan[] hosts = { new MacVlan(0x001122334455L, 0), new MacVlan(0xfeffabcdef00L, 0),
            new MacVlan(0xfeffabcdef05L, 1), new MacVlan(0xfeffabcdef0aL, 100),
            new MacVlan(0xfeffabcdefffL, 123), new MacVlan(0x000000000001L, 4094),
            new MacVlan(0x00000000000aL, 4094), new MacVlan(0xfc927ace41d7L, 4095), };

    List<MappedHost> mhosts = new ArrayList<>();
    for (MacVlan mv : hosts) {
        SalPort sport = getPort();
        hostMap.put(mv, sport);

        MappedHost mhost = new MappedHostBuilder().setMacAddress(mv.getMacAddress())
                .setPortId(sport.getNodeConnectorId()).setVlanId(new VlanId(mv.getVlanId())).build();
        mhosts.add(mhost);
        MacMapStatus mst = new MacMapStatusBuilder().setMappedHost(mhosts).build();
        vmst = new VTNMacMapStatus(mst);
        hostMap.verify(vmst.toMacMapStatus());

        // Add one more host at the same port.
        long mac = mv.getAddress();
        MacVlan newMv = new MacVlan(mac + 1L, mv.getVlanId());
        hostMap.put(newMv, sport);

        mhost = new MappedHostBuilder().setMacAddress(newMv.getMacAddress())
                .setPortId(sport.getNodeConnectorId()).setVlanId(new VlanId(newMv.getVlanId())).build();
        mhosts.add(mhost);
        mst = new MacMapStatusBuilder().setMappedHost(mhosts).build();
        vmst = new VTNMacMapStatus(mst);
        hostMap.verify(vmst.toMacMapStatus());
    }

    // Test case for invalid mac-map-status.
    MappedHost mhost = new MappedHostBuilder().build();
    mhosts = Collections.singletonList(mhost);
    MacMapStatus mst = new MacMapStatusBuilder().setMappedHost(mhosts).build();
    try {
        new VTNMacMapStatus(mst);
        unexpected();
    } catch (IllegalStateException e) {
        Throwable cause = e.getCause();
        assertEquals(NullPointerException.class, cause.getClass());
        String msg = "Unable to cache mac-map-status: " + cause.getMessage();
        assertEquals(msg, e.getMessage());
    }
}