Commit ebd6f453 authored by Nicolas Gilmard's avatar Nicolas Gilmard
Browse files

Add test for loading adapter reflexively

Correct field name in BluetoothServer
parent 29381725
......@@ -24,4 +24,4 @@ cursorIDRemappingConstant = 1024
# Add the property "tableAdapter" with the adapter to load
# Syntax is : tableAdapter = packageName.ClassName
# i.e : lu.list.itis.dkd.tui.adapter.TuioAdapter
\ No newline at end of file
# i.e : tableAdapter = lu.list.itis.dkd.tui.adapter.TuioAdapter
\ No newline at end of file
......@@ -59,8 +59,8 @@ public class BluetoothServer extends ServerAdapter {
*/
public BluetoothServer(String uuidService) throws IOException {
this.uuidService = uuidService;
UUID SERVICE_ID = new UUID(uuidService, false);
String url = "btspp://localhost:" + SERVICE_ID.toString() + ";name=service"; //$NON-NLS-1$ //$NON-NLS-2$
UUID serviceId = new UUID(uuidService, false);
String url = "btspp://localhost:" + serviceId.toString() + ";name=service"; //$NON-NLS-1$ //$NON-NLS-2$
LocalDevice.getLocalDevice().setDiscoverable(DiscoveryAgent.GIAC);
server = (StreamConnectionNotifier) Connector.open(url);
}
......
/**
* Copyright Luxembourg Institute of Science and Technology, 2015. All rights reserved. If you wish
* to use this code for any purpose, please contact the author(s).
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package lu.list.itis.dkd.tui;
import java.security.Permission;
/**
* @author gilmard
* @since [major].[minor]
* @version [major].[minor].[micro]
*/
public class ExitDeniedSecurityManager extends SecurityManager {
public static final class ExitSecurityException extends SecurityException {
private final int status;
public ExitSecurityException(final int status) {
this.status = status;
}
public int getStatus() {
return this.status;
}
}
@Override
public void checkExit(final int status) {
throw new ExitSecurityException(status);
}
@Override
public void checkPermission(final Permission perm) {}
/* TODO: Make sure you override everything with an empty method as above */
}
\ No newline at end of file
/**
* Copyright Luxembourg Institute of Science and Technology, 2015. All rights reserved. If you wish
* to use this code for any purpose, please contact the author(s).
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package lu.list.itis.dkd.tui;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import lu.list.itis.dkd.tui.ExitDeniedSecurityManager.ExitSecurityException;
import lu.list.itis.dkd.tui.adapter.TangibleObject;
import lu.list.itis.dkd.tui.adapter.TuiAdapter;
import lu.list.itis.dkd.tui.content.Content;
import lu.list.itis.dkd.tui.event.ContentEvent;
import lu.list.itis.dkd.tui.exception.BuildException;
import lu.tudor.ssi.kiss.dbc.annotation.NonNullByDefault;
import org.junit.Before;
import org.junit.Test;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Collection;
import java.util.HashSet;
import java.util.Properties;
import java.util.logging.Logger;
/**
* Test case for testing the {@link TangibleApplication} class.
*
* @author Eric TOBIAS [eric.tobias@list.lu]
* @since 1.0
* @version 1.0.2
*/
public class TangibleApplicationTest2 {
private String propertiesLocation = "test_properties.properties"; //$NON-NLS-1$
private TangibleApplication application;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
System.setSecurityManager(new ExitDeniedSecurityManager());
}
/**
* Test method for
* {@link lu.list.itis.dkd.tui.TangibleApplication#TangibleApplication(java.lang.String)}.
*
* @throws Exception
*/
@SuppressWarnings("javadoc")
@Test
public void testTangibleApplication() throws Exception {
FileInputStream in = new FileInputStream(propertiesLocation);
Properties props = new Properties();
props.load(in);
FileOutputStream out = new FileOutputStream(propertiesLocation);
// InstanciationException
props.setProperty("tableAdapter", "lu.list.itis.dkd.tui.adapter.TuiAdapter"); //$NON-NLS-1$ //$NON-NLS-2$
props.store(out, null);
try {
application = new TestTangibleApplication(propertiesLocation);
fail("Expected exit"); //$NON-NLS-1$
} catch (ExitSecurityException e) {
int status = e.getStatus();
assertEquals(42, status);
}
// ClassNotFoundException
props.load(in);
props.setProperty("tableAdapter", "lu.list.itis.dkd.tui.adapter.TuAdapter"); //$NON-NLS-1$ //$NON-NLS-2$
props.store(out, null);
try {
application = new TestTangibleApplication(propertiesLocation);
fail("Expected exit25"); //$NON-NLS-1$
} catch (ExitSecurityException e) {
int status = e.getStatus();
assertEquals(42, status);
}
// props.load(in);
// props.setProperty("tableAdapter", "lu.list.itis.dkd.tui.adapter.TuAdapter");
// props.store(out, null);
// try {
//
// application = new TestTangibleApplication(propertiesLocation);
// fail("Expected exit25"); //$NON-NLS-1$
// } catch (ExitSecurityException e) {
// int status = e.getStatus();
// assertEquals(42, status);
// }
in.close();
out.close();
}
/**
* Test method for {@link lu.list.itis.dkd.tui.TangibleApplication#connect()}.
*/
public void testConnect() {
fail("Method not implemented in mock!"); //$NON-NLS-1$
}
/**
* Test method for {@link lu.list.itis.dkd.tui.TangibleApplication#getInterfaceManager()}.
*/
public void testGetInterfaceManager() {
fail("Method not implemented in mock!"); //$NON-NLS-1$
}
/**
* Test method for {@link lu.list.itis.dkd.tui.TangibleApplication#getObjectManager()} and
* {@link lu.list.itis.dkd.tui.TangibleApplication#setObjectManager(TangibleObjectManager)}.
*/
@SuppressWarnings("null")
public void testSetAndGetObjectManager() {
fail("Method not implemented in mock!"); //$NON-NLS-1$
}
/**
* Test method for {@link lu.list.itis.dkd.tui.TangibleApplication#getContentManager()} and
* {@link lu.list.itis.dkd.tui.TangibleApplication#setContentManager(lu.list.itis.dkd.tui.TangibleContentManager)}
* .
*/
public void testSetAndGetContentManager() {
fail("Method not implemented in mock!"); //$NON-NLS-1$
}
/**
* Class implementing the abstract {@link TangibleApplication} for test purposes.
*
* @author Eric TOBIAS [eric.tobias@tudor.lu]
* @since 13 Mar 2014
* @version 1
*/
public class TestTangibleApplication extends TangibleApplication {
/**
* Constructor initialising several basic properties.
*
* @param newPropertiesFileURI
* The URI of the properties file to load.
* @throws Exception
*/
protected TestTangibleApplication(String newPropertiesFileURI) throws Exception {
super(newPropertiesFileURI);
}
}
/**
* Class implementing the abstract {@link TangibleContentManager} for test purposes.
*
* @author Eric TOBIAS [eric.tobias@tudor.lu]
* @since 1.0
* @version 1.0.2
*/
@NonNullByDefault
public class TestTangibleContentManager extends TangibleContentManager {
/**
* {@inheritDoc}
*/
@Override
public void contentUpdated(ContentEvent event) {
fail("Method not implemented in mock!"); //$NON-NLS-1$
}
/**
* {@inheritDoc}
*/
@Override
public Collection<Content> getDrawableContents() {
fail("Method not implemented in mock!"); //$NON-NLS-1$
return new HashSet<Content>();
}
}
/**
* Class implementing the abstract {@link TangibleObjectManager} for test purposes.
*
* @author Eric TOBIAS [eric.tobias@tudor.lu]
* @since 13 Mar 2014
* @version 1
*/
public class TestTangibleObjectManager extends TangibleObjectManager {
/**
* Constructor initialising several fields and setting up the list of managed tangibles.
*
* @param applicationContext
* The {@link TangibleApplication} hosting this manager.
* @param applicationLogger
* The {@link Logger} to use for all logging purposes.
* @param properties
* The properties instance from which to load the default values from.
*/
@NonNullByDefault
public TestTangibleObjectManager(TangibleApplication applicationContext, Logger applicationLogger, Properties properties) {
super(applicationContext, applicationLogger, properties);
}
/**
* {@inheritDoc}
*/
@Override
public void defineWidgets() throws BuildException {
throw new BuildException("No widgets to build in this mock!"); //$NON-NLS-1$
}
}
/**
* Class implementing the abstract {@link TangibleObjectManager} for test purposes.
*
* @author Eric TOBIAS [eric.tobias@tudor.lu]
* @since 13 Mar 2014
* @version 1
*/
public class TestTuioConcreteAdapter extends TuiAdapter {
/**
* Default constructor.
*
* @param interfaceManager
* The {@link TangibleInterfaceManager} responsible for refreshing the interface.
*/
public TestTuioConcreteAdapter(TangibleInterfaceManager interfaceManager) {
super(interfaceManager);
}
@Override
public void connect() {
// TODO Auto-generated method stub
}
@Override
public void disconnect() {
// TODO Auto-generated method stub
}
@Override
public TangibleObjectManager getObjectManager() {
// TODO Auto-generated method stub
return null;
}
@Override
public void setObjectManager(TangibleObjectManager objectManager) {
// TODO Auto-generated method stub
}
@Override
public Collection<TangibleObject> getActiveCursors() {
// TODO Auto-generated method stub
return null;
}
@Override
public Collection<TangibleObject> getActiveObjects() {
// TODO Auto-generated method stub
return null;
}
@Override
public TangibleObject getCursor(long id) {
// TODO Auto-generated method stub
return null;
}
@Override
public TangibleObject getObject(long id) {
// TODO Auto-generated method stub
return null;
}
/*
* /** {@inheritDoc}
*/
/*
* @Override public void defineWidgets() throws BuildException { throw new
* BuildException("No widgets to build in this mock!"); }
*/
}
}
\ No newline at end of file
......@@ -6,3 +6,61 @@
<!DOCTYPE log SYSTEM "logger.dtd">
<log>
</log>
<?xml version="1.0" encoding="windows-1252" standalone="no"?>
<!DOCTYPE log SYSTEM "logger.dtd">
<log>
<record>
<date>2015-05-04T14:10:36</date>
<millis>1430741436587</millis>
<sequence>0</sequence>
<logger>TangibleApplication</logger>
<level>SEVERE</level>
<class>lu.list.itis.dkd.tui.TangibleApplication</class>
<method>&lt;init&gt;</method>
<thread>1</thread>
<message>The class tuio was not found. Check the spelling !</message>
</record>
<record>
<date>2015-05-04T14:10:42</date>
<millis>1430741442122</millis>
<sequence>1</sequence>
<logger>TangibleApplication</logger>
<level>CONFIG</level>
<class>lu.list.itis.dkd.tui.TangibleInterfaceManager$TUIKeyAdapter</class>
<method>keyPressed</method>
<thread>15</thread>
<message>The keypress could not be associated to a case!</message>
</record>
<record>
<date>2015-05-04T14:10:42</date>
<millis>1430741442273</millis>
<sequence>2</sequence>
<logger>TangibleApplication</logger>
<level>CONFIG</level>
<class>lu.list.itis.dkd.tui.TangibleInterfaceManager$TUIKeyAdapter</class>
<method>keyPressed</method>
<thread>15</thread>
<message>The keypress could not be associated to a case!</message>
</record>
<record>
<date>2015-05-04T14:10:50</date>
<millis>1430741450625</millis>
<sequence>3</sequence>
<logger>TangibleApplication</logger>
<level>CONFIG</level>
<class>lu.list.itis.dkd.tui.TangibleInterfaceManager$TUIKeyAdapter</class>
<method>keyPressed</method>
<thread>15</thread>
<message>The keypress could not be associated to a case!</message>
</record>
<record>
<date>2015-05-04T14:10:50</date>
<millis>1430741450833</millis>
<sequence>4</sequence>
<logger>TangibleApplication</logger>
<level>CONFIG</level>
<class>lu.list.itis.dkd.tui.TangibleInterfaceManager$TUIKeyAdapter</class>
<method>keyPressed</method>
<thread>15</thread>
<message>The keypress could not be associated to a case!</message>
</record>
# Properties of the TangibleGIS
contentFileURI = contentLAMILO.xml
calibrationFileURI = calibration.xml
# Properties for the Logger
logger.event.output.location = test_log.txt
logger.event.output.enabled = true
logger.level = FINE
logger.event.configuration = logger.xml
# Properties of the TangibleGISComponent
calibrationMode = false
centeredLuxembourg = false
legendScale = 0.8
infoTimerFreq = 600
zoomTimerFreq = 1000
# widget IDs
zoomWidgetID = 0
infoWidgetID = 1
backgroundWidgetID = 2
splitWidgetID = 22
recenterWidgetID = 23
# Properties for calibrating the interface
frameTitle = NUI Application
windowWidth = 1280
windowHeight = 800
fullScreen = false
font = Arial
fontSize = 13
colour = BLACK
centred = false
# Adapter to load
tableAdapter = tuio
#The value below is best left at or above 1024. It serves the purpose of cursor ID remapping.
cursorIDRemappingConstant = 2048
# Properties for the calibration of the object manager
\ No newline at end of file
#Mon May 04 16:26:54 CEST 2015
frameTitle=NUI Application
zoomWidgetID=0
logger.event.configuration=logger.xml
fontSize=13
backgroundWidgetID=2
recenterWidgetID=23
logger.event.output.location=test_log.txt
calibrationFileURI=calibration.xml
infoWidgetID=1
windowHeight=800
colour=BLACK
fullScreen=false
zoomTimerFreq=1000
contentFileURI=contentLAMILO.xml
infoTimerFreq=600
centeredLuxembourg=false
font=Arial
splitWidgetID=22
logger.event.output.enabled=true
tableAdapter=lu.list.itis.dkd.tui.adapter.TuiAdapter
calibrationMode=false
legendScale=0.8
centred=false
windowWidth=1280
logger.level=FINE
cursorIDRemappingConstant=2048
#Mon May 04 16:26:55 CEST 2015
frameTitle=NUI Application
zoomWidgetID=0
logger.event.configuration=logger.xml
fontSize=13
backgroundWidgetID=2
recenterWidgetID=23
logger.event.output.location=test_log.txt
calibrationFileURI=calibration.xml
infoWidgetID=1
windowHeight=800
colour=BLACK
fullScreen=false
zoomTimerFreq=1000
contentFileURI=contentLAMILO.xml
infoTimerFreq=600
centeredLuxembourg=false
font=Arial
splitWidgetID=22
logger.event.output.enabled=true
tableAdapter=lu.list.itis.dkd.tui.adapter.TuAdapter
calibrationMode=false
legendScale=0.8
centred=false
windowWidth=1280
logger.level=FINE
cursorIDRemappingConstant=2048
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment