Modified: ace/trunk/org.apache.ace.deployment/test/org/apache/ace/deployment/streamgenerator/impl/StreamTest.java URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.deployment/test/org/apache/ace/deployment/streamgenerator/impl/StreamTest.java?rev=1732517&r1=1732516&r2=1732517&view=diff ============================================================================== --- ace/trunk/org.apache.ace.deployment/test/org/apache/ace/deployment/streamgenerator/impl/StreamTest.java (original) +++ ace/trunk/org.apache.ace.deployment/test/org/apache/ace/deployment/streamgenerator/impl/StreamTest.java Fri Feb 26 16:55:17 2016 @@ -18,14 +18,21 @@ */ package org.apache.ace.deployment.streamgenerator.impl; -import static org.apache.ace.test.utils.TestUtils.BROKEN; -import static org.apache.ace.test.utils.TestUtils.UNIT; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; +import static org.testng.Assert.fail; import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.net.URLConnection; +import java.util.ArrayList; import java.util.HashSet; +import java.util.List; +import java.util.concurrent.Callable; +import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; @@ -94,8 +101,7 @@ public class StreamTest { } } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + fail(e.getMessage()); } } } @@ -115,8 +121,7 @@ public class StreamTest { } } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + fail(e.getMessage()); } } } @@ -136,8 +141,7 @@ public class StreamTest { } } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + fail(e.getMessage()); } } } @@ -157,8 +161,7 @@ public class StreamTest { } } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + fail(e.getMessage()); } } } @@ -178,8 +181,7 @@ public class StreamTest { } } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + fail(e.getMessage()); } } } @@ -202,8 +204,7 @@ public class StreamTest { } } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + fail(e.getMessage()); } } } @@ -214,32 +215,41 @@ public class StreamTest { /** * The specification requires the stream to be readable by JarInputStream (114.3) so make sure it is. */ - @Test(groups = { UNIT }) public void isJarInputStreamReadable() throws Exception { isJarInputStreamReadable(new JarInputStream(m_generator.getDeploymentPackage("test", "1.0.0")), false); isJarInputStreamReadable(new JarInputStream(m_generator.getDeploymentPackage("test", "0.0.0", "1.0.0")), true); } private void isJarInputStreamReadable(JarInputStream jis, boolean fixPackage) throws Exception { - assert jis != null : "We should have got an input stream for this deployment package."; + assertNotNull(jis, "We should have got an input stream for this deployment package."); + Manifest m = jis.getManifest(); - assert m != null : "The stream should contain a valid manifest."; + assertNotNull(m, "The stream should contain a valid manifest."); + Attributes att = m.getMainAttributes(); - assert att.getValue("DeploymentPackage-SymbolicName").equals("test"); - assert att.getValue("DeploymentPackage-Version").equals("1.0.0"); - assert (fixPackage && att.getValue("DeploymentPackage-FixPack").equals("[0.0.0,1.0.0)")) || (att.getValue("DeploymentPackage-FixPack") == null); + assertEquals(att.getValue("DeploymentPackage-SymbolicName"), "test"); + assertEquals(att.getValue("DeploymentPackage-Version"), "1.0.0"); + + if (fixPackage) { + assertEquals(att.getValue("DeploymentPackage-FixPack"), "[0.0.0,1.0.0)"); + } + else { + assertNull(att.getValue("DeploymentPackage-FixPack")); + } + HashSet<String> names = new HashSet<>(); JarEntry e = jis.getNextJarEntry(); while (e != null) { String name = e.getName(); names.add(name); + if (fixPackage && name.equals("A2.jar")) { - assert e.getAttributes().getValue("DeploymentPackage-Missing").equals("true"); + assertEquals(e.getAttributes().getValue("DeploymentPackage-Missing"), "true"); } // we could check the name here against the manifest // and make sure we actually get what was promised Attributes a = m.getAttributes(name); - assert a != null : "The stream should contain a named section for " + name + " in the manifest."; + assertNotNull(a, "The stream should contain a named section for " + name + " in the manifest."); byte[] buffer = new byte[COPY_BUFFER_SIZE]; int bytes = jis.read(buffer); @@ -251,52 +261,82 @@ public class StreamTest { e = jis.getNextJarEntry(); } if (!fixPackage) { - assert names.size() == 3 : "The stream should have contained three resources."; + assertEquals(names.size(), 3, "The stream should have contained three resources."); } else { - assert names.size() == 2 : "The stream should have contained three resources"; + assertEquals(names.size(), 2, "The stream should have contained three resources"); } - assert names.contains("A1.jar") : "The stream should have contained a resource called A1.jar"; - assert fixPackage ^ names.contains("A2.jar") : "The stream should have contained a resource called A2.jar"; - assert names.contains("A3.jar") : "The stream should have contained a resource called A3.jar"; + assertTrue(names.contains("A1.jar"), "The stream should have contained a resource called A1.jar"); + assertTrue(fixPackage ^ names.contains("A2.jar"), "The stream should have contained a resource called A2.jar"); + assertTrue(names.contains("A3.jar"), "The stream should have contained a resource called A3.jar"); } /** - * Test reading 100 streams sequentially. + * Test reading many streams sequentially. */ - @Test(groups = { UNIT, BROKEN }) - public void hundredStreamsSequentially() throws Exception { - for (int i = 0; i < 100; i++) { - isJarInputStreamReadable(); + @Test + public void manyStreamsSequentially() { + final int procs = Runtime.getRuntime().availableProcessors() + 1; + final int loopCount = 50; + final int totalReads = procs * loopCount; + + final List<Exception> failures = new ArrayList<>(); + + for (int i = 0; i < totalReads; i++) { + try { + isJarInputStreamReadable(); + } + catch (Exception exception) { + failures.add(exception); + } } - } - private Exception m_failure; + assertTrue(failures.isEmpty(), "Test failed: " + failures); + } /** - * Test reading 100 streams concurrently. + * Test reading many streams concurrently. */ - @Test(groups = { UNIT, BROKEN }) // marked broken after discussing it with Karl - public void hundredStreamsConcurrently() throws Exception { - ExecutorService e = Executors.newFixedThreadPool(5); - for (int i = 0; i < 10; i++) { - e.execute(new Runnable() { - public void run() { - for (int i = 0; i < 10; i++) { + @Test + public void manyStreamsConcurrently() throws InterruptedException { + final int procs = Runtime.getRuntime().availableProcessors() + 1; + final int loopCount = 50; + final int totalReads = procs * loopCount; + + final List<Exception> failures = new ArrayList<>(); + + final CountDownLatch startLatch = new CountDownLatch(1); + final CountDownLatch stopLatch = new CountDownLatch(totalReads); + + ExecutorService e = Executors.newFixedThreadPool(procs); + for (int i = 0; i < procs; i++) { + e.submit(new Callable<Void>() { + public Void call() throws Exception { + startLatch.await(); + + for (int i = 0; i < loopCount; i++) { try { isJarInputStreamReadable(); + stopLatch.countDown(); } catch (Exception e) { - m_failure = e; + failures.add(e); } } + + return null; } }); } + + // Let all threads start at the same time... + startLatch.countDown(); + assertTrue(stopLatch.await(10, TimeUnit.SECONDS), "Not all streams were properly read?!"); + e.shutdown(); - e.awaitTermination(10, TimeUnit.SECONDS); + assertTrue(e.awaitTermination(10, TimeUnit.SECONDS)); - assert m_failure == null : "Test failed: " + m_failure.getLocalizedMessage(); + assertTrue(failures.isEmpty(), "Test failed: " + failures); } /** @@ -306,7 +346,7 @@ public class StreamTest { public URLConnection createConnection(URL url) throws IOException { return url.openConnection(); } - + public URLConnection createConnection(URL url, User user) throws IOException { return createConnection(url); }
Modified: ace/trunk/org.apache.ace.discovery/test/org/apache/ace/discovery/property/PropertyBasedDiscoveryTest.java URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.discovery/test/org/apache/ace/discovery/property/PropertyBasedDiscoveryTest.java?rev=1732517&r1=1732516&r2=1732517&view=diff ============================================================================== --- ace/trunk/org.apache.ace.discovery/test/org/apache/ace/discovery/property/PropertyBasedDiscoveryTest.java (original) +++ ace/trunk/org.apache.ace.discovery/test/org/apache/ace/discovery/property/PropertyBasedDiscoveryTest.java Fri Feb 26 16:55:17 2016 @@ -15,8 +15,6 @@ */ package org.apache.ace.discovery.property; -import static org.apache.ace.test.utils.TestUtils.UNIT; - import java.net.URI; import java.net.URISyntaxException; import java.net.URL; @@ -29,14 +27,14 @@ import org.testng.Assert; import org.testng.annotations.Test; public class PropertyBasedDiscoveryTest { - @Test(groups = { UNIT }) + @Test public void discoverWithoutPropertyUpdate() { PropertyBasedDiscovery discovery = new PropertyBasedDiscovery(); URL url = discovery.discover(); Assert.assertNull(url); } - @Test(groups = { UNIT }) + @Test public void discoverWithPropertyUpdate() throws ConfigurationException, URISyntaxException { PropertyBasedDiscovery discovery = new PropertyBasedDiscovery(); Dictionary<String, Object> dict = new Hashtable<>(); Modified: ace/trunk/org.apache.ace.discovery/test/org/apache/ace/discovery/property/SimpleDiscoveryTest.java URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.discovery/test/org/apache/ace/discovery/property/SimpleDiscoveryTest.java?rev=1732517&r1=1732516&r2=1732517&view=diff ============================================================================== --- ace/trunk/org.apache.ace.discovery/test/org/apache/ace/discovery/property/SimpleDiscoveryTest.java (original) +++ ace/trunk/org.apache.ace.discovery/test/org/apache/ace/discovery/property/SimpleDiscoveryTest.java Fri Feb 26 16:55:17 2016 @@ -18,8 +18,6 @@ */ package org.apache.ace.discovery.property; -import static org.apache.ace.test.utils.TestUtils.UNIT; - import java.net.URL; import java.util.Dictionary; import java.util.Hashtable; @@ -45,9 +43,10 @@ public class SimpleDiscoveryTest { /** * Test if setting a valid configuration is handled correctly + * * @throws Exception */ - @Test(groups = { UNIT }) + @Test public void simpleDiscoveryValidConfiguration() throws ConfigurationException { Dictionary<String, String> properties = new Hashtable<>(); properties.put(SERVERURL_KEY, VALID_URL); @@ -58,9 +57,10 @@ public class SimpleDiscoveryTest { /** * Test if setting an invalid configuration is handled correctly. + * * @throws ConfigurationException */ - @Test(groups = {UNIT}, expectedExceptions = ConfigurationException.class) + @Test(expectedExceptions = ConfigurationException.class) public void simpleDiscoveryInvalidConfiguration() throws ConfigurationException { Dictionary<String, String> properties = new Hashtable<>(); properties.put(SERVERURL_KEY, INVALID_URL); @@ -69,9 +69,10 @@ public class SimpleDiscoveryTest { /** * Test if supplying an empty configuration results in the service's default being used. + * * @throws ConfigurationException */ - @Test(groups = {UNIT}) + @Test public void simpleDiscoveryEmptyConfiguration() throws ConfigurationException { // set valid config Dictionary<String, String> properties = new Hashtable<>(); Modified: ace/trunk/org.apache.ace.feedback.common/test/org/apache/ace/feedback/EventTest.java URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.feedback.common/test/org/apache/ace/feedback/EventTest.java?rev=1732517&r1=1732516&r2=1732517&view=diff ============================================================================== --- ace/trunk/org.apache.ace.feedback.common/test/org/apache/ace/feedback/EventTest.java (original) +++ ace/trunk/org.apache.ace.feedback.common/test/org/apache/ace/feedback/EventTest.java Fri Feb 26 16:55:17 2016 @@ -18,7 +18,6 @@ */ package org.apache.ace.feedback; -import static org.apache.ace.test.utils.TestUtils.UNIT; import static org.testng.Assert.*; import java.util.Dictionary; @@ -35,7 +34,7 @@ public class EventTest { private static final String TARGET_ID = "target"; private static final long STORE_ID = 1234; - @Test(groups = { UNIT }) + @Test() public void testCreateEventFromStringOk() throws Exception { String input = "target,1234,1,2,3,key2,value2,key1,value1"; @@ -55,7 +54,7 @@ public class EventTest { assertEquals("value2", props.get("key2")); } - @Test(groups = { UNIT }) + @Test() public void testCreateEventWithDictionaryOk() throws Exception { Event event = new Event(TARGET_ID, STORE_ID, 1, 2, 3, createDict("key1", "value1", "key2", "value2")); @@ -73,7 +72,7 @@ public class EventTest { assertEquals("value2", props.get("key2")); } - @Test(groups = { UNIT }) + @Test() public void testCreateEventWithoutPropertiesOk() throws Exception { Event event = new Event(TARGET_ID, STORE_ID, 1, 2, 3); @@ -88,7 +87,7 @@ public class EventTest { assertTrue(props.isEmpty()); } - @Test(groups = { UNIT }) + @Test() public void testCreateEventWithPropertiesOk() throws Exception { Event event = new Event(TARGET_ID, STORE_ID, 1, 2, 3, createMap("key1", "value1", "key2", "value2")); Modified: ace/trunk/org.apache.ace.identification/test/org/apache/ace/identification/ifconfig/IfconfigIdentificationTest.java URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.identification/test/org/apache/ace/identification/ifconfig/IfconfigIdentificationTest.java?rev=1732517&r1=1732516&r2=1732517&view=diff ============================================================================== --- ace/trunk/org.apache.ace.identification/test/org/apache/ace/identification/ifconfig/IfconfigIdentificationTest.java (original) +++ ace/trunk/org.apache.ace.identification/test/org/apache/ace/identification/ifconfig/IfconfigIdentificationTest.java Fri Feb 26 16:55:17 2016 @@ -18,8 +18,6 @@ */ package org.apache.ace.identification.ifconfig; -import static org.apache.ace.test.utils.TestUtils.UNIT; - import org.apache.ace.test.utils.TestUtils; import org.osgi.service.log.LogService; import org.testng.annotations.BeforeTest; @@ -35,7 +33,7 @@ public class IfconfigIdentificationTest TestUtils.configureObject(m_identification, LogService.class); } - @Test(groups = { UNIT }) + @Test public void testMacAddressVerifying() throws Exception { assert m_identification.isValidMac("FF:FF:FF:FF:FF:FF"); assert m_identification.isValidMac("01:23:45:67:89:01"); Modified: ace/trunk/org.apache.ace.identification/test/org/apache/ace/identification/property/PropertyBasedIdentificationTest.java URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.identification/test/org/apache/ace/identification/property/PropertyBasedIdentificationTest.java?rev=1732517&r1=1732516&r2=1732517&view=diff ============================================================================== --- ace/trunk/org.apache.ace.identification/test/org/apache/ace/identification/property/PropertyBasedIdentificationTest.java (original) +++ ace/trunk/org.apache.ace.identification/test/org/apache/ace/identification/property/PropertyBasedIdentificationTest.java Fri Feb 26 16:55:17 2016 @@ -18,7 +18,6 @@ */ package org.apache.ace.identification.property; -import static org.apache.ace.test.utils.TestUtils.UNIT; import static org.mockito.Mockito.mock; import java.lang.reflect.Field; @@ -32,13 +31,13 @@ import org.testng.Assert; import org.testng.annotations.Test; public class PropertyBasedIdentificationTest { - @Test(groups = { UNIT }) + @Test() public void getIdWithoutUpdate() { PropertyBasedIdentification basedIdentification = new PropertyBasedIdentification(); Assert.assertNull(basedIdentification.getID()); } - @Test(groups = { UNIT }) + @Test() public void getIdWithUpdate() throws ConfigurationException { PropertyBasedIdentification basedIdentification = new PropertyBasedIdentification(); Dictionary<String, Object> dict = new Hashtable<>(); @@ -47,7 +46,7 @@ public class PropertyBasedIdentification Assert.assertEquals(basedIdentification.getID(), "myTargetId"); } - @Test(groups = { UNIT }) + @Test() public void getIdOverwrite() throws ConfigurationException { PropertyBasedIdentification basedIdentification = new PropertyBasedIdentification(); injectServices(basedIdentification); Modified: ace/trunk/org.apache.ace.identification/test/org/apache/ace/identification/property/SimpleIdentificationTest.java URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.identification/test/org/apache/ace/identification/property/SimpleIdentificationTest.java?rev=1732517&r1=1732516&r2=1732517&view=diff ============================================================================== --- ace/trunk/org.apache.ace.identification/test/org/apache/ace/identification/property/SimpleIdentificationTest.java (original) +++ ace/trunk/org.apache.ace.identification/test/org/apache/ace/identification/property/SimpleIdentificationTest.java Fri Feb 26 16:55:17 2016 @@ -18,8 +18,6 @@ */ package org.apache.ace.identification.property; -import static org.apache.ace.test.utils.TestUtils.UNIT; - import java.util.Hashtable; import org.apache.ace.identification.IdentificationConstants; @@ -45,7 +43,7 @@ public class SimpleIdentificationTest { * @throws Exception */ @SuppressWarnings("serial") - @Test(groups = { UNIT }) + @Test public void testSimpleIdentification() throws Exception { m_identification.updated( new Hashtable<String, Object>() { Modified: ace/trunk/org.apache.ace.log.itest/bnd.bnd URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.log.itest/bnd.bnd?rev=1732517&r1=1732516&r2=1732517&view=diff ============================================================================== --- ace/trunk/org.apache.ace.log.itest/bnd.bnd (original) +++ ace/trunk/org.apache.ace.log.itest/bnd.bnd Fri Feb 26 16:55:17 2016 @@ -1,6 +1,5 @@ # Licensed to the Apache Software Foundation (ASF) under the terms of ASLv2 (http://www.apache.org/licenses/LICENSE-2.0). -Test-Cases: ${classes;CONCRETE;EXTENDS;org.apache.ace.it.IntegrationTestBase} -buildpath: \ ${^-buildpath},\ junit.osgi,\ @@ -50,10 +49,16 @@ Test-Cases: ${classes;CONCRETE;EXTENDS;o org.apache.ace.log.api;version=latest,\ org.apache.ace.feedback.common;version=latest,\ org.apache.ace.http.context;version=latest +-runvm: -ea +-runee: JavaSE-1.7 +-runsystempackages: sun.reflect +-runproperties: ${itestrunprops} +-baseline: + +Test-Cases: ${classes;CONCRETE;EXTENDS;org.apache.ace.it.IntegrationTestBase} Private-Package: org.apache.ace.it.log Bundle-Version: 1.0.0 Bundle-Name: Apache ACE Log itest Bundle-Description: Integration test bundle for Apache ACE Log Bundle-Category: itest --baseline: Modified: ace/trunk/org.apache.ace.log/test/org/apache/ace/log/LogDescriptorTest.java URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.log/test/org/apache/ace/log/LogDescriptorTest.java?rev=1732517&r1=1732516&r2=1732517&view=diff ============================================================================== --- ace/trunk/org.apache.ace.log/test/org/apache/ace/log/LogDescriptorTest.java (original) +++ ace/trunk/org.apache.ace.log/test/org/apache/ace/log/LogDescriptorTest.java Fri Feb 26 16:55:17 2016 @@ -18,21 +18,19 @@ */ package org.apache.ace.log; -import static org.apache.ace.test.utils.TestUtils.UNIT; - import org.apache.ace.feedback.Descriptor; import org.apache.ace.range.SortedRangeSet; import org.testng.annotations.Test; public class LogDescriptorTest { - @Test(groups = { UNIT }) + @Test() public void serializeDescriptor() { Descriptor descriptor = new Descriptor("gwid", 1, new SortedRangeSet("2-3")); assert descriptor.toRepresentation().equals("gwid,1,2-3") : "The representation of our descriptor is incorrect:" + descriptor.toRepresentation(); } - @Test(groups = { UNIT }) + @Test() public void deserializeDescriptor() { Descriptor descriptor = new Descriptor("gwid,1,2-3"); assert descriptor.getTargetID().equals("gwid") : "Target ID not correctly parsed."; @@ -40,7 +38,7 @@ public class LogDescriptorTest { assert descriptor.getRangeSet().toRepresentation().equals("2-3") : "There should be nothing in the diff between the set in the descriptor and the check-set."; } - @Test(groups = { UNIT }) + @Test() public void deserializeMultiRangeDescriptor() { Descriptor descriptor = new Descriptor("gwid,1,1-4$k6$k8$k10-20"); assert descriptor.getTargetID().equals("gwid") : "Target ID not correctly parsed."; @@ -49,7 +47,7 @@ public class LogDescriptorTest { assert representation.equals("1-4,6,8,10-20") : "There should be nothing in the diff between the set in the descriptor and the check-set, but we parsed: " + representation; } - @Test(groups = { UNIT }) + @Test() public void deserializeMultiRangeDescriptorWithFunnyGWID() { String line = "gw$$id,1,1-4$k6$k8$k10-20"; Descriptor descriptor = new Descriptor(line); @@ -60,7 +58,7 @@ public class LogDescriptorTest { assert representation.equals("1-4,6,8,10-20") : "There should be nothing in the diff between the set in the descriptor and the check-set, but we parsed: " + representation; } - @Test(groups = { UNIT }, expectedExceptions = IllegalArgumentException.class) + @Test(expectedExceptions = IllegalArgumentException.class) public void deserializeInvalidDescriptor() throws Exception { new Descriptor("invalidStringRepresentation"); } Modified: ace/trunk/org.apache.ace.log/test/org/apache/ace/log/LogEventTest.java URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.log/test/org/apache/ace/log/LogEventTest.java?rev=1732517&r1=1732516&r2=1732517&view=diff ============================================================================== --- ace/trunk/org.apache.ace.log/test/org/apache/ace/log/LogEventTest.java (original) +++ ace/trunk/org.apache.ace.log/test/org/apache/ace/log/LogEventTest.java Fri Feb 26 16:55:17 2016 @@ -18,8 +18,6 @@ */ package org.apache.ace.log; -import static org.apache.ace.test.utils.TestUtils.UNIT; - import java.util.HashMap; import java.util.Map; @@ -28,7 +26,7 @@ import org.apache.ace.feedback.Event; import org.testng.annotations.Test; public class LogEventTest { - @Test(groups = { UNIT }) + @Test() public void serializeLogEvent() { Event e = new Event("gwid", 1, 2, 3, AuditEvent.FRAMEWORK_STARTED); assert e.toRepresentation().equals("gwid,1,2,3," + AuditEvent.FRAMEWORK_STARTED); @@ -40,7 +38,7 @@ public class LogEventTest { assert e.toRepresentation().equals("gwid$kgwid$n$r$$,1,2,3," + AuditEvent.FRAMEWORK_STARTED); } - @Test(groups = { UNIT }) + @Test() public void deserializeLogEvent() { Event e = new Event("gwid$kgwid$n$r$$,1,2,3," + AuditEvent.FRAMEWORK_STARTED + ",a,1,b,2,c,3"); assert e.getTargetID().equals("gwid,gwid\n\r$") : "Target ID is not correctly parsed"; @@ -55,7 +53,7 @@ public class LogEventTest { assert p.get("c").equals("3") : "Property a should be 1"; } - @Test(groups = { UNIT }) + @Test() public void deserializeIllegalLogEvent() { try { new Event("garbage in, garbage out!"); Modified: ace/trunk/org.apache.ace.log/test/org/apache/ace/log/listener/LogTest.java URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.log/test/org/apache/ace/log/listener/LogTest.java?rev=1732517&r1=1732516&r2=1732517&view=diff ============================================================================== --- ace/trunk/org.apache.ace.log/test/org/apache/ace/log/listener/LogTest.java (original) +++ ace/trunk/org.apache.ace.log/test/org/apache/ace/log/listener/LogTest.java Fri Feb 26 16:55:17 2016 @@ -18,8 +18,6 @@ */ package org.apache.ace.log.listener; -import static org.apache.ace.test.utils.TestUtils.UNIT; - import java.util.Dictionary; import java.util.Hashtable; import java.util.List; @@ -51,7 +49,7 @@ public class LogTest { /** * Test whether logging to the cache and setting a new Log causes the log entries to be flushed to this new Log. */ - @Test(groups = { UNIT }) + @Test() public void testLogCacheFlush() throws Exception { assert ((MockLog) m_mockLog).getLogEntries().size() == 0 : "MockLog is not empty on start of test"; @@ -73,7 +71,7 @@ public class LogTest { * Test whether after unsetting the Log, no new log entries are added, but that they are added to the cache instead * (test the latter by flushing the cache). */ - @Test(groups = { UNIT }) + @Test() public void testUnsettingLog() throws Exception { assert ((MockLog) m_mockLog).getLogEntries().size() == 0 : "MockLog is not empty on start of test"; m_logProxy.setLog(m_mockLog); @@ -98,11 +96,11 @@ public class LogTest { } /** - * Basic functionality of the ListenerImpl is covered, the rest of the situations will probably be covered by integration - * tests. Note: test the deployment event INSTALL only when a BundleContext is available + * Basic functionality of the ListenerImpl is covered, the rest of the situations will probably be covered by + * integration tests. Note: test the deployment event INSTALL only when a BundleContext is available */ @SuppressWarnings("unchecked") - @Test(groups = { UNIT }) + @Test() public void testEventConverting() throws Exception { ListenerImpl listeners = new ListenerImpl(null, m_logProxy); listeners.startInternal(); Modified: ace/trunk/org.apache.ace.log/test/org/apache/ace/log/server/servlet/LogServletTest.java URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.log/test/org/apache/ace/log/server/servlet/LogServletTest.java?rev=1732517&r1=1732516&r2=1732517&view=diff ============================================================================== --- ace/trunk/org.apache.ace.log/test/org/apache/ace/log/server/servlet/LogServletTest.java (original) +++ ace/trunk/org.apache.ace.log/test/org/apache/ace/log/server/servlet/LogServletTest.java Fri Feb 26 16:55:17 2016 @@ -18,8 +18,6 @@ */ package org.apache.ace.log.server.servlet; -import static org.apache.ace.test.utils.TestUtils.UNIT; - import java.io.IOException; import java.util.ArrayList; import java.util.Dictionary; @@ -63,7 +61,7 @@ public class LogServletTest { protected void tearDown() throws Exception { } - @Test(groups = { UNIT }) + @Test() public void queryLog() throws Exception { MockServletOutputStream output = new MockServletOutputStream(); boolean result = m_logServlet.handleQuery(m_range.getTargetID(), String.valueOf(m_range.getStoreID()), null, output); @@ -74,8 +72,8 @@ public class LogServletTest { assert result; assert (m_range.toRepresentation() + "\n").equals(output.m_text); } - - @Test(groups = { UNIT }) + + @Test() public void queryLogWithTargetFilter() throws Exception { MockServletOutputStream output = new MockServletOutputStream(); boolean result = m_logServlet.handleQuery(m_range.getTargetID(), null, null, output); @@ -86,17 +84,17 @@ public class LogServletTest { assert result; assert (m_range.toRepresentation() + "\n").equals(output.m_text); } - - @Test(groups = { UNIT }) + + @Test() public void receiveLowestID() throws Exception { - // no lowest ID set + // no lowest ID set MockServletOutputStream output = new MockServletOutputStream(); boolean result = m_logServlet.handleReceiveIDs(m_range.getTargetID(), String.valueOf(m_range.getStoreID()), null, output); assert result; String expected = ""; String actual = output.m_text; assert expected.equals(actual) : "We expected '" + expected + "', but received '" + actual + "'"; - + // set lowest ID m_mockStore.setLowestID(m_range.getTargetID(), m_range.getStoreID(), 5); output = new MockServletOutputStream(); @@ -107,17 +105,17 @@ public class LogServletTest { assert expected.equals(actual) : "We expected '" + expected + "', but received '" + actual + "'"; } - @Test(groups = { UNIT }) + @Test() public void sendLowestID() throws Exception { MockServletInputStream input = new MockServletInputStream(); String expected = m_range.getTargetID() + "," + m_range.getStoreID() + ",9\n"; input.setBytes(expected.getBytes()); m_logServlet.handleSendIDs(input); long lowestID = m_mockStore.getLowestID(m_range.getTargetID(), m_range.getStoreID()); - assert 9 == lowestID : "Expected lowest ID to be 9, but got: " + lowestID; + assert 9 == lowestID : "Expected lowest ID to be 9, but got: " + lowestID; } - @Test(groups = { UNIT }) + @Test() public void receiveLog() throws Exception { MockServletOutputStream output = new MockServletOutputStream(); boolean result = m_logServlet.handleReceive(m_range.getTargetID(), String.valueOf(m_range.getStoreID()), "1", null, output); @@ -127,14 +125,15 @@ public class LogServletTest { assert expected.equals(actual) : "We expected '" + expected + "', but received '" + actual + "'"; output = new MockServletOutputStream(); - result = m_logServlet.handleReceive(m_range.getTargetID(), String.valueOf(m_range.getStoreID()), null , null, output); + result = m_logServlet.handleReceive(m_range.getTargetID(), String.valueOf(m_range.getStoreID()), null, null, output); assert result; expected = m_event1.toRepresentation() + "\n" + m_event2.toRepresentation() + "\n"; actual = output.m_text; - assert expected.equals(actual) : "We expected '" + expected + "', but received '" + actual + "'";; + assert expected.equals(actual) : "We expected '" + expected + "', but received '" + actual + "'"; + ; } - @Test(groups = { UNIT }) + @Test() public void sendLog() throws Exception { MockServletInputStream input = new MockServletInputStream(); String expected = m_event1.toRepresentation() + "\n" + m_event2.toRepresentation() + "\n"; @@ -150,43 +149,48 @@ public class LogServletTest { } private static class Tuple { - private final String m_targetID; - private final long m_logID; - public Tuple(String targetID, long logID) { - if (targetID == null) { - throw new IllegalArgumentException("TargetID cannot be null"); - } - m_targetID = targetID; - m_logID = logID; - } - public String getTargetID() { - return m_targetID; - } - public long getLogID() { - return m_logID; - } - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (int) (m_logID ^ (m_logID >>> 32)); - result = prime * result + m_targetID.hashCode(); - return result; - } - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - Tuple other = (Tuple) obj; - return (m_logID == other.getLogID() && m_targetID.equals(other.getTargetID())); - } + private final String m_targetID; + private final long m_logID; + + public Tuple(String targetID, long logID) { + if (targetID == null) { + throw new IllegalArgumentException("TargetID cannot be null"); + } + m_targetID = targetID; + m_logID = logID; + } + + public String getTargetID() { + return m_targetID; + } + + public long getLogID() { + return m_logID; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (int) (m_logID ^ (m_logID >>> 32)); + result = prime * result + m_targetID.hashCode(); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + Tuple other = (Tuple) obj; + return (m_logID == other.getLogID() && m_targetID.equals(other.getTargetID())); + } } private class MockLogStore implements LogStore { @@ -202,40 +206,48 @@ public class LogServletTest { } return events; } + public List<Descriptor> getDescriptors(String targetID) { - List<Descriptor> ranges = new ArrayList<>(); + List<Descriptor> ranges = new ArrayList<>(); ranges.add(m_range); return ranges; } + public List<Descriptor> getDescriptors() { List<Descriptor> ranges = new ArrayList<>(); ranges.add(m_range); return ranges; } + public Descriptor getDescriptor(String targetID, long logID) throws IOException { return m_range; } + public void put(List<Event> events) throws IOException { m_events = events; } + public void clean() throws IOException { throw new UnsupportedOperationException("not implemented"); } + @Override public Event put(String targetID, int type, Dictionary props) throws IOException { throw new UnsupportedOperationException("not implemented"); } + private Map<Tuple, Long> m_lowestIDs = new HashMap<>(); - - @Override - public void setLowestID(String targetID, long logID, long lowestID) throws IOException { - m_lowestIDs.put(new Tuple(targetID, logID), lowestID); - } - @Override - public long getLowestID(String targetID, long logID) throws IOException { - Long result = m_lowestIDs.get(new Tuple(targetID, logID)); - return result == null ? 0 : result.longValue(); - } + + @Override + public void setLowestID(String targetID, long logID, long lowestID) throws IOException { + m_lowestIDs.put(new Tuple(targetID, logID), lowestID); + } + + @Override + public long getLowestID(String targetID, long logID) throws IOException { + Long result = m_lowestIDs.get(new Tuple(targetID, logID)); + return result == null ? 0 : result.longValue(); + } } private class MockServletOutputStream extends ServletOutputStream { @@ -245,6 +257,7 @@ public class LogServletTest { public void print(String s) throws IOException { m_text = m_text.concat(s); } + @Override public void write(int arg0) throws IOException { } Modified: ace/trunk/org.apache.ace.log/test/org/apache/ace/log/server/store/impl/ServerLogStoreTester.java URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.log/test/org/apache/ace/log/server/store/impl/ServerLogStoreTester.java?rev=1732517&r1=1732516&r2=1732517&view=diff ============================================================================== --- ace/trunk/org.apache.ace.log/test/org/apache/ace/log/server/store/impl/ServerLogStoreTester.java (original) +++ ace/trunk/org.apache.ace.log/test/org/apache/ace/log/server/store/impl/ServerLogStoreTester.java Fri Feb 26 16:55:17 2016 @@ -18,8 +18,6 @@ */ package org.apache.ace.log.server.store.impl; -import static org.apache.ace.test.utils.TestUtils.UNIT; - import java.io.File; import java.io.IOException; import java.util.ArrayList; @@ -66,7 +64,7 @@ public class ServerLogStoreTester { } @SuppressWarnings("serial") - @Test(groups = { UNIT }) + @Test() public void testLog() throws IOException { Map<String, String> props = new HashMap<>(); props.put("test", "bar"); @@ -97,7 +95,7 @@ public class ServerLogStoreTester { } @SuppressWarnings("serial") - @Test(groups = { UNIT }) + @Test() public void testLogOutOfOrder() throws IOException { Map<String, String> props = new HashMap<>(); props.put("test", "bar"); @@ -121,7 +119,7 @@ public class ServerLogStoreTester { } @SuppressWarnings("serial") - @Test(groups = { UNIT }) + @Test() public void testLogOutOfOrderOneByOne() throws IOException { Map<String, String> props = new HashMap<>(); props.put("test", "bar"); @@ -148,9 +146,8 @@ public class ServerLogStoreTester { assert out.size() == 3 : "Stored events differ from the added: " + out.size(); } - @SuppressWarnings("serial") - @Test(groups = { UNIT }) + @Test() public void testLogLowestID() throws IOException { Map<String, String> props = new HashMap<>(); props.put("test", "bar"); @@ -195,7 +192,7 @@ public class ServerLogStoreTester { } @SuppressWarnings("serial") - @Test(groups = { UNIT }) + @Test() public void testLogIDGenerationWithLowestID() throws IOException { Dictionary<String, String> props = new Hashtable<>(); props.put("test", "foo"); @@ -213,10 +210,10 @@ public class ServerLogStoreTester { assert range.equals("1-20") : "Incorrect range in descriptor: " + range; List<Event> stored = getStoredEvents(); assert stored.size() == 20 : "Exactly 20 events should have been stored"; - + m_logStore.setLowestID("target", logID, 10); assert 10 == m_logStore.getLowestID("target", logID) : "Lowest ID should be 10, not: " + m_logStore.getLowestID("target", logID); - + stored = getStoredEvents(); assert stored.size() == 11 : "Exactly 11 events should have been stored, we found " + stored.size(); descriptors = m_logStore.getDescriptors(); @@ -235,7 +232,7 @@ public class ServerLogStoreTester { for (long id = 1; id <= 20; id++) { System.out.println("Event: " + m_logStore.put("target", 1, props).toRepresentation()); } - + stored = getStoredEvents(); assert stored.size() == 20 : "Exactly 20 events should have been stored, we found " + stored.size(); descriptors = m_logStore.getDescriptors(); @@ -243,9 +240,9 @@ public class ServerLogStoreTester { range = descriptors.get(0).getRangeSet().toRepresentation(); assert range.equals("21-40") : "Incorrect range in descriptor: " + range; } - + private List<Event> getStoredEvents() throws IOException { - List<Event> stored = new ArrayList<>(); + List<Event> stored = new ArrayList<>(); for (Descriptor range : m_logStore.getDescriptors()) { System.out.println("TID: " + range.getTargetID()); for (Descriptor range2 : m_logStore.getDescriptors(range.getTargetID())) { @@ -253,11 +250,10 @@ public class ServerLogStoreTester { System.out.println(" Range: " + range2.getRangeSet()); } } - return stored; - } - - - @Test(groups = { UNIT }) + return stored; + } + + @Test() public void testCreateLogMessagesConcurrently() throws Exception { final Properties props = new Properties(); props.put("test", "bar"); @@ -266,16 +262,18 @@ public class ServerLogStoreTester { assert ranges.isEmpty() : "New store should have no ranges."; ExecutorService exec = Executors.newFixedThreadPool(10); for (final String target : new String[] { "g1", "g2", "g3", "g4", "g5", "g6", "g7", "g8", "g9", "g10" }) { - exec.execute(new Runnable() { public void run() { - for (long id = 0; id < 1000; id++) { - try { - m_logStore.put(target, 1, props); - } - catch (IOException e) { - throw new RuntimeException(e); - } - } - };} ); + exec.execute(new Runnable() { + public void run() { + for (long id = 0; id < 1000; id++) { + try { + m_logStore.put(target, 1, props); + } + catch (IOException e) { + throw new RuntimeException(e); + } + } + }; + }); } exec.shutdown(); exec.awaitTermination(10, TimeUnit.SECONDS); @@ -283,9 +281,8 @@ public class ServerLogStoreTester { List<Event> stored = getStoredEvents(); assert stored.size() == 10000 : "Incorrect number of events got stored: " + stored.size(); } - - - @Test(groups = { TestUtils.UNIT }) + + @Test() public void testLogWithSpecialCharacters() throws IOException { String targetID = "myta\0rget"; Event event = new Event(targetID, 1, 1, System.currentTimeMillis(), AuditEvent.FRAMEWORK_STARTED); @@ -297,14 +294,14 @@ public class ServerLogStoreTester { } @SuppressWarnings({ "rawtypes", "unchecked" }) - @Test(groups = { TestUtils.UNIT }) + @Test() public void testMaximumNumberOfEvents() throws Exception { Dictionary settings = new Properties(); settings.put(MAXIMUM_NUMBER_OF_EVENTS, "1"); m_logStore.updated(settings); - + List<Event> events = new ArrayList<>(); - for (String target : new String[] { "target"}) { + for (String target : new String[] { "target" }) { for (long log : new long[] { 1 }) { for (long id : new long[] { 1, 2 }) { events.add(new Event(target, log, id, System.currentTimeMillis(), AuditEvent.FRAMEWORK_STARTED, new HashMap<String, String>())); @@ -326,21 +323,21 @@ public class ServerLogStoreTester { } @SuppressWarnings({ "rawtypes", "unchecked" }) - @Test(groups = { TestUtils.UNIT }) + @Test() public void testMaximumNumberOfEventsMultipleLogs() throws Exception { Dictionary settings = new Properties(); settings.put(MAXIMUM_NUMBER_OF_EVENTS, "1"); m_logStore.updated(settings); - + List<Event> events = new ArrayList<>(); - for (String target : new String[] { "target"}) { - for (long log : new long[] { 1,2 }) { + for (String target : new String[] { "target" }) { + for (long log : new long[] { 1, 2 }) { for (long id : new long[] { 1, 2 }) { events.add(new Event(target, log, id, System.currentTimeMillis(), AuditEvent.FRAMEWORK_STARTED, new HashMap<String, String>())); } } } - + m_logStore.put(events); List<Descriptor> allDescriptors = m_logStore.getDescriptors(); assert allDescriptors.size() == 2 : "Expected two descriptor, found: " + allDescriptors.size(); @@ -354,10 +351,10 @@ public class ServerLogStoreTester { } @SuppressWarnings({ "rawtypes", "unchecked" }) - @Test(groups = { TestUtils.UNIT }) + @Test() public void testClean() throws Exception { List<Event> events = new ArrayList<>(); - for (String target : new String[] { "target"}) { + for (String target : new String[] { "target" }) { for (long log : new long[] { 1, 2 }) { for (long id : new long[] { 1, 2, 3, 4 }) { events.add(new Event(target, log, id, System.currentTimeMillis(), AuditEvent.FRAMEWORK_STARTED, new HashMap<String, String>())); @@ -369,7 +366,7 @@ public class ServerLogStoreTester { Dictionary settings = new Properties(); settings.put(MAXIMUM_NUMBER_OF_EVENTS, "1"); m_logStore.updated(settings); - + m_logStore.clean(); List<Descriptor> allDescriptors = m_logStore.getDescriptors(); assert allDescriptors.size() == 2 : "Expected two descriptor, found: " + allDescriptors.size(); @@ -381,12 +378,9 @@ public class ServerLogStoreTester { } } } - - - - + @SuppressWarnings("serial") - @Test(groups = { UNIT }) + @Test() public void testConcurrentLog() throws IOException, InterruptedException { ExecutorService es = Executors.newFixedThreadPool(8); final Map<String, String> props = new HashMap<>(); @@ -412,7 +406,7 @@ public class ServerLogStoreTester { // TODO Auto-generated catch block e.printStackTrace(); } - + } }); } @@ -429,8 +423,7 @@ public class ServerLogStoreTester { out.add(event.toRepresentation()); } } - - + private void delete(File root) { if (root.isDirectory()) { for (File child : root.listFiles()) { Modified: ace/trunk/org.apache.ace.log/test/org/apache/ace/log/server/task/LogTaskTest.java URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.log/test/org/apache/ace/log/server/task/LogTaskTest.java?rev=1732517&r1=1732516&r2=1732517&view=diff ============================================================================== --- ace/trunk/org.apache.ace.log/test/org/apache/ace/log/server/task/LogTaskTest.java (original) +++ ace/trunk/org.apache.ace.log/test/org/apache/ace/log/server/task/LogTaskTest.java Fri Feb 26 16:55:17 2016 @@ -18,7 +18,6 @@ */ package org.apache.ace.log.server.task; -import static org.apache.ace.test.utils.TestUtils.UNIT; import static org.testng.Assert.*; import java.io.IOException; @@ -59,7 +58,7 @@ public class LogTaskTest { /** * This test tests both delta computation and push behavior. */ - @Test(groups = { UNIT }) + @Test() public void testDeltaComputation() throws IOException { // TODO: Test the new LogDescriptor. List<Descriptor> src = new ArrayList<>(); Modified: ace/trunk/org.apache.ace.log/test/org/apache/ace/log/target/store/impl/GatewayLogStoreTest.java URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.log/test/org/apache/ace/log/target/store/impl/GatewayLogStoreTest.java?rev=1732517&r1=1732516&r2=1732517&view=diff ============================================================================== --- ace/trunk/org.apache.ace.log/test/org/apache/ace/log/target/store/impl/GatewayLogStoreTest.java (original) +++ ace/trunk/org.apache.ace.log/test/org/apache/ace/log/target/store/impl/GatewayLogStoreTest.java Fri Feb 26 16:55:17 2016 @@ -18,8 +18,6 @@ */ package org.apache.ace.log.target.store.impl; -import static org.apache.ace.test.utils.TestUtils.UNIT; - import java.io.File; import java.io.IOException; import java.util.ArrayList; @@ -43,7 +41,7 @@ public class GatewayLogStoreTest { @BeforeMethod(alwaysRun = true) protected void setUp() throws Exception { - m_dir = File.createTempFile(LogStore.class.getName(), null); + m_dir = File.createTempFile(LogStore.class.getName(), null); m_dir.delete(); m_logStore = new LogStoreImpl(m_dir); TestUtils.configureObject(m_logStore, LogService.class); @@ -64,18 +62,30 @@ public class GatewayLogStoreTest { } @SuppressWarnings({ "serial" }) - @Test(groups = {UNIT}) + @Test public void testLog() throws IOException { long[] ids = m_logStore.getLogIDs(); assert ids.length == 1 : "New store should have only one id"; List<String> events = new ArrayList<>(); - events.add(m_logStore.put(AuditEvent.FRAMEWORK_STARTED, new Properties() {{put("test", "test");}}).toRepresentation()); - events.add(m_logStore.put(AuditEvent.BUNDLE_INSTALLED, new Properties() {{put("test", "test");}}).toRepresentation()); - events.add(m_logStore.put(AuditEvent.DEPLOYMENTADMIN_COMPLETE, new Properties() {{put("test", "test");}}).toRepresentation()); + events.add(m_logStore.put(AuditEvent.FRAMEWORK_STARTED, new Properties() { + { + put("test", "test"); + } + }).toRepresentation()); + events.add(m_logStore.put(AuditEvent.BUNDLE_INSTALLED, new Properties() { + { + put("test", "test"); + } + }).toRepresentation()); + events.add(m_logStore.put(AuditEvent.DEPLOYMENTADMIN_COMPLETE, new Properties() { + { + put("test", "test"); + } + }).toRepresentation()); ids = m_logStore.getLogIDs(); assert ids.length == 1 : "Error free store should have only one id"; long highest = m_logStore.getHighestID(ids[0]); - assert highest == 3 : "Store with 3 entries should have 3 as highest id but was: " + highest; + assert highest == 3 : "Store with 3 entries should have 3 as highest id but was: " + highest; List<String> result = new ArrayList<>(); for (Event event : (List<Event>) m_logStore.get(ids[0])) { result.add(event.toRepresentation()); @@ -88,7 +98,7 @@ public class GatewayLogStoreTest { assert result.equals(events) : "Events " + events + " should equal full log " + result; } - @Test(groups = {UNIT}, expectedExceptions = {IOException.class}) + @Test(expectedExceptions = { IOException.class }) public void testExceptionHandling() throws IOException { m_logStore.handleException(m_logStore.getLog(4711), new IOException("test")); } Modified: ace/trunk/org.apache.ace.log/test/org/apache/ace/log/target/task/LogSyncTaskTest.java URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.log/test/org/apache/ace/log/target/task/LogSyncTaskTest.java?rev=1732517&r1=1732516&r2=1732517&view=diff ============================================================================== --- ace/trunk/org.apache.ace.log/test/org/apache/ace/log/target/task/LogSyncTaskTest.java (original) +++ ace/trunk/org.apache.ace.log/test/org/apache/ace/log/target/task/LogSyncTaskTest.java Fri Feb 26 16:55:17 2016 @@ -18,8 +18,6 @@ */ package org.apache.ace.log.target.task; -import static org.apache.ace.test.utils.TestUtils.UNIT; - import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -58,28 +56,30 @@ public class LogSyncTaskTest { TestUtils.configureObject(m_task, LogStore.class); } - @Test(groups = { UNIT }) + @Test() public synchronized void getRange() throws Exception { final Descriptor range = new Descriptor(TARGET_ID, 1, new SortedRangeSet("1-10")); m_task.getDescriptor(new InputStream() { int m_count = 0; byte[] m_bytes = (range.toRepresentation() + "\n").getBytes(); + @Override public int read() throws IOException { if (m_count < m_bytes.length) { byte b = m_bytes[m_count]; m_count++; return b; - } else { + } + else { return -1; } } }); } - @Test(groups = { UNIT }) + @Test() public synchronized void synchronizeLog() throws Exception { - final Descriptor range = new Descriptor(TARGET_ID, 1, new SortedRangeSet(new long[] {0})); + final Descriptor range = new Descriptor(TARGET_ID, 1, new SortedRangeSet(new long[] { 0 })); final Event event = new Event(TARGET_ID, 1, 1, 1, 1); final List<Event> events = new ArrayList<>(); events.add(event); @@ -87,13 +87,15 @@ public class LogSyncTaskTest { InputStream input = new InputStream() { byte[] bytes = range.toRepresentation().getBytes(); int count = 0; + @Override public int read() throws IOException { if (count < bytes.length) { byte b = bytes[count]; count++; return b; - } else { + } + else { return -1; } } @@ -102,15 +104,25 @@ public class LogSyncTaskTest { public List<?> get(long logID, long from, long to) throws IOException { return events; } + public long getHighestID(long logID) throws IOException { return event.getID(); } - public List<?> get(long logID) throws IOException { return null; } - public long[] getLogIDs() throws IOException { return null; } - public Event put(int type, Dictionary props) throws IOException { return null; } + + public List<?> get(long logID) throws IOException { + return null; + } + + public long[] getLogIDs() throws IOException { + return null; + } + + public Event put(int type, Dictionary props) throws IOException { + return null; + } }); MockConnection connection = new MockConnection(new URL("http://mock")); - + m_task.synchronizeLog(1, input, connection); String expectedString = event.toRepresentation() + "\n"; String actualString = connection.getString(); @@ -153,8 +165,9 @@ public class LogSyncTaskTest { } private class MockOutputStream extends OutputStream { - byte[] bytes = new byte[8*1024]; + byte[] bytes = new byte[8 * 1024]; int count = 0; + @Override public void write(int arg0) throws IOException { bytes[count] = (byte) arg0; Modified: ace/trunk/org.apache.ace.obr/test/org/apache/ace/obr/metadata/repoindeximpl/RepoIndexMetadataTest.java URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.obr/test/org/apache/ace/obr/metadata/repoindeximpl/RepoIndexMetadataTest.java?rev=1732517&r1=1732516&r2=1732517&view=diff ============================================================================== --- ace/trunk/org.apache.ace.obr/test/org/apache/ace/obr/metadata/repoindeximpl/RepoIndexMetadataTest.java (original) +++ ace/trunk/org.apache.ace.obr/test/org/apache/ace/obr/metadata/repoindeximpl/RepoIndexMetadataTest.java Fri Feb 26 16:55:17 2016 @@ -18,8 +18,6 @@ */ package org.apache.ace.obr.metadata.repoindeximpl; -import static org.apache.ace.test.utils.TestUtils.UNIT; - import java.io.BufferedReader; import java.io.File; import java.io.FileReader; @@ -44,7 +42,7 @@ public class RepoIndexMetadataTest { /** * Generate metadata index, verify contents */ - @Test(groups = { UNIT }) + @Test() public void generateMetaData() throws Exception { File dir = File.createTempFile("meta", ""); dir.delete(); @@ -72,7 +70,7 @@ public class RepoIndexMetadataTest { /** * Generate a metadata index, remove a bundle, regenerate metadata, verify. */ - @Test(groups = { UNIT }) + @Test() public void updateMetaData() throws Exception { File dir = File.createTempFile("meta", ""); dir.delete(); @@ -101,7 +99,7 @@ public class RepoIndexMetadataTest { /** * Generate metadata index with partially invalid contents, verify contents */ - @Test(groups = { UNIT }) + @Test() public void generatePartiallyInvalidMetaData() throws Exception { File dir = File.createTempFile("meta", ""); dir.delete(); Modified: ace/trunk/org.apache.ace.obr/test/org/apache/ace/obr/metadata/util/ResourceMetaDataTest.java URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.obr/test/org/apache/ace/obr/metadata/util/ResourceMetaDataTest.java?rev=1732517&r1=1732516&r2=1732517&view=diff ============================================================================== --- ace/trunk/org.apache.ace.obr/test/org/apache/ace/obr/metadata/util/ResourceMetaDataTest.java (original) +++ ace/trunk/org.apache.ace.obr/test/org/apache/ace/obr/metadata/util/ResourceMetaDataTest.java Fri Feb 26 16:55:17 2016 @@ -18,8 +18,6 @@ */ package org.apache.ace.obr.metadata.util; -import static org.apache.ace.test.utils.TestUtils.UNIT; - import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -32,23 +30,23 @@ import org.testng.annotations.Test; public class ResourceMetaDataTest { - @Test(groups = { UNIT }) + @Test() public void checkArtifactMetadataGeneration() throws Exception { ResourceMetaData data = ResourceMetaData.getArtifactMetaData("foo.bar-1.0.3.xml"); assert "foo.bar".equals(data.getSymbolicName()) : "Generated symbolic name should be 'foo.bar', was " + data.getSymbolicName(); assert "1.0.3".equals(data.getVersion()) : "Generated version should be '1.0.3', was " + data.getVersion(); assert "xml".equals(data.getExtension()) : "Extension should be 'xml', was " + data.getExtension(); } - - @Test(groups = { UNIT }) + + @Test() public void checkConfigurationTemplateMetadataGeneration() throws Exception { ResourceMetaData data = ResourceMetaData.getArtifactMetaData("org.foo.configuration-1.0.0.xml-target-1-2.0.0.xml"); assert "org.foo.configuration-1.0.0.xml-target-1".equals(data.getSymbolicName()) : "Generated symbolic name should be 'org.foo.configuration-1.0.0.xml-target-1', was " + data.getSymbolicName(); assert "2.0.0".equals(data.getVersion()) : "Generated version should be '2.0.0', was " + data.getVersion(); assert "xml".equals(data.getExtension()) : "Extension should be 'xml', was " + data.getExtension(); - } + } - @Test(groups = { UNIT }) + @Test() public void checkBundleMetadataGeneration() throws Exception { ResourceMetaData data = ResourceMetaData.getBundleMetaData(createBundle("foo.bar", "1.0.3")); assert "foo.bar".equals(data.getSymbolicName()) : "Generated symbolic name should be 'foo.bar', was " + data.getSymbolicName(); Modified: ace/trunk/org.apache.ace.obr/test/org/apache/ace/obr/servlet/BundleServletTest.java URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.obr/test/org/apache/ace/obr/servlet/BundleServletTest.java?rev=1732517&r1=1732516&r2=1732517&view=diff ============================================================================== --- ace/trunk/org.apache.ace.obr/test/org/apache/ace/obr/servlet/BundleServletTest.java (original) +++ ace/trunk/org.apache.ace.obr/test/org/apache/ace/obr/servlet/BundleServletTest.java Fri Feb 26 16:55:17 2016 @@ -18,8 +18,6 @@ */ package org.apache.ace.obr.servlet; -import static org.apache.ace.test.utils.TestUtils.UNIT; - import java.io.BufferedInputStream; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -204,7 +202,7 @@ public class BundleServletTest { } } - @Test(groups = { UNIT }) + @Test() public void testGetValidResource() throws Exception { m_requestFile = m_testFile.getName(); m_bundleServlet.doGet(m_request, m_response); @@ -215,7 +213,7 @@ public class BundleServletTest { assert checkStream : "One stream stopped before the other one did."; } - @Test(groups = { UNIT }) + @Test() public void testGetInValidResource() throws Exception { m_requestFile = "UnknownFile"; m_bundleServlet.doGet(m_request, m_response); @@ -223,7 +221,7 @@ public class BundleServletTest { assert m_status == HttpServletResponse.SC_NOT_FOUND : "We should have got response code " + HttpServletResponse.SC_NOT_FOUND + " and we got " + m_status; } - @Test(groups = { UNIT }) + @Test() public void testPostResource() throws Exception { m_requestFile = "NewFile"; m_bundleServlet.doPost(m_request, m_response); @@ -233,7 +231,7 @@ public class BundleServletTest { assert m_status == HttpServletResponse.SC_CONFLICT; } - @Test(groups = { UNIT }) + @Test() public void testRemoveResource() throws Exception { m_requestFile = "RemoveMe"; m_bundleServlet.doDelete(m_request, m_response); @@ -243,7 +241,7 @@ public class BundleServletTest { assert m_status == HttpServletResponse.SC_NOT_FOUND; } - @Test(groups = { UNIT }) + @Test() public void testRemoveResourceInPath() throws Exception { m_requestFile = "path/to/file"; m_bundleServlet.doDelete(m_request, m_response); Modified: ace/trunk/org.apache.ace.obr/test/org/apache/ace/obr/storage/file/BundleFileStoreSplitTest.java URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.obr/test/org/apache/ace/obr/storage/file/BundleFileStoreSplitTest.java?rev=1732517&r1=1732516&r2=1732517&view=diff ============================================================================== --- ace/trunk/org.apache.ace.obr/test/org/apache/ace/obr/storage/file/BundleFileStoreSplitTest.java (original) +++ ace/trunk/org.apache.ace.obr/test/org/apache/ace/obr/storage/file/BundleFileStoreSplitTest.java Fri Feb 26 16:55:17 2016 @@ -18,21 +18,19 @@ */ package org.apache.ace.obr.storage.file; -import static org.apache.ace.test.utils.TestUtils.UNIT; - import static org.testng.Assert.*; import org.testng.annotations.Test; public class BundleFileStoreSplitTest { - @Test(groups = { UNIT }) + @Test public void testBasicSplit() throws Exception { - assertEquals(BundleFileStore.split("org.foo"), new String[] {"org", "foo"}); - assertEquals(BundleFileStore.split("org.foo-1.0.0.SNAPSHOT"), new String[] {"org", "foo-1.0.0.SNAPSHOT"}); - assertEquals(BundleFileStore.split("org.foo.bar.of.chocolate"), new String[] {"org", "foo", "bar", "of", "chocolate"}); - assertEquals(BundleFileStore.split("org.foo.1"), new String[] {"org", "foo.1"}); - assertEquals(BundleFileStore.split("org.foo-1.0.org.foo-1.0"), new String[] {"org", "foo-1.0.org.foo-1.0"}); - assertEquals(BundleFileStore.split(""), new String[] {""}); - assertEquals(BundleFileStore.split("."), new String[] {"."}); - assertEquals(BundleFileStore.split("abc."), new String[] {"abc."}); + assertEquals(BundleFileStore.split("org.foo"), new String[] { "org", "foo" }); + assertEquals(BundleFileStore.split("org.foo-1.0.0.SNAPSHOT"), new String[] { "org", "foo-1.0.0.SNAPSHOT" }); + assertEquals(BundleFileStore.split("org.foo.bar.of.chocolate"), new String[] { "org", "foo", "bar", "of", "chocolate" }); + assertEquals(BundleFileStore.split("org.foo.1"), new String[] { "org", "foo.1" }); + assertEquals(BundleFileStore.split("org.foo-1.0.org.foo-1.0"), new String[] { "org", "foo-1.0.org.foo-1.0" }); + assertEquals(BundleFileStore.split(""), new String[] { "" }); + assertEquals(BundleFileStore.split("."), new String[] { "." }); + assertEquals(BundleFileStore.split("abc."), new String[] { "abc." }); } } Modified: ace/trunk/org.apache.ace.obr/test/org/apache/ace/obr/storage/file/BundleFileStoreTest.java URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.obr/test/org/apache/ace/obr/storage/file/BundleFileStoreTest.java?rev=1732517&r1=1732516&r2=1732517&view=diff ============================================================================== --- ace/trunk/org.apache.ace.obr/test/org/apache/ace/obr/storage/file/BundleFileStoreTest.java (original) +++ ace/trunk/org.apache.ace.obr/test/org/apache/ace/obr/storage/file/BundleFileStoreTest.java Fri Feb 26 16:55:17 2016 @@ -18,8 +18,6 @@ */ package org.apache.ace.obr.storage.file; -import static org.apache.ace.test.utils.TestUtils.UNIT; - import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -97,7 +95,7 @@ public class BundleFileStoreTest { /** * Test whether the metadata is generated when getting a bundle from the repository. */ - @Test(groups = { UNIT }) + @Test() public void getBundle() throws Exception { m_bundleStore.get(m_bundleSubstitute1.getName()); assert !m_metadata.generated() : "During getting a bundle, the metadata should not be regenerated."; @@ -106,16 +104,16 @@ public class BundleFileStoreTest { /** * Test that the bundle store reutrns null for non-existing files. */ - @Test(groups = { UNIT }) + @Test() public void getNonExistingBundle() throws Exception { assert m_bundleStore.get("blaat") == null : "Getting an non-existing file did not result in null?"; } /** - * Test whether retrieving the index.xml results in a call to the (mock) metadata generator, and the original - * file should correspond with the retrieved file. + * Test whether retrieving the index.xml results in a call to the (mock) metadata generator, and the original file + * should correspond with the retrieved file. */ - @Test(groups = { UNIT }) + @Test() public void getRepositoryFile() throws Exception { InputStream newInputStream = m_bundleStore.get("index.xml"); assert m_metadata.generated() : "During getting the repository file, the metadata should be regenerated."; @@ -135,7 +133,7 @@ public class BundleFileStoreTest { * Test whether the BundleStore notices the set of bundles has changed (bundle updated), and makes a call to the * (mock) metadata generator. */ - @Test(groups = { UNIT }) + @Test() public void updateBundle() throws Exception { m_bundleStore.get("index.xml"); assert m_metadata.numberOfCalls() == 1 : "The MetadataGenerator should be called once"; @@ -154,7 +152,7 @@ public class BundleFileStoreTest { * (mock) metadata generator. Also a call should be made when a bundle is replaced by another one (number of bundles * stay the same, but one bundle is replaced by another). */ - @Test(groups = { UNIT }) + @Test() public void addBundle() throws Exception { m_bundleStore.get("index.xml"); assert m_metadata.numberOfCalls() == 1 : "The MetadataGenerator should be called once"; @@ -179,7 +177,7 @@ public class BundleFileStoreTest { * Test whether the BundleStore notices the set of bundles has not changed, and thus will not make a call to the * (mock) metadata generator. */ - @Test(groups = { UNIT }) + @Test() public void replaceWithSameBundle() throws Exception { m_bundleStore.get("bundleSub1.jar"); assert m_metadata.numberOfCalls() == 0 : "The MetadataGenerator should not be called"; @@ -204,7 +202,7 @@ public class BundleFileStoreTest { * Test whether changing the directory where the bundles are stored, does not result in a call to the (mock) * metadata generator, as the metadata will only be regenerated after getting a file. */ - @Test(groups = { UNIT }) + @Test() public void updateConfigurationWithValidConfiguration() throws Exception { File subDir = new File(m_directory.getAbsolutePath(), "changedDirectory"); subDir.mkdir(); @@ -229,7 +227,7 @@ public class BundleFileStoreTest { * Test whether changing the directory where the bundles are stored to something that is not a directory, this * should fail. */ - @Test(groups = { UNIT }) + @Test() public void updateConfigurationWithIsNotDirectory() throws Exception { boolean exceptionThrown = false; @@ -252,7 +250,7 @@ public class BundleFileStoreTest { file.delete(); } - @Test(groups = { UNIT }) + @Test() public void putBundle() throws Exception { File bundle = createTmpResource("foo.bar", "1.0.0"); String filePath = m_bundleStore.put(new FileInputStream(bundle), null, false); @@ -261,7 +259,7 @@ public class BundleFileStoreTest { assert file.exists(); } - @Test(groups = { UNIT }) + @Test() public void putBundleSameDuplicate() throws Exception { File bundle = createTmpResource("foo.bar", "1.0.0"); String filePath = m_bundleStore.put(new FileInputStream(bundle), null, false); @@ -271,17 +269,17 @@ public class BundleFileStoreTest { assert filePath2.equals(filePath); } - @Test(groups = { UNIT }) + @Test() public void putBundleDifferentDuplicate() throws Exception { - File bundle = createTmpResource("foo.bar", "1.0.0", new byte[] {1}); - File bundle2 = createTmpResource("foo.bar", "1.0.0", new byte[] {2}); + File bundle = createTmpResource("foo.bar", "1.0.0", new byte[] { 1 }); + File bundle2 = createTmpResource("foo.bar", "1.0.0", new byte[] { 2 }); String filePath = m_bundleStore.put(new FileInputStream(bundle), null, false); assert filePath != null; String filePath2 = m_bundleStore.put(new FileInputStream(bundle2), null, false); assert filePath2 == null; } - @Test(groups = { UNIT }, expectedExceptions = { IOException.class }, expectedExceptionsMessageRegExp = "Not a valid bundle and no filename found.*") + @Test(expectedExceptions = { IOException.class }, expectedExceptionsMessageRegExp = "Not a valid bundle and no filename found.*") public void putBundleFail() throws Exception { File bundle = createTmpResource(null, "1.0.0"); String filePath = m_bundleStore.put(new FileInputStream(bundle), null, false); @@ -290,7 +288,7 @@ public class BundleFileStoreTest { assert file.exists(); } - @Test(groups = { UNIT }) + @Test() public void putRemoveArtifact() throws Exception { File bundle = createTmpResource(null, null); String filePath = m_bundleStore.put(new FileInputStream(bundle), "foo.bar-2.3.7.test1.xxx", false); @@ -299,7 +297,7 @@ public class BundleFileStoreTest { assert file.exists(); } - @Test(groups = { UNIT }) + @Test() public void putArtifactDefaultVersion() throws Exception { File bundle = createTmpResource(null, null); String filePath = m_bundleStore.put(new FileInputStream(bundle), "foo.bar.xxx", false); @@ -308,7 +306,7 @@ public class BundleFileStoreTest { assert file.exists(); } - @Test(groups = { UNIT }) + @Test() public void putArtifactMavenVersion() throws Exception { File bundle = createTmpResource(null, null); String filePath = m_bundleStore.put(new FileInputStream(bundle), "foo.bar-2.3.7-test1.xxx", false); @@ -317,19 +315,19 @@ public class BundleFileStoreTest { assert file.exists(); } - @Test(groups = { UNIT }, expectedExceptions = { IOException.class }, expectedExceptionsMessageRegExp = "Not a valid bundle and no filename found.*") + @Test(expectedExceptions = { IOException.class }, expectedExceptionsMessageRegExp = "Not a valid bundle and no filename found.*") public void putArtifactFail1() throws Exception { File bundle = createTmpResource(null, null); m_bundleStore.put(new FileInputStream(bundle), null, false); } - @Test(groups = { UNIT }, expectedExceptions = { IOException.class }, expectedExceptionsMessageRegExp = "Not a valid bundle and no filename found.*") + @Test(expectedExceptions = { IOException.class }, expectedExceptionsMessageRegExp = "Not a valid bundle and no filename found.*") public void putArtifactFail2() throws Exception { File bundle = createTmpResource(null, null); m_bundleStore.put(new FileInputStream(bundle), "", false); } - @Test(groups = { UNIT }) + @Test() public void removeBundle() throws Exception { File bundle = createTmpResource("foo.bar", "1.0.0"); String filePath = m_bundleStore.put(new FileInputStream(bundle), null, false); @@ -339,14 +337,14 @@ public class BundleFileStoreTest { assert !file.exists(); } - @Test(groups = { UNIT }) + @Test() public void removeBundleFaill() throws Exception { File file = new File(m_directory, "no/such/file"); assert !file.exists(); assert !m_bundleStore.remove("no/such/file"); } - @Test(groups = { UNIT }) + @Test() public void removeArtifact() throws Exception { File bundle = createTmpResource(null, null); String filePath = m_bundleStore.put(new FileInputStream(bundle), "foo.bar-2.3.7.test1.xxx", false); @@ -361,7 +359,7 @@ public class BundleFileStoreTest { * Test whether not configuring the directory (so retrieving the directory returns null), results in a * ConfigurationException. Updating with null as dictionary should only clean up things, and nothing else. */ - @Test(groups = { UNIT }) + @Test() public void updateConfigurationWithNull() throws Exception { boolean exceptionThrown = false; @@ -391,7 +389,7 @@ public class BundleFileStoreTest { * Test whether not configuring the directory (so retrieving the directory returns null), results in a * ConfigurationException. */ - @Test(groups = { UNIT }) + @Test() public void updateConfigurationWithSameDirectory() throws Exception { Dictionary<String, Object> props = new Hashtable<>(); @@ -405,15 +403,15 @@ public class BundleFileStoreTest { } assert !m_metadata.generated() : "After changing the directory, the metadata should not be regenerated."; } - + private File createTmpResource(String symbolicName, String version) throws IOException { - return createTmpResource(symbolicName, version, null); + return createTmpResource(symbolicName, version, null); } - + private File createTmpResource(String symbolicName, String version, byte[] data) throws IOException { File tmpFile = File.createTempFile("tmpbundle-", "jar"); tmpFile.deleteOnExit(); - + Manifest manifest = new Manifest(); manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0"); if (symbolicName != null) { @@ -424,8 +422,8 @@ public class BundleFileStoreTest { } JarOutputStream target = new JarOutputStream(new FileOutputStream(tmpFile), manifest); if (data != null) { - target.putNextEntry(new ZipEntry("data")); - target.write(data, 0, data.length); + target.putNextEntry(new ZipEntry("data")); + target.write(data, 0, data.length); } target.close(); return tmpFile; Modified: ace/trunk/org.apache.ace.range.api/test/org/apache/ace/range/SortedRangeSetTest.java URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.range.api/test/org/apache/ace/range/SortedRangeSetTest.java?rev=1732517&r1=1732516&r2=1732517&view=diff ============================================================================== --- ace/trunk/org.apache.ace.range.api/test/org/apache/ace/range/SortedRangeSetTest.java (original) +++ ace/trunk/org.apache.ace.range.api/test/org/apache/ace/range/SortedRangeSetTest.java Fri Feb 26 16:55:17 2016 @@ -18,15 +18,13 @@ */ package org.apache.ace.range; -import static org.apache.ace.test.utils.TestUtils.UNIT; - import java.util.Iterator; import org.testng.Assert; import org.testng.annotations.Test; public class SortedRangeSetTest { - @Test(groups = { UNIT }) + @Test() public void manipulateSimpleRanges() { Range r1 = new Range("5"); assert r1.getLow() == 5 : "Lowest value should be 5"; @@ -45,7 +43,7 @@ public class SortedRangeSetTest { Range r3 = new Range(5); assert r3.getLow() == 5 : "Lowest value should be 5"; assert r3.getHigh() == 5 : "Highest value should be 5"; - Range r4 = new Range(6,8); + Range r4 = new Range(6, 8); assert r4.getLow() == 6 : "Lowest value should be 6"; assert r4.getHigh() == 8 : "Highest value should be 8"; Range r5 = new Range(5); @@ -55,7 +53,7 @@ public class SortedRangeSetTest { assert r5.getLow() == 2 : "Lowest value should be 2"; } - @Test(groups = { UNIT }) + @Test() public void manipulateSortedRangeSets() { SortedRangeSet s1 = new SortedRangeSet("1,3,5-8"); RangeIterator ri1 = s1.iterator(); @@ -67,7 +65,7 @@ public class SortedRangeSetTest { assert ri1.next() == 8 : "Illegal value in range iterator"; assert !ri1.hasNext() : "There should not be more values in the iterator"; assert new SortedRangeSet("1-20").diffDest(new SortedRangeSet("5-25")).toRepresentation().equals("21-25") : "Result of diff should be 21-25"; - assert new SortedRangeSet(new long[] {1,3,5,7,9}).diffDest(new SortedRangeSet("1-10")).toRepresentation().equals("2,4,6,8,10") : "Result of diff should be 2,4,6,8,10"; + assert new SortedRangeSet(new long[] { 1, 3, 5, 7, 9 }).diffDest(new SortedRangeSet("1-10")).toRepresentation().equals("2,4,6,8,10") : "Result of diff should be 2,4,6,8,10"; assert new SortedRangeSet("1-5,8,12").diffDest(new SortedRangeSet("1-5,7,9,12,20")).toRepresentation().equals("7,9,20") : "Result of diff should be 7,9,20"; assert new SortedRangeSet("1").union(new SortedRangeSet("2")).toRepresentation().equals("1-2") : "Result of union should be 1-2"; assert new SortedRangeSet("1-4").union(new SortedRangeSet("6-9")).toRepresentation().equals("1-4,6-9") : "Result of union should be 1-4,6-9"; @@ -76,8 +74,8 @@ public class SortedRangeSetTest { Assert.assertEquals(new SortedRangeSet("1-3,5-10").union(new SortedRangeSet("4")).toRepresentation(), "1-10", "Result of union failed."); Assert.assertEquals(new SortedRangeSet("1-5,8,12").union(new SortedRangeSet("4-8,9-11")).toRepresentation(), "1-12", "Result of union failed."); } - - @Test(groups = { UNIT }) + + @Test() public void validateRangeIterators() { SortedRangeSet srs1 = new SortedRangeSet("1-10"); Iterator i1 = srs1.rangeIterator(); @@ -93,8 +91,8 @@ public class SortedRangeSetTest { SortedRangeSet srs3 = new SortedRangeSet(""); assert !srs3.iterator().hasNext() : "Iterator should be empty."; } - - @Test(groups = { UNIT }) + + @Test() public void validateReverseRangeIterators() throws Exception { SortedRangeSet srs1 = new SortedRangeSet("1-10"); RangeIterator i1 = srs1.reverseIterator(); @@ -104,7 +102,7 @@ public class SortedRangeSetTest { Assert.assertFalse(i1.hasNext(), "We should have iterated over all elements of our simple range."); SortedRangeSet srs2 = new SortedRangeSet("1-5,8,10-15"); RangeIterator i2 = srs2.reverseIterator(); - long[] i2s = { 15, 14, 13, 12, 11, 10, 8, 5, 4, 3, 2, 1}; + long[] i2s = { 15, 14, 13, 12, 11, 10, 8, 5, 4, 3, 2, 1 }; for (int i = 0; i < i2s.length; i++) { Assert.assertEquals(i2.next(), i2s[i]); } @@ -114,9 +112,9 @@ public class SortedRangeSetTest { assert !srs3.reverseIterator().hasNext() : "Iterator should be empty."; } - @Test(groups = { UNIT }) + @Test() public void validateSortedRangeSetArrayConstructor() throws Exception { - long[] a1 = new long[] {1,2,3,5,10}; + long[] a1 = new long[] { 1, 2, 3, 5, 10 }; SortedRangeSet s1 = new SortedRangeSet(a1); RangeIterator i1 = s1.iterator(); for (int i = 0; i < a1.length; i++) { @@ -125,8 +123,8 @@ public class SortedRangeSetTest { Assert.assertEquals(s1.toRepresentation(), "1-3,5,10"); Assert.assertFalse(i1.hasNext(), "We should have iterated over all elements of our range."); - long[] a2 = new long[] {10,2,3,5,10,2,1,5,1}; - long[] a2s = new long[] {1,2,3,5,10}; + long[] a2 = new long[] { 10, 2, 3, 5, 10, 2, 1, 5, 1 }; + long[] a2s = new long[] { 1, 2, 3, 5, 10 }; SortedRangeSet s2 = new SortedRangeSet(a2); RangeIterator i2 = s2.iterator(); for (int i = 0; i < a2s.length; i++) { @@ -135,11 +133,11 @@ public class SortedRangeSetTest { Assert.assertEquals(s2.toRepresentation(), "1-3,5,10"); Assert.assertFalse(i2.hasNext(), "We should have iterated over all elements of our range."); Assert.assertEquals((new SortedRangeSet(new long[] {})).toRepresentation(), (new SortedRangeSet(new long[] {})).toRepresentation()); - Assert.assertEquals((new SortedRangeSet(new long[] {1})).toRepresentation(), (new SortedRangeSet(new long[] {1,1,1})).toRepresentation()); - Assert.assertEquals((new SortedRangeSet(new long[] {3,2,1})).toRepresentation(), (new SortedRangeSet(new long[] {1,2,3,2,1})).toRepresentation()); + Assert.assertEquals((new SortedRangeSet(new long[] { 1 })).toRepresentation(), (new SortedRangeSet(new long[] { 1, 1, 1 })).toRepresentation()); + Assert.assertEquals((new SortedRangeSet(new long[] { 3, 2, 1 })).toRepresentation(), (new SortedRangeSet(new long[] { 1, 2, 3, 2, 1 })).toRepresentation()); } - @Test(groups = { UNIT }, expectedExceptions = IllegalArgumentException.class) + @Test(expectedExceptions = IllegalArgumentException.class) public void invalidRange() { new SortedRangeSet("8-5"); } Modified: ace/trunk/org.apache.ace.repository.itest/bnd.bnd URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.repository.itest/bnd.bnd?rev=1732517&r1=1732516&r2=1732517&view=diff ============================================================================== --- ace/trunk/org.apache.ace.repository.itest/bnd.bnd (original) +++ ace/trunk/org.apache.ace.repository.itest/bnd.bnd Fri Feb 26 16:55:17 2016 @@ -1,7 +1,7 @@ # Licensed to the Apache Software Foundation (ASF) under the terms of ASLv2 (http://www.apache.org/licenses/LICENSE-2.0). -Test-Cases: ${classes;CONCRETE;EXTENDS;org.apache.ace.it.IntegrationTestBase} -buildpath: \ + ${^-buildpath},\ junit.osgi,\ osgi.core;version=6.0.0,\ osgi.cmpn,\ @@ -10,9 +10,10 @@ Test-Cases: ${classes;CONCRETE;EXTENDS;o org.apache.ace.repository.api;version=latest,\ org.apache.felix.http.api,\ org.apache.felix.dependencymanager --runfw: org.apache.felix.framework;version='[5.2.0,6)' --runvm: -ea --runbundles: osgi.cmpn,\ + +-runfw: org.apache.felix.framework;version='[5,6)' +-runbundles: \ + osgi.cmpn,\ org.apache.felix.log,\ org.apache.felix.dependencymanager,\ org.apache.felix.configadmin,\ @@ -27,10 +28,17 @@ Test-Cases: ${classes;CONCRETE;EXTENDS;o org.apache.ace.repository.impl;version=latest,\ org.apache.ace.repository.servlets;version=latest,\ org.apache.ace.http.context;version=latest - +-runvm: -ea +-runee: JavaSE-1.7 +-runsystempackages: sun.reflect +-runproperties: ${itestrunprops} +-baseline: + +Test-Cases: ${classes;CONCRETE;EXTENDS;org.apache.ace.it.IntegrationTestBase} + Private-Package: org.apache.ace.it.repository + Bundle-Version: 1.0.0 Bundle-Name: Apache ACE Repository itest Bundle-Description: Integration test bundle for Apache ACE Repository Bundle-Category: itest --baseline:
