001: /*****************************************************************************
002: * Source code information
003: * -----------------------
004: * Original author Ian Dickinson, HP Labs Bristol
005: * Author email Ian.Dickinson@hp.com
006: * Package Jena 2
007: * Web http://sourceforge.net/projects/jena/
008: * Created 22 Feb 2003
009: * Filename $RCSfile: TestOntEvents.java,v $
010: * Revision $Revision: 1.7 $
011: * Release status $State: Exp $
012: *
013: * Last modified on $Date: 2008/01/02 12:07:41 $
014: * by $Author: andy_seaborne $
015: *
016: * (c) Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
017: * (see footer for full conditions)
018: *****************************************************************************/package com.hp.hpl.jena.ontology.event.test;
019:
020: // Imports
021: ///////////////
022: import com.hp.hpl.jena.ontology.*;
023: import com.hp.hpl.jena.ontology.event.OntEventHandler;
024: import com.hp.hpl.jena.ontology.impl.test.*;
025: import com.hp.hpl.jena.rdf.model.*;
026:
027: /**
028: * <p>
029: * Test cases for ontology events
030: * </p>
031: *
032: * @author Ian Dickinson, HP Labs (<a href="mailto:Ian.Dickinson@hp.com">email</a>)
033: * @version Release @release@ ($Id: TestOntEvents.java,v 1.7 2008/01/02 12:07:41 andy_seaborne Exp $)
034: */
035: public class TestOntEvents extends OntTestBase {
036:
037: // Constants
038: //////////////////////////////////
039:
040: // Static variables
041: //////////////////////////////////
042:
043: // Instance variables
044: //////////////////////////////////
045:
046: // Constructors
047: //////////////////////////////////
048:
049: public TestOntEvents(String name) {
050: super (name);
051: }
052:
053: // External signature methods
054: //////////////////////////////////
055:
056: // Internal implementation methods
057: //////////////////////////////////
058:
059: //==============================================================================
060: // Inner class definitions
061: //==============================================================================
062:
063: private static class OntEventTestCase extends OntTestBase {
064: private ModelUpdater m_updater;
065: private OntModel m_model;
066: private Resource m_expected;
067: private boolean m_taleOfExpected = false;
068: private boolean m_taleOfUnexpected = false;
069:
070: private OntEventTestCase(String name, ModelUpdater upd,
071: String lang, Resource event) {
072: super (name);
073: m_updater = upd;
074: m_model = ModelFactory.createOntologyModel(lang);
075: m_expected = event;
076: }
077:
078: public void runTest() {
079: // first register an event handler for the expected event
080: m_model.getEventManager().addHandler(m_expected,
081: new OntEventHandler() {
082: public void action(Resource event, boolean add,
083: Model source, RDFNode arg0,
084: RDFNode arg1, RDFNode arg2) {
085:
086: }
087: });
088: }
089:
090: public void setUp() {
091: // ensure the ont doc manager is in a consistent state
092: OntDocumentManager.getInstance().reset(true);
093: }
094:
095: }
096:
097: private static interface ModelUpdater {
098: public void update(OntModel m);
099: }
100: }
101:
102: /*
103: (c) Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
104: All rights reserved.
105:
106: Redistribution and use in source and binary forms, with or without
107: modification, are permitted provided that the following conditions
108: are met:
109:
110: 1. Redistributions of source code must retain the above copyright
111: notice, this list of conditions and the following disclaimer.
112:
113: 2. Redistributions in binary form must reproduce the above copyright
114: notice, this list of conditions and the following disclaimer in the
115: documentation and/or other materials provided with the distribution.
116:
117: 3. The name of the author may not be used to endorse or promote products
118: derived from this software without specific prior written permission.
119:
120: THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
121: IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
122: OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
123: IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
124: INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
125: NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
126: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
127: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
128: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
129: THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
130: */
|