Examples of FilterAction


Examples of net.suberic.pooka.filter.FilterAction

   * Generates a FilterAction from the given property.
   */
  public static FilterAction generateFilterAction(String actionProperty) throws ClassNotFoundException, InstantiationException , IllegalAccessException {
    String className = Pooka.getProperty(actionProperty + ".class", "");
    Class filterClass = Class.forName(className);
    FilterAction newAction = (FilterAction)filterClass.newInstance();
    newAction.initializeFilter(actionProperty);
    return newAction;
  }
View Full Code Here

Examples of net.suberic.pooka.filter.FilterAction

  /**
   * Runs the configured spam action on this message.
   */
  public void runSpamAction() {
    FilterAction spamFilter = null;
    try {
      spamFilter = MessageFilter.generateFilterAction("Pooka.spamAction");
    } catch (Exception e) {
      int configureNow = Pooka.getUIFactory().showConfirmDialog("Spam action currently not configured.  Would you like to configure it now?", "Configure Spam action", javax.swing.JOptionPane.YES_NO_OPTION);
      if (configureNow == javax.swing.JOptionPane.YES_OPTION) {
        // show configure screen.
        Pooka.getUIFactory().showEditorWindow(Pooka.getProperty("Preferences.Spam.label", "Spam"), "Pooka.spamAction");
      }

    }
    if (spamFilter != null) {
      Vector v = new Vector();
      v.add(this.getMessageProxy());
      java.util.List removed = spamFilter.performFilter(v);
      if (removed != null && removed.size() > 0) {
        try {
          getFolderInfo().expunge();
        } catch (Exception me) {
          // throw it away
View Full Code Here

Examples of org.openengsb.core.api.remote.FilterAction

    @Test
    public void testMethodCallMarashalFilter_shouldMarshalOutgoingMessage() throws Exception {
        JsonOutgoingMethodCallMarshalFilter jsonOutgoingMethodCallMarshalFilter =
            new JsonOutgoingMethodCallMarshalFilter();
        FilterAction mock = mock(FilterAction.class);
        when(mock.filter(any(MethodCallMessage.class), any(Map.class))).thenReturn(RESULT_MESSAGE);
        when(mock.getSupportedInputType()).thenAnswer(new Returns(String.class));
        when(mock.getSupportedOutputType()).thenAnswer(new Returns(String.class));
        jsonOutgoingMethodCallMarshalFilter.setNext(mock);
        MethodResultMessage result =
            (MethodResultMessage) jsonOutgoingMethodCallMarshalFilter.filter(new MethodCallMessage(),
                new HashMap<String, Object>());
        Object arg = result.getResult().getArg();
View Full Code Here

Examples of org.openengsb.core.api.remote.FilterAction

    }

    @Test
    public void testIncomingMethodCallMarashalFilter_shouldMarshalIngoingMessage() throws Exception {
        JsonMethodCallMarshalFilter jsonMethodCallMarshalFilter = new JsonMethodCallMarshalFilter();
        FilterAction mock = mock(FilterAction.class);
        TestModel testResult = new TestModel();
        testResult.setId(42);
        testResult.setName("bar");
        MethodResultMessage testResultMessage =
            new MethodResultMessage(new MethodResult(testResult), "foo");
        when(mock.filter(any(MethodCallMessage.class), any(Map.class))).thenReturn(testResultMessage);
        when(mock.getSupportedInputType()).thenAnswer(new Returns(MethodCallMessage.class));
        when(mock.getSupportedOutputType()).thenAnswer(new Returns(MethodResultMessage.class));
        jsonMethodCallMarshalFilter.setNext(mock);
        jsonMethodCallMarshalFilter.filter(CALL_MESSAGE, new HashMap<String, Object>());
    }
View Full Code Here

Examples of org.openengsb.core.api.remote.FilterAction

            new FilterChainFactory<String, String>(String.class, String.class);

        List<Object> filters = Arrays.asList(new Object[]{ JsonMethodCallMarshalFilter.class, requestMapperFilter });
        filterChainFactory.setFilters(filters);

        FilterAction filterChain = filterChainFactory.create();

        ObjectMapper objectMapper = new ObjectMapper();
        MethodCall methodCall = new MethodCall("test", new Object[]{ "foo" });
        MethodCallMessage request = new MethodCallMessage(methodCall, "bar");
        String input = objectMapper.writeValueAsString(request);
        String result = (String) filterChain.filter(input, new HashMap<String, Object>());
        MethodResultMessage returnValue = objectMapper.readValue(result, MethodResultMessage.class);
        assertThat((String) returnValue.getResult().getArg(), is("foo"));
        assertThat(returnValue.getCallId(), is("bar"));
    }
View Full Code Here

Examples of org.openengsb.core.api.remote.FilterAction

        List<Object> filters =
            Arrays
                .asList(new Object[]{ XmlDecoderFilter.class, XmlMethodCallMarshalFilter.class, requestMapperFilter, });
        filterChainFactory.setFilters(filters);

        FilterAction filterChain = filterChainFactory.create();

        MethodCall methodCall = new MethodCall("test", new Object[]{ "foo" }, Arrays.asList(String.class.getName()));
        MethodCallMessage request = new MethodCallMessage(methodCall, "bar");

        JAXBContext jaxbContext = JAXBContext.newInstance(MethodCallMessage.class, MethodResultMessage.class);
        final Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
        final Marshaller marshaller = jaxbContext.createMarshaller();

        DOMResult domResult = new DOMResult();
        marshaller.marshal(new JAXBElement<MethodCallMessage>(new QName(MethodCallMessage.class.getSimpleName()),
            MethodCallMessage.class, request), domResult);
        String input = XmlDecoderFilter.writeDocument(domResult.getNode());
        String result = (String) filterChain.filter(input, new HashMap<String, Object>());

        Document parseDocument = XmlDecoderFilter.parseDocument(result);
        MethodResultMessage value = unmarshaller.unmarshal(parseDocument, MethodResultMessage.class).getValue();
        String value2 = unmarshaller.unmarshal((Node) value.getResult().getArg(), String.class).getValue();
        value.getResult().setArg(value2);
View Full Code Here

Examples of org.openengsb.core.api.remote.FilterAction

            new FilterChainFactory<String, String>(String.class, String.class);

        List<Object> filters = Arrays.asList(new Object[]{ JsonMethodCallMarshalFilter.class, requestMapperFilter, });
        filterChainFactory.setFilters(filters);

        FilterAction filterChain = filterChainFactory.create();

        ObjectMapper objectMapper = new ObjectMapper();
        MethodCall methodCall = new MethodCall("test", new Object[]{ "foo" });
        MethodCallMessage request = new MethodCallMessage(methodCall, "bar");
        String input = objectMapper.writeValueAsString(request);
        HashMap<String, Object> metaData = new HashMap<String, Object>();
        filterChain.filter(input, metaData);
        assertThat((String) metaData.get("callId"), is("bar"));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.