| | |
| | | package com.hxh.spring.test; |
| | | |
| | | import com.yeshi.buwan.dao.HomeNoticeDao; |
| | | import com.yeshi.buwan.domain.HomeNotice; |
| | | import com.yeshi.buwan.domain.SolrVideo; |
| | | import com.yeshi.buwan.domain.VideoInfo; |
| | | import com.yeshi.buwan.dto.search.SolrResultDTO; |
| | | import com.yeshi.buwan.dto.search.SolrVideoSearchFilter; |
| | | import com.yeshi.buwan.iqiyi.util.IqiyiUtil; |
| | | import com.yeshi.buwan.service.imp.VideoInfoService; |
| | | import com.yeshi.buwan.service.manager.SolrAlbumDataManager; |
| | | import org.apache.http.auth.Credentials; |
| | | import org.apache.http.auth.UsernamePasswordCredentials; |
| | | import org.apache.solr.client.solrj.SolrClient; |
| | | import org.apache.solr.client.solrj.SolrRequest; |
| | | import org.apache.solr.client.solrj.SolrServerException; |
| | | import org.apache.solr.common.util.NamedList; |
| | | import org.apache.solr.client.solrj.impl.HttpSolrClient; |
| | | import org.junit.Test; |
| | | import org.junit.runner.RunWith; |
| | | import org.springframework.data.solr.core.SolrTemplate; |
| | | import org.springframework.data.solr.server.support.HttpSolrClientFactory; |
| | | import org.springframework.data.solr.server.support.HttpSolrClientFactoryBean; |
| | | import org.springframework.test.context.ContextConfiguration; |
| | | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; |
| | | import org.springframework.test.context.web.WebAppConfiguration; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.IOException; |
| | | import java.util.List; |
| | | import java.security.Principal; |
| | | import java.util.Optional; |
| | | |
| | | |
| | | @RunWith(SpringJUnit4ClassRunner.class) |
| | | @ContextConfiguration(locations = {"classpath:spring.xml"}) |
| | | @WebAppConfiguration |
| | | //Optional@RunWith(SpringJUnit4ClassRunner.class) |
| | | //@ContextConfiguration(locations = {"classpath:spring.xml"}) |
| | | //@WebAppConfiguration |
| | | public class SolrTest { |
| | | |
| | | @Resource |
| | |
| | | |
| | | @Test |
| | | public void addSolrAlbum() { |
| | | solrDataManager.syncAlbum("8224447"); |
| | | SolrClient solrClient=new SolrClient() { |
| | | @Override |
| | | public NamedList<Object> request(SolrRequest solrRequest, String s) throws SolrServerException, IOException { |
| | | return null; |
| | | // solrDataManager.syncAlbum("8224447"); |
| | | SolrClient solrClient = new HttpSolrClient.Builder("http://203.195.196.115:8983/solr").build(); |
| | | Credentials credentials = new UsernamePasswordCredentials("solr", "IV0EHq1OnNrj6gvRCwvFwTrZ1+z1oBbnQdiVC3otuq0= Ndd7LKvVBAaZIF0QAVi1ekCfAJXr1GGfLtRUXhgrF8c="); |
| | | HttpSolrClientFactory factory = new HttpSolrClientFactory(solrClient, null, null); |
| | | SolrTemplate solrTemplate = new SolrTemplate(factory); |
| | | solrTemplate.afterPropertiesSet(); |
| | | Optional<SolrVideo> solrVideoOptional = solrTemplate.getById("buwan_album", "8077525", SolrVideo.class); |
| | | System.out.println(solrVideoOptional); |
| | | } |
| | | |
| | | @Override |
| | | public void close() throws IOException { |
| | | |
| | | } |
| | | }; |
| | | Credentials credentials=new Credentials(); |
| | | HttpSolrClientFactory factory=new HttpSolrClientFactory(); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |