mirror of
https://github.com/Rogiel/l2jserver2
synced 2025-12-10 01:12:52 +00:00
Modularizes the Maven project
This commit modularizes the maven project into several modules: - l2jserver2-common: common sources for both login and gameserver - l2jserver2-gameserver: the game server - l2jserver2-loginserver: the login server - l2jserver2-tools: refactored src/tools/java soure folder
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* This file is part of l2jserver <l2jserver.com>.
|
||||
*
|
||||
* l2jserver is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* l2jserver is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.db.dao.mysql5;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Stage;
|
||||
import com.l2jserver.GameServerModule;
|
||||
import com.l2jserver.model.dao.CharacterDAO;
|
||||
import com.l2jserver.model.id.object.provider.CharacterIDProvider;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.service.ServiceManager;
|
||||
import com.l2jserver.service.ServiceStartException;
|
||||
import com.l2jserver.service.database.DatabaseService;
|
||||
import com.l2jserver.service.game.template.TemplateService;
|
||||
import com.l2jserver.service.game.world.WorldService;
|
||||
|
||||
public class MySQL5CharacterDAOTest {
|
||||
private final Injector injector = Guice.createInjector(Stage.PRODUCTION,
|
||||
new GameServerModule());
|
||||
|
||||
@Test
|
||||
public void testCachedLoad() throws ServiceStartException {
|
||||
injector.getInstance(ServiceManager.class).start(TemplateService.class);
|
||||
injector.getInstance(ServiceManager.class).start(DatabaseService.class);
|
||||
injector.getInstance(ServiceManager.class).start(WorldService.class);
|
||||
|
||||
final CharacterDAO dao = injector.getInstance(CharacterDAO.class);
|
||||
final L2Character char1 = dao.select(injector.getInstance(
|
||||
CharacterIDProvider.class).resolveID(268437456));
|
||||
final L2Character char2 = dao.select(injector.getInstance(
|
||||
CharacterIDProvider.class).resolveID(268437456));
|
||||
|
||||
Assert.assertSame(char1, char2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* This file is part of l2jserver <l2jserver.com>.
|
||||
*
|
||||
* l2jserver is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* l2jserver is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.model.id.provider;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.l2jserver.model.id.ID;
|
||||
import com.l2jserver.model.id.object.CharacterID;
|
||||
import com.l2jserver.model.id.object.provider.CharacterIDProvider;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.service.ServiceManager;
|
||||
import com.l2jserver.service.ServiceModule;
|
||||
import com.l2jserver.service.ServiceStartException;
|
||||
import com.l2jserver.service.database.DatabaseService;
|
||||
import com.l2jserver.service.database.H2DAOModule;
|
||||
import com.l2jserver.service.game.template.TemplateService;
|
||||
import com.l2jserver.service.game.world.WorldService;
|
||||
|
||||
public class CharacterIDProviderTest {
|
||||
private final Injector injector = Guice.createInjector(new ServiceModule(),
|
||||
new H2DAOModule(), new IDProviderModule());
|
||||
private CharacterIDProvider charIdFactory;
|
||||
|
||||
@Before
|
||||
public void tearUp() throws ServiceStartException {
|
||||
injector.getInstance(ServiceManager.class).start(TemplateService.class);
|
||||
injector.getInstance(ServiceManager.class).start(DatabaseService.class);
|
||||
injector.getInstance(ServiceManager.class).start(WorldService.class);
|
||||
charIdFactory = injector.getInstance(CharacterIDProvider.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateID() {
|
||||
final ID<Integer> id1 = charIdFactory.createID();
|
||||
final ID<Integer> id2 = charIdFactory.createID();
|
||||
Assert.assertNotNull(id1);
|
||||
Assert.assertFalse(id1.equals(id2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDestroy() {
|
||||
final CharacterID id1 = charIdFactory.createID();
|
||||
Assert.assertNotNull(id1);
|
||||
charIdFactory.destroy(id1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetObject() throws ServiceStartException {
|
||||
final CharacterID id = charIdFactory.resolveID(268437456);
|
||||
final L2Character character = id.getObject();
|
||||
|
||||
Assert.assertNotNull(character);
|
||||
System.out.println(character.getAppearance().getHairColor());
|
||||
|
||||
Assert.assertNotNull(character);
|
||||
Assert.assertEquals(id, character.getID());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* This file is part of l2jserver <l2jserver.com>.
|
||||
*
|
||||
* l2jserver is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* l2jserver is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service.game.scripting;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Scopes;
|
||||
|
||||
public class ScriptingServiceImplTest {
|
||||
private final Injector injector = Guice
|
||||
.createInjector(new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(ScriptingService.class).to(ScriptingServiceImpl.class)
|
||||
.in(Scopes.SINGLETON);
|
||||
}
|
||||
});
|
||||
private final ScriptingService service = injector
|
||||
.getInstance(ScriptingService.class);
|
||||
|
||||
@Test
|
||||
public void testLoading() throws Exception {
|
||||
final List<ScriptContext> contexts = service.load(new File(
|
||||
"src/test/resources/scripting/testcase.xml"));
|
||||
Assert.assertEquals(1, contexts.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreatingInstance() throws Exception {
|
||||
final List<ScriptContext> contexts = service.load(new File(
|
||||
"src/test/resources/scripting/testcase.xml"));
|
||||
Assert.assertEquals(1, contexts.size());
|
||||
final ScriptContext context = contexts.get(0);
|
||||
Class<?> clazz = context.getClassLoader().loadClass(
|
||||
"test.ScriptingCompilerTest");
|
||||
Assert.assertNotNull(clazz);
|
||||
Assert.assertEquals("ScriptingCompilerTest", clazz.getSimpleName());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* This file is part of l2jserver <l2jserver.com>.
|
||||
*
|
||||
* l2jserver is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* l2jserver is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service.game.scripting.impl.compiled;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import com.l2jserver.service.game.scripting.CompilationResult;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*
|
||||
*/
|
||||
public class PrecompiledScriptCompilerTest {
|
||||
/**
|
||||
* Test method for
|
||||
* {@link com.l2jserver.service.game.scripting.impl.compiled.PrecompiledScriptCompiler#compile(java.lang.Iterable)}
|
||||
* .
|
||||
*/
|
||||
// @Test
|
||||
public void testCompileIterableOfFile() {
|
||||
final PrecompiledScriptCompiler compiler = new PrecompiledScriptCompiler();
|
||||
final CompilationResult result = compiler.compile(FileUtils.listFiles(
|
||||
new File("target/scripts/script/template"),
|
||||
new String[] { "class" }, true));
|
||||
System.out.println(result.getCompiledClasses()[0]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* This file is part of l2jserver <l2jserver.com>.
|
||||
*
|
||||
* l2jserver is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* l2jserver is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service.game.template;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.l2jserver.model.id.provider.IDProviderModule;
|
||||
import com.l2jserver.model.id.template.provider.ItemTemplateIDProvider;
|
||||
import com.l2jserver.service.ServiceManager;
|
||||
import com.l2jserver.service.ServiceModule;
|
||||
import com.l2jserver.service.ServiceStartException;
|
||||
import com.l2jserver.service.database.H2DAOModule;
|
||||
|
||||
public class StaticTemplateServiceTest {
|
||||
private final Injector injector = Guice.createInjector(new ServiceModule(),
|
||||
new IDProviderModule(), new H2DAOModule());
|
||||
private final ItemTemplateIDProvider factory = injector
|
||||
.getInstance(ItemTemplateIDProvider.class);
|
||||
|
||||
@Test
|
||||
public void testAdena() throws ServiceStartException {
|
||||
injector.getInstance(ServiceManager.class).start(TemplateService.class);
|
||||
System.out.println(factory.resolveID(57).getTemplate());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
* This file is part of l2jserver <l2jserver.com>.
|
||||
*
|
||||
* l2jserver is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* l2jserver is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service.world;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Stage;
|
||||
import com.l2jserver.GameServerModule;
|
||||
import com.l2jserver.model.id.object.provider.CharacterIDProvider;
|
||||
import com.l2jserver.model.id.object.provider.ItemIDProvider;
|
||||
import com.l2jserver.model.world.Item;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.item.ItemDropEvent;
|
||||
import com.l2jserver.model.world.item.ItemEvent;
|
||||
import com.l2jserver.model.world.item.ItemListener;
|
||||
import com.l2jserver.model.world.player.event.PlayerEvent;
|
||||
import com.l2jserver.model.world.player.event.PlayerListener;
|
||||
import com.l2jserver.model.world.player.event.PlayerSpawnEvent;
|
||||
import com.l2jserver.service.ServiceManager;
|
||||
import com.l2jserver.service.ServiceStartException;
|
||||
import com.l2jserver.service.game.world.WorldIDService;
|
||||
import com.l2jserver.service.game.world.WorldService;
|
||||
import com.l2jserver.service.game.world.event.WorldEventDispatcher;
|
||||
|
||||
public class WorldEventDispatcherImplTest {
|
||||
private WorldService world;
|
||||
private WorldEventDispatcher dispatcher;
|
||||
|
||||
private CharacterIDProvider cidFactory;
|
||||
private ItemIDProvider iidFactory;
|
||||
|
||||
@Before
|
||||
public void tearUp() throws ServiceStartException {
|
||||
Injector injector = Guice.createInjector(Stage.PRODUCTION,
|
||||
new GameServerModule());
|
||||
|
||||
injector.getInstance(ServiceManager.class).start(WorldIDService.class);
|
||||
|
||||
cidFactory = injector.getInstance(CharacterIDProvider.class);
|
||||
iidFactory = injector.getInstance(ItemIDProvider.class);
|
||||
|
||||
world = injector.getInstance(WorldService.class);
|
||||
dispatcher = injector.getInstance(WorldEventDispatcher.class);
|
||||
Assert.assertNotNull(world);
|
||||
Assert.assertNotNull(dispatcher);
|
||||
world.start();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListeners1() throws InterruptedException {
|
||||
final L2Character character1 = new L2Character(null);
|
||||
character1.setID(cidFactory.createID());
|
||||
final L2Character character2 = new L2Character(null);
|
||||
character2.setID(cidFactory.createID());
|
||||
final Item item1 = new Item(null);
|
||||
item1.setID(iidFactory.createID());
|
||||
world.add(character1);
|
||||
world.add(character2);
|
||||
world.add(item1);
|
||||
|
||||
final AtomicBoolean bool = new AtomicBoolean();
|
||||
Assert.assertFalse(bool.get());
|
||||
|
||||
dispatcher.addListener(character1, new PlayerListener() {
|
||||
@Override
|
||||
protected boolean dispatch(PlayerEvent e) {
|
||||
bool.set(true);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
dispatcher.addListener(character1, new PlayerListener() {
|
||||
@Override
|
||||
protected boolean dispatch(PlayerEvent e) {
|
||||
bool.set(true);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
dispatcher.dispatch(new PlayerSpawnEvent(character1, null));
|
||||
Thread.sleep(100); // wait a bit for dispatching to happen
|
||||
Assert.assertTrue(bool.get());
|
||||
|
||||
bool.set(false);
|
||||
|
||||
dispatcher.dispatch(new PlayerSpawnEvent(character1, null));
|
||||
Thread.sleep(100); // wait a bit for dispatching to happen
|
||||
Assert.assertFalse(bool.get());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListeners2() throws InterruptedException {
|
||||
final L2Character character1 = new L2Character(null);
|
||||
character1.setID(cidFactory.createID());
|
||||
final L2Character character2 = new L2Character(null);
|
||||
character2.setID(cidFactory.createID());
|
||||
final Item item1 = new Item(null);
|
||||
item1.setID(iidFactory.createID());
|
||||
final Item item2 = new Item(null);
|
||||
item2.setID(iidFactory.createID());
|
||||
world.add(character1);
|
||||
world.add(character2);
|
||||
world.add(item1);
|
||||
world.add(item2);
|
||||
|
||||
final AtomicBoolean bool1 = new AtomicBoolean();
|
||||
final AtomicBoolean bool2 = new AtomicBoolean();
|
||||
|
||||
Assert.assertFalse(bool1.get());
|
||||
Assert.assertFalse(bool2.get());
|
||||
|
||||
dispatcher.addListener(character1, new PlayerListener() {
|
||||
@Override
|
||||
public boolean dispatch(PlayerEvent e) {
|
||||
bool1.set(true);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
dispatcher.addListener(item1, new ItemListener() {
|
||||
@Override
|
||||
public boolean dispatch(ItemEvent e) {
|
||||
bool2.set(true);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
dispatcher.dispatch(new ItemDropEvent(character1, item1));
|
||||
Thread.sleep(1000); // wait a bit for dispatching to happen
|
||||
|
||||
Assert.assertFalse(bool1.get());
|
||||
Assert.assertTrue(bool2.get());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* This file is part of l2jserver <l2jserver.com>.
|
||||
*
|
||||
* l2jserver is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* l2jserver is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service.world;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.l2jserver.GameServerModule;
|
||||
import com.l2jserver.model.id.object.provider.CharacterIDProvider;
|
||||
import com.l2jserver.model.world.Item;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.WorldObject;
|
||||
import com.l2jserver.service.ServiceManager;
|
||||
import com.l2jserver.service.ServiceStartException;
|
||||
import com.l2jserver.service.game.world.WorldService;
|
||||
import com.l2jserver.service.game.world.filter.impl.InstanceFilter;
|
||||
|
||||
public class WorldServiceImplTest {
|
||||
private WorldService world;
|
||||
private CharacterIDProvider provider;
|
||||
|
||||
@Before
|
||||
public void tearUp() throws ServiceStartException {
|
||||
Injector injector = Guice.createInjector(new GameServerModule());
|
||||
|
||||
world = injector.getInstance(ServiceManager.class).start(
|
||||
WorldService.class);
|
||||
provider = injector.getInstance(CharacterIDProvider.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAdd() {
|
||||
final L2Character character = new L2Character(null);
|
||||
character.setID(provider.createID());
|
||||
Assert.assertTrue(world.add(character));
|
||||
}
|
||||
|
||||
@Test(expected = NullPointerException.class)
|
||||
public void testAddNullId() {
|
||||
final L2Character character = new L2Character(null);
|
||||
world.add(character);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemove() {
|
||||
final L2Character character = new L2Character(null);
|
||||
character.setID(provider.createID());
|
||||
Assert.assertTrue(world.add(character));
|
||||
Assert.assertTrue(world.remove(character));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveOther() {
|
||||
final L2Character character1 = new L2Character(null);
|
||||
character1.setID(provider.createID());
|
||||
|
||||
final L2Character character2 = new L2Character(null);
|
||||
character2.setID(provider.createID());
|
||||
|
||||
Assert.assertTrue(world.add(character1));
|
||||
Assert.assertFalse(world.remove(character2));
|
||||
}
|
||||
|
||||
@Test(expected = NullPointerException.class)
|
||||
public void testRemoveNullId() {
|
||||
final L2Character character = new L2Character(null);
|
||||
world.add(character);
|
||||
world.remove(character);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testContains() {
|
||||
final L2Character character = new L2Character(null);
|
||||
character.setID(provider.createID());
|
||||
Assert.assertTrue(world.add(character));
|
||||
Assert.assertTrue(world.contains(character));
|
||||
}
|
||||
|
||||
@Test(expected = NullPointerException.class)
|
||||
public void testContainsNullId() {
|
||||
final L2Character character = new L2Character(null);
|
||||
world.add(character);
|
||||
Assert.assertTrue(world.contains(character));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIterator() {
|
||||
final L2Character character1 = new L2Character(null);
|
||||
character1.setID(provider.createID());
|
||||
final L2Character character2 = new L2Character(null);
|
||||
character2.setID(provider.createID());
|
||||
final Item item1 = new Item(null);
|
||||
item1.setID(provider.createID());
|
||||
world.add(character1);
|
||||
world.add(character2);
|
||||
world.add(item1);
|
||||
|
||||
for (final WorldObject o : world) {
|
||||
Assert.assertNotNull(o);
|
||||
}
|
||||
final Iterable<Item> it = world.iterable(new InstanceFilter<Item>(
|
||||
Item.class));
|
||||
for (final WorldObject o : it) {
|
||||
Assert.assertNotNull(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
* This file is part of l2jserver <l2jserver.com>.
|
||||
*
|
||||
* l2jserver is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* l2jserver is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.util.calculator;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*
|
||||
*/
|
||||
public class CalculatorTest {
|
||||
// @Test
|
||||
// public void testSimple() {
|
||||
// final SimpleCalculator<CalculatorContext> calc = new
|
||||
// SimpleCalculator<CalculatorContext>();
|
||||
//
|
||||
// calc.add(new SetFunction(0, 10));
|
||||
// calc.add(new MultiplicationFunction(1, 2));
|
||||
// calc.add(new SetFunction(2, 30));
|
||||
//
|
||||
// final CalculatorContext ctx = new CalculatorContext();
|
||||
// Assert.assertEquals(30.0, calc.calculate(ctx));
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testPercent() {
|
||||
// final SimpleCalculator<CalculatorContext> calc = new
|
||||
// SimpleCalculator<CalculatorContext>();
|
||||
//
|
||||
// calc.add(new SetFunction(0, 10));
|
||||
// calc.add(new MultiplicationFunction(1, 2));
|
||||
// calc.add(new PercentFunction(2, 75));
|
||||
//
|
||||
// final CalculatorContext ctx = new CalculatorContext();
|
||||
// Assert.assertEquals(15.0, calc.calculate(ctx));
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testComplex() {
|
||||
// final SimpleCalculator<CalculatorContext> calc = new
|
||||
// SimpleCalculator<CalculatorContext>();
|
||||
//
|
||||
// calc.add(new SetFunction(0, 10));
|
||||
// calc.add(new MultiplicationFunction(1, 2));
|
||||
// calc.add(new PercentFunction(2, 75));
|
||||
// calc.add(new SumFunction(3, 3));
|
||||
// calc.add(new SubtractFunction(4, 8));
|
||||
// calc.add(new DivisionFunction(5, 2));
|
||||
//
|
||||
// final CalculatorContext ctx = new CalculatorContext();
|
||||
// Assert.assertEquals(5.0, calc.calculate(ctx));
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testNesting() {
|
||||
// final SimpleCalculator<CalculatorContext> calc1 = new
|
||||
// SimpleCalculator<CalculatorContext>();
|
||||
// final CalculatorContext ctx1 = new CalculatorContext();
|
||||
//
|
||||
// calc1.add(new SetFunction(0, 10));
|
||||
// calc1.add(new MultiplicationFunction(1, 2));
|
||||
// calc1.add(new PercentFunction(2, 75));
|
||||
// calc1.add(new SumFunction(3, 3));
|
||||
// calc1.add(new SubtractFunction(4, 8));
|
||||
// calc1.add(new DivisionFunction(5, 2));
|
||||
//
|
||||
// Assert.assertEquals(5.0, calc1.calculate(ctx1));
|
||||
//
|
||||
// final SimpleCalculator<CalculatorContext> calc2 = new
|
||||
// SimpleCalculator<CalculatorContext>();
|
||||
// final CalculatorContext ctx2 = new CalculatorContext();
|
||||
//
|
||||
// calc2.add(new MultiplicationFunction(0, 2));
|
||||
// calc2.add(new PercentFunction(1, 75));
|
||||
// calc2.add(new SumFunction(2, 3));
|
||||
// calc2.add(new SubtractFunction(3, 8));
|
||||
// calc2.add(new DivisionFunction(4, 2));
|
||||
//
|
||||
// Assert.assertEquals(-2.5, calc2.calculate(ctx2));
|
||||
//
|
||||
// final SimpleCalculator<CalculatorContext> calc3 = new
|
||||
// SimpleCalculator<CalculatorContext>();
|
||||
// final CalculatorContext ctx3 = new CalculatorContext();
|
||||
// calc3.add(calc1);
|
||||
// calc3.add(calc2);
|
||||
//
|
||||
// // this should be executed
|
||||
// calc2.add(new SumFunction(10, 1));
|
||||
//
|
||||
// Assert.assertEquals(2.25, calc3.calculate(ctx3));
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testImporting() {
|
||||
// final SimpleCalculator<CalculatorContext> calc1 = new
|
||||
// SimpleCalculator<CalculatorContext>();
|
||||
// final CalculatorContext ctx1 = new CalculatorContext();
|
||||
//
|
||||
// calc1.add(new SetFunction(0, 10));
|
||||
// calc1.add(new MultiplicationFunction(2, 2));
|
||||
// calc1.add(new PercentFunction(4, 75));
|
||||
// calc1.add(new SumFunction(6, 3));
|
||||
// calc1.add(new SubtractFunction(8, 8));
|
||||
// calc1.add(new DivisionFunction(10, 2));
|
||||
//
|
||||
// Assert.assertEquals(5.0, calc1.calculate(ctx1));
|
||||
//
|
||||
// final SimpleCalculator<CalculatorContext> calc2 = new
|
||||
// SimpleCalculator<CalculatorContext>();
|
||||
// final CalculatorContext ctx2 = new CalculatorContext();
|
||||
//
|
||||
// calc2.add(new MultiplicationFunction(1, 2));
|
||||
// calc2.add(new PercentFunction(3, 75));
|
||||
// calc2.add(new SumFunction(5, 3));
|
||||
// calc2.add(new SubtractFunction(7, 8));
|
||||
// calc2.add(new DivisionFunction(9, 2));
|
||||
//
|
||||
// Assert.assertEquals(-2.5, calc2.calculate(ctx2));
|
||||
//
|
||||
// final SimpleCalculator<CalculatorContext> calc3 = new
|
||||
// SimpleCalculator<CalculatorContext>();
|
||||
// final CalculatorContext ctx3 = new CalculatorContext();
|
||||
// calc3.importFunctions(calc1);
|
||||
// calc3.importFunctions(calc2);
|
||||
//
|
||||
// // this should not be executed
|
||||
// calc2.add(new SumFunction(11, 50));
|
||||
//
|
||||
// Assert.assertEquals(1.25, calc3.calculate(ctx3));
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testRounding() {
|
||||
// final SimpleCalculator<CalculatorContext> calc = new
|
||||
// SimpleCalculator<CalculatorContext>();
|
||||
//
|
||||
// calc.add(new MultiplicationFunction(0, 2));
|
||||
// calc.add(new PercentFunction(1, 75));
|
||||
// calc.add(new SumFunction(2, 3));
|
||||
// calc.add(new SubtractFunction(3, 8.1));
|
||||
// calc.add(new DivisionFunction(4, 2));
|
||||
// calc.add(new RoundFunction(5));
|
||||
//
|
||||
// final CalculatorContext ctx = new CalculatorContext();
|
||||
// Assert.assertEquals(-3.0, calc.calculate(ctx));
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package test;
|
||||
|
||||
public class ScriptingCompilerTest {
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version='1.0' encoding='UTF-8' ?>
|
||||
|
||||
<!--
|
||||
~ This file is part of l2jserver.
|
||||
~
|
||||
~ l2jserver is free software: you can redistribute it and/or modify
|
||||
~ it under the terms of the GNU General Public License as published by
|
||||
~ the Free Software Foundation, either version 3 of the License, or
|
||||
~ (at your option) any later version.
|
||||
~
|
||||
~ l2jserver is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
~ GNU General Public License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License
|
||||
~ along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<scriptlist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="../../contexts.xsd">
|
||||
<scriptinfo root="./src/test/resources/scripting"/>
|
||||
</scriptlist>
|
||||
10
l2jserver2-gameserver/src/test/resources/test-config.xml
Normal file
10
l2jserver2-gameserver/src/test/resources/test-config.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="configuration configuration.xsd"
|
||||
xsi:noNamespaceSchemaLocation="configuration">
|
||||
<configuration>
|
||||
<test>
|
||||
<testvalue>test</testvalue>
|
||||
<integer>256</integer>
|
||||
</test>
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user