Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright (c) 2010 Dmytro Pishchukhin (http://osgilab.org)
  * This program is made available under the terms of the MIT License.
  */
 
 package org.osgilab.testing.commons.assertions;
 
 import  org.osgi.framework.FrameworkUtil;
import  org.osgi.framework.InvalidSyntaxException;

A set of OSGi Filter specific assertion methods useful for writing tests.

Before use it should be initialized org.osgilab.testing.commons.assertions.OSGiAssert.init(org.osgi.framework.BundleContext)

Author(s):
dmytro.pishchukhin
Version:
1.0
See also:
java.lang.AssertionError
org.osgilab.testing.commons.assertions.OSGiAssert
public class FilterAssert extends OSGiAssert {
    
Utility class. Only static methods are available.
    private FilterAssert() {
    }

    
Asserts that given filter is correct. If it not as expected AssertionError without a message is thrown

Parameters:
filter filter
    public static void assertFilterCorrect(String filter) {
        assertFilterCorrect(nullfilter);
    }

    
Asserts that given filter is correct. If it not as expected AssertionError is thrown with the given message

Parameters:
message message
filter filter
    public static void assertFilterCorrect(String messageString filter) {
        Assert.assertNotNull("Filter is null"filter);
        try {
            FrameworkUtil.createFilter(filter);
        } catch (InvalidSyntaxException e) {
            Assert.fail(message);
        }
    }

    
Asserts that given filter is incorrect. If it not as expected AssertionError without a message is thrown

Parameters:
filter filter
    public static void assertFilterIncorrect(String filter) {
        assertFilterIncorrect(nullfilter);
    }

    
Asserts that given filter is incorrect. If it not as expected AssertionError is thrown with the given message

Parameters:
message message
filter filter
    public static void assertFilterIncorrect(String messageString filter) {
        Assert.assertNotNull("Filter is null"filter);
        try {
            FrameworkUtil.createFilter(filter);
            Assert.fail(message);
        } catch (InvalidSyntaxException e) {
            // do nothing
        }
    }
New to GrepCode? Check out our FAQ X