Search in sources :

Example 71 with MessageImpl

use of org.apache.cxf.message.MessageImpl in project cxf by apache.

the class SearchContextImplTest method doTestFiqlSearchBean.

private void doTestFiqlSearchBean(String queryString) {
    Message m = new MessageImpl();
    m.put(Message.QUERY_STRING, queryString);
    SearchContext context = new SearchContextImpl(m);
    SearchCondition<SearchBean> sc = context.getCondition(SearchBean.class);
    assertNotNull(sc);
    List<SearchBean> beans = new ArrayList<>();
    SearchBean sb1 = new SearchBean();
    sb1.set("name", "CXF is cool");
    beans.add(sb1);
    SearchBean sb2 = new SearchBean();
    sb2.set("name", "CXF Rocks");
    sb2.set("id", "124");
    beans.add(sb2);
    List<SearchBean> found = sc.findAll(beans);
    assertEquals(1, found.size());
    assertEquals(sb2, found.get(0));
    assertTrue(sc instanceof AndSearchCondition);
    assertNull(sc.getStatement());
    List<SearchCondition<SearchBean>> scs = sc.getSearchConditions();
    assertEquals(2, scs.size());
    SearchCondition<SearchBean> sc1 = scs.get(0);
    assertEquals("name", sc1.getStatement().getProperty());
    SearchCondition<SearchBean> sc2 = scs.get(1);
    assertEquals("id", sc2.getStatement().getProperty());
    assertTrue("123".equals(sc1.getStatement().getValue()) && "CXF Rocks".equals(sc2.getStatement().getValue()) || "123".equals(sc2.getStatement().getValue()) && "CXF Rocks".equals(sc1.getStatement().getValue()));
}
Also used : Message(org.apache.cxf.message.Message) ArrayList(java.util.ArrayList) MessageImpl(org.apache.cxf.message.MessageImpl)

Example 72 with MessageImpl

use of org.apache.cxf.message.MessageImpl in project cxf by apache.

the class SearchContextImplTest method testWrongQueryException.

@Test(expected = SearchParseException.class)
public void testWrongQueryException() {
    Message m = new MessageImpl();
    m.put(Message.QUERY_STRING, "_s=ab");
    new SearchContextImpl(m).getCondition(Book.class);
}
Also used : Message(org.apache.cxf.message.Message) MessageImpl(org.apache.cxf.message.MessageImpl) Test(org.junit.Test)

Example 73 with MessageImpl

use of org.apache.cxf.message.MessageImpl in project cxf by apache.

the class SearchContextImplTest method testPrimitiveStatementSearchBeanComlexName.

@Test
public void testPrimitiveStatementSearchBeanComlexName() {
    Message m = new MessageImpl();
    m.put(Message.QUERY_STRING, "_s=complex.name==CXF");
    SearchContext context = new SearchContextImpl(m);
    SearchCondition<SearchBean> sc = context.getCondition(SearchBean.class);
    assertNotNull(sc);
    PrimitiveStatement ps = sc.getStatement();
    assertNotNull(ps);
    assertEquals("complex.name", ps.getProperty());
    assertEquals("CXF", ps.getValue());
    assertEquals(ConditionType.EQUALS, ps.getCondition());
    assertEquals(String.class, ps.getValueType());
}
Also used : Message(org.apache.cxf.message.Message) MessageImpl(org.apache.cxf.message.MessageImpl) Test(org.junit.Test)

Example 74 with MessageImpl

use of org.apache.cxf.message.MessageImpl in project cxf by apache.

the class SearchContextImplTest method testSingleEquals.

@Test
public void testSingleEquals() {
    Message m = new MessageImpl();
    m.put(Message.QUERY_STRING, "_s=name=CXF");
    m.put("fiql.support.single.equals.operator", "true");
    SearchContext context = new SearchContextImpl(m);
    SearchCondition<SearchBean> sc = context.getCondition(SearchBean.class);
    assertNotNull(sc);
    PrimitiveStatement ps = sc.getStatement();
    assertNotNull(ps);
    assertEquals("name", ps.getProperty());
    assertEquals("CXF", ps.getValue());
    assertEquals(ConditionType.EQUALS, ps.getCondition());
    assertEquals(String.class, ps.getValueType());
}
Also used : Message(org.apache.cxf.message.Message) MessageImpl(org.apache.cxf.message.MessageImpl) Test(org.junit.Test)

Example 75 with MessageImpl

use of org.apache.cxf.message.MessageImpl in project cxf by apache.

the class SearchContextImplTest method testPlainQuery3.

@Test
public void testPlainQuery3() {
    Message m = new MessageImpl();
    m.put("search.use.plain.queries", true);
    m.put(Message.QUERY_STRING, "a=b&c=d");
    String exp = new SearchContextImpl(m).getSearchExpression();
    assertEquals("(a==b;c==d)", exp);
}
Also used : Message(org.apache.cxf.message.Message) MessageImpl(org.apache.cxf.message.MessageImpl) Test(org.junit.Test)

Aggregations

MessageImpl (org.apache.cxf.message.MessageImpl)610 Message (org.apache.cxf.message.Message)291 Test (org.junit.Test)290 ExchangeImpl (org.apache.cxf.message.ExchangeImpl)193 WrappedMessageContext (org.apache.cxf.jaxws.context.WrappedMessageContext)152 Exchange (org.apache.cxf.message.Exchange)148 StaticSTSProperties (org.apache.cxf.sts.StaticSTSProperties)137 PasswordCallbackHandler (org.apache.cxf.sts.common.PasswordCallbackHandler)115 Crypto (org.apache.wss4j.common.crypto.Crypto)113 CustomTokenPrincipal (org.apache.wss4j.common.principal.CustomTokenPrincipal)107 JAXBElement (javax.xml.bind.JAXBElement)100 RequestSecurityTokenType (org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenType)93 RequestSecurityTokenResponseType (org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenResponseType)86 STSPropertiesMBean (org.apache.cxf.sts.STSPropertiesMBean)83 Element (org.w3c.dom.Element)74 ArrayList (java.util.ArrayList)62 ServiceMBean (org.apache.cxf.sts.service.ServiceMBean)61 StaticService (org.apache.cxf.sts.service.StaticService)61 Principal (java.security.Principal)59 Endpoint (org.apache.cxf.endpoint.Endpoint)58