001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.resiliency.spi;
016    
017    import com.liferay.portal.kernel.resiliency.spi.remote.RemoteSPI;
018    
019    import java.rmi.RemoteException;
020    
021    /**
022     * @author Shuyang Zhou
023     */
024    public class MockRemoteSPI extends RemoteSPI {
025    
026            public MockRemoteSPI(SPIConfiguration spiConfiguration) {
027                    super(spiConfiguration);
028            }
029    
030            @Override
031            public void addServlet(
032                    String contextPath, String docBasePath, String mappingPattern,
033                    String servletClassName) {
034    
035                    throw new UnsupportedOperationException();
036            }
037    
038            @Override
039            public void addWebapp(String contextPath, String docBasePath) {
040                    throw new UnsupportedOperationException();
041            }
042    
043            @Override
044            public String getSPIProviderName() {
045                    return _spiProviderName;
046            }
047    
048            @Override
049            public void init() {
050                    throw new UnsupportedOperationException();
051            }
052    
053            public void setFailOnDestroy(boolean failOnDestroy) {
054                    _failOnDestroy = failOnDestroy;
055            }
056    
057            public void setFailOnStop(boolean failOnStop) {
058                    _failOnStop = failOnStop;
059            }
060    
061            public void setSpiProviderName(String spiProviderName) {
062                    _spiProviderName = spiProviderName;
063            }
064    
065            @Override
066            public void start() {
067                    throw new UnsupportedOperationException();
068            }
069    
070            @Override
071            public void stop() throws RemoteException {
072                    if (_failOnStop) {
073                            throw new RemoteException();
074                    }
075            }
076    
077            @Override
078            protected void doDestroy() throws RemoteException {
079                    if (_failOnDestroy) {
080                            throw new RemoteException();
081                    }
082            }
083    
084            private boolean _failOnDestroy;
085            private boolean _failOnStop;
086            private String _spiProviderName;
087    
088    }